mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
This commit is contained in:
parent
bb547ce1c4
commit
6f433c8656
445 changed files with 4797 additions and 4268 deletions
|
@ -23,18 +23,18 @@ public:
|
|||
StackOfOpenElements() = default;
|
||||
~StackOfOpenElements();
|
||||
|
||||
DOM::Element& first() { return m_elements.first(); }
|
||||
DOM::Element& last() { return m_elements.last(); }
|
||||
DOM::Element& first() { return *m_elements.first(); }
|
||||
DOM::Element& last() { return *m_elements.last(); }
|
||||
|
||||
bool is_empty() const { return m_elements.is_empty(); }
|
||||
void push(NonnullRefPtr<DOM::Element> element) { m_elements.append(move(element)); }
|
||||
NonnullRefPtr<DOM::Element> pop() { return m_elements.take_last(); }
|
||||
void push(JS::NonnullGCPtr<DOM::Element> element) { m_elements.append(JS::make_handle(*element)); }
|
||||
JS::NonnullGCPtr<DOM::Element> pop() { return *m_elements.take_last(); }
|
||||
void remove(DOM::Element const& element);
|
||||
void replace(DOM::Element const& to_remove, NonnullRefPtr<DOM::Element> to_add);
|
||||
void insert_immediately_below(NonnullRefPtr<DOM::Element> element_to_add, DOM::Element const& target);
|
||||
void replace(DOM::Element const& to_remove, JS::NonnullGCPtr<DOM::Element> to_add);
|
||||
void insert_immediately_below(JS::NonnullGCPtr<DOM::Element> element_to_add, DOM::Element const& target);
|
||||
|
||||
const DOM::Element& current_node() const { return m_elements.last(); }
|
||||
DOM::Element& current_node() { return m_elements.last(); }
|
||||
const DOM::Element& current_node() const { return *m_elements.last(); }
|
||||
DOM::Element& current_node() { return *m_elements.last(); }
|
||||
|
||||
bool has_in_scope(FlyString const& tag_name) const;
|
||||
bool has_in_button_scope(FlyString const& tag_name) const;
|
||||
|
@ -47,25 +47,25 @@ public:
|
|||
bool contains(const DOM::Element&) const;
|
||||
bool contains(FlyString const& tag_name) const;
|
||||
|
||||
NonnullRefPtrVector<DOM::Element> const& elements() const { return m_elements; }
|
||||
NonnullRefPtrVector<DOM::Element>& elements() { return m_elements; }
|
||||
Vector<JS::Handle<DOM::Element>> const& elements() const { return m_elements; }
|
||||
Vector<JS::Handle<DOM::Element>>& elements() { return m_elements; }
|
||||
|
||||
void pop_until_an_element_with_tag_name_has_been_popped(FlyString const&);
|
||||
|
||||
DOM::Element* topmost_special_node_below(const DOM::Element&);
|
||||
JS::GCPtr<DOM::Element> topmost_special_node_below(DOM::Element const&);
|
||||
|
||||
struct LastElementResult {
|
||||
DOM::Element* element;
|
||||
JS::GCPtr<DOM::Element> element;
|
||||
ssize_t index;
|
||||
};
|
||||
LastElementResult last_element_with_tag_name(FlyString const&);
|
||||
DOM::Element* element_immediately_above(DOM::Element const&);
|
||||
JS::GCPtr<DOM::Element> element_immediately_above(DOM::Element const&);
|
||||
|
||||
private:
|
||||
bool has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const&) const;
|
||||
bool has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const&) const;
|
||||
|
||||
NonnullRefPtrVector<DOM::Element> m_elements;
|
||||
Vector<JS::Handle<DOM::Element>> m_elements;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue