Changeset 85512 in webkit


Ignore:
Timestamp:
May 2, 2011 1:23:21 PM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-05-02 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

showLineTree/showLineTreeForThis would make working with the line box tree easier
https://bugs.webkit.org/show_bug.cgi?id=59662

Adding a showLineTree/showLineTreeForThis method to help visualize and debug
the line tree. Also adding a missing showRenderTreeForThis method to RenderObject.

No new tests since this is a debugging feature only and not compiled in release.

  • rendering/InlineBox.cpp: (WebCore::InlineBox::showLineTreeForThis): (WebCore::InlineBox::showLineTreeAndMark): (WebCore::InlineBox::showBox): (showLineTree):
  • rendering/InlineBox.h:
  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::showLineTreeAndMark):
  • rendering/InlineFlowBox.h:
  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::showBox):
  • rendering/InlineTextBox.h:
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::showLineTreeAndMark):
  • rendering/RenderBlock.h:
  • rendering/RenderObject.cpp: (WebCore::RenderObject::showRenderTreeForThis): (WebCore::RenderObject::showLineTreeForThis): (showTree): (showLineTree):
  • rendering/RenderObject.h:
Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85510 r85512  
     12011-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
    1352011-05-02  Dimitri Glazkov  <dglazkov@chromium.org>
    236
  • trunk/Source/WebCore/rendering/InlineBox.cpp

    r83540 r85512  
    8080
    8181#ifndef NDEBUG
     82const char* InlineBox::boxName() const
     83{
     84    return "InlineBox";
     85}
     86
    8287void InlineBox::showTreeForThis() const
    8388{
    8489    if (m_renderer)
    8590        m_renderer->showTreeForThis();
     91}
     92
     93void InlineBox::showLineTreeForThis() const
     94{
     95    if (m_renderer)
     96        m_renderer->containingBlock()->showLineTreeAndMark(this, "*");
     97}
     98
     99void 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
     114void 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());
    86120}
    87121#endif
     
    340374}
    341375
    342 #endif
     376void showLineTree(const WebCore::InlineBox* b)
     377{
     378    if (b)
     379        b->showLineTreeForThis();
     380}
     381
     382#endif
  • trunk/Source/WebCore/rendering/InlineBox.h

    r84956 r85512  
    148148#ifndef NDEBUG
    149149    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;
    150155#endif
    151156
     
    387392// Outside the WebCore namespace for ease of invocation from gdb.
    388393void showTree(const WebCore::InlineBox*);
     394void showLineTree(const WebCore::InlineBox*);
    389395#endif
    390396
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r84854 r85512  
    14331433#ifndef NDEBUG
    14341434
     1435const char* InlineFlowBox::boxName() const
     1436{
     1437    return "InlineFlowBox";
     1438}
     1439
     1440void 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
    14351447void InlineFlowBox::checkConsistency() const
    14361448{
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r83679 r85512  
    6262#ifndef NDEBUG
    6363    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;
    6467#endif
    6568
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r85411 r85512  
    12921292}
    12931293
     1294#ifndef NDEBUG
     1295
     1296const char* InlineTextBox::boxName() const
     1297{
     1298    return "InlineTextBox";
     1299}
     1300
     1301void 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
    12941320} // namespace WebCore
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r83075 r85512  
    8989    int logicalLeftVisualOverflow() const { return logicalOverflowRect().x(); }
    9090    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
    9296private:
    9397    int selectionTop();
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r85094 r85512  
    62676267}
    62686268
     6269
     6270#ifndef NDEBUG
     6271
     6272void 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
    62696281} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r84956 r85512  
    226226    int logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
    227227
     228#ifndef NDEBUG
     229    void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
     230#endif
    228231protected:
    229232    // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode.
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r85256 r85512  
    13861386}
    13871387
     1388void RenderObject::showRenderTreeForThis() const
     1389{
     1390    showRenderTree(this, 0);
     1391}
     1392
     1393void RenderObject::showLineTreeForThis() const
     1394{
     1395    if (containingBlock())
     1396        containingBlock()->showLineTreeAndMark(0, 0, 0, 0, this);
     1397}
     1398
    13881399void RenderObject::showRenderObject() const
    13891400{
     
    14041415    if (node()) {
    14051416        if (printedCharacters)
    1406             for (; printedCharacters < 39; printedCharacters++)
     1417            for (; printedCharacters < showTreeCharacterOffset; printedCharacters++)
    14071418                fputc(' ', stderr);
    14081419        fputc('\t', stderr);
     
    26272638#ifndef NDEBUG
    26282639
    2629 void showTree(const WebCore::RenderObject* ro)
    2630 {
    2631     if (ro)
    2632         ro->showTreeForThis();
     2640void showTree(const WebCore::RenderObject* object)
     2641{
     2642    if (object)
     2643        object->showTreeForThis();
     2644}
     2645
     2646void showLineTree(const WebCore::RenderObject* object)
     2647{
     2648    if (object)
     2649        object->showLineTreeForThis();
    26332650}
    26342651
  • trunk/Source/WebCore/rendering/RenderObject.h

    r85067 r85512  
    108108#endif
    109109
     110#ifndef NDEBUG
     111const int showTreeCharacterOffset = 39;
     112#endif
     113
    110114// Base class for all rendering tree objects.
    111115class RenderObject : public CachedResourceClient {
     
    223227#ifndef NDEBUG
    224228    void showTreeForThis() const;
     229    void showRenderTreeForThis() const;
     230    void showLineTreeForThis() const;
    225231
    226232    void showRenderObject() const;
     
    11271133// Outside the WebCore namespace for ease of invocation from gdb.
    11281134void showTree(const WebCore::RenderObject*);
     1135void showLineTree(const WebCore::RenderObject*);
    11291136void showRenderTree(const WebCore::RenderObject* object1);
    11301137// We don't make object2 an optional parameter so that showRenderTree
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r82611 r85512  
    814814}
    815815
     816#ifndef NDEBUG
     817const char* RootInlineBox::boxName() const
     818{
     819    return "RootInlineBox";
     820}
     821#endif
     822
    816823} // namespace WebCore
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r84096 r85512  
    162162    Node* getLogicalStartBoxWithNode(InlineBox*&) const;
    163163    Node* getLogicalEndBoxWithNode(InlineBox*&) const;
     164#ifndef NDEBUG
     165    virtual const char* boxName() const;
     166#endif
    164167private:
    165168    bool hasEllipsisBox() const { return m_hasEllipsisBoxOrHyphen; }
Note: See TracChangeset for help on using the changeset viewer.