The back pointer from the heap-allocated vector of attributes to the element is a waste of space. We should move the data from the current NamedNodeMap class into a new heap-allocated class that is independent of the DOM. The NamedNodeMap class should then just be a class with an Element* in it. The pointer to NamedNodeMap could go into ElementRareData or some other map, and all the operations could be done based on data stored in the element and its data structures. NamedNodeMap would no longer have any data of its own.
I intend to implement this in steps. The first one is bug 77233 which would add ElementAttributeData, that will be the internal attribute storage. In that patch it is still part of NamedNodeMap, so no real change happen yet. It already contains the style related members that were in NamedNodeMap. The next step is moving m_attributes to the ElementAttributeData, and the last step would be moving ElementAttributeData to Element and moving NamedNodeMap inside ElementRareData.
Created attachment 130754 [details] Patch
It took more steps than planned because I made them smaller. In the end this made things easier to review. Tomorrow I'm planning to improve the ChangeLog with some empirical data of memory usage.
Comment on attachment 130754 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130754&action=review > Source/WebCore/dom/Element.cpp:203 > +NamedNodeMap* Element::attributes() const I don't think this function should have const qualifier.
Comment on attachment 130754 [details] Patch Attachment 130754 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/11861141
Created attachment 130810 [details] Patch
Comment on attachment 130754 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130754&action=review >> Source/WebCore/dom/Element.cpp:203 >> +NamedNodeMap* Element::attributes() const > > I don't think this function should have const qualifier. What about Node::attributes()?
Committed r110172: <http://trac.webkit.org/changeset/110172>
Comment on attachment 130810 [details] Patch Clearing review flag from an old attachment so that it doesn't show on the review queue.
Mass moving XML DOM bugs to the "DOM" Component.