From 1c406294fc426a2d083e7d5f30f7e4e97ef4a794 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Mar 2020 13:15:11 +0100 Subject: [PATCH] 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! :^) --- Base/home/anon/www/dom.html | 12 +++++++ Base/home/anon/www/welcome.html | 1 + Libraries/LibWeb/Bindings/DocumentWrapper.cpp | 29 +++++++++++++++++ Libraries/LibWeb/Bindings/DocumentWrapper.h | 21 +++++++++++++ Libraries/LibWeb/Bindings/NodeWrapper.cpp | 20 ++++++++++++ Libraries/LibWeb/Bindings/NodeWrapper.h | 23 ++++++++++++++ Libraries/LibWeb/Bindings/Wrappable.cpp | 18 +++++++++++ Libraries/LibWeb/Bindings/Wrappable.h | 31 +++++++++++++++++++ Libraries/LibWeb/Bindings/Wrapper.h | 19 ++++++++++++ Libraries/LibWeb/DOM/Document.cpp | 3 ++ Libraries/LibWeb/DOM/Document.h | 2 ++ Libraries/LibWeb/DOM/Node.h | 5 ++- Libraries/LibWeb/Forward.h | 10 ++++++ Libraries/LibWeb/Makefile | 3 ++ 14 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 Base/home/anon/www/dom.html create mode 100644 Libraries/LibWeb/Bindings/DocumentWrapper.cpp create mode 100644 Libraries/LibWeb/Bindings/DocumentWrapper.h create mode 100644 Libraries/LibWeb/Bindings/NodeWrapper.cpp create mode 100644 Libraries/LibWeb/Bindings/NodeWrapper.h create mode 100644 Libraries/LibWeb/Bindings/Wrappable.cpp create mode 100644 Libraries/LibWeb/Bindings/Wrappable.h create mode 100644 Libraries/LibWeb/Bindings/Wrapper.h diff --git a/Base/home/anon/www/dom.html b/Base/home/anon/www/dom.html new file mode 100644 index 0000000000..0c6a15dfad --- /dev/null +++ b/Base/home/anon/www/dom.html @@ -0,0 +1,12 @@ + + + + +
+ + + diff --git a/Base/home/anon/www/welcome.html b/Base/home/anon/www/welcome.html index 6f7f3a3a78..4f2d30a013 100644 --- a/Base/home/anon/www/welcome.html +++ b/Base/home/anon/www/welcome.html @@ -23,6 +23,7 @@ h1 {

This is a very simple browser built on the LibWeb engine.

Some small test pages: