Title: [207212] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/LayoutTests/ChangeLog (207211 => 207212)


--- branches/safari-602-branch/LayoutTests/ChangeLog	2016-10-12 08:41:54 UTC (rev 207211)
+++ branches/safari-602-branch/LayoutTests/ChangeLog	2016-10-12 08:41:58 UTC (rev 207212)
@@ -1,5 +1,21 @@
 2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r206975. rdar://problem/28545012
+
+    2016-10-07  Ryosuke Niwa  <rn...@webkit.org>
+
+            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-12  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r206280. rdar://problem/28476953
 
     2016-09-22  Brady Eidson  <beid...@apple.com>

Added: branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt (0 => 207212)


--- branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length-expected.txt	2016-10-12 08:41:58 UTC (rev 207212)
@@ -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: branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length.html (0 => 207212)


--- branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/fast/dom/NodeList/form-labels-length.html	2016-10-12 08:41:58 UTC (rev 207212)
@@ -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: branches/safari-602-branch/Source/WebCore/ChangeLog (207211 => 207212)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-12 08:41:54 UTC (rev 207211)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-12 08:41:58 UTC (rev 207212)
@@ -1,5 +1,34 @@
 2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r206975. rdar://problem/28545012
+
+    2016-10-07  Ryosuke Niwa  <rn...@webkit.org>
+
+            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-12  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r206280. rdar://problem/28476953
 
     2016-09-22  Brady Eidson  <beid...@apple.com>

Modified: branches/safari-602-branch/Source/WebCore/dom/Document.cpp (207211 => 207212)


--- branches/safari-602-branch/Source/WebCore/dom/Document.cpp	2016-10-12 08:41:54 UTC (rev 207211)
+++ branches/safari-602-branch/Source/WebCore/dom/Document.cpp	2016-10-12 08:41:58 UTC (rev 207212)
@@ -484,9 +484,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)
@@ -4001,9 +3998,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: branches/safari-602-branch/Source/WebCore/dom/Document.h (207211 => 207212)


--- branches/safari-602-branch/Source/WebCore/dom/Document.h	2016-10-12 08:41:54 UTC (rev 207211)
+++ branches/safari-602-branch/Source/WebCore/dom/Document.h	2016-10-12 08:41:58 UTC (rev 207212)
@@ -1585,10 +1585,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: branches/safari-602-branch/Source/WebCore/dom/Node.cpp (207211 => 207212)


--- branches/safari-602-branch/Source/WebCore/dom/Node.cpp	2016-10-12 08:41:54 UTC (rev 207211)
+++ branches/safari-602-branch/Source/WebCore/dom/Node.cpp	2016-10-12 08:41:58 UTC (rev 207212)
@@ -814,19 +814,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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to