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

Side by Side Diff: third_party/WebKit/Source/platform/testing/PaintPrinters.cpp

Issue 2574713003: Add toString() for paint property node classes (Closed)
Patch Set: Update test Created 4 years 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/testing/PaintPrinters.h" 5 #include "platform/testing/PaintPrinters.h"
6 6
7 #include "platform/graphics/paint/PaintChunk.h" 7 #include "platform/graphics/paint/PaintChunk.h"
8 #include "platform/graphics/paint/PaintChunkProperties.h" 8 #include "platform/graphics/paint/PaintChunkProperties.h"
9 #include <iomanip> // NOLINT 9 #include <iomanip> // NOLINT
10 #include <ostream> // NOLINT 10 #include <ostream> // NOLINT
11 11
12 namespace { 12 namespace {
13 class StreamStateSaver : private std::ios { 13 class StreamStateSaver : private std::ios {
14 WTF_MAKE_NONCOPYABLE(StreamStateSaver); 14 WTF_MAKE_NONCOPYABLE(StreamStateSaver);
15 15
16 public: 16 public:
17 StreamStateSaver(std::ios& other) : std::ios(nullptr), m_other(other) { 17 StreamStateSaver(std::ios& other) : std::ios(nullptr), m_other(other) {
18 copyfmt(other); 18 copyfmt(other);
19 } 19 }
20 ~StreamStateSaver() { m_other.copyfmt(*this); } 20 ~StreamStateSaver() { m_other.copyfmt(*this); }
21 21
22 private: 22 private:
23 std::ios& m_other; 23 std::ios& m_other;
24 }; 24 };
25 } // unnamed namespace 25 } // unnamed namespace
26 26
27 namespace blink { 27 namespace blink {
28 28
29 // basic_ostream::operator<<(const void*) is drunk.
30 static void PrintPointer(const void* ptr, std::ostream& os) {
31 StreamStateSaver saver(os);
32 uintptr_t intPtr = reinterpret_cast<uintptr_t>(ptr);
33 os << "0x" << std::setfill('0') << std::setw(sizeof(uintptr_t) * 2)
34 << std::hex << intPtr;
35 }
36
37 void PrintTo(const ClipPaintPropertyNode& node, std::ostream* os) {
38 *os << "ClipPaintPropertyNode(clip=";
39 PrintTo(node.clipRect(), os);
40 *os << ", localTransformSpace=";
41 PrintPointer(node.localTransformSpace(), *os);
42 *os << ", parent=";
43 PrintPointer(node.parent(), *os);
44 *os << ")";
45 }
46
47 void PrintTo(const PaintChunk& chunk, std::ostream* os) { 29 void PrintTo(const PaintChunk& chunk, std::ostream* os) {
48 *os << "PaintChunk(begin=" << chunk.beginIndex << ", end=" << chunk.endIndex 30 *os << "PaintChunk(begin=" << chunk.beginIndex << ", end=" << chunk.endIndex
49 << ", id="; 31 << ", id=";
50 if (!chunk.id) { 32 if (!chunk.id) {
51 *os << "null"; 33 *os << "null";
52 } else { 34 } else {
53 *os << "(" << &chunk.id->client << ", "; 35 *os << "(" << &chunk.id->client << ", ";
54 #ifndef NDEBUG 36 #ifndef NDEBUG
55 *os << DisplayItem::typeAsDebugString(chunk.id->type); 37 *os << DisplayItem::typeAsDebugString(chunk.id->type);
56 #else 38 #else
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 printedProperty = true; 90 printedProperty = true;
109 } 91 }
110 92
111 if (printedProperty) 93 if (printedProperty)
112 *os << ", "; 94 *os << ", ";
113 *os << "backfaceHidden=" << properties.backfaceHidden; 95 *os << "backfaceHidden=" << properties.backfaceHidden;
114 96
115 *os << ")"; 97 *os << ")";
116 } 98 }
117 99
118 void PrintTo(const TransformPaintPropertyNode& transformPaintProperty, 100 void PrintTo(const ClipPaintPropertyNode& node, std::ostream* os) {
119 std::ostream* os) { 101 *os << "ClipPaintPropertyNode(" << node.toString().ascii().data() << ")";
120 *os << "TransformPaintPropertyNode(matrix=";
121 PrintTo(transformPaintProperty.matrix(), os);
122 *os << ", origin=";
123 PrintTo(transformPaintProperty.origin(), os);
124 *os << ")";
125 } 102 }
126 103
127 void PrintTo(const EffectPaintPropertyNode& effect, std::ostream* os) { 104 void PrintTo(const TransformPaintPropertyNode& node, std::ostream* os) {
128 *os << "EffectPaintPropertyNode(opacity=" << effect.opacity() << ")"; 105 *os << "TransformPaintPropertyNode(" << node.toString().ascii().data() << ")";
106 }
107
108 void PrintTo(const EffectPaintPropertyNode& node, std::ostream* os) {
109 *os << "EffectPaintPropertyNode(" << node.toString().ascii().data() << ")";
129 } 110 }
130 111
131 void PrintTo(const ScrollPaintPropertyNode& node, std::ostream* os) { 112 void PrintTo(const ScrollPaintPropertyNode& node, std::ostream* os) {
132 *os << "ScrollPaintPropertyNode(clip="; 113 *os << "ScrollPaintPropertyNode(" << node.toString().ascii().data() << ")";
133 PrintTo(node.clip(), os);
134 *os << ", bounds=";
135 PrintTo(node.bounds(), os);
136 *os << ", userScrollableHorizontal=" << node.userScrollableHorizontal();
137 *os << ", userScrollableVertical=" << node.userScrollableVertical();
138 *os << ", scrollOffsetTranslation=";
139 PrintPointer(node.scrollOffsetTranslation(), *os);
140 *os << ", parent=";
141 PrintPointer(node.parent(), *os);
142 *os << ")";
143 } 114 }
144 115
145 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698