mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Make LocationObject a PlatformObject
This commit is contained in:
parent
2fe97fa8db
commit
0e47754ac8
Notes:
sideshowbarker
2024-07-17 07:24:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0e47754ac8 Pull-request: https://github.com/SerenityOS/serenity/pull/14816 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg ✅
2 changed files with 21 additions and 9 deletions
|
@ -23,9 +23,18 @@ namespace Web::Bindings {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#the-location-interface
|
||||
LocationObject::LocationObject(JS::Realm& realm)
|
||||
: Object(verify_cast<HTML::Window>(realm.global_object()).cached_web_prototype("Location"))
|
||||
, m_default_properties(heap())
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
set_prototype(&verify_cast<HTML::Window>(realm.global_object()).cached_web_prototype("Location"));
|
||||
}
|
||||
|
||||
LocationObject::~LocationObject() = default;
|
||||
|
||||
void LocationObject::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& property : m_default_properties)
|
||||
visitor.visit(property);
|
||||
}
|
||||
|
||||
void LocationObject::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -10,20 +10,18 @@
|
|||
#include <AK/URL.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
class LocationObject final : public JS::Object {
|
||||
JS_OBJECT(LocationObject, JS::Object);
|
||||
class LocationObject final : public Bindings::PlatformObject {
|
||||
JS_OBJECT(LocationObject, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
explicit LocationObject(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual ~LocationObject() override = default;
|
||||
virtual ~LocationObject() override;
|
||||
|
||||
virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override;
|
||||
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;
|
||||
|
@ -40,6 +38,11 @@ public:
|
|||
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
||||
|
||||
private:
|
||||
explicit LocationObject(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
DOM::Document const* relevant_document() const;
|
||||
AK::URL url() const;
|
||||
|
||||
|
@ -61,7 +64,7 @@ private:
|
|||
CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map;
|
||||
|
||||
// [[DefaultProperties]], https://html.spec.whatwg.org/multipage/history.html#defaultproperties
|
||||
JS::MarkedVector<JS::Value> m_default_properties;
|
||||
Vector<JS::Value> m_default_properties;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue