+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}
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))
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 (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();
}
if (node->isFrameOwnerElement()) {
HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
Document* doc = frameOwner->contentDocument();
- if (doc) {
- startListening(doc);
+ if (doc)
return doc->firstChild();
- }
}
node = node->firstChild();
while (isWhitespace(node))