Title: [87716] trunk/Source/WebCore
- Revision
- 87716
- Author
- [email protected]
- Date
- 2011-05-31 00:39:32 -0700 (Tue, 31 May 2011)
Log Message
2011-05-30 Hayato Ito <[email protected]>
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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (87715 => 87716)
--- trunk/Source/WebCore/ChangeLog 2011-05-31 07:29:20 UTC (rev 87715)
+++ trunk/Source/WebCore/ChangeLog 2011-05-31 07:39:32 UTC (rev 87716)
@@ -1,3 +1,18 @@
+2011-05-30 Hayato Ito <[email protected]>
+
+ 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:
+
2011-05-30 James Kozianski <[email protected]>
Reviewed by Kent Tamura.
Modified: trunk/Source/WebCore/dom/Node.cpp (87715 => 87716)
--- trunk/Source/WebCore/dom/Node.cpp 2011-05-31 07:29:20 UTC (rev 87715)
+++ trunk/Source/WebCore/dom/Node.cpp 2011-05-31 07:39:32 UTC (rev 87716)
@@ -57,6 +57,7 @@
#include "Frame.h"
#include "FrameView.h"
#include "HTMLElement.h"
+#include "HTMLFrameOwnerElement.h"
#include "HTMLNames.h"
#include "InspectorInstrumentation.h"
#include "KeyboardEvent.h"
@@ -2375,6 +2376,47 @@
strncpy(buffer, result.utf8().data(), length - 1);
}
+static ContainerNode* parentOrHostOrFrameOwner(Node* node)
+{
+ ContainerNode* parent = node->parentOrHostNode();
+ if (!parent && node->document() && node->document()->frame())
+ parent = node->document()->frame()->ownerElement();
+ return parent;
+}
+
+static Node* traverseNextNodeAcrossFrame(Node* node)
+{
+ if (node->isFrameOwnerElement())
+ return static_cast<HTMLFrameOwnerElement*>(node)->contentDocument();
+ if (ShadowRoot* shadow = shadowRoot(node))
+ return traverseNextNodeAcrossFrame(shadow);
+ if (node->firstChild())
+ return node->firstChild();
+ if (node->nextSibling())
+ return node->nextSibling();
+ while (node && !node->nextSibling())
+ node = parentOrHostOrFrameOwner(node);
+ if (node)
+ return node->nextSibling();
+ return 0;
+}
+
+void Node::showTreeForThisAcrossFrame() const
+{
+ Node* rootNode = const_cast<Node*>(this);
+ while (parentOrHostOrFrameOwner(rootNode))
+ rootNode = parentOrHostOrFrameOwner(rootNode);
+ for (Node* node = rootNode; node; node = traverseNextNodeAcrossFrame(node)) {
+ if (node == this)
+ fputs("*", stderr);
+ String indent;
+ for (Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = parentOrHostOrFrameOwner(tmpNode))
+ indent += "\t";
+ fputs(indent.utf8().data(), stderr);
+ node->showNode();
+ }
+}
+
#endif
// --------
Modified: trunk/Source/WebCore/dom/Node.h (87715 => 87716)
--- trunk/Source/WebCore/dom/Node.h 2011-05-31 07:29:20 UTC (rev 87715)
+++ trunk/Source/WebCore/dom/Node.h 2011-05-31 07:39:32 UTC (rev 87716)
@@ -501,6 +501,7 @@
void showNode(const char* prefix = "") const;
void showTreeForThis() const;
void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const;
+ void showTreeForThisAcrossFrame() const;
#endif
void removeNodeListCacheIfPossible();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes