Changeset 87753 in webkit


Ignore:
Timestamp:
May 31, 2011 2:55:41 PM (13 years ago)
Author:
leviw@chromium.org
Message:

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

Reviewed by Simon Fraser.

Change InlineBox::paint and its overloaded variants to use IntPoint
https://bugs.webkit.org/show_bug.cgi?id=61804

Changing InlineBox::paint, its 7 overloaded variants, and RootInlineBox::paintEllipsisBox
to use IntPoint for their paint offset instead of a pair of ints.

No new tests since this is just a refactoring.

  • rendering/EllipsisBox.cpp: (WebCore::EllipsisBox::paint):
  • rendering/EllipsisBox.h:
  • rendering/InlineBox.cpp: (WebCore::InlineBox::paint):
  • rendering/InlineBox.h:
  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::paint):
  • rendering/InlineFlowBox.h:
  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::paint):
  • rendering/InlineTextBox.h:
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::paintEllipsisBoxes):
  • rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended):
  • rendering/RenderLineBoxList.cpp: (WebCore::RenderLineBoxList::paint):
  • rendering/RootInlineBox.cpp: (WebCore::RootInlineBox::paintEllipsisBox): (WebCore::RootInlineBox::paint):
  • rendering/RootInlineBox.h:
  • rendering/svg/SVGInlineFlowBox.cpp: (WebCore::SVGInlineFlowBox::paint):
  • rendering/svg/SVGInlineFlowBox.h:
  • rendering/svg/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::paint):
  • rendering/svg/SVGInlineTextBox.h:
  • rendering/svg/SVGRootInlineBox.cpp: (WebCore::SVGRootInlineBox::paint):
  • rendering/svg/SVGRootInlineBox.h:
Location:
trunk/Source/WebCore
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87752 r87753  
     12011-05-31  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Change InlineBox::paint and its overloaded variants to use IntPoint
     6        https://bugs.webkit.org/show_bug.cgi?id=61804
     7
     8        Changing InlineBox::paint, its 7 overloaded variants, and RootInlineBox::paintEllipsisBox
     9        to use IntPoint for their paint offset instead of a pair of ints.
     10
     11        No new tests since this is just a refactoring.
     12
     13        * rendering/EllipsisBox.cpp:
     14        (WebCore::EllipsisBox::paint):
     15        * rendering/EllipsisBox.h:
     16        * rendering/InlineBox.cpp:
     17        (WebCore::InlineBox::paint):
     18        * rendering/InlineBox.h:
     19        * rendering/InlineFlowBox.cpp:
     20        (WebCore::InlineFlowBox::paint):
     21        * rendering/InlineFlowBox.h:
     22        * rendering/InlineTextBox.cpp:
     23        (WebCore::InlineTextBox::paint):
     24        * rendering/InlineTextBox.h:
     25        * rendering/RenderBlock.cpp:
     26        (WebCore::RenderBlock::paintEllipsisBoxes):
     27        * rendering/RenderBoxModelObject.cpp:
     28        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     29        * rendering/RenderLineBoxList.cpp:
     30        (WebCore::RenderLineBoxList::paint):
     31        * rendering/RootInlineBox.cpp:
     32        (WebCore::RootInlineBox::paintEllipsisBox):
     33        (WebCore::RootInlineBox::paint):
     34        * rendering/RootInlineBox.h:
     35        * rendering/svg/SVGInlineFlowBox.cpp:
     36        (WebCore::SVGInlineFlowBox::paint):
     37        * rendering/svg/SVGInlineFlowBox.h:
     38        * rendering/svg/SVGInlineTextBox.cpp:
     39        (WebCore::SVGInlineTextBox::paint):
     40        * rendering/svg/SVGInlineTextBox.h:
     41        * rendering/svg/SVGRootInlineBox.cpp:
     42        (WebCore::SVGRootInlineBox::paint):
     43        * rendering/svg/SVGRootInlineBox.h:
     44
    1452011-05-31  James Robinson  <jamesr@chromium.org>
    246
  • trunk/Source/WebCore/rendering/EllipsisBox.cpp

    r87152 r87753  
    3131namespace WebCore {
    3232
    33 void EllipsisBox::paint(PaintInfo& paintInfo, int tx, int ty, int lineTop, int lineBottom)
     33void EllipsisBox::paint(PaintInfo& paintInfo, const IntPoint& paintOffset, int lineTop, int lineBottom)
    3434{
    3535    GraphicsContext* context = paintInfo.context;
     
    4747    const Font& font = style->font();
    4848    if (selectionState() != RenderObject::SelectionNone) {
    49         paintSelection(context, tx, ty, style, font);
     49        paintSelection(context, paintOffset.x(), paintOffset.y(), style, font);
    5050
    5151        // Select the correct color for painting the text.
     
    5656
    5757    // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
    58     context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent()));
     58    context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(m_x + paintOffset.x(), m_y + paintOffset.y() + style->fontMetrics().ascent()));
    5959
    6060    // Restore the regular fill color.
     
    6767    if (m_markupBox) {
    6868        // Paint the markup box
    69         tx += m_x + m_logicalWidth - m_markupBox->x();
    70         ty += m_y + style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent());
    71         m_markupBox->paint(paintInfo, tx, ty, lineTop, lineBottom);
     69        IntPoint adjustedPaintOffset = paintOffset;
     70        adjustedPaintOffset.move(m_x + m_logicalWidth - m_markupBox->x(),
     71            m_y + style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent()));
     72        m_markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
    7273    }
    7374}
  • trunk/Source/WebCore/rendering/EllipsisBox.h

    r86705 r87753  
    4040    }
    4141
    42     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     42    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    4343    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom);
    4444    void setSelectionState(RenderObject::SelectionState s) { m_selectionState = s; }
  • trunk/Source/WebCore/rendering/InlineBox.cpp

    r86705 r87753  
    194194}
    195195
    196 void InlineBox::paint(PaintInfo& paintInfo, int tx, int ty, int /* lineTop */, int /*lineBottom*/)
     196void InlineBox::paint(PaintInfo& paintInfo, const IntPoint& paintOffset, int /* lineTop */, int /*lineBottom*/)
    197197{
    198198    if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
    199199        return;
    200200
    201     IntPoint childPoint = IntPoint(tx, ty);
     201    IntPoint childPoint = paintOffset;
    202202    if (parent()->renderer()->style()->isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
    203203        childPoint = renderer()->containingBlock()->flipForWritingMode(toRenderBox(renderer()), childPoint, RenderBox::ParentToChildFlippingAdjustment);
  • trunk/Source/WebCore/rendering/InlineBox.h

    r86705 r87753  
    130130    }
    131131
    132     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     132    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    133133    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom);
    134134
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r87018 r87753  
    947947}
    948948
    949 void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty, int lineTop, int lineBottom)
     949void InlineFlowBox::paint(PaintInfo& paintInfo, const IntPoint& paintOffset, int lineTop, int lineBottom)
    950950{
    951951    IntRect overflowRect(visualOverflowRect(lineTop, lineBottom));
    952952    overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase));
    953953    flipForWritingMode(overflowRect);
    954     overflowRect.move(tx, ty);
     954    overflowRect.move(paintOffset);
    955955   
    956956    if (!paintInfo.rect.intersects(overflowRect))
     
    992992            }
    993993        } else if (paintInfo.phase == PaintPhaseMask) {
    994             paintMask(paintInfo, tx, ty);
     994            paintMask(paintInfo, paintOffset.x(), paintOffset.y());
    995995            return;
    996996        } else {
    997997            // Paint our background, border and box-shadow.
    998             paintBoxDecorations(paintInfo, tx, ty);
     998            paintBoxDecorations(paintInfo, paintOffset.x(), paintOffset.y());
    999999        }
    10001000    }
     
    10121012        for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
    10131013            if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPaintingLayer())
    1014                 curr->paint(childInfo, tx, ty, lineTop, lineBottom);
     1014                curr->paint(childInfo, paintOffset, lineTop, lineBottom);
    10151015        }
    10161016    }
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r86705 r87753  
    109109    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
    110110    void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, const IntRect&);
    111     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     111    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    112112    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom);
    113113
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r87687 r87753  
    464464}
    465465
    466 void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty, int /*lineTop*/, int /*lineBottom*/)
     466void InlineTextBox::paint(PaintInfo& paintInfo, const IntPoint& paintOffset, int /*lineTop*/, int /*lineBottom*/)
    467467{
    468468    if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE ||
     
    474474    int logicalLeftSide = logicalLeftVisualOverflow();
    475475    int logicalRightSide = logicalRightVisualOverflow();
    476     int logicalStart = logicalLeftSide + (isHorizontal() ? tx : ty);
     476    int logicalStart = logicalLeftSide + (isHorizontal() ? paintOffset.x() : paintOffset.y());
    477477    int logicalExtent = logicalRightSide - logicalLeftSide;
    478478   
    479479    int paintEnd = isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rect.maxY();
    480480    int paintStart = isHorizontal() ? paintInfo.rect.x() : paintInfo.rect.y();
     481   
     482    IntPoint adjustedPaintOffset = paintOffset;
    481483   
    482484    if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart)
     
    504506            int widthOfHiddenText = m_logicalWidth - widthOfVisibleText;
    505507            // FIXME: The hit testing logic also needs to take this translation int account.
    506             if (isHorizontal())
    507                 tx += isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText;
    508             else
    509                 ty += isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText;
     508            IntSize truncationOffset(isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText, 0);
     509            adjustedPaintOffset.move(isHorizontal() ? truncationOffset : truncationOffset.transposedSize());
    510510        }
    511511    }
     
    515515    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    516516   
    517     ty -= styleToUse->isHorizontalWritingMode() ? 0 : logicalHeight();
     517    adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? 0 : -logicalHeight());
    518518
    519519    FloatPoint boxOrigin = locationIncludingFlipping();
    520     boxOrigin.move(tx, ty);   
     520    boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y());
    521521    FloatRect boxRect(boxOrigin, IntSize(logicalWidth(), logicalHeight()));
    522522
     
    545545        // Custom highlighters go behind everything else.
    546546        if (styleToUse->highlight() != nullAtom && !context->paintingDisabled())
    547             paintCustomHighlight(tx, ty, styleToUse->highlight());
     547            paintCustomHighlight(adjustedPaintOffset.x(), adjustedPaintOffset.y(), styleToUse->highlight());
    548548#endif
    549549
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r87483 r87753  
    111111
    112112protected:
    113     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     113    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    114114    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom);
    115115
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r87443 r87753  
    26092609            h = curr->logicalHeight();
    26102610            if (curr->ellipsisBox() && yPos < paintInfo.rect.maxY() && yPos + h > paintInfo.rect.y())
    2611                 curr->paintEllipsisBox(paintInfo, tx, ty, curr->lineTop(), curr->lineBottom());
     2611                curr->paintEllipsisBox(paintInfo, IntPoint(tx, ty), curr->lineTop(), curr->lineBottom());
    26122612        }
    26132613    }
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r87121 r87753  
    695695        if (box) {
    696696            RootInlineBox* root = box->root();
    697             box->paint(info, scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y(), root->lineTop(), root->lineBottom());
     697            box->paint(info, IntPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), root->lineTop(), root->lineBottom());
    698698        } else {
    699699            int x = isBox() ? toRenderBox(this)->x() : 0;
  • trunk/Source/WebCore/rendering/RenderLineBoxList.cpp

    r87019 r87753  
    260260        if (lineIntersectsDirtyRect(renderer, curr, info, tx, ty)) {
    261261            RootInlineBox* root = curr->root();
    262             curr->paint(info, tx, ty, root->lineTop(), root->lineBottom());
     262            curr->paint(info, IntPoint(tx, ty), root->lineTop(), root->lineBottom());
    263263        }
    264264    }
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r86705 r87753  
    134134}
    135135
    136 void RootInlineBox::paintEllipsisBox(PaintInfo& paintInfo, int tx, int ty, int lineTop, int lineBottom) const
     136void RootInlineBox::paintEllipsisBox(PaintInfo& paintInfo, const IntPoint& paintOffset, int lineTop, int lineBottom) const
    137137{
    138138    if (hasEllipsisBox() && paintInfo.shouldPaintWithinRoot(renderer()) && renderer()->style()->visibility() == VISIBLE
    139139            && paintInfo.phase == PaintPhaseForeground)
    140         ellipsisBox()->paint(paintInfo, tx, ty, lineTop, lineBottom);
     140        ellipsisBox()->paint(paintInfo, paintOffset, lineTop, lineBottom);
    141141}
    142142
     
    179179#endif
    180180
    181 void RootInlineBox::paint(PaintInfo& paintInfo, int tx, int ty, int lineTop, int lineBottom)
    182 {
    183     InlineFlowBox::paint(paintInfo, tx, ty, lineTop, lineBottom);
    184     paintEllipsisBox(paintInfo, tx, ty, lineTop, lineBottom);
     181void RootInlineBox::paint(PaintInfo& paintInfo, const IntPoint& paintOffset, int lineTop, int lineBottom)
     182{
     183    InlineFlowBox::paint(paintInfo, paintOffset, lineTop, lineBottom);
     184    paintEllipsisBox(paintInfo, paintOffset, lineTop, lineBottom);
    185185#if PLATFORM(MAC)
    186186    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    187187    if (styleToUse->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    188         paintCustomHighlight(paintInfo, tx, ty, styleToUse->highlight());
     188        paintCustomHighlight(paintInfo, paintOffset.x(), paintOffset.y(), styleToUse->highlight());
    189189#endif
    190190}
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r86705 r87753  
    8484    EllipsisBox* ellipsisBox() const;
    8585
    86     void paintEllipsisBox(PaintInfo&, int tx, int ty, int lineTop, int lineBottom) const;
     86    void paintEllipsisBox(PaintInfo&, const IntPoint&, int lineTop, int lineBottom) const;
    8787
    8888    virtual void clearTruncation();
     
    9696#endif
    9797
    98     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     98    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    9999    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom);
    100100
  • trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp

    r87483 r87753  
    5050}
    5151
    52 void SVGInlineFlowBox::paint(PaintInfo& paintInfo, int, int, int, int)
     52void SVGInlineFlowBox::paint(PaintInfo& paintInfo, const IntPoint&, int, int)
    5353{
    5454    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
     
    6666                computeTextMatchMarkerRectForRenderer(toRenderSVGInlineText(static_cast<SVGInlineTextBox*>(child)->textRenderer()));
    6767
    68             child->paint(childPaintInfo, 0, 0, 0, 0);
     68            child->paint(childPaintInfo, IntPoint(), 0, 0);
    6969        }
    7070    }
  • trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h

    r82611 r87753  
    4242
    4343    void paintSelectionBackground(PaintInfo&);
    44     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     44    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    4545
    4646    virtual IntRect calculateBoundaries() const;
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r87152 r87753  
    241241}
    242242
    243 void SVGInlineTextBox::paint(PaintInfo& paintInfo, int, int, int, int)
     243void SVGInlineTextBox::paint(PaintInfo& paintInfo, const IntPoint&, int, int)
    244244{
    245245    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h

    r82611 r87753  
    4747
    4848    void paintSelectionBackground(PaintInfo&);
    49     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     49    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    5050    virtual IntRect selectionRect(int absx, int absy, int startPosition, int endPosition);
    5151
  • trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp

    r86927 r87753  
    3737namespace WebCore {
    3838
    39 void SVGRootInlineBox::paint(PaintInfo& paintInfo, int, int, int, int)
     39void SVGRootInlineBox::paint(PaintInfo& paintInfo, const IntPoint&, int, int)
    4040{
    4141    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
     
    6565                SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(toRenderSVGInlineText(static_cast<SVGInlineTextBox*>(child)->textRenderer()));
    6666
    67             child->paint(childPaintInfo, 0, 0, 0, 0);
     67            child->paint(childPaintInfo, IntPoint(), 0, 0);
    6868        }
    6969    }
  • trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h

    r86927 r87753  
    4646    void setLogicalHeight(int height) { m_logicalHeight = height; }
    4747
    48     virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
     48    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    4949
    5050    void computePerCharacterLayoutInformation();
Note: See TracChangeset for help on using the changeset viewer.