Changeset 89979 in webkit


Ignore:
Timestamp:
Jun 28, 2011 5:53:04 PM (13 years ago)
Author:
leviw@chromium.org
Message:

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

Reviewed by Eric Seidel.

Switch paintBoxShadow and paintBoxDecorations to new layout types
https://bugs.webkit.org/show_bug.cgi?id=63577

Switching paintBoxShadow and paintBoxDecorations to layout type abstraction
from more integral types.

No new tests as this is just moving to an abstraction.

  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::paintBoxShadow): (WebCore::InlineFlowBox::paintBoxDecorations):
  • rendering/InlineFlowBox.h:
  • rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations):
  • rendering/RenderBox.h:
  • rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintBoxShadow):
  • rendering/RenderBoxModelObject.h:
  • rendering/RenderFieldset.cpp: (WebCore::RenderFieldset::paintBoxDecorations):
  • rendering/RenderFieldset.h:
  • rendering/RenderTable.cpp: (WebCore::RenderTable::paintBoxDecorations):
  • rendering/RenderTable.h:
  • rendering/RenderTableCell.cpp: (WebCore::RenderTableCell::paintBoxDecorations):
  • rendering/RenderTableCell.h:
  • rendering/RenderView.cpp: (WebCore::RenderView::paintBoxDecorations):
  • rendering/RenderView.h:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89977 r89979  
     12011-06-28  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch paintBoxShadow and paintBoxDecorations to new layout types
     6        https://bugs.webkit.org/show_bug.cgi?id=63577
     7
     8        Switching paintBoxShadow and paintBoxDecorations to layout type abstraction
     9        from more integral types.
     10
     11        No new tests as this is just moving to an abstraction.
     12
     13        * rendering/InlineFlowBox.cpp:
     14        (WebCore::InlineFlowBox::paintBoxShadow):
     15        (WebCore::InlineFlowBox::paintBoxDecorations):
     16        * rendering/InlineFlowBox.h:
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::paintBoxDecorations):
     19        * rendering/RenderBox.h:
     20        * rendering/RenderBoxModelObject.cpp:
     21        (WebCore::RenderBoxModelObject::paintBoxShadow):
     22        * rendering/RenderBoxModelObject.h:
     23        * rendering/RenderFieldset.cpp:
     24        (WebCore::RenderFieldset::paintBoxDecorations):
     25        * rendering/RenderFieldset.h:
     26        * rendering/RenderTable.cpp:
     27        (WebCore::RenderTable::paintBoxDecorations):
     28        * rendering/RenderTable.h:
     29        * rendering/RenderTableCell.cpp:
     30        (WebCore::RenderTableCell::paintBoxDecorations):
     31        * rendering/RenderTableCell.h:
     32        * rendering/RenderView.cpp:
     33        (WebCore::RenderView::paintBoxDecorations):
     34        * rendering/RenderView.h:
     35
    1362011-06-28  Emil A Eklund  <eae@chromium.org>
    237
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r89974 r89979  
    10641064}
    10651065
    1066 void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, ShadowStyle shadowStyle, const IntRect& paintRect)
     1066void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, ShadowStyle shadowStyle, const LayoutRect& paintRect)
    10671067{
    10681068    if ((!prevLineBox() && !nextLineBox()) || !parent())
     
    10951095}
    10961096
    1097 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
     1097void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    10981098{
    10991099    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
     
    11011101
    11021102    // Pixel snap background/border painting.
    1103     IntRect frameRect = roundedFrameRect();
     1103    LayoutRect frameRect = roundedFrameRect();
    11041104
    11051105    constrainToLineTopAndBottomIfNeeded(frameRect);
    11061106   
    11071107    // Move x/y to our coordinates.
    1108     IntRect localRect(frameRect);
     1108    LayoutRect localRect(frameRect);
    11091109    flipForWritingMode(localRect);
    1110     IntPoint adjustedPaintoffset = paintOffset + localRect.location();
     1110    LayoutPoint adjustedPaintoffset = paintOffset + localRect.location();
    11111111   
    11121112    GraphicsContext* context = paintInfo.context;
     
    11161116    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    11171117    if ((!parent() && m_firstLine && styleToUse != renderer()->style()) || (parent() && renderer()->hasBoxDecorations())) {
    1118         IntRect paintRect = IntRect(adjustedPaintoffset, frameRect.size());
     1118        LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size());
    11191119        // Shadow comes first and is behind the background and border.
    11201120        paintBoxShadow(context, styleToUse, Normal, paintRect);
     
    11451145                // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
    11461146                // but it isn't even clear how this should work at all.
    1147                 int logicalOffsetOnLine = 0;
     1147                LayoutUnit logicalOffsetOnLine = 0;
    11481148                for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
    11491149                    logicalOffsetOnLine += curr->logicalWidth();
    1150                 int totalLogicalWidth = logicalOffsetOnLine;
     1150                LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
    11511151                for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
    11521152                    totalLogicalWidth += curr->logicalWidth();
    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;
     1153                LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : 0);
     1154                LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ? 0 : logicalOffsetOnLine);
     1155                LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width();
     1156                LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth;
    11571157
    11581158                GraphicsContextStateSaver stateSaver(*context);
    11591159                context->clip(paintRect);
    1160                 boxModelObject()->paintBorder(context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
     1160                boxModelObject()->paintBorder(context, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
    11611161            }
    11621162        }
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r89974 r89979  
    104104    IntRect roundedFrameRect() const;
    105105   
    106     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     106    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
    107107    virtual void paintMask(PaintInfo&, const LayoutPoint&);
    108108    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
    109109    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
    110     void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, const IntRect&);
     110    void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, const LayoutRect&);
    111111    virtual void paint(PaintInfo&, const IntPoint&, int lineTop, int lineBottom);
    112112    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, int lineTop, int lineBottom);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r89977 r89979  
    828828}
    829829
    830 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
     830void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    831831{
    832832    if (!paintInfo.shouldPaintWithinRoot(this))
    833833        return;
    834     IntRect paintRect(paintOffset, size());
     834    LayoutRect paintRect(paintOffset, size());
    835835
    836836    // 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

    r89977 r89979  
    354354
    355355    virtual void paintObject(PaintInfo&, const IntPoint&) { ASSERT_NOT_REACHED(); }
    356     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     356    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
    357357    virtual void paintMask(PaintInfo&, const LayoutPoint&);
    358358    virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r89977 r89979  
    20912091}
    20922092
    2093 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, const IntRect& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
     2093void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, const LayoutRect& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    20942094{
    20952095    // FIXME: Deal with border-image.  Would be great to use border-image as a mask.
     
    21092109            continue;
    21102110
    2111         IntSize shadowOffset(shadow->x(), shadow->y());
    2112         int shadowBlur = shadow->blur();
    2113         int shadowSpread = shadow->spread();
     2111        LayoutSize shadowOffset(shadow->x(), shadow->y());
     2112        LayoutUnit shadowBlur = shadow->blur();
     2113        LayoutUnit shadowSpread = shadow->spread();
    21142114       
    21152115        if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
     
    21242124                continue;
    21252125
    2126             IntRect shadowRect(border.rect());
     2126            LayoutRect shadowRect(border.rect());
    21272127            shadowRect.inflate(shadowBlur + shadowSpread);
    21282128            shadowRect.move(shadowOffset);
     
    21332133            // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
    21342134            // bleed in (due to antialiasing) if the context is transformed.
    2135             IntSize extraOffset(paintRect.width() + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
     2135            LayoutSize extraOffset(paintRect.width() + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
    21362136            shadowOffset -= extraOffset;
    21372137            fillRect.move(extraOffset);
     
    21582158                context->fillRoundedRect(fillRect, Color::black, s->colorSpace());
    21592159            } else {
    2160                 IntRect rectToClipOut = border.rect();
     2160                LayoutRect rectToClipOut = border.rect();
    21612161
    21622162                // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
     
    21772177        } else {
    21782178            // Inset shadow.
    2179             IntRect holeRect(border.rect());
     2179            LayoutRect holeRect(border.rect());
    21802180            holeRect.inflate(-shadowSpread);
    21812181
     
    22062206            Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255);
    22072207
    2208             IntRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset);
     2208            LayoutRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset);
    22092209            RoundedIntRect roundedHole(holeRect, border.radii());
    22102210
     
    22182218                context->clip(border.rect());
    22192219
    2220             IntSize extraOffset(2 * paintRect.width() + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
     2220            LayoutSize extraOffset(2 * paintRect.width() + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
    22212221            context->translate(extraOffset.width(), extraOffset.height());
    22222222            shadowOffset -= extraOffset;
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r89977 r89979  
    121121    void paintBorder(GraphicsContext*, const IntRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    122122    bool paintNinePieceImage(GraphicsContext*, const IntRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
    123     void paintBoxShadow(GraphicsContext*, const IntRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     123    void paintBoxShadow(GraphicsContext*, const LayoutRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    124124    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
    125125   
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r89974 r89979  
    119119}
    120120
    121 void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
     121void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    122122{
    123123    if (!paintInfo.shouldPaintWithinRoot(this))
    124124        return;
    125125
    126     IntRect paintRect(paintOffset, size());
     126    LayoutRect paintRect(paintOffset, size());
    127127    RenderBox* legend = findLegend();
    128128    if (!legend)
     
    133133    // https://bugs.webkit.org/show_bug.cgi?id=47236
    134134    if (style()->isHorizontalWritingMode()) {
    135         int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
     135        LayoutUnit yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
    136136        paintRect.setHeight(paintRect.height() - yOff);
    137137        paintRect.setY(paintRect.y() + yOff);
    138138    } else {
    139         int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2;
     139        LayoutUnit xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2;
    140140        paintRect.setWidth(paintRect.width() - xOff);
    141141        paintRect.setX(paintRect.x() + xOff);
     
    157157    // https://bugs.webkit.org/show_bug.cgi?id=47236
    158158    if (style()->isHorizontalWritingMode()) {
    159         int clipTop = paintRect.y();
    160         int clipHeight = max(static_cast<int>(style()->borderTopWidth()), legend->height());
    161         graphicsContext->clipOut(IntRect(paintRect.x() + legend->x(), clipTop, legend->width(), clipHeight));
     159        LayoutUnit clipTop = paintRect.y();
     160        LayoutUnit clipHeight = max(static_cast<LayoutUnit>(style()->borderTopWidth()), legend->height());
     161        graphicsContext->clipOut(LayoutRect(paintRect.x() + legend->x(), clipTop, legend->width(), clipHeight));
    162162    } else {
    163         int clipLeft = paintRect.x();
    164         int clipWidth = max(static_cast<int>(style()->borderLeftWidth()), legend->width());
    165         graphicsContext->clipOut(IntRect(clipLeft, paintRect.y() + legend->y(), clipWidth, legend->height()));
     163        LayoutUnit clipLeft = paintRect.x();
     164        LayoutUnit clipWidth = max(static_cast<LayoutUnit>(style()->borderLeftWidth()), legend->width());
     165        graphicsContext->clipOut(LayoutRect(clipLeft, paintRect.y() + legend->y(), clipWidth, legend->height()));
    166166    }
    167167
  • trunk/Source/WebCore/rendering/RenderFieldset.h

    r89974 r89979  
    4545    virtual bool stretchesToMinIntrinsicLogicalWidth() const { return true; }
    4646
    47     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     47    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
    4848    virtual void paintMask(PaintInfo&, const LayoutPoint&);
    4949};
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r89974 r89979  
    550550}
    551551
    552 void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
     552void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    553553{
    554554    if (!paintInfo.shouldPaintWithinRoot(this))
    555555        return;
    556556
    557     IntRect rect(paintOffset, size());
     557    LayoutRect rect(paintOffset, size());
    558558    subtractCaptionRect(rect);
    559559
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r89974 r89979  
    997997}
    998998
    999 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset)
     999void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    10001000{
    10011001    if (!paintInfo.shouldPaintWithinRoot(this))
     
    10061006        return;
    10071007
    1008     IntRect paintRect = IntRect(paintOffset, size());
     1008    LayoutRect paintRect = LayoutRect(paintOffset, size());
    10091009    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
    10101010   
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r89974 r89979  
    143143    virtual void computeLogicalWidth();
    144144
    145     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     145    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
    146146    virtual void paintMask(PaintInfo&, const LayoutPoint&);
    147147
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r89760 r89979  
    186186}
    187187   
    188 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint&)
     188void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
    189189{
    190190    // 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

    r89754 r89979  
    7171
    7272    virtual void paint(PaintInfo&, const IntPoint&);
    73     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     73    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
    7474
    7575    enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld };
Note: See TracChangeset for help on using the changeset viewer.