summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-04-03 15:06:16 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-03 16:34:34 +0200
commit975b209b9bc2b495410caea3117e593af1daea20 (patch)
tree80260486e500550eb3eb99b920422d832bb1fc2f /Userland/Libraries/LibWeb
parent55d9f1cced2f3ee431222a7d2f52773501a0759d (diff)
downloadserenity-975b209b9bc2b495410caea3117e593af1daea20.zip
LibWeb: Set Constructor.name and Prototype.constructor of generated interfaces
Object introspection in the Browser's JS console is still not great, but this makes it a lot easier to find out the exact type of an object by checking its 'constructor' property. It also fixes all the things that rely on these properties being set, of course :^)
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h221
1 files changed, 114 insertions, 107 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
index 555322ddfc..de560b6b26 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
@@ -234,112 +234,119 @@
#include <LibWeb/Bindings/XMLHttpRequestEventTargetPrototype.h>
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
-#define ADD_WINDOW_OBJECT_INTERFACE(name) \
- { \
- ensure_web_constructor<name##Constructor>(#name); \
+#define ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, constructor_name, prototype_name) \
+ { \
+ auto& constructor = ensure_web_constructor<constructor_name>(#interface_name); \
+ constructor.define_property(vm.names.name, js_string(vm, #interface_name), JS::Attribute::Configurable); \
+ auto& prototype = ensure_web_prototype<prototype_name>(#interface_name); \
+ prototype.define_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); \
}
-#define ADD_WINDOW_OBJECT_INTERFACES \
- ADD_WINDOW_OBJECT_INTERFACE(CanvasRenderingContext2D) \
- ADD_WINDOW_OBJECT_INTERFACE(CharacterData) \
- ADD_WINDOW_OBJECT_INTERFACE(Comment) \
- ADD_WINDOW_OBJECT_INTERFACE(CSSStyleSheet) \
- ADD_WINDOW_OBJECT_INTERFACE(DocumentFragment) \
- ADD_WINDOW_OBJECT_INTERFACE(Document) \
- ADD_WINDOW_OBJECT_INTERFACE(DocumentType) \
- ADD_WINDOW_OBJECT_INTERFACE(DOMException) \
- ADD_WINDOW_OBJECT_INTERFACE(DOMImplementation) \
- ADD_WINDOW_OBJECT_INTERFACE(Element) \
- ADD_WINDOW_OBJECT_INTERFACE(Event) \
- ADD_WINDOW_OBJECT_INTERFACE(EventTarget) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLAnchorElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLAreaElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLAudioElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLBaseElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLBodyElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLBRElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLButtonElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLCanvasElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDataElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDataListElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDetailsElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDialogElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDirectoryElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDivElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLDListElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLEmbedElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLFieldSetElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLFontElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLFormElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLFrameElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLFrameSetElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLHeadElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLHeadingElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLHRElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLHtmlElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLIFrameElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLImageElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLInputElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLLabelElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLLegendElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLLIElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLLinkElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMapElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMarqueeElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMediaElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMenuElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMetaElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLMeterElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLModElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLObjectElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLOListElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLOptGroupElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLOptionElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLOutputElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLParagraphElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLParamElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLPictureElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLPreElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLProgressElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLQuoteElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLScriptElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLSelectElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLSlotElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLSourceElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLSpanElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLStyleElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableCaptionElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableCellElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableColElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableRowElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTableSectionElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTemplateElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTextAreaElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTimeElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTitleElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLTrackElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLUListElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLUnknownElement) \
- ADD_WINDOW_OBJECT_INTERFACE(HTMLVideoElement) \
- ADD_WINDOW_OBJECT_INTERFACE(Image) \
- ADD_WINDOW_OBJECT_INTERFACE(ImageData) \
- ADD_WINDOW_OBJECT_INTERFACE(MouseEvent) \
- ADD_WINDOW_OBJECT_INTERFACE(Node) \
- ADD_WINDOW_OBJECT_INTERFACE(Performance) \
- ADD_WINDOW_OBJECT_INTERFACE(PerformanceTiming) \
- ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
- ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
- ADD_WINDOW_OBJECT_INTERFACE(StyleSheet) \
- ADD_WINDOW_OBJECT_INTERFACE(StyleSheetList) \
- ADD_WINDOW_OBJECT_INTERFACE(SubmitEvent) \
- ADD_WINDOW_OBJECT_INTERFACE(SVGElement) \
- ADD_WINDOW_OBJECT_INTERFACE(SVGGeometryElement) \
- ADD_WINDOW_OBJECT_INTERFACE(SVGGraphicsElement) \
- ADD_WINDOW_OBJECT_INTERFACE(SVGPathElement) \
- ADD_WINDOW_OBJECT_INTERFACE(SVGSVGElement) \
- ADD_WINDOW_OBJECT_INTERFACE(Text) \
- ADD_WINDOW_OBJECT_INTERFACE(UIEvent) \
- ADD_WINDOW_OBJECT_INTERFACE(XMLHttpRequest) \
- ADD_WINDOW_OBJECT_INTERFACE(XMLHttpRequestEventTarget)
+#define ADD_WINDOW_OBJECT_INTERFACE(interface_name) \
+ ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, interface_name##Constructor, interface_name##Prototype)
+
+#define ADD_WINDOW_OBJECT_INTERFACES \
+ auto& vm = this->vm(); \
+ ADD_WINDOW_OBJECT_INTERFACE(CanvasRenderingContext2D) \
+ ADD_WINDOW_OBJECT_INTERFACE(CharacterData) \
+ ADD_WINDOW_OBJECT_INTERFACE(Comment) \
+ ADD_WINDOW_OBJECT_INTERFACE(CSSStyleSheet) \
+ ADD_WINDOW_OBJECT_INTERFACE(DocumentFragment) \
+ ADD_WINDOW_OBJECT_INTERFACE(Document) \
+ ADD_WINDOW_OBJECT_INTERFACE(DocumentType) \
+ ADD_WINDOW_OBJECT_INTERFACE(DOMException) \
+ ADD_WINDOW_OBJECT_INTERFACE(DOMImplementation) \
+ ADD_WINDOW_OBJECT_INTERFACE(Element) \
+ ADD_WINDOW_OBJECT_INTERFACE(Event) \
+ ADD_WINDOW_OBJECT_INTERFACE(EventTarget) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLAnchorElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLAreaElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLAudioElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLBaseElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLBodyElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLBRElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLButtonElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLCanvasElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDataElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDataListElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDetailsElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDialogElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDirectoryElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDivElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLDListElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLEmbedElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLFieldSetElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLFontElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLFormElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLFrameElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLFrameSetElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLHeadElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLHeadingElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLHRElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLHtmlElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLIFrameElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLImageElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLInputElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLLabelElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLLegendElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLLIElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLLinkElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMapElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMarqueeElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMediaElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMenuElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMetaElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLMeterElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLModElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLObjectElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLOListElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLOptGroupElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLOptionElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLOutputElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLParagraphElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLParamElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLPictureElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLPreElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLProgressElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLQuoteElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLScriptElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLSelectElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLSlotElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLSourceElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLSpanElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLStyleElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableCaptionElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableCellElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableColElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableRowElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTableSectionElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTemplateElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTextAreaElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTimeElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTitleElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLTrackElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLUListElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLUnknownElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(HTMLVideoElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(ImageData) \
+ ADD_WINDOW_OBJECT_INTERFACE(MouseEvent) \
+ ADD_WINDOW_OBJECT_INTERFACE(Node) \
+ ADD_WINDOW_OBJECT_INTERFACE(Performance) \
+ ADD_WINDOW_OBJECT_INTERFACE(PerformanceTiming) \
+ ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
+ ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
+ ADD_WINDOW_OBJECT_INTERFACE(StyleSheet) \
+ ADD_WINDOW_OBJECT_INTERFACE(StyleSheetList) \
+ ADD_WINDOW_OBJECT_INTERFACE(SubmitEvent) \
+ ADD_WINDOW_OBJECT_INTERFACE(SVGElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(SVGGeometryElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(SVGGraphicsElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(SVGPathElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(SVGSVGElement) \
+ ADD_WINDOW_OBJECT_INTERFACE(Text) \
+ ADD_WINDOW_OBJECT_INTERFACE(UIEvent) \
+ ADD_WINDOW_OBJECT_INTERFACE(XMLHttpRequest) \
+ ADD_WINDOW_OBJECT_INTERFACE(XMLHttpRequestEventTarget) \
+ ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(Image, ImageConstructor, HTMLImageElementPrototype)