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
commit 1c406294fc
Notes: sideshowbarker 2024-07-19 08:18:52 +09:00
14 changed files with 196 additions and 1 deletions

View file

@ -0,0 +1,23 @@
#pragma once
#include <LibWeb/Bindings/Wrapper.h>
namespace Web {
namespace Bindings {
class NodeWrapper : public Wrapper {
public:
explicit NodeWrapper(Node&);
virtual ~NodeWrapper() override;
Node& node() { return *m_node; }
const Node& node() const { return *m_node; }
private:
virtual const char* class_name() const override { return "Node"; }
NonnullRefPtr<Node> m_node;
};
}
}