diff options
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/EventListenerWrapper.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/EventWrapper.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/ImageDataWrapper.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/LocationObject.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/NavigatorObject.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/Wrapper.h | 10 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp | 8 |
9 files changed, 18 insertions, 27 deletions
diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h index 7595a63d1c..2fe903858b 100644 --- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h +++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h @@ -32,6 +32,7 @@ namespace Web { namespace Bindings { class CanvasRenderingContext2DWrapper final : public Wrapper { + JS_OBJECT(CanvasRenderingContext2DWrapper, Wrapper); public: CanvasRenderingContext2DWrapper(JS::GlobalObject&, CanvasRenderingContext2D&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; @@ -41,8 +42,6 @@ public: const CanvasRenderingContext2D& impl() const { return m_impl; } private: - virtual const char* class_name() const override { return "CanvasRenderingContext2DWrapper"; } - JS_DECLARE_NATIVE_FUNCTION(fill_rect); JS_DECLARE_NATIVE_FUNCTION(stroke_rect); JS_DECLARE_NATIVE_FUNCTION(draw_image); diff --git a/Libraries/LibWeb/Bindings/EventListenerWrapper.h b/Libraries/LibWeb/Bindings/EventListenerWrapper.h index 4aeb0cfec1..6fad8eaff2 100644 --- a/Libraries/LibWeb/Bindings/EventListenerWrapper.h +++ b/Libraries/LibWeb/Bindings/EventListenerWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class EventListenerWrapper final : public Wrapper { + JS_OBJECT(EventListenerWrapper, Wrapper); + public: EventListenerWrapper(JS::GlobalObject&, EventListener&); virtual ~EventListenerWrapper() override; @@ -40,8 +42,6 @@ public: const EventListener& impl() const { return *m_impl; } private: - virtual const char* class_name() const override { return "EventListenerWrapper"; } - NonnullRefPtr<EventListener> m_impl; }; diff --git a/Libraries/LibWeb/Bindings/EventWrapper.h b/Libraries/LibWeb/Bindings/EventWrapper.h index baf7ef56ad..1e9f4b04b2 100644 --- a/Libraries/LibWeb/Bindings/EventWrapper.h +++ b/Libraries/LibWeb/Bindings/EventWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class EventWrapper : public Wrapper { + JS_OBJECT(EventWrapper, Wrapper); + public: EventWrapper(JS::GlobalObject&, Event&); virtual ~EventWrapper() override; @@ -40,8 +42,6 @@ public: const Event& event() const { return m_event; } private: - virtual const char* class_name() const override { return "EventWrapper"; } - NonnullRefPtr<Event> m_event; }; diff --git a/Libraries/LibWeb/Bindings/ImageDataWrapper.h b/Libraries/LibWeb/Bindings/ImageDataWrapper.h index 97868071ce..059b28d0eb 100644 --- a/Libraries/LibWeb/Bindings/ImageDataWrapper.h +++ b/Libraries/LibWeb/Bindings/ImageDataWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class ImageDataWrapper : public Wrapper { + JS_OBJECT(ImageDataWrapper, Wrapper); + public: ImageDataWrapper(JS::GlobalObject&, ImageData&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; @@ -41,8 +43,6 @@ public: const ImageData& impl() const { return m_impl; } private: - virtual const char* class_name() const override { return "ImageDataWrapper"; } - JS_DECLARE_NATIVE_GETTER(width_getter); JS_DECLARE_NATIVE_GETTER(height_getter); JS_DECLARE_NATIVE_GETTER(data_getter); diff --git a/Libraries/LibWeb/Bindings/LocationObject.h b/Libraries/LibWeb/Bindings/LocationObject.h index 97133efafc..e0ebb55f32 100644 --- a/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Libraries/LibWeb/Bindings/LocationObject.h @@ -33,14 +33,14 @@ namespace Web { namespace Bindings { class LocationObject final : public JS::Object { + JS_OBJECT(LocationObject, JS::Object); + public: explicit LocationObject(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~LocationObject() override; private: - virtual const char* class_name() const override { return "LocationObject"; } - JS_DECLARE_NATIVE_FUNCTION(reload); JS_DECLARE_NATIVE_GETTER(href_getter); diff --git a/Libraries/LibWeb/Bindings/NavigatorObject.h b/Libraries/LibWeb/Bindings/NavigatorObject.h index ddef82f8f7..b05ecc26cd 100644 --- a/Libraries/LibWeb/Bindings/NavigatorObject.h +++ b/Libraries/LibWeb/Bindings/NavigatorObject.h @@ -33,14 +33,14 @@ namespace Web { namespace Bindings { class NavigatorObject final : public JS::Object { + JS_OBJECT(NavigatorObject, JS::Object); + public: NavigatorObject(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~NavigatorObject() override; private: - virtual const char* class_name() const override { return "NavigatorObject"; } - JS_DECLARE_NATIVE_GETTER(user_agent_getter); }; diff --git a/Libraries/LibWeb/Bindings/Wrapper.h b/Libraries/LibWeb/Bindings/Wrapper.h index bcb72bb440..5fc5abc606 100644 --- a/Libraries/LibWeb/Bindings/Wrapper.h +++ b/Libraries/LibWeb/Bindings/Wrapper.h @@ -37,20 +37,14 @@ namespace Bindings { class Wrapper : public JS::Object , public Weakable<Wrapper> { -public: - virtual bool is_event_target_wrapper() const { return false; } - virtual bool is_node_wrapper() const { return false; } - virtual bool is_document_wrapper() const { return false; } - virtual bool is_element_wrapper() const { return false; } - virtual bool is_htmlelement_wrapper() const { return false; } + JS_OBJECT(Wrapper, JS::Object); +public: protected: explicit Wrapper(Object& prototype) : Object(&prototype) { } - - virtual bool is_web_wrapper() const final { return true; } }; } diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h index dcc2fdfe48..8667825a50 100644 --- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h +++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h @@ -32,14 +32,14 @@ namespace Web { namespace Bindings { class XMLHttpRequestPrototype final : public JS::Object { + JS_OBJECT(XMLHttpRequestPrototype, JS::Object); + public: explicit XMLHttpRequestPrototype(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~XMLHttpRequestPrototype() override; private: - virtual const char* class_name() const override { return "XMLHttpRequestPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(open); JS_DECLARE_NATIVE_FUNCTION(send); diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 324d7c3ab4..0f52953e03 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -315,6 +315,7 @@ static void generate_header(const IDL::Interface& interface) out() << "namespace Bindings {"; out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {"; + out() << " JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");"; out() << "public:"; out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);"; out() << " virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;"; @@ -332,7 +333,6 @@ static void generate_header(const IDL::Interface& interface) out() << " virtual bool " << is_foo_wrapper_name << "() const final { return true; }"; out() << "private:"; - out() << " virtual const char* class_name() const override { return \"" << interface.name << "\"; }"; for (auto& function : interface.functions) { out() << " JS_DECLARE_NATIVE_FUNCTION(" << snake_name(function.name) << ");"; @@ -412,8 +412,7 @@ void generate_implementation(const IDL::Interface& interface) out() << " auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);"; out() << " if (!this_object)"; out() << " return {};"; - auto is_foo_wrapper_name = snake_name(String::format("Is%s", wrapper_class.characters())); - out() << " if (!this_object->is_web_wrapper() || !static_cast<Wrapper*>(this_object)->" << is_foo_wrapper_name << "()) {"; + out() << " if (!this_object->inherits(\"" << wrapper_class << "\")) {"; out() << " interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.name << "\");"; out() << " return nullptr;"; out() << " }"; @@ -441,8 +440,7 @@ void generate_implementation(const IDL::Interface& interface) out() << " auto " << cpp_name << "_object = " << js_name << js_suffix << ".to_object(interpreter, global_object);"; out() << " if (interpreter.exception())"; generate_return(); - auto is_foo_wrapper_name = snake_name(String::format("Is%sWrapper", parameter.type.name.characters())); - out() << " if (!" << cpp_name << "_object->is_web_wrapper() || !static_cast<Wrapper*>(" << cpp_name << "_object)->" << is_foo_wrapper_name << "()) {"; + out() << " if (!" << cpp_name << "_object->inherits(\"" << parameter.type.name << "Wrapper\")) {"; out() << " interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << parameter.type.name << "\");"; generate_return(); out() << " }"; |