Changeset 87716 in webkit


Ignore:
Timestamp:
May 31, 2011 12:39:32 AM (13 years ago)
Author:
hayato@chromium.org
Message:

2011-05-30 Hayato Ito <hayato@chromium.org>

Reviewed by Ryosuke Niwa.

Add a utility function for dumping a tree for the Node, including a document of a frame.
https://bugs.webkit.org/show_bug.cgi?id=61727

No new tests since added functions are only available in debug builds.

  • dom/Node.cpp: (WebCore::parentOrHostOrFrameOwner): (WebCore::traverseNextNodeAcrossFrame): (WebCore::Node::showTreeForThisAcrossFrame):
  • dom/Node.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87713 r87716  
     12011-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
    1162011-05-30  James Kozianski  <koz@chromium.org>
    217
  • trunk/Source/WebCore/dom/Node.cpp

    r87371 r87716  
    5858#include "FrameView.h"
    5959#include "HTMLElement.h"
     60#include "HTMLFrameOwnerElement.h"
    6061#include "HTMLNames.h"
    6162#include "InspectorInstrumentation.h"
     
    23762377}
    23772378
     2379static 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
     2387static 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
     2404void 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
    23782420#endif
    23792421
  • trunk/Source/WebCore/dom/Node.h

    r87371 r87716  
    502502    void showTreeForThis() const;
    503503    void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const;
     504    void showTreeForThisAcrossFrame() const;
    504505#endif
    505506
Note: See TracChangeset for help on using the changeset viewer.