Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h

Issue 2647063002: Move property tree debugging code to platform/graphics/paint/ (try #2) (Closed)
Patch Set: none Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h b/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
index 19555592996153b78883df9520f1af9cc9f6b1c2..22d308f37e2e372cd39186d63c03a70d9a120831 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
@@ -11,6 +11,7 @@
#include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "wtf/HashFunctions.h"
#include "wtf/HashTraits.h"
+#include "wtf/text/StringBuilder.h"
namespace blink {
@@ -112,6 +113,11 @@ class PLATFORM_EXPORT PropertyTreeState {
// DCHECK(iterator.next()->innermostNode() == None);
InnermostNode innermostNode() const;
+#if DCHECK_IS_ON()
+ // Dumps the tree from this state up to the root as a string.
+ String toTreeString() const;
+#endif
+
private:
RefPtr<const TransformPaintPropertyNode> m_transform;
RefPtr<const ClipPaintPropertyNode> m_clip;
@@ -139,6 +145,51 @@ class PLATFORM_EXPORT PropertyTreeStateIterator {
PropertyTreeState m_properties;
};
+#if DCHECK_IS_ON()
+
+template <typename PropertyTreeNode>
+class PropertyTreeStatePrinter {
+ public:
+ String pathAsString(const PropertyTreeNode* lastNode) {
+ const PropertyTreeNode* node = lastNode;
+ while (!node->isRoot()) {
+ addPropertyNode(node, "");
+ node = node->parent();
+ }
+ addPropertyNode(node, "root");
+
+ StringBuilder stringBuilder;
+ addAllPropertyNodes(stringBuilder, node);
+ return stringBuilder.toString();
+ }
+
+ void addPropertyNode(const PropertyTreeNode* node, String debugInfo) {
+ m_nodeToDebugString.set(node, debugInfo);
+ }
+
+ void addAllPropertyNodes(StringBuilder& stringBuilder,
+ const PropertyTreeNode* node,
+ unsigned indent = 0) {
+ DCHECK(node);
+ for (unsigned i = 0; i < indent; i++)
+ stringBuilder.append(' ');
+ if (m_nodeToDebugString.contains(node))
+ stringBuilder.append(m_nodeToDebugString.get(node));
+ stringBuilder.append(String::format(" %p ", node));
+ stringBuilder.append(node->toString());
+ stringBuilder.append("\n");
+
+ for (const auto* childNode : m_nodeToDebugString.keys()) {
+ if (childNode->parent() == node)
+ addAllPropertyNodes(stringBuilder, childNode, indent + 2);
+ }
+ }
+
+ HashMap<const PropertyTreeNode*, String> m_nodeToDebugString;
+};
+
+#endif
+
} // namespace blink
#endif // PropertyTreeState_h

Powered by Google App Engine
This is Rietveld 408576698