mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Weakly store NamedNodeMap's & Attribute's associated Element
This is similar to how Gecko avoids a reference cycle, where both the NamedNodeMap and Attribute would otherwise store a strong reference to their associated Element. Gecko manually clears stored raw references when an Element is destroyed, whereas we use weak references to do so automatically. Attribute's ownerElement getter and setter are moved out of line to avoid an #include cycle between Element and Attribute.
This commit is contained in:
parent
356d5821e7
commit
b67f6daf05
4 changed files with 35 additions and 8 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -50,7 +51,7 @@ public:
|
|||
private:
|
||||
explicit NamedNodeMap(Element const& associated_element);
|
||||
|
||||
Element const& m_associated_element;
|
||||
WeakPtr<Element> m_associated_element;
|
||||
NonnullRefPtrVector<Attribute> m_attributes;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue