Changeset 86384 in webkit


Ignore:
Timestamp:
May 12, 2011 3:00:39 PM (13 years ago)
Author:
leviw@chromium.org
Message:

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

Reviewed by Eric Seidel.

Switch paintBoxShadow to use IntRect
https://bugs.webkit.org/show_bug.cgi?id=60713

Switching paintBoxShadow from taking four ints to taking an IntRect.

No new tests since this is refactoring.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86383 r86384  
     12011-05-12  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch paintBoxShadow to use IntRect
     6        https://bugs.webkit.org/show_bug.cgi?id=60713
     7
     8        Switching paintBoxShadow from taking four ints to taking an IntRect.
     9
     10        No new tests since this is refactoring.
     11
     12        * rendering/InlineFlowBox.cpp:
     13        (WebCore::InlineFlowBox::paintBoxShadow):
     14        (WebCore::InlineFlowBox::paintBoxDecorations):
     15        * rendering/InlineFlowBox.h:
     16        * rendering/RenderBox.cpp:
     17        (WebCore::RenderBox::paintBoxDecorationsWithSize):
     18        * rendering/RenderBoxModelObject.cpp:
     19        (WebCore::RenderBoxModelObject::paintBoxShadow):
     20        * rendering/RenderBoxModelObject.h:
     21        * rendering/RenderFieldset.cpp:
     22        (WebCore::RenderFieldset::paintBoxDecorations):
     23        * rendering/RenderTable.cpp:
     24        (WebCore::RenderTable::paintBoxDecorations):
     25        * rendering/RenderTableCell.cpp:
     26        (WebCore::RenderTableCell::paintBoxDecorations):
     27
    1282011-05-12  Maciej Stachowiak  <mjs@apple.com>
    229
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r86303 r86384  
    10641064}
    10651065
    1066 void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, ShadowStyle shadowStyle, int tx, int ty, int w, int h)
     1066void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, ShadowStyle shadowStyle, const IntRect& paintRect)
    10671067{
    10681068    if ((!prevLineBox() && !nextLineBox()) || !parent())
    1069         boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s, shadowStyle);
     1069        boxModelObject()->paintBoxShadow(context, paintRect, s, shadowStyle);
    10701070    else {
    10711071        // FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't
    10721072        // protrude incorrectly at the edges, and we want to possibly include shadows cast from the previous/following lines
    1073         boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s, shadowStyle, includeLogicalLeftEdge(), includeLogicalRightEdge());
     1073        boxModelObject()->paintBoxShadow(context, paintRect, s, shadowStyle, includeLogicalLeftEdge(), includeLogicalRightEdge());
    10741074    }
    10751075}
     
    11101110    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    11111111    if ((!parent() && m_firstLine && styleToUse != renderer()->style()) || (parent() && renderer()->hasBoxDecorations())) {
     1112        IntRect paintRect = IntRect(tx, ty, w, h);
    11121113        // Shadow comes first and is behind the background and border.
    1113         paintBoxShadow(context, styleToUse, Normal, tx, ty, w, h);
     1114        paintBoxShadow(context, styleToUse, Normal, paintRect);
    11141115
    11151116        Color c = styleToUse->visitedDependentColor(CSSPropertyBackgroundColor);
    1116         paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), IntRect(tx, ty, w, h));
    1117         paintBoxShadow(context, styleToUse, Inset, tx, ty, w, h);
     1117        paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect);
     1118        paintBoxShadow(context, styleToUse, Inset, paintRect);
    11181119
    11191120        // :first-line cannot be used to put borders on a line. Always paint borders with our
     
    11281129            // cases only a single call to draw is required.
    11291130            if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
    1130                 boxModelObject()->paintBorder(context, IntRect(tx, ty, w, h), renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
     1131                boxModelObject()->paintBorder(context, paintRect, renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
    11311132            else {
    11321133                // We have a border image that spans multiple lines.
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r86303 r86384  
    108108    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
    109109    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
    110     void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h);
     110    void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, const IntRect&);
    111111    virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
    112112    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, int lineTop, int lineBottom);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r86377 r86384  
    842842    // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have
    843843    // custom shadows of their own.
    844     paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Normal);
     844    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
    845845
    846846    BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context);
     
    871871            theme()->paintDecorations(this, paintInfo, paintRect);
    872872    }
    873     paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Inset);
     873    paintBoxShadow(paintInfo.context, paintRect, style(), Inset);
    874874
    875875    // The theme will tell us whether or not we should also paint the CSS border.
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r86359 r86384  
    20812081}
    20822082
    2083 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
     2083void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, const IntRect& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    20842084{
    20852085    // FIXME: Deal with border-image.  Would be great to use border-image as a mask.
     
    20882088        return;
    20892089
    2090     IntRect borderRect(tx, ty, w, h);
    2091     RoundedIntRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge)
    2092                                                    : s->getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
     2090    RoundedIntRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge)
     2091                                                   : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge);
    20932092
    20942093    bool hasBorderRadius = s->hasBorderRadius();
     
    21242123            // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
    21252124            // bleed in (due to antialiasing) if the context is transformed.
    2126             IntSize extraOffset(w + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
     2125            IntSize extraOffset(paintRect.width() + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
    21272126            shadowOffset -= extraOffset;
    21282127            fillRect.move(extraOffset);
     
    22092208                context->clip(border.rect());
    22102209
    2211             IntSize extraOffset(2 * w + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
     2210            IntSize extraOffset(2 * paintRect.width() + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
    22122211            context->translate(extraOffset.width(), extraOffset.height());
    22132212            shadowOffset -= extraOffset;
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r86359 r86384  
    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*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     123    void paintBoxShadow(GraphicsContext*, const IntRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    124124    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const IntSize& = IntSize(), CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
    125125   
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r86377 r86384  
    143143    }
    144144
    145     paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal);
    146 
    147     paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), IntRect(tx, ty, w, h));
    148     paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset);
     145    IntRect paintRect = IntRect(tx, ty, w, h);
     146   
     147    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
     148    paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect);
     149    paintBoxShadow(paintInfo.context, paintRect, style(), Inset);
    149150
    150151    if (!style()->hasBorder())
     
    168169    }
    169170
    170     paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
     171    paintBorder(paintInfo.context, paintRect, style());
    171172}
    172173
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r86377 r86384  
    559559    subtractCaptionRect(rect);
    560560
    561     paintBoxShadow(paintInfo.context, rect.x(), rect.y(), rect.width(), rect.height(), style(), Normal);
     561    paintBoxShadow(paintInfo.context, rect, style(), Normal);
    562562   
    563563    if (isRoot())
     
    568568        paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), rect);
    569569
    570     paintBoxShadow(paintInfo.context, rect.x(), rect.y(), rect.width(), rect.height(), style(), Inset);
     570    paintBoxShadow(paintInfo.context, rect, style(), Inset);
    571571
    572572    if (style()->hasBorder() && !collapseBorders())
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r86377 r86384  
    10081008        return;
    10091009
    1010     int w = width();
    1011     int h = height();
    1012    
    1013     paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal);
     1010    IntRect paintRect = IntRect(IntPoint(tx, ty), size());
     1011    paintBoxShadow(paintInfo.context, paintRect, style(), Normal);
    10141012   
    10151013    // Paint our cell background.
    10161014    paintBackgroundsBehindCell(paintInfo, tx, ty, this);
    10171015
    1018     paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset);
     1016    paintBoxShadow(paintInfo.context, paintRect, style(), Inset);
    10191017
    10201018    if (!style()->hasBorder() || tableElt->collapseBorders())
    10211019        return;
    10221020
    1023     paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
     1021    paintBorder(paintInfo.context, paintRect, style());
    10241022}
    10251023
Note: See TracChangeset for help on using the changeset viewer.