Unreviewed, rolling out r104263 and r104381.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 06:57:57 +0000 (06:57 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 06:57:57 +0000 (06:57 +0000)
http://trac.webkit.org/changeset/104263
http://trac.webkit.org/changeset/104381
https://bugs.webkit.org/show_bug.cgi?id=76029

Preparation to rollout r104210 (Requested by rniwa on
#webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-01-10

Source/WebCore:

* dom/DynamicNodeList.cpp:
(WebCore::DynamicSubtreeNodeList::SubtreeCaches::setLengthCache):
(WebCore::DynamicSubtreeNodeList::SubtreeCaches::setItemCache):
(WebCore::DynamicSubtreeNodeList::length):
(WebCore::DynamicSubtreeNodeList::item):
* dom/DynamicNodeList.h:
(WebCore::DynamicSubtreeNodeList::SubtreeCaches::isLengthCacheValid):
(WebCore::DynamicSubtreeNodeList::SubtreeCaches::isItemCacheValid):
(WebCore::DynamicSubtreeNodeList::SubtreeCaches::domVersionIsConsistent):

LayoutTests:

* fast/dom/node-list-length-after-removing-node-expected.txt: Removed.
* fast/dom/node-list-length-after-removing-node.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104673 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/node-list-length-after-removing-node-expected.txt [deleted file]
LayoutTests/fast/dom/node-list-length-after-removing-node.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/dom/DynamicNodeList.cpp
Source/WebCore/dom/DynamicNodeList.h

index 7e60f7a07f00ecc7426f945eb65c350868a634ee..1e618b4af18e96af915d8611f6e14a71ccfc606a 100644 (file)
@@ -1,3 +1,16 @@
+2012-01-10  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r104263 and r104381.
+        http://trac.webkit.org/changeset/104263
+        http://trac.webkit.org/changeset/104381
+        https://bugs.webkit.org/show_bug.cgi?id=76029
+
+        Preparation to rollout r104210 (Requested by rniwa on
+        #webkit).
+
+        * fast/dom/node-list-length-after-removing-node-expected.txt: Removed.
+        * fast/dom/node-list-length-after-removing-node.html: Removed.
+
 2012-01-04  Kent Tamura  <tkent@chromium.org>
 
         A radio button not in a Document should not join a radio button group
diff --git a/LayoutTests/fast/dom/node-list-length-after-removing-node-expected.txt b/LayoutTests/fast/dom/node-list-length-after-removing-node-expected.txt
deleted file mode 100644 (file)
index 3688b0e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-This tests accessing an item in node list and then querying the length of the node list after removing the item. WebKit should not crash.
-
-PASS
diff --git a/LayoutTests/fast/dom/node-list-length-after-removing-node.html b/LayoutTests/fast/dom/node-list-length-after-removing-node.html
deleted file mode 100644 (file)
index df832ce..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body onload="runTest()">
-<p>This tests accessing an item in node list and then querying the length of the node list after removing the item.
-WebKit should not crash.</p>
-<span></span><span></span>
-<div id="result"></div>
-<script>
-
-var nodeList = document.getElementsByTagName('span');
-document.body.removeChild(nodeList[0]);
-
-if (window.layoutTestController)
-    layoutTestController.dumpAsText();
-
-if (window.GCController)
-   GCController.collect();
-else {
-    for (var i = 0; i < 10000; ++i)
-        new Object;
-}
-
-document.body.offsetLeft;
-
-function runTest() {
-    document.getElementById('result').innerHTML = nodeList.length == 1 ? 'PASS' : 'FAIL';
-}
-
-</script>
-</body>
-</html>
index ca6add0fbd8bb2f9687c5f513ca5c1aac6163ff6..46fc53fb1caacf3938f6410821e62344d3635eed 100644 (file)
@@ -1,3 +1,23 @@
+2012-01-10  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r104263 and r104381.
+        http://trac.webkit.org/changeset/104263
+        http://trac.webkit.org/changeset/104381
+        https://bugs.webkit.org/show_bug.cgi?id=76029
+
+        Preparation to rollout r104210 (Requested by rniwa on
+        #webkit).
+
+        * dom/DynamicNodeList.cpp:
+        (WebCore::DynamicSubtreeNodeList::SubtreeCaches::setLengthCache):
+        (WebCore::DynamicSubtreeNodeList::SubtreeCaches::setItemCache):
+        (WebCore::DynamicSubtreeNodeList::length):
+        (WebCore::DynamicSubtreeNodeList::item):
+        * dom/DynamicNodeList.h:
+        (WebCore::DynamicSubtreeNodeList::SubtreeCaches::isLengthCacheValid):
+        (WebCore::DynamicSubtreeNodeList::SubtreeCaches::isItemCacheValid):
+        (WebCore::DynamicSubtreeNodeList::SubtreeCaches::domVersionIsConsistent):
+
 2012-01-10  David Kilzer  <ddkilzer@apple.com>
 
         Add TestWebKitAPI tests for KURL
index 6e4ef818bbffab96459645c19edc0315b7967437..c234512874fcd09325f7c2a98754fd5b215cd35b 100644 (file)
@@ -36,24 +36,25 @@ DynamicSubtreeNodeList::SubtreeCaches::SubtreeCaches()
 {
 }
 
-void DynamicSubtreeNodeList::SubtreeCaches::setLengthCache(Document* document, unsigned length)
+void DynamicSubtreeNodeList::SubtreeCaches::setLengthCache(Node* node, unsigned length)
 {
-    if (m_isItemCacheValid && !domVersionIsConsistent(document))
+    if (m_isItemCacheValid && !domVersionIsConsistent()) {
+        m_cachedItem = node;
         m_isItemCacheValid = false;
+    }
     m_cachedLength = length;
     m_isLengthCacheValid = true;
-    m_domTreeVersionAtTimeOfCaching = document->domTreeVersion();
+    m_domTreeVersionAtTimeOfCaching = node->document()->domTreeVersion();
 }
 
 void DynamicSubtreeNodeList::SubtreeCaches::setItemCache(Node* item, unsigned offset)
 {
-    Document* document = item->document();
-    if (m_isLengthCacheValid && !domVersionIsConsistent(document))
+    if (m_isLengthCacheValid && !domVersionIsConsistent())
         m_isLengthCacheValid = false;
     m_cachedItem = item;
     m_cachedItemOffset = offset;
     m_isItemCacheValid = true;
-    m_domTreeVersionAtTimeOfCaching = document->domTreeVersion();
+    m_domTreeVersionAtTimeOfCaching = item->document()->domTreeVersion();
 }
 
 void DynamicSubtreeNodeList::SubtreeCaches::reset()
@@ -76,8 +77,7 @@ DynamicSubtreeNodeList::~DynamicSubtreeNodeList()
 
 unsigned DynamicSubtreeNodeList::length() const
 {
-    Document* document = node()->document();
-    if (m_caches.isLengthCacheValid(document))
+    if (m_caches.isLengthCacheValid())
         return m_caches.cachedLength();
 
     unsigned length = 0;
@@ -85,7 +85,7 @@ unsigned DynamicSubtreeNodeList::length() const
     for (Node* n = node()->firstChild(); n; n = n->traverseNextNode(rootNode()))
         length += n->isElementNode() && nodeMatches(static_cast<Element*>(n));
 
-    m_caches.setLengthCache(document, length);
+    m_caches.setLengthCache(node(), length);
 
     return length;
 }
@@ -126,7 +126,7 @@ Node* DynamicSubtreeNodeList::item(unsigned offset) const
 {
     int remainingOffset = offset;
     Node* start = node()->firstChild();
-    if (m_caches.isItemCacheValid(node()->document())) {
+    if (m_caches.isItemCacheValid()) {
         if (offset == m_caches.cachedItemOffset())
             return m_caches.cachedItem();
         if (offset > m_caches.cachedItemOffset() || m_caches.cachedItemOffset() - offset < offset) {
index a4022929cdada2501c6df0b60861a895dea68831..7f36e8190ad061016a5751a8e54a600db526eaa4 100644 (file)
@@ -86,28 +86,27 @@ private:
     public:
         SubtreeCaches();
 
-        bool isLengthCacheValid(Document* document) const { return m_isLengthCacheValid && domVersionIsConsistent(document); }
-        bool isItemCacheValid(Document* document) const { return m_isItemCacheValid && domVersionIsConsistent(document); }
+        bool isLengthCacheValid() const { return m_isLengthCacheValid && domVersionIsConsistent(); }
+        bool isItemCacheValid() const { return m_isItemCacheValid && domVersionIsConsistent(); }
 
         unsigned cachedLength() const { return m_cachedLength; }
         Node* cachedItem() const { return m_cachedItem; }
         unsigned cachedItemOffset() const { return m_cachedItemOffset; }
 
-        void setLengthCache(Document*, unsigned length);
+        void setLengthCache(Node* nodeForDocumentVersion, unsigned length);
         void setItemCache(Node*, unsigned offset);
         void reset();
 
     private:
         Node* m_cachedItem;
         unsigned m_cachedItemOffset;
-        unsigned m_cachedLength : 30;
-        unsigned m_isLengthCacheValid : 1;
-        unsigned m_isItemCacheValid : 1;
+        unsigned m_cachedLength;
+        bool m_isLengthCacheValid : 1;
+        bool m_isItemCacheValid : 1;
 
-        bool domVersionIsConsistent(Document* document) const
+        bool domVersionIsConsistent() const
         {
-            ASSERT(document);
-            return document->domTreeVersion() == m_domTreeVersionAtTimeOfCaching;
+            return m_cachedItem && m_cachedItem->document()->domTreeVersion() == m_domTreeVersionAtTimeOfCaching;
         }
         uint64_t m_domTreeVersionAtTimeOfCaching;
     };