Changeset 85512 in webkit
- Timestamp:
- May 2, 2011 1:23:21 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85510 r85512 1 2011-05-02 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 showLineTree/showLineTreeForThis would make working with the line box tree easier 6 https://bugs.webkit.org/show_bug.cgi?id=59662 7 8 Adding a showLineTree/showLineTreeForThis method to help visualize and debug 9 the line tree. Also adding a missing showRenderTreeForThis method to RenderObject. 10 11 No new tests since this is a debugging feature only and not compiled in release. 12 13 * rendering/InlineBox.cpp: 14 (WebCore::InlineBox::showLineTreeForThis): 15 (WebCore::InlineBox::showLineTreeAndMark): 16 (WebCore::InlineBox::showBox): 17 (showLineTree): 18 * rendering/InlineBox.h: 19 * rendering/InlineFlowBox.cpp: 20 (WebCore::InlineFlowBox::showLineTreeAndMark): 21 * rendering/InlineFlowBox.h: 22 * rendering/InlineTextBox.cpp: 23 (WebCore::InlineTextBox::showBox): 24 * rendering/InlineTextBox.h: 25 * rendering/RenderBlock.cpp: 26 (WebCore::RenderBlock::showLineTreeAndMark): 27 * rendering/RenderBlock.h: 28 * rendering/RenderObject.cpp: 29 (WebCore::RenderObject::showRenderTreeForThis): 30 (WebCore::RenderObject::showLineTreeForThis): 31 (showTree): 32 (showLineTree): 33 * rendering/RenderObject.h: 34 1 35 2011-05-02 Dimitri Glazkov <dglazkov@chromium.org> 2 36 -
trunk/Source/WebCore/rendering/InlineBox.cpp
r83540 r85512 80 80 81 81 #ifndef NDEBUG 82 const char* InlineBox::boxName() const 83 { 84 return "InlineBox"; 85 } 86 82 87 void InlineBox::showTreeForThis() const 83 88 { 84 89 if (m_renderer) 85 90 m_renderer->showTreeForThis(); 91 } 92 93 void InlineBox::showLineTreeForThis() const 94 { 95 if (m_renderer) 96 m_renderer->containingBlock()->showLineTreeAndMark(this, "*"); 97 } 98 99 void InlineBox::showLineTreeAndMark(const InlineBox* markedBox1, const char* markedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const RenderObject* obj, int depth) const 100 { 101 int printedCharacters = 0; 102 if (this == markedBox1) 103 printedCharacters += fprintf(stderr, "%s", markedLabel1); 104 if (this == markedBox2) 105 printedCharacters += fprintf(stderr, "%s", markedLabel2); 106 if (renderer() == obj) 107 printedCharacters += fprintf(stderr, "*"); 108 for (; printedCharacters < depth * 2; printedCharacters++) 109 fputc(' ', stderr); 110 111 showBox(printedCharacters); 112 } 113 114 void InlineBox::showBox(int printedCharacters) const 115 { 116 printedCharacters += fprintf(stderr, "%s\t%p", boxName(), this); 117 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) 118 fputc(' ', stderr); 119 fprintf(stderr, "\t%s %p\n", renderer() ? renderer()->renderName() : "No Renderer", renderer()); 86 120 } 87 121 #endif … … 340 374 } 341 375 342 #endif 376 void showLineTree(const WebCore::InlineBox* b) 377 { 378 if (b) 379 b->showLineTreeForThis(); 380 } 381 382 #endif -
trunk/Source/WebCore/rendering/InlineBox.h
r84956 r85512 148 148 #ifndef NDEBUG 149 149 void showTreeForThis() const; 150 void showLineTreeForThis() const; 151 152 virtual void showBox(int = 0) const; 153 virtual void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0, int = 0) const; 154 virtual const char* boxName() const; 150 155 #endif 151 156 … … 387 392 // Outside the WebCore namespace for ease of invocation from gdb. 388 393 void showTree(const WebCore::InlineBox*); 394 void showLineTree(const WebCore::InlineBox*); 389 395 #endif 390 396 -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r84854 r85512 1433 1433 #ifndef NDEBUG 1434 1434 1435 const char* InlineFlowBox::boxName() const 1436 { 1437 return "InlineFlowBox"; 1438 } 1439 1440 void InlineFlowBox::showLineTreeAndMark(const InlineBox* markedBox1, const char* markedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const RenderObject* obj, int depth) const 1441 { 1442 InlineBox::showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLabel2, obj, depth); 1443 for (const InlineBox* box = firstChild(); box; box = box->nextOnLine()) 1444 box->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLabel2, obj, depth + 1); 1445 } 1446 1435 1447 void InlineFlowBox::checkConsistency() const 1436 1448 { -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r83679 r85512 62 62 #ifndef NDEBUG 63 63 virtual ~InlineFlowBox(); 64 65 virtual void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0, int = 0) const; 66 virtual const char* boxName() const; 64 67 #endif 65 68 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r85411 r85512 1292 1292 } 1293 1293 1294 #ifndef NDEBUG 1295 1296 const char* InlineTextBox::boxName() const 1297 { 1298 return "InlineTextBox"; 1299 } 1300 1301 void InlineTextBox::showBox(int printedCharacters) const 1302 { 1303 const RenderText* obj = toRenderText(renderer()); 1304 String value = obj->text(); 1305 value = value.substring(start(), len()); 1306 value.replace('\\', "\\\\"); 1307 value.replace('\n', "\\n"); 1308 printedCharacters += fprintf(stderr, "%s\t%p", boxName(), this); 1309 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) 1310 fputc(' ', stderr); 1311 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); 1312 const int rendererCharacterOffset = 24; 1313 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1314 fputc(' ', stderr); 1315 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().data()); 1316 } 1317 1318 #endif 1319 1294 1320 } // namespace WebCore -
trunk/Source/WebCore/rendering/InlineTextBox.h
r83075 r85512 89 89 int logicalLeftVisualOverflow() const { return logicalOverflowRect().x(); } 90 90 int logicalRightVisualOverflow() const { return logicalOverflowRect().maxX(); } 91 91 92 #ifndef NDEBUG 93 virtual void showBox(int = 0) const; 94 virtual const char* boxName() const; 95 #endif 92 96 private: 93 97 int selectionTop(); -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r85094 r85512 6267 6267 } 6268 6268 6269 6270 #ifndef NDEBUG 6271 6272 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* markedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const RenderObject* obj) const 6273 { 6274 showRenderObject(); 6275 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) 6276 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLabel2, obj, 1); 6277 } 6278 6279 #endif 6280 6269 6281 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderBlock.h
r84956 r85512 226 226 int logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); } 227 227 228 #ifndef NDEBUG 229 void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const; 230 #endif 228 231 protected: 229 232 // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode. -
trunk/Source/WebCore/rendering/RenderObject.cpp
r85256 r85512 1386 1386 } 1387 1387 1388 void RenderObject::showRenderTreeForThis() const 1389 { 1390 showRenderTree(this, 0); 1391 } 1392 1393 void RenderObject::showLineTreeForThis() const 1394 { 1395 if (containingBlock()) 1396 containingBlock()->showLineTreeAndMark(0, 0, 0, 0, this); 1397 } 1398 1388 1399 void RenderObject::showRenderObject() const 1389 1400 { … … 1404 1415 if (node()) { 1405 1416 if (printedCharacters) 1406 for (; printedCharacters < 39; printedCharacters++)1417 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) 1407 1418 fputc(' ', stderr); 1408 1419 fputc('\t', stderr); … … 2627 2638 #ifndef NDEBUG 2628 2639 2629 void showTree(const WebCore::RenderObject* ro) 2630 { 2631 if (ro) 2632 ro->showTreeForThis(); 2640 void showTree(const WebCore::RenderObject* object) 2641 { 2642 if (object) 2643 object->showTreeForThis(); 2644 } 2645 2646 void showLineTree(const WebCore::RenderObject* object) 2647 { 2648 if (object) 2649 object->showLineTreeForThis(); 2633 2650 } 2634 2651 -
trunk/Source/WebCore/rendering/RenderObject.h
r85067 r85512 108 108 #endif 109 109 110 #ifndef NDEBUG 111 const int showTreeCharacterOffset = 39; 112 #endif 113 110 114 // Base class for all rendering tree objects. 111 115 class RenderObject : public CachedResourceClient { … … 223 227 #ifndef NDEBUG 224 228 void showTreeForThis() const; 229 void showRenderTreeForThis() const; 230 void showLineTreeForThis() const; 225 231 226 232 void showRenderObject() const; … … 1127 1133 // Outside the WebCore namespace for ease of invocation from gdb. 1128 1134 void showTree(const WebCore::RenderObject*); 1135 void showLineTree(const WebCore::RenderObject*); 1129 1136 void showRenderTree(const WebCore::RenderObject* object1); 1130 1137 // We don't make object2 an optional parameter so that showRenderTree -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r82611 r85512 814 814 } 815 815 816 #ifndef NDEBUG 817 const char* RootInlineBox::boxName() const 818 { 819 return "RootInlineBox"; 820 } 821 #endif 822 816 823 } // namespace WebCore -
trunk/Source/WebCore/rendering/RootInlineBox.h
r84096 r85512 162 162 Node* getLogicalStartBoxWithNode(InlineBox*&) const; 163 163 Node* getLogicalEndBoxWithNode(InlineBox*&) const; 164 #ifndef NDEBUG 165 virtual const char* boxName() const; 166 #endif 164 167 private: 165 168 bool hasEllipsisBox() const { return m_hasEllipsisBoxOrHyphen; }
Note: See TracChangeset
for help on using the changeset viewer.