1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

LibWeb: Actually instantiate all the web constructors/prototypes

We now instantiate all the generated web API constructors and expose
them on the window object. We also set the generated prototypes on
instantiated wrappers.

Also, we should obviously find a way to generate this code. :^)
This commit is contained in:
Andreas Kling 2021-01-18 09:50:00 +01:00
parent 252a98042d
commit ee7fa49b88
4 changed files with 349 additions and 7 deletions

View file

@ -53,6 +53,11 @@ public:
RangePrototype* range_prototype() { return m_range_prototype; }
RangeConstructor* range_constructor() { return m_range_constructor; }
JS::Object* web_prototype(const String& class_name) { return m_prototypes.get(class_name).value_or(nullptr); }
JS::NativeFunction* web_constructor(const String& class_name) { return m_constructors.get(class_name).value_or(nullptr); }
void set_web_prototype(const String& class_name, JS::Object* prototype) { m_prototypes.set(class_name, prototype); }
void set_web_constructor(const String& class_name, JS::NativeFunction* constructor) { m_constructors.set(class_name, constructor); }
private:
virtual const char* class_name() const override { return "WindowObject"; }
virtual void visit_edges(Visitor&) override;
@ -82,6 +87,9 @@ private:
RangePrototype* m_range_prototype { nullptr };
RangeConstructor* m_range_constructor { nullptr };
HashMap<String, JS::Object*> m_prototypes;
HashMap<String, JS::NativeFunction*> m_constructors;
};
}