Changeset 87716 in webkit
- Timestamp:
- May 31, 2011 12:39:32 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87713 r87716 1 2011-05-30 Hayato Ito <hayato@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Add a utility function for dumping a tree for the Node, including a document of a frame. 6 https://bugs.webkit.org/show_bug.cgi?id=61727 7 8 No new tests since added functions are only available in debug builds. 9 10 * dom/Node.cpp: 11 (WebCore::parentOrHostOrFrameOwner): 12 (WebCore::traverseNextNodeAcrossFrame): 13 (WebCore::Node::showTreeForThisAcrossFrame): 14 * dom/Node.h: 15 1 16 2011-05-30 James Kozianski <koz@chromium.org> 2 17 -
trunk/Source/WebCore/dom/Node.cpp
r87371 r87716 58 58 #include "FrameView.h" 59 59 #include "HTMLElement.h" 60 #include "HTMLFrameOwnerElement.h" 60 61 #include "HTMLNames.h" 61 62 #include "InspectorInstrumentation.h" … … 2376 2377 } 2377 2378 2379 static ContainerNode* parentOrHostOrFrameOwner(Node* node) 2380 { 2381 ContainerNode* parent = node->parentOrHostNode(); 2382 if (!parent && node->document() && node->document()->frame()) 2383 parent = node->document()->frame()->ownerElement(); 2384 return parent; 2385 } 2386 2387 static Node* traverseNextNodeAcrossFrame(Node* node) 2388 { 2389 if (node->isFrameOwnerElement()) 2390 return static_cast<HTMLFrameOwnerElement*>(node)->contentDocument(); 2391 if (ShadowRoot* shadow = shadowRoot(node)) 2392 return traverseNextNodeAcrossFrame(shadow); 2393 if (node->firstChild()) 2394 return node->firstChild(); 2395 if (node->nextSibling()) 2396 return node->nextSibling(); 2397 while (node && !node->nextSibling()) 2398 node = parentOrHostOrFrameOwner(node); 2399 if (node) 2400 return node->nextSibling(); 2401 return 0; 2402 } 2403 2404 void Node::showTreeForThisAcrossFrame() const 2405 { 2406 Node* rootNode = const_cast<Node*>(this); 2407 while (parentOrHostOrFrameOwner(rootNode)) 2408 rootNode = parentOrHostOrFrameOwner(rootNode); 2409 for (Node* node = rootNode; node; node = traverseNextNodeAcrossFrame(node)) { 2410 if (node == this) 2411 fputs("*", stderr); 2412 String indent; 2413 for (Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = parentOrHostOrFrameOwner(tmpNode)) 2414 indent += "\t"; 2415 fputs(indent.utf8().data(), stderr); 2416 node->showNode(); 2417 } 2418 } 2419 2378 2420 #endif 2379 2421 -
trunk/Source/WebCore/dom/Node.h
r87371 r87716 502 502 void showTreeForThis() const; 503 503 void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const; 504 void showTreeForThisAcrossFrame() const; 504 505 #endif 505 506
Note: See TracChangeset
for help on using the changeset viewer.