2011-01-11 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 14:07:34 +0000 (14:07 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 14:07:34 +0000 (14:07 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: innerFirstChild has a side effect which should be called explicitly.

        If a node is a frame's owner then innerFirstChild method
        subscribes DOMAgent instance to the frame's doc's events.
        I think this should be done explicitly when we meet with
        the node for the first time. As I understand it happens
        in buildArrayForContainerChildren method.

        https://bugs.webkit.org/show_bug.cgi?id=52204

        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::startListeningFrameDoc):
        (WebCore::InspectorDOMAgent::buildArrayForContainerChildren):
        (WebCore::InspectorDOMAgent::innerFirstChild):
        * inspector/InspectorDOMAgent.h:

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h

index 77776f03715a4eed570202a9f1e5395f2729d02a..63333408e084b8f14b7fe4834f99649bcbe9fd3e 100644 (file)
@@ -1,3 +1,23 @@
+2011-01-11  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: innerFirstChild has a side effect which should be called explicitly.
+
+        If a node is a frame's owner then innerFirstChild method
+        subscribes DOMAgent instance to the frame's doc's events.
+        I think this should be done explicitly when we meet with
+        the node for the first time. As I understand it happens
+        in buildArrayForContainerChildren method.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52204
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::startListeningFrameDoc):
+        (WebCore::InspectorDOMAgent::buildArrayForContainerChildren):
+        (WebCore::InspectorDOMAgent::innerFirstChild):
+        * inspector/InspectorDOMAgent.h:
+
 2011-01-11  Adam Roben  <aroben@apple.com>
 
         Delete WKCACFLayer.{cpp,h}
 2011-01-11  Adam Roben  <aroben@apple.com>
 
         Delete WKCACFLayer.{cpp,h}
index e42bf2a0e0cce6b7eed869c0042052b6f2a24a01..5d8f408888a0dcf84dbbb977aa18d660154644c7 100644 (file)
@@ -268,6 +268,15 @@ void InspectorDOMAgent::releaseDanglingNodes()
     m_danglingNodeToIdMaps.clear();
 }
 
     m_danglingNodeToIdMaps.clear();
 }
 
+void InspectorDOMAgent::startListeningFrameDocument(Node* frameOwnerNode)
+{
+    ASSERT(frameOwnerNode->isFrameOwnerElement());
+    HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(frameOwnerNode);
+    Document* doc = frameOwner->contentDocument();
+    if (doc)
+        startListening(doc);
+}
+
 void InspectorDOMAgent::startListening(Document* doc)
 {
     if (m_documents.contains(doc))
 void InspectorDOMAgent::startListening(Document* doc)
 {
     if (m_documents.contains(doc))
@@ -947,20 +956,24 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForElementAttributes(Ele
 PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap)
 {
     RefPtr<InspectorArray> children = InspectorArray::create();
 PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap)
 {
     RefPtr<InspectorArray> children = InspectorArray::create();
+    Node* child = innerFirstChild(container);
+
     if (depth == 0) {
         // Special case the_only text child.
     if (depth == 0) {
         // Special case the_only text child.
-        if (innerChildNodeCount(container) == 1) {
-            Node *child = innerFirstChild(container);
-            if (child->nodeType() == Node::TEXT_NODE)
-                children->pushObject(buildObjectForNode(child, 0, nodesMap));
-        }
+        if (child && child->nodeType() == Node::TEXT_NODE && !innerNextSibling(child))
+            children->pushObject(buildObjectForNode(child, 0, nodesMap));
         return children.release();
     } else if (depth > 0) {
         depth--;
     }
 
         return children.release();
     } else if (depth > 0) {
         depth--;
     }
 
-    for (Node *child = innerFirstChild(container); child; child = innerNextSibling(child))
+    if (container->isFrameOwnerElement())
+        startListeningFrameDocument(container);
+
+    while (child) {
         children->pushObject(buildObjectForNode(child, depth, nodesMap));
         children->pushObject(buildObjectForNode(child, depth, nodesMap));
+        child = innerNextSibling(child);
+    }
     return children.release();
 }
 
     return children.release();
 }
 
@@ -987,10 +1000,8 @@ Node* InspectorDOMAgent::innerFirstChild(Node* node)
     if (node->isFrameOwnerElement()) {
         HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
         Document* doc = frameOwner->contentDocument();
     if (node->isFrameOwnerElement()) {
         HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
         Document* doc = frameOwner->contentDocument();
-        if (doc) {
-            startListening(doc);
+        if (doc)
             return doc->firstChild();
             return doc->firstChild();
-        }
     }
     node = node->firstChild();
     while (isWhitespace(node))
     }
     node = node->firstChild();
     while (isWhitespace(node))
index 1611baa8bb62e8ae110ff8bc0130a37cc02c9d64..36627f57d97c234d863b58e1236dcb6147503fd8 100644 (file)
@@ -148,6 +148,7 @@ namespace WebCore {
         void removeDOMBreakpoint(long nodeId, long type);
 
     private:
         void removeDOMBreakpoint(long nodeId, long type);
 
     private:
+        void startListeningFrameDocument(Node* frameOwnerNode);
         void startListening(Document* document);
         void stopListening(Document* document);
 
         void startListening(Document* document);
         void stopListening(Document* document);