From 63e6b1e0ac3d92e04dfb0afa161f3918d5460e95 Mon Sep 17 00:00:00 2001 From: "loislo@chromium.org" Date: Tue, 11 Jan 2011 14:07:34 +0000 Subject: [PATCH] 2011-01-11 Ilya Tikhonovsky 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 | 20 +++++++++++++ .../WebCore/inspector/InspectorDOMAgent.cpp | 29 +++++++++++++------ Source/WebCore/inspector/InspectorDOMAgent.h | 1 + 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 77776f03715a..63333408e084 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2011-01-11 Ilya Tikhonovsky + + 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 Delete WKCACFLayer.{cpp,h} diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index e42bf2a0e0cc..5d8f408888a0 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -268,6 +268,15 @@ void InspectorDOMAgent::releaseDanglingNodes() m_danglingNodeToIdMaps.clear(); } +void InspectorDOMAgent::startListeningFrameDocument(Node* frameOwnerNode) +{ + ASSERT(frameOwnerNode->isFrameOwnerElement()); + HTMLFrameOwnerElement* frameOwner = static_cast(frameOwnerNode); + Document* doc = frameOwner->contentDocument(); + if (doc) + startListening(doc); +} + void InspectorDOMAgent::startListening(Document* doc) { if (m_documents.contains(doc)) @@ -947,20 +956,24 @@ PassRefPtr InspectorDOMAgent::buildArrayForElementAttributes(Ele PassRefPtr InspectorDOMAgent::buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap) { RefPtr children = InspectorArray::create(); + Node* child = innerFirstChild(container); + 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--; } - for (Node *child = innerFirstChild(container); child; child = innerNextSibling(child)) + if (container->isFrameOwnerElement()) + startListeningFrameDocument(container); + + while (child) { children->pushObject(buildObjectForNode(child, depth, nodesMap)); + child = innerNextSibling(child); + } return children.release(); } @@ -987,10 +1000,8 @@ Node* InspectorDOMAgent::innerFirstChild(Node* node) if (node->isFrameOwnerElement()) { HTMLFrameOwnerElement* frameOwner = static_cast(node); Document* doc = frameOwner->contentDocument(); - if (doc) { - startListening(doc); + if (doc) return doc->firstChild(); - } } node = node->firstChild(); while (isWhitespace(node)) diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 1611baa8bb62..36627f57d97c 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -148,6 +148,7 @@ namespace WebCore { void removeDOMBreakpoint(long nodeId, long type); private: + void startListeningFrameDocument(Node* frameOwnerNode); void startListening(Document* document); void stopListening(Document* document); -- 2.36.0