<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[24889] trunk</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/24889">24889</a></dd>
<dt>Author</dt> <dd>andersca</dd>
<dt>Date</dt> <dd>2007-08-06 13:10:53 -0700 (Mon, 06 Aug 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>LayoutTests:

        Reviewed by Darin.

        &lt;rdar://problem/5360748&gt; 
        REGRESSION(r21002-r21003) Flash widget sniffer doesn't work (affects iWeb)
        
        Add test case by Kurt Revis.
        
        * fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt: Added.
        * fast/dom/NodeList/invalidate-node-lists-when-parsing.html: Added.

WebCore:

        Reviewed by Darin.

        &lt;rdar://problem/5360748&gt;
        REGRESSION(r21002-r21003) Flash widget sniffer doesn't work
        
        Add a per-document NodeList counter. When parsing, only call notifyNodeListsChildrenChanged
        if the document has node lists.
        
        * dom/ContainerNode.cpp:
        (WebCore::ContainerNode::addChild):
        * dom/Document.cpp:
        (WebCore::Document::Document):
        * dom/Document.h:
        (WebCore::Document::addNodeList):
        (WebCore::Document::removeNodeList):
        (WebCore::Document::hasNodeLists):
        * dom/Node.cpp:
        (WebCore::Node::registerNodeList):
        (WebCore::Node::unregisterNodeList):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoredomContainerNodecpp">trunk/WebCore/dom/ContainerNode.cpp</a></li>
<li><a href="#trunkWebCoredomDocumentcpp">trunk/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkWebCoredomDocumenth">trunk/WebCore/dom/Document.h</a></li>
<li><a href="#trunkWebCoredomNodecpp">trunk/WebCore/dom/Node.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomNodeListinvalidatenodelistswhenparsingexpectedtxt">trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomNodeListinvalidatenodelistswhenparsinghtml">trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/LayoutTests/ChangeLog        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2007-08-06  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Reviewed by Darin.
+
+        &lt;rdar://problem/5360748&gt; 
+        REGRESSION(r21002-r21003) Flash widget sniffer doesn't work (affects iWeb)
+        
+        Add test case by Kurt Revis.
+        
+        * fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt: Added.
+        * fast/dom/NodeList/invalidate-node-lists-when-parsing.html: Added.
+
</ins><span class="cx"> 2007-08-06  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Beth made this reduction/test, Geoff and I both helped refine it.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomNodeListinvalidatenodelistswhenparsingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt (0 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed.
+
+If the test passes, you should see &quot;before: not found&quot; and &quot;after: found&quot;.
+
+If the cache is not invalidated when the testElement is parsed, both before and after will be &quot;not found&quot;, which is a failure.
+
+before: not found
+after: found
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomNodeListinvalidatenodelistswhenparsinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html (0 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot; &gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
+        &lt;title&gt;5360748&lt;/title&gt;
+
+        &lt;script type=&quot;text/javascript&quot;&gt;
+            function print(message)
+            {
+                var paragraph = document.createElement(&quot;li&quot;);
+                paragraph.appendChild(document.createTextNode(message));
+                document.getElementById(&quot;console&quot;).appendChild(paragraph);
+            }
+            function test()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+            }
+            function testForElement(testName) {
+                var found = containsElementWithId(document.body, &quot;testElement&quot;);
+                return testName + &quot;: &quot; + (found ? &quot;found&quot; : &quot;not found&quot;);
+            }
+            function containsElementWithId(el, id) {
+                var found = false;
+    
+                if (el.id == id) {
+                    found = true;
+                } else {
+                    var children = el.childNodes;
+                    for (var i=0; !found &amp;&amp; i &lt; children.length; i++)
+                        found = containsElementWithId(children[i], id);            
+                }
+                
+                return found;
+            }
+        &lt;/script&gt;        
+    &lt;/head&gt;
+    &lt;body onload=&quot;test()&quot;&gt;
+
+    &lt;p&gt;This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed.&lt;/p&gt;
+    &lt;p&gt;If the test passes, you should see &amp;quot;before: not found&amp;quot; and &amp;quot;after: found&amp;quot;.&lt;/p&gt;
+    &lt;p&gt;If the cache is not invalidated when the testElement is parsed, both before and after will be &amp;quot;not found&amp;quot;, which is a failure.&lt;/p&gt;
+    &lt;hr&gt;
+    &lt;p&gt;&lt;ol id=console&gt;&lt;/ol&gt;&lt;/p&gt;
+
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        result1 = testForElement(&quot;before&quot;);    // expect not to see &quot;testElement&quot;
+    &lt;/script&gt;
+
+    &lt;p id=&quot;testElement&quot;&gt;&lt;/p&gt;
+    
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        result2 = testForElement(&quot;after&quot;);    // expect to see &quot;testElement&quot;
+
+        // don't show the results until the tests are finished -- it changes the DOM and could affect the tests
+        print(result1);
+        print(result2);
+    &lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/WebCore/ChangeLog        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2007-08-06  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Reviewed by Darin.
+
+        &lt;rdar://problem/5360748&gt;
+        REGRESSION(r21002-r21003) Flash widget sniffer doesn't work
+        
+        Add a per-document NodeList counter. When parsing, only call notifyNodeListsChildrenChanged
+        if the document has node lists.
+        
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::addChild):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/Document.h:
+        (WebCore::Document::addNodeList):
+        (WebCore::Document::removeNodeList):
+        (WebCore::Document::hasNodeLists):
+        * dom/Node.cpp:
+        (WebCore::Node::registerNodeList):
+        (WebCore::Node::unregisterNodeList):
+
</ins><span class="cx"> 2007-08-06  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Maciej.
</span></span></pre></div>
<a id="trunkWebCoredomContainerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/ContainerNode.cpp (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/ContainerNode.cpp        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/WebCore/dom/ContainerNode.cpp        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -570,6 +570,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (inDocument())
</span><span class="cx">         newChild-&gt;insertedIntoDocument();
</span><ins>+    if (document()-&gt;hasNodeLists())
+        notifyNodeListsChildrenChanged();
</ins><span class="cx">     childrenChanged();
</span><span class="cx">     
</span><span class="cx">     if (newChild-&gt;isElementNode())
</span></span></pre></div>
<a id="trunkWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.cpp (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.cpp        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/WebCore/dom/Document.cpp        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -279,6 +279,7 @@
</span><span class="cx"> #if USE(LOW_BANDWIDTH_DISPLAY)
</span><span class="cx">     , m_inLowBandwidthDisplay(false)
</span><span class="cx"> #endif    
</span><ins>+    , m_numNodeLists(0)
</ins><span class="cx"> {
</span><span class="cx">     m_document.resetSkippingRef(this);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.h (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.h        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/WebCore/dom/Document.h        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -652,8 +652,12 @@
</span><span class="cx">     void setDocLoader(DocLoader* loader) { m_docLoader = loader; }
</span><span class="cx">     bool inLowBandwidthDisplay() const { return m_inLowBandwidthDisplay; }
</span><span class="cx">     void setLowBandwidthDisplay(bool lowBandWidth) { m_inLowBandwidthDisplay = lowBandWidth; }
</span><del>-#endif     
-
</del><ins>+#endif 
+    
+    void addNodeList() { m_numNodeLists++; }
+    void removeNodeList() { m_numNodeLists--; }
+    bool hasNodeLists() const { return m_numNodeLists != 0; }
+    
</ins><span class="cx"> protected:
</span><span class="cx">     CSSStyleSelector* m_styleSelector;
</span><span class="cx">     bool m_didCalculateStyleSelector;
</span><span class="lines">@@ -878,6 +882,7 @@
</span><span class="cx">     
</span><span class="cx">     bool m_useSecureKeyboardEntryWhenActive;
</span><span class="cx"> 
</span><ins>+    unsigned m_numNodeLists;
</ins><span class="cx"> #if USE(LOW_BANDWIDTH_DISPLAY)
</span><span class="cx">     bool m_inLowBandwidthDisplay;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Node.cpp (24888 => 24889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Node.cpp        2007-08-06 20:02:20 UTC (rev 24888)
+++ trunk/WebCore/dom/Node.cpp        2007-08-06 20:10:53 UTC (rev 24889)
</span><span class="lines">@@ -435,13 +435,14 @@
</span><span class="cx">     if (!m_nodeLists)
</span><span class="cx">         m_nodeLists = new NodeListsNodeData;
</span><span class="cx">     m_nodeLists-&gt;m_registeredLists.add(list);
</span><ins>+    m_document-&gt;addNodeList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Node::unregisterNodeList(NodeList* list)
</span><span class="cx"> {
</span><del>-    if (!m_nodeLists)
-        return;
</del><ins>+    ASSERT(m_nodeLists);
</ins><span class="cx">     m_nodeLists-&gt;m_registeredLists.remove(list);
</span><ins>+    m_document-&gt;removeNodeList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Node::notifyLocalNodeListsAttributeChanged()
</span></span></pre>
</div>
</div>

</body>
</html>