1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

LibWeb: Start implementing basic JavaScript DOM bindings

This patch introduces the Wrapper and Wrappable classes.

Node now inherits from Wrappable, and can be wrapped in a GC-allocated
Bindings::NodeWrapper object. The only property we expose right now is
the very simple nodeName property.

When a Document's JS::Interpreter is first instantiated, we add a
"document" property with a DocumentWrapper object to the global object.

This is pretty cool! :^)
This commit is contained in:
Andreas Kling 2020-03-14 13:15:11 +01:00
parent 9c9d3f0904
commit 1c406294fc
14 changed files with 196 additions and 1 deletions

View file

@ -31,6 +31,7 @@
#include <LibGUI/MessageBox.h>
#include <LibJS/GlobalObject.h>
#include <LibJS/Interpreter.h>
#include <LibWeb/Bindings/DocumentWrapper.h>
#include <LibWeb/CSS/StyleResolver.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentType.h>
@ -346,6 +347,8 @@ JS::Interpreter& Document::interpreter()
GUI::MessageBox::show(arguments[0].to_string(), "Alert", GUI::MessageBox::Type::Information);
return JS::js_undefined();
});
m_interpreter->global_object().put("document", wrap(m_interpreter->heap(), *this));
}
return *m_interpreter;
}