Commit Graph

4 Commits

Author SHA1 Message Date
Timothy Flynn
6efbafa6e0 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
Timothy Flynn
b67f6daf05 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.
2021-10-18 09:58:52 +02:00
Timothy Flynn
454d218716 LibWeb: Set an attribute's owning element when it is known 2021-10-17 13:51:10 +01:00
Timothy Flynn
e01dfaac9a LibWeb: Implement Attribute closer to the spec and with an IDL file
Note our Attribute class is what the spec refers to as just "Attr". The
main differences between the existing implementation and the spec are
just that the spec defines more fields.

Attributes can contain namespace URIs and prefixes. However, note that
these are not parsed in HTML documents unless the document content-type
is XML. So for now, these are initialized to null. Web pages are able to
set the namespace via JavaScript (setAttributeNS), so these fields may
be filled in when the corresponding APIs are implemented.

The main change to be aware of is that an attribute is a node. This has
implications on how attributes are stored in the Element class. Nodes
are non-copyable and non-movable because these constructors are deleted
by the EventTarget base class. This means attributes cannot be stored in
a Vector or HashMap as these containers assume copyability / movability.
So for now, the Vector holding attributes is changed to hold RefPtrs to
attributes instead. This might change when attribute storage is
implemented according to the spec (by way of NamedNodeMap).
2021-10-17 13:51:10 +01:00