Changeset 88033 in webkit


Ignore:
Timestamp:
Jun 3, 2011 11:43:15 AM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-06-03 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Switch paintBoxDecorations to IntPoint
https://bugs.webkit.org/show_bug.cgi?id=61968

Switching paintBoxDecorations to take an IntPoint representing
the paint offset instead of a pair of ints. Also cleaning up
some duplicated code in InlineFlowBox related to constraining
the paint rect to the linetop and linebottom.

No new tests since this is just refactoring.

  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::paint): (WebCore::InlineFlowBox::constrainToLineTopAndBottomIfNeeded): Added to remove duplicate code in paintBoxDecorations and paintMask. (WebCore::InlineFlowBox::paintBoxDecorations): (WebCore::InlineFlowBox::paintMask):
  • rendering/InlineFlowBox.h:
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::paintObject):
  • rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations):
  • rendering/RenderBox.h:
  • rendering/RenderFieldset.cpp: (WebCore::RenderFieldset::paintBoxDecorations):
  • rendering/RenderFieldset.h:
  • rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::paint):
  • rendering/RenderTable.cpp: (WebCore::RenderTable::paintObject): (WebCore::RenderTable::paintBoxDecorations):
  • rendering/RenderTable.h:
  • rendering/RenderTableCell.cpp: (WebCore::RenderTableCell::paintBoxDecorations):
  • rendering/RenderTableCell.h:
  • rendering/RenderView.cpp: (WebCore::RenderView::paintBoxDecorations):
  • rendering/RenderView.h:
  • rendering/RenderWidget.cpp: (WebCore::RenderWidget::paint):
  • rendering/svg/RenderSVGRoot.cpp: (WebCore::RenderSVGRoot::paint):
Location:
trunk/Source/WebCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88029 r88033  
     12011-06-03  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch paintBoxDecorations to IntPoint
     6        https://bugs.webkit.org/show_bug.cgi?id=61968
     7
     8        Switching paintBoxDecorations to take an IntPoint representing
     9        the paint offset instead of a pair of ints. Also cleaning up
     10        some duplicated code in InlineFlowBox related to constraining
     11        the paint rect to the linetop and linebottom.
     12
     13        No new tests since this is just refactoring.
     14
     15        * rendering/InlineFlowBox.cpp:
     16        (WebCore::InlineFlowBox::paint):
     17        (WebCore::InlineFlowBox::constrainToLineTopAndBottomIfNeeded): Added
     18        to remove duplicate code in paintBoxDecorations and paintMask.
     19        (WebCore::InlineFlowBox::paintBoxDecorations):
     20        (WebCore::InlineFlowBox::paintMask):
     21        * rendering/InlineFlowBox.h:
     22        * rendering/RenderBlock.cpp:
     23        (WebCore::RenderBlock::paintObject):
     24        * rendering/RenderBox.cpp:
     25        (WebCore::RenderBox::paintBoxDecorations):
     26        * rendering/RenderBox.h:
     27        * rendering/RenderFieldset.cpp:
     28        (WebCore::RenderFieldset::paintBoxDecorations):
     29        * rendering/RenderFieldset.h:
     30        * rendering/RenderReplaced.cpp:
     31        (WebCore::RenderReplaced::paint):
     32        * rendering/RenderTable.cpp:
     33        (WebCore::RenderTable::paintObject):
     34        (WebCore::RenderTable::paintBoxDecorations):
     35        * rendering/RenderTable.h:
     36        * rendering/RenderTableCell.cpp:
     37        (WebCore::RenderTableCell::paintBoxDecorations):
     38        * rendering/RenderTableCell.h:
     39        * rendering/RenderView.cpp:
     40        (WebCore::RenderView::paintBoxDecorations):
     41        * rendering/RenderView.h:
     42        * rendering/RenderWidget.cpp:
     43        (WebCore::RenderWidget::paint):
     44        * rendering/svg/RenderSVGRoot.cpp:
     45        (WebCore::RenderSVGRoot::paint):
     46
    1472011-06-03  Doreen Jiang  <doreen.jiang@nokia.com>
    248
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r87989 r88033  
    996996        } else {
    997997            // Paint our background, border and box-shadow.
    998             paintBoxDecorations(paintInfo, paintOffset.x(), paintOffset.y());
     998            paintBoxDecorations(paintInfo, paintOffset);
    999999        }
    10001000    }
     
    10751075}
    10761076
    1077 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     1077void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(IntRect& rect) const
     1078{
     1079    bool noQuirksMode = renderer()->document()->inNoQuirksMode();
     1080    if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
     1081        const RootInlineBox* rootBox = root();
     1082        int logicalTop = isHorizontal() ? rect.y() : rect.x();
     1083        int logicalHeight = isHorizontal() ? rect.height() : rect.width();
     1084        int bottom = min(rootBox->lineBottom(), logicalTop + logicalHeight);
     1085        logicalTop = max(rootBox->lineTop(), logicalTop);
     1086        logicalHeight = bottom - logicalTop;
     1087        if (isHorizontal()) {
     1088            rect.setY(logicalTop);
     1089            rect.setHeight(logicalHeight);
     1090        } else {
     1091            rect.setX(logicalTop);
     1092            rect.setWidth(logicalHeight);
     1093        }
     1094    }
     1095}
     1096
     1097void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
    10781098{
    10791099    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
     
    10821102    // Pixel snap background/border painting.
    10831103    IntRect frameRect = roundedFrameRect();
    1084     int x = frameRect.x();
    1085     int y = frameRect.y();
    1086     int w = frameRect.width();
    1087     int h = frameRect.height();
    1088 
    1089     // Constrain our background/border painting to the line top and bottom if necessary.
    1090     bool noQuirksMode = renderer()->document()->inNoQuirksMode();
    1091     if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
    1092         RootInlineBox* rootBox = root();
    1093         int& top = isHorizontal() ? y : x;
    1094         int& logicalHeight = isHorizontal() ? h : w;
    1095         int bottom = min(rootBox->lineBottom(), top + logicalHeight);
    1096         top = max(rootBox->lineTop(), top);
    1097         logicalHeight = bottom - top;
    1098     }
     1104
     1105    constrainToLineTopAndBottomIfNeeded(frameRect);
    10991106   
    11001107    // Move x/y to our coordinates.
    1101     IntRect localRect(x, y, w, h);
     1108    IntRect localRect(frameRect);
    11021109    flipForWritingMode(localRect);
    1103     tx += localRect.x();
    1104     ty += localRect.y();
     1110    IntPoint adjustedPaintoffset = paintOffset + localRect.location();
    11051111   
    11061112    GraphicsContext* context = paintInfo.context;
     
    11101116    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    11111117    if ((!parent() && m_firstLine && styleToUse != renderer()->style()) || (parent() && renderer()->hasBoxDecorations())) {
    1112         IntRect paintRect = IntRect(tx, ty, w, h);
     1118        IntRect paintRect = IntRect(adjustedPaintoffset, frameRect.size());
    11131119        // Shadow comes first and is behind the background and border.
    11141120        paintBoxShadow(context, styleToUse, Normal, paintRect);
     
    11451151                for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
    11461152                    totalLogicalWidth += curr->logicalWidth();
    1147                 int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0);
    1148                 int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine);
    1149                 int stripWidth = isHorizontal() ? totalLogicalWidth : w;
    1150                 int stripHeight = isHorizontal() ? h : totalLogicalWidth;
     1153                int stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : 0);
     1154                int stripY = adjustedPaintoffset.y() - (isHorizontal() ? 0 : logicalOffsetOnLine);
     1155                int stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width();
     1156                int stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth;
    11511157
    11521158                GraphicsContextStateSaver stateSaver(*context);
    1153                 context->clip(IntRect(tx, ty, w, h));
     1159                context->clip(paintRect);
    11541160                boxModelObject()->paintBorder(context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
    11551161            }
     
    11651171    // Pixel snap mask painting.
    11661172    IntRect frameRect = roundedFrameRect();
    1167     int x = frameRect.x();
    1168     int y = frameRect.y();
    1169     int w = frameRect.width();
    1170     int h = frameRect.height();
    1171 
    1172     // Constrain our background/border painting to the line top and bottom if necessary.
    1173     bool noQuirksMode = renderer()->document()->inNoQuirksMode();
    1174     if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
    1175         RootInlineBox* rootBox = root();
    1176         int& top = isHorizontal() ? y : x;
    1177         int& logicalHeight = isHorizontal() ? h : w;
    1178         int bottom = min(rootBox->lineBottom(), top + logicalHeight);
    1179         top = max(rootBox->lineTop(), top);
    1180         logicalHeight = bottom - top;
    1181     }
     1173
     1174    constrainToLineTopAndBottomIfNeeded(frameRect);
    11821175   
    11831176    // Move x/y to our coordinates.
    1184     IntRect localRect(x, y, w, h);
     1177    IntRect localRect(frameRect);
    11851178    flipForWritingMode(localRect);
    11861179    tx += localRect.x();
     
    12061199    }
    12071200
    1208     paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), IntRect(tx, ty, w, h), compositeOp);
     1201    IntRect paintRect = IntRect(IntPoint(tx, ty), frameRect.size());
     1202    paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), paintRect, compositeOp);
    12091203   
    12101204    bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer()->style()->effectiveZoom());
     
    12151209    // cases only a single call to draw is required.
    12161210    if (!prevLineBox() && !nextLineBox()) {
    1217         boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(tx, ty, w, h), renderer()->style(), maskNinePieceImage, compositeOp);
     1211        boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(IntPoint(tx, ty), frameRect.size()), renderer()->style(), maskNinePieceImage, compositeOp);
    12181212    } else {
    12191213        // We have a mask image that spans multiple lines.
     
    12271221        int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0);
    12281222        int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine);
    1229         int stripWidth = isHorizontal() ? totalLogicalWidth : w;
    1230         int stripHeight = isHorizontal() ? h : totalLogicalWidth;
     1223        int stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width();
     1224        int stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth;
    12311225
    12321226        GraphicsContextStateSaver stateSaver(*paintInfo.context);
    1233         paintInfo.context->clip(IntRect(tx, ty, w, h));
     1227        paintInfo.context->clip(paintRect);
    12341228        boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, compositeOp);
    12351229    }
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r87964 r88033  
    104104    IntRect roundedFrameRect() const;
    105105   
    106     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     106    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    107107    virtual void paintMask(PaintInfo&, int tx, int ty);
    108108    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
     
    277277    void addTextBoxVisualOverflow(InlineTextBox*, GlyphOverflowAndFallbackFontsMap&, IntRect& logicalVisualOverflow);
    278278    void addReplacedChildOverflow(const InlineBox*, IntRect& logicalLayoutOverflow, IntRect& logicalVisualOverflow);
     279    void constrainToLineTopAndBottomIfNeeded(IntRect&) const;
    279280
    280281protected:
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r87989 r88033  
    24652465    if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) && style()->visibility() == VISIBLE) {
    24662466        if (hasBoxDecorations())
    2467             paintBoxDecorations(paintInfo, tx, ty);
     2467            paintBoxDecorations(paintInfo, IntPoint(tx, ty));
    24682468        if (hasColumns())
    24692469            paintColumnRules(paintInfo, tx, ty);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r87989 r88033  
    826826}
    827827
    828 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     828void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
    829829{
    830830    if (!paintInfo.shouldPaintWithinRoot(this))
    831831        return;
    832     IntRect paintRect(tx, ty, width(), height());
     832    IntRect paintRect(paintOffset, size());
    833833
    834834    // border-fit can adjust where we paint our border and background.  If set, we snugly fit our line box descendants.  (The iChat
  • trunk/Source/WebCore/rendering/RenderBox.h

    r87881 r88033  
    354354
    355355    virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); }
    356     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     356    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    357357    virtual void paintMask(PaintInfo&, IntSize);
    358358    virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r86670 r88033  
    119119}
    120120
    121 void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     121void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
    122122{
    123123    if (!paintInfo.shouldPaintWithinRoot(this))
    124124        return;
    125125
    126     int w = width();
    127     int h = height();
     126    IntRect paintRect(paintOffset, size());
    128127    RenderBox* legend = findLegend();
    129128    if (!legend)
    130         return RenderBlock::paintBoxDecorations(paintInfo, tx, ty);
     129        return RenderBlock::paintBoxDecorations(paintInfo, paintOffset);
    131130
    132131    // FIXME: We need to work with "rl" and "bt" block flow directions.  In those
     
    135134    if (style()->isHorizontalWritingMode()) {
    136135        int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
    137         h -= yOff;
    138         ty += yOff;
     136        paintRect.setHeight(paintRect.height() - yOff);
     137        paintRect.setY(paintRect.y() + yOff);
    139138    } else {
    140139        int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2;
    141         w -= xOff;
    142         tx += xOff;
     140        paintRect.setWidth(paintRect.width() - xOff);
     141        paintRect.setX(paintRect.x() + xOff);
    143142    }
    144 
    145     IntRect paintRect = IntRect(tx, ty, w, h);
    146143   
    147144    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
     
    160157    // https://bugs.webkit.org/show_bug.cgi?id=47236
    161158    if (style()->isHorizontalWritingMode()) {
    162         int clipTop = ty;
     159        int clipTop = paintRect.y();
    163160        int clipHeight = max(static_cast<int>(style()->borderTopWidth()), legend->height());
    164         graphicsContext->clipOut(IntRect(tx + legend->x(), clipTop, legend->width(), clipHeight));
     161        graphicsContext->clipOut(IntRect(paintRect.x() + legend->x(), clipTop, legend->width(), clipHeight));
    165162    } else {
    166         int clipLeft = tx;
     163        int clipLeft = paintRect.x();
    167164        int clipWidth = max(static_cast<int>(style()->borderLeftWidth()), legend->width());
    168         graphicsContext->clipOut(IntRect(clipLeft, ty + legend->y(), clipWidth, legend->height()));
     165        graphicsContext->clipOut(IntRect(clipLeft, paintRect.y() + legend->y(), clipWidth, legend->height()));
    169166    }
    170167
  • trunk/Source/WebCore/rendering/RenderFieldset.h

    r86377 r88033  
    4545    virtual bool stretchesToMinIntrinsicLogicalWidth() const { return true; }
    4646
    47     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     47    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    4848    virtual void paintMask(PaintInfo&, IntSize);
    4949};
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r87989 r88033  
    104104   
    105105    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
    106         paintBoxDecorations(paintInfo, tx, ty);
     106        paintBoxDecorations(paintInfo, IntPoint(tx, ty));
    107107   
    108108    if (paintInfo.phase == PaintPhaseMask) {
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r87018 r88033  
    478478    PaintPhase paintPhase = paintInfo.phase;
    479479    if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) && hasBoxDecorations() && style()->visibility() == VISIBLE)
    480         paintBoxDecorations(paintInfo, tx, ty);
     480        paintBoxDecorations(paintInfo, IntPoint(tx, ty));
    481481
    482482    if (paintPhase == PaintPhaseMask) {
     
    551551}
    552552
    553 void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     553void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
    554554{
    555555    if (!paintInfo.shouldPaintWithinRoot(this))
    556556        return;
    557557
    558     IntRect rect(tx, ty, width(), height());
     558    IntRect rect(paintOffset, size());
    559559    subtractCaptionRect(rect);
    560560
  • trunk/Source/WebCore/rendering/RenderTable.h

    r86705 r88033  
    217217    virtual void paint(PaintInfo&, int tx, int ty);
    218218    virtual void paintObject(PaintInfo&, int tx, int ty);
    219     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     219    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    220220    virtual void paintMask(PaintInfo&, IntSize);
    221221    virtual void layout();
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r87989 r88033  
    10021002}
    10031003
    1004 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     1004void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
    10051005{
    10061006    if (!paintInfo.shouldPaintWithinRoot(this))
     
    10111011        return;
    10121012
    1013     IntRect paintRect = IntRect(IntPoint(tx, ty), size());
     1013    IntRect paintRect = IntRect(paintOffset, size());
    10141014    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
    10151015   
    10161016    // Paint our cell background.
    1017     paintBackgroundsBehindCell(paintInfo, tx, ty, this);
     1017    paintBackgroundsBehindCell(paintInfo, paintOffset.x(), paintOffset.y(), this);
    10181018
    10191019    paintBoxShadow(paintInfo.context, paintRect, style(), Inset);
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r86449 r88033  
    143143    virtual void computeLogicalWidth();
    144144
    145     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     145    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    146146    virtual void paintMask(PaintInfo&, IntSize);
    147147
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r87989 r88033  
    185185}
    186186   
    187 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int, int)
     187void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint&)
    188188{
    189189    // Check to see if we are enclosed by a layer that requires complex painting rules.  If so, we cannot blit
  • trunk/Source/WebCore/rendering/RenderView.h

    r87277 r88033  
    7171
    7272    virtual void paint(PaintInfo&, int tx, int ty);
    73     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     73    virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    7474
    7575    enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld };
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r87866 r88033  
    257257
    258258    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
    259         paintBoxDecorations(paintInfo, tx, ty);
     259        paintBoxDecorations(paintInfo, IntPoint(tx, ty));
    260260
    261261    if (paintInfo.phase == PaintPhaseMask) {
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r88007 r88033  
    273273
    274274    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) && isVisible)
    275         paintBoxDecorations(paintInfo, borderBoxOriginInContainer.x(), borderBoxOriginInContainer.y());
     275        paintBoxDecorations(paintInfo, borderBoxOriginInContainer);
    276276
    277277    if (paintInfo.phase == PaintPhaseBlockBackground)
Note: See TracChangeset for help on using the changeset viewer.