[webkit-changes] cvs commit: WebCore/khtml/xml dom_nodeimpl.cpp
dom_nodeimpl.h
Justin
justing at opensource.apple.com
Thu Jun 16 19:13:13 PDT 2005
justing 05/06/16 19:13:13
Modified: . ChangeLog
khtml/editing selection.cpp selection.h visible_position.cpp
visible_position.h
khtml/xml dom_nodeimpl.cpp dom_nodeimpl.h
Log:
Added a few debugging methods to highlight Selections, VisiblePositions and Nodes in the DOM tree.
Reviewed by Dave Harrison
Test cases added: None, changes are only to aid debugging
* khtml/editing/selection.cpp:
(khtml::Selection::showTree):
* khtml/editing/selection.h:
* khtml/editing/visible_position.cpp:
(khtml::VisiblePosition::showTree):
* khtml/editing/visible_position.h:
* khtml/xml/dom_nodeimpl.cpp:
(NodeImpl::showNode):
(NodeImpl::showTree):
(NodeImpl::showTreeAndMark):
* khtml/xml/dom_nodeimpl.h:
Revision Changes Path
1.4267 +20 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4266
retrieving revision 1.4267
diff -u -r1.4266 -r1.4267
--- ChangeLog 16 Jun 2005 19:42:20 -0000 1.4266
+++ ChangeLog 17 Jun 2005 02:13:07 -0000 1.4267
@@ -1,3 +1,23 @@
+2005-06-16 Justin Garcia <justin.garcia at apple.com>
+
+ Added a few debugging methods to highlight Selections, VisiblePositions and Nodes in the DOM tree.
+
+ Reviewed by Dave Harrison
+
+ Test cases added: None, changes are only to aid debugging
+
+ * khtml/editing/selection.cpp:
+ (khtml::Selection::showTree):
+ * khtml/editing/selection.h:
+ * khtml/editing/visible_position.cpp:
+ (khtml::VisiblePosition::showTree):
+ * khtml/editing/visible_position.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::showNode):
+ (NodeImpl::showTree):
+ (NodeImpl::showTreeAndMark):
+ * khtml/xml/dom_nodeimpl.h:
+
2005-06-14 David Hyatt <hyatt at apple.com>
Add an initial implementation of QualifiedName and HTMLNames. These classes are not used by anyone yet.
1.87 +5 -0 WebCore/khtml/editing/selection.cpp
Index: selection.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/selection.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- selection.cpp 13 May 2005 16:48:51 -0000 1.86
+++ selection.cpp 17 Jun 2005 02:13:11 -0000 1.87
@@ -1093,6 +1093,11 @@
strncpy(buffer, result.string().latin1(), length - 1);
}
#undef FormatBufferSize
+
+void Selection::showTree()
+{
+ m_start.node()->showTreeAndMark(m_start.node(), "S", m_end.node(), "E");
+}
#endif
} // namespace DOM
1.38 +1 -0 WebCore/khtml/editing/selection.h
Index: selection.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/selection.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- selection.h 16 May 2005 19:19:38 -0000 1.37
+++ selection.h 17 Jun 2005 02:13:11 -0000 1.38
@@ -119,6 +119,7 @@
#ifndef NDEBUG
void formatForDebugger(char *buffer, unsigned length) const;
+ void showTree();
#endif
private:
1.49 +5 -0 WebCore/khtml/editing/visible_position.cpp
Index: visible_position.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_position.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- visible_position.cpp 26 May 2005 20:30:12 -0000 1.48
+++ visible_position.cpp 17 Jun 2005 02:13:11 -0000 1.49
@@ -405,6 +405,11 @@
{
m_deepPosition.formatForDebugger(buffer, length);
}
+
+void VisiblePosition::showTree()
+{
+ m_deepPosition.node()->showTreeAndMark(m_deepPosition.node(), "*", NULL, NULL);
+}
#endif
SharedPtr<RangeImpl> makeRange(const VisiblePosition &start, const VisiblePosition &end)
1.28 +1 -0 WebCore/khtml/editing/visible_position.h
Index: visible_position.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_position.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- visible_position.h 13 May 2005 16:48:51 -0000 1.27
+++ visible_position.h 17 Jun 2005 02:13:11 -0000 1.28
@@ -82,6 +82,7 @@
#ifndef NDEBUG
void formatForDebugger(char *buffer, unsigned length) const;
+ void showTree();
#endif
private:
1.153 +20 -8 WebCore/khtml/xml/dom_nodeimpl.cpp
Index: dom_nodeimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_nodeimpl.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -r1.152 -r1.153
--- dom_nodeimpl.cpp 31 May 2005 01:20:46 -0000 1.152
+++ dom_nodeimpl.cpp 17 Jun 2005 02:13:12 -0000 1.153
@@ -1601,7 +1601,7 @@
#ifndef NDEBUG
-void NodeImpl::displayNode(const char *prefix)
+void NodeImpl::showNode(const char *prefix)
{
if (!prefix)
prefix = "";
@@ -1614,18 +1614,30 @@
fprintf(stderr, "%s%s\t%p\n", prefix, nodeName().string().local8Bit().data(), this);
}
-void NodeImpl::displayTree()
+void NodeImpl::showTree()
{
- NodeImpl *rootNode = rootEditableElement() ? : this;
- NodeImpl *node;
-
+ showTreeAndMark(this, "*", NULL, NULL);
+}
+
+void NodeImpl::showTreeAndMark(NodeImpl * markedNode1, const char * markedLabel1, NodeImpl * markedNode2, const char * markedLabel2)
+{
+ NodeImpl *rootNode;
+ NodeImpl *node = this;
+ while(node->parentNode() != NULL && node->id() != ID_BODY)
+ node = node->parentNode();
+ rootNode = node;
+
for (node = rootNode; node; node = node->traverseNextNode()) {
NodeImpl *tmpNode;
- if (node == this)
- fprintf(stderr, "*");
+
+ if (node == markedNode1)
+ fprintf(stderr, markedLabel1);
+ if (node == markedNode2)
+ fprintf(stderr, markedLabel2);
+
for (tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = tmpNode->parentNode())
fprintf(stderr, "\t");
- node->displayNode(0);
+ node->showNode(0);
}
}
1.86 +4 -2 WebCore/khtml/xml/dom_nodeimpl.h
Index: dom_nodeimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_nodeimpl.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- dom_nodeimpl.h 12 May 2005 01:16:01 -0000 1.85
+++ dom_nodeimpl.h 17 Jun 2005 02:13:12 -0000 1.86
@@ -470,8 +470,10 @@
#ifndef NDEBUG
virtual void formatForDebugger(char *buffer, unsigned length) const;
- void displayNode(const char *prefix="");
- void displayTree();
+ void showNode(const char *prefix="");
+ void showTree();
+ void showTreeAndMark(NodeImpl * markedNode1, const char * markedLabel1, NodeImpl * markedNode2, const char * markedLabel2);
+
#endif
void registerNodeList(NodeListImpl *list);
More information about the webkit-changes
mailing list