Title: [207954] releases/WebKitGTK/webkit-2.14
Revision
207954
Author
[email protected]
Date
2016-10-27 00:45:34 -0700 (Thu, 27 Oct 2016)

Log Message

Merge r206975 - REGRESSION(r165103): labels list doesn't get invalidated when other lists are invalidated at document level
https://bugs.webkit.org/show_bug.cgi?id=163145

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by Document::invalidateNodeListAndCollectionCaches removing all node lists regardless
of whether they have been invalidated or not.

Fixed the bug by removing only those node lists that got invalidated via LiveNodeList::invalidateCache.

Test: fast/dom/NodeList/form-labels-length.html

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::unregisterNodeListForInvalidation): Removed the conditional which allowed removal to
happen while m_listsInvalidatedAtDocument is empty inside invalidateNodeListAndCollectionCaches.
* dom/Document.h:
* dom/Node.cpp:
(WebCore::Document::invalidateNodeListAndCollectionCaches): Just remove the node lists being invalidated via
LiveNodeList's invalidateCache, which calls unregisterNodeListForInvalidation, instead of removing them all.
We make a copy of the list of node lists into a local vector because mutating HashMap while iterating over it
is not a safe operation.

LayoutTests:

Added a regression test.

* fast/dom/NodeList/form-labels-length-expected.txt: Added.
* fast/dom/NodeList/form-labels-length.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (207953 => 207954)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog	2016-10-27 07:34:21 UTC (rev 207953)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog	2016-10-27 07:45:34 UTC (rev 207954)
@@ -1,3 +1,15 @@
+2016-10-07  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r165103): labels list doesn't get invalidated when other lists are invalidated at document level
+        https://bugs.webkit.org/show_bug.cgi?id=163145
+
+        Reviewed by Darin Adler.
+
+        Added a regression test.
+
+        * fast/dom/NodeList/form-labels-length-expected.txt: Added.
+        * fast/dom/NodeList/form-labels-length.html: Added.
+
 2016-10-07  Zalan Bujtas  <[email protected]>
 
         https://vuldb.com/?cvssv3.2012 takes long time to load.

Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt (0 => 207954)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt	2016-10-27 07:45:34 UTC (rev 207954)
@@ -0,0 +1,10 @@
+Tests that removing and inserting an input element always invalidates the cache in the labels node list
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS input.labels.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length.html (0 => 207954)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/dom/NodeList/form-labels-length.html	2016-10-27 07:45:34 UTC (rev 207954)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script src=""
+<script>
+
+description('Tests that removing and inserting an input element always invalidates the cache in the labels node list');
+
+var iframe = document.createElement('iframe');
+document.body.appendChild(iframe);
+var doc = iframe.contentDocument;
+
+doc.body.innerHTML = '<form><label><input id=someInput></label><label for="" id=otherInput>';
+var input = doc.getElementById('someInput');
+var form = doc.querySelector('form');
+form.elements[0];
+input.labels[0];
+form.id = 'someId';
+form.remove();
+doc.body.appendChild(input);
+
+shouldBe('input.labels.length', '0');
+
+</script>
+<script src=""
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (207953 => 207954)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-10-27 07:34:21 UTC (rev 207953)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-10-27 07:45:34 UTC (rev 207954)
@@ -1,3 +1,28 @@
+2016-10-07  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r165103): labels list doesn't get invalidated when other lists are invalidated at document level
+        https://bugs.webkit.org/show_bug.cgi?id=163145
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by Document::invalidateNodeListAndCollectionCaches removing all node lists regardless
+        of whether they have been invalidated or not.
+
+        Fixed the bug by removing only those node lists that got invalidated via LiveNodeList::invalidateCache.
+
+        Test: fast/dom/NodeList/form-labels-length.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::unregisterNodeListForInvalidation): Removed the conditional which allowed removal to
+        happen while m_listsInvalidatedAtDocument is empty inside invalidateNodeListAndCollectionCaches.
+        * dom/Document.h:
+        * dom/Node.cpp:
+        (WebCore::Document::invalidateNodeListAndCollectionCaches): Just remove the node lists being invalidated via
+        LiveNodeList's invalidateCache, which calls unregisterNodeListForInvalidation, instead of removing them all.
+        We make a copy of the list of node lists into a local vector because mutating HashMap while iterating over it
+        is not a safe operation.
+
 2016-10-07  Brent Fulgham  <[email protected]>
 
         EventHandler functions that need to guarantee event handler lifetime need to use Ref<Frame>

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.cpp (207953 => 207954)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.cpp	2016-10-27 07:34:21 UTC (rev 207953)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.cpp	2016-10-27 07:45:34 UTC (rev 207954)
@@ -485,9 +485,6 @@
     , m_xmlStandalone(StandaloneUnspecified)
     , m_hasXMLDeclaration(false)
     , m_designMode(inherit)
-#if !ASSERT_DISABLED
-    , m_inInvalidateNodeListAndCollectionCaches(false)
-#endif
 #if ENABLE(DASHBOARD_SUPPORT)
     , m_hasAnnotatedRegions(false)
     , m_annotatedRegionsDirty(false)
@@ -4008,9 +4005,7 @@
         return;
 
     list.setRegisteredForInvalidationAtDocument(false);
-    ASSERT(m_inInvalidateNodeListAndCollectionCaches
-        ? m_listsInvalidatedAtDocument.isEmpty()
-        : m_listsInvalidatedAtDocument.contains(&list));
+    ASSERT(m_listsInvalidatedAtDocument.contains(&list));
     m_listsInvalidatedAtDocument.remove(&list);
 }
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.h (207953 => 207954)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.h	2016-10-27 07:34:21 UTC (rev 207953)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Document.h	2016-10-27 07:45:34 UTC (rev 207954)
@@ -1579,10 +1579,6 @@
 
     HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
     HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
-#if !ASSERT_DISABLED
-    bool m_inInvalidateNodeListAndCollectionCaches;
-#endif
-
     unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
 
     RefPtr<XPathEvaluator> m_xpathEvaluator;

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Node.cpp (207953 => 207954)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Node.cpp	2016-10-27 07:34:21 UTC (rev 207953)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/dom/Node.cpp	2016-10-27 07:45:34 UTC (rev 207954)
@@ -841,19 +841,15 @@
 
 void Document::invalidateNodeListAndCollectionCaches(const QualifiedName* attrName)
 {
-#if !ASSERT_DISABLED
-    m_inInvalidateNodeListAndCollectionCaches = true;
-#endif
-    HashSet<LiveNodeList*> lists = WTFMove(m_listsInvalidatedAtDocument);
-    m_listsInvalidatedAtDocument.clear();
+    Vector<LiveNodeList*, 8> lists;
+    copyToVector(m_listsInvalidatedAtDocument, lists);
     for (auto* list : lists)
         list->invalidateCacheForAttribute(attrName);
-    HashSet<HTMLCollection*> collections = WTFMove(m_collectionsInvalidatedAtDocument);
+
+    Vector<HTMLCollection*, 8> collections;
+    copyToVector(m_collectionsInvalidatedAtDocument, collections);
     for (auto* collection : collections)
         collection->invalidateCacheForAttribute(attrName);
-#if !ASSERT_DISABLED
-    m_inInvalidateNodeListAndCollectionCaches = false;
-#endif
 }
 
 void Node::invalidateNodeListAndCollectionCachesInAncestors(const QualifiedName* attrName, Element* attributeOwnerElement)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to