|
| 1 | +2012-07-13 Ryosuke Niwa <rniwa@webkit.org> |
| 2 | + |
| 3 | + HTMLCollection should use DynamicNodeList's invalidation model |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=90326 |
| 5 | + |
| 6 | + Reviewed by Anders Carlsson. |
| 7 | + |
| 8 | + Make HTMLCollection invalidated upon attribute and children changes instead of invalidating it on demand |
| 9 | + by comparing DOM tree versions. Node that HTMLCollections owned by Document are invalidated with other |
| 10 | + document-rooted node lists in m_listsInvalidatedAtDocument for simplicity although this mechanism is |
| 11 | + normally used for node lists owned by a non-Document node that contains nodes outside of its subtree. |
| 12 | + ItemProperties and FormControls are more "traditional" users of the mechanism. |
| 13 | + |
| 14 | + Also, merged DynamicNodeList::invalidateCache and HTMLCollection::invalidateCache. |
| 15 | + |
| 16 | + * dom/Document.cpp: |
| 17 | + (WebCore::Document::registerNodeListCache): Renamed. No longer takes NodeListInvalidationType or |
| 18 | + NodeListRootType since they can be obtained from the cache base. Increment the node list counter for |
| 19 | + InvalidateOnIdNameAttrChange when a HTMLCollection is passed in since all HTMLCollections need to be |
| 20 | + invalidated on id or name content attribute changes due to named getters. |
| 21 | + (WebCore::Document::unregisterNodeListCache): Ditto. |
| 22 | + (WebCore::shouldInvalidateNodeListForType): |
| 23 | + (WebCore::Document::shouldInvalidateNodeListCaches): |
| 24 | + (WebCore::Document::clearNodeListCaches): |
| 25 | + * dom/Document.h: |
| 26 | + (WebCore): Added InvalidateOnIdNameAttrChange, InvalidateOnHRefAttrChange, and InvalidateOnAnyAttrChange. |
| 27 | + (Document): |
| 28 | + * dom/DynamicNodeList.cpp: |
| 29 | + (WebCore::DynamicNodeListCacheBase::invalidateCache): Added. Invalidates caches of both DynamicNodeList |
| 30 | + and HTMLCollection. We can't afford to use virtual function calls here because this function is called on |
| 31 | + all node lists and HTML collections owned by ancestors of an element under which a node is added, removed, |
| 32 | + or its attributes are changed. |
| 33 | + (WebCore): |
| 34 | + * dom/DynamicNodeList.h: |
| 35 | + (WebCore::DynamicNodeListCacheBase::DynamicNodeListCacheBase): Initializes member variables directly |
| 36 | + instead of calling clearCache now that DynamicNodeListCacheBase::invalidateCache has become polymorphic. |
| 37 | + (DynamicNodeListCacheBase): Increased the number of bits for m_invalidationType since we now have 9 |
| 38 | + invalidation types. |
| 39 | + (WebCore::DynamicSubtreeNodeList::~DynamicSubtreeNodeList): |
| 40 | + (WebCore::DynamicSubtreeNodeList::DynamicSubtreeNodeList): |
| 41 | + * dom/ElementRareData.h: |
| 42 | + (ElementRareData): |
| 43 | + (WebCore::ElementRareData::clearHTMLCollectionCaches): Added. |
| 44 | + (WebCore::ElementRareData::adoptTreeScope): Added; similar to NodeRareData::adoptTreeScope. |
| 45 | + * dom/Node.cpp: |
| 46 | + (WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged): Clears HTML collection caches as well as |
| 47 | + node list caches. |
| 48 | + (WebCore::Node::invalidateNodeListsCacheAfterChildrenChanged): Ditto. |
| 49 | + * dom/NodeRareData.h: |
| 50 | + (WebCore::NodeListsNodeData::adoptTreeScope): |
| 51 | + * dom/TreeScopeAdopter.cpp: |
| 52 | + (WebCore::TreeScopeAdopter::moveTreeToNewScope): Calls ElementRareData's adoptTreeScope as well as |
| 53 | + NodeRareData's. |
| 54 | + * html/HTMLAllCollection.cpp: |
| 55 | + (WebCore::HTMLAllCollection::namedItemWithIndex): |
| 56 | + * html/HTMLCollection.cpp: |
| 57 | + (WebCore::rootTypeFromCollectionType): Added. As mentioned above, treat all Document-owned HTML collection |
| 58 | + as if rooted at document for convenience. |
| 59 | + (WebCore::invalidationTypeExcludingIdAndNameAttributes): Added. Since all HTML collection requires |
| 60 | + invalidation on id and name content attribute changes, which is taken care by the special logic in |
| 61 | + Document::registerNodeListCache, exclude those two attributes from consideration. |
| 62 | + (WebCore::HTMLCollection::HTMLCollection): Calls Document::registerNodeListCache. |
| 63 | + (WebCore::HTMLCollection::~HTMLCollection): Calls Document::unregisterNodeListCache. |
| 64 | + (WebCore::HTMLCollection::length): |
| 65 | + (WebCore::HTMLCollection::item): |
| 66 | + (WebCore::HTMLCollection::namedItem): |
| 67 | + (WebCore::HTMLCollection::updateNameCache): |
| 68 | + * html/HTMLCollection.h: |
| 69 | + (WebCore::HTMLCollectionCacheBase::HTMLCollectionCacheBase): |
| 70 | + (HTMLCollectionCacheBase): Removed m_cacheTreeVersion and clearCache since they're no longer used. |
| 71 | + (HTMLCollection): |
| 72 | + * html/HTMLFormCollection.cpp: |
| 73 | + (WebCore::HTMLFormCollection::namedItem): |
| 74 | + (WebCore::HTMLFormCollection::updateNameCache): |
| 75 | + * html/HTMLOptionsCollection.h: |
| 76 | + (HTMLOptionsCollection): |
| 77 | + * html/HTMLPropertiesCollection.cpp: |
| 78 | + (WebCore::HTMLPropertiesCollection::updateNameCache): |
| 79 | + * html/HTMLPropertiesCollection.h: |
| 80 | + (WebCore::HTMLPropertiesCollection::invalidateCache): |
| 81 | + |
1 | 82 | 2012-07-13 Shawn Singh <shawnsingh@chromium.org> |
2 | 83 |
|
3 | 84 | [chromium] Remove incorrect debug assertion in LayerRendererChromium.cpp |
|
0 commit comments