Changeset 86377 in webkit


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

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

Reviewed by Eric Seidel.

Switch paintMask and paintMaskImages off of ints
https://bugs.webkit.org/show_bug.cgi?id=60578

Primarily switching paintMask and paintMaskImages to use IntSize and IntRect respectively.
In the process of that:

  • added an "expand" function to IntRect that allows you to add an IntSize or pair of integers to the size portion of an IntRect.
  • changed borderFitAdjust to take an IntRect. It modifies only the x and width attributes.

No new tests since this refactoring.

  • platform/graphics/IntRect.h: (WebCore::IntRect::expand): Added for convenience.
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::paintObject): (WebCore::RenderBlock::borderFitAdjust):
  • rendering/RenderBlock.h:
  • rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorationsWithSize): (WebCore::RenderBox::paintMask): (WebCore::RenderBox::paintMaskImages):
  • rendering/RenderBox.h: (WebCore::RenderBox::borderFitAdjust):
  • rendering/RenderFieldset.cpp: (WebCore::RenderFieldset::paintMask):
  • rendering/RenderFieldset.h:
  • rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::paint):
  • rendering/RenderReplica.cpp: (WebCore::RenderReplica::paint):
  • rendering/RenderTable.cpp: (WebCore::RenderTable::paintObject): (WebCore::RenderTable::paintMask):
  • rendering/RenderTable.h:
  • rendering/RenderTableCell.cpp: (WebCore::RenderTableCell::paintMask):
  • rendering/RenderTableCell.h:
  • rendering/RenderWidget.cpp: (WebCore::RenderWidget::paint):
Location:
trunk/Source/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86375 r86377  
     12011-05-12  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch paintMask and paintMaskImages off of ints
     6        https://bugs.webkit.org/show_bug.cgi?id=60578
     7
     8        Primarily switching paintMask and paintMaskImages to use IntSize and IntRect respectively.
     9        In the process of that:
     10         - added an "expand" function to IntRect that allows you to add an IntSize or pair of
     11           integers to the size portion of an IntRect.
     12         - changed borderFitAdjust to take an IntRect. It modifies only the x and width attributes.
     13
     14        No new tests since this refactoring.
     15
     16        * platform/graphics/IntRect.h:
     17        (WebCore::IntRect::expand): Added for convenience.
     18        * rendering/RenderBlock.cpp:
     19        (WebCore::RenderBlock::paintObject):
     20        (WebCore::RenderBlock::borderFitAdjust):
     21        * rendering/RenderBlock.h:
     22        * rendering/RenderBox.cpp:
     23        (WebCore::RenderBox::paintBoxDecorationsWithSize):
     24        (WebCore::RenderBox::paintMask):
     25        (WebCore::RenderBox::paintMaskImages):
     26        * rendering/RenderBox.h:
     27        (WebCore::RenderBox::borderFitAdjust):
     28        * rendering/RenderFieldset.cpp:
     29        (WebCore::RenderFieldset::paintMask):
     30        * rendering/RenderFieldset.h:
     31        * rendering/RenderReplaced.cpp:
     32        (WebCore::RenderReplaced::paint):
     33        * rendering/RenderReplica.cpp:
     34        (WebCore::RenderReplica::paint):
     35        * rendering/RenderTable.cpp:
     36        (WebCore::RenderTable::paintObject):
     37        (WebCore::RenderTable::paintMask):
     38        * rendering/RenderTable.h:
     39        * rendering/RenderTableCell.cpp:
     40        (WebCore::RenderTableCell::paintMask):
     41        * rendering/RenderTableCell.h:
     42        * rendering/RenderWidget.cpp:
     43        (WebCore::RenderWidget::paint):
     44
    1452011-05-12  Patrick Gansterer  <paroga@webkit.org>
    246
  • trunk/Source/WebCore/platform/graphics/IntRect.h

    r84273 r86377  
    108108    IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); }
    109109
    110     void move(const IntSize& s) { m_location += s; }
     110    void move(const IntSize& size) { m_location += size; }
    111111    void move(int dx, int dy) { m_location.move(dx, dy); }
    112    
     112
     113    void expand(const IntSize& size) { m_location += size; }
     114    void expand(int dw, int dh) { m_size.expand(dw, dh); }
     115
    113116    void shiftXEdgeTo(int edge)
    114117    {
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r86160 r86377  
    24632463
    24642464    if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) {
    2465         paintMask(paintInfo, tx, ty);
     2465        paintMask(paintInfo, IntSize(tx, ty));
    24662466        return;
    24672467    }
     
    55965596}
    55975597
    5598 void RenderBlock::borderFitAdjust(int& x, int& w) const
     5598void RenderBlock::borderFitAdjust(IntRect& rect) const
    55995599{
    56005600    if (style()->borderFit() == BorderFitBorder)
     
    56045604    int left = INT_MAX;
    56055605    int right = INT_MIN;
    5606     int oldWidth = w;
     5606    int oldWidth = rect.width();
    56075607    adjustForBorderFit(0, left, right);
    56085608    if (left != INT_MAX) {
    56095609        left -= (borderLeft() + paddingLeft());
    56105610        if (left > 0) {
    5611             x += left;
    5612             w -= left;
     5611            rect.move(left, 0);
     5612            rect.expand(-left, 0);
    56135613        }
    56145614    }
     
    56165616        right += (borderRight() + paddingRight());
    56175617        if (right < oldWidth)
    5618             w -= (oldWidth - right);
     5618            rect.expand(-(oldWidth - right), 0);
    56195619    }
    56205620}
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r86160 r86377  
    361361    BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*);
    362362
    363     virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set.
     363    virtual void borderFitAdjust(IntRect&) const; // Shrink the box in which the border paints if border-fit is set.
    364364
    365365    virtual void updateBeforeAfterContent(PseudoId);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r86359 r86377  
    838838    // border-fit can adjust where we paint our border and background.  If set, we snugly fit our line box descendants.  (The iChat
    839839    // balloon layout is an example of this).
    840     borderFitAdjust(tx, width);
     840    borderFitAdjust(paintRect);
    841841
    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, tx, ty, width, height, style(), Normal);
     844    paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Normal);
    845845
    846846    BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context);
     
    871871            theme()->paintDecorations(this, paintInfo, paintRect);
    872872    }
    873     paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Inset);
     873    paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Inset);
    874874
    875875    // The theme will tell us whether or not we should also paint the CSS border.
    876876    if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder())
    877         paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance);
     877        paintBorder(paintInfo.context, paintRect, style(), bleedAvoidance);
    878878
    879879    if (bleedAvoidance == BackgroundBleedUseTransparencyLayer)
     
    881881}
    882882
    883 void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
     883void RenderBox::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
    884884{
    885885    if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask || paintInfo.context->paintingDisabled())
    886886        return;
    887887
    888     int w = width();
    889     int h = height();
     888    IntRect paintRect = IntRect(toPoint(paintOffset), size());
    890889
    891890    // border-fit can adjust where we paint our border and background.  If set, we snugly fit our line box descendants.  (The iChat
    892891    // balloon layout is an example of this).
    893     borderFitAdjust(tx, w);
    894 
    895     paintMaskImages(paintInfo, tx, ty, w, h);
    896 }
    897 
    898 void RenderBox::paintMaskImages(const PaintInfo& paintInfo, int tx, int ty, int w, int h)
     892    borderFitAdjust(paintRect);
     893
     894    paintMaskImages(paintInfo, paintRect);
     895}
     896
     897void RenderBox::paintMaskImages(const PaintInfo& paintInfo, const IntRect& paintRect)
    899898{
    900899    // Figure out if we need to push a transparency layer to render our mask.
     
    954953
    955954    if (allMaskImagesLoaded) {
    956         IntRect paintRect = IntRect(tx, ty, w, h);
    957955        paintFillLayers(paintInfo, Color(), style()->maskLayers(), paintRect, BackgroundBleedNone, compositeOp);
    958956        paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage(), compositeOp);
  • trunk/Source/WebCore/rendering/RenderBox.h

    r86303 r86377  
    253253    int computeContentBoxLogicalHeight(int height) const;
    254254
    255     virtual void borderFitAdjust(int& /*x*/, int& /*w*/) const { } // Shrink the box in which the border paints if border-fit is set.
     255    virtual void borderFitAdjust(IntRect&) const { } // Shrink the box in which the border paints if border-fit is set.
    256256
    257257    // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
     
    346346    virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); }
    347347    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
    348     virtual void paintMask(PaintInfo&, int tx, int ty);
     348    virtual void paintMask(PaintInfo&, IntSize);
    349349    virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
    350350
     
    410410
    411411    void paintBoxDecorationsWithSize(PaintInfo&, int tx, int ty, int width, int height);
    412     void paintMaskImages(const PaintInfo&, int tx, int ty, int width, int height);
     412    void paintMaskImages(const PaintInfo&, const IntRect&);
    413413
    414414#if PLATFORM(MAC)
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r86303 r86377  
    171171}
    172172
    173 void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)
     173void RenderFieldset::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
    174174{
    175175    if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
    176176        return;
    177177
    178     int w = width();
    179     int h = height();
     178    IntRect paintRect = IntRect(toPoint(paintOffset), size());
     179    IntSize adjustedSize = size();
    180180    RenderBox* legend = findLegend();
    181181    if (!legend)
    182         return RenderBlock::paintMask(paintInfo, tx, ty);
     182        return RenderBlock::paintMask(paintInfo, paintOffset);
    183183
    184184    // FIXME: We need to work with "rl" and "bt" block flow directions.  In those
     
    187187    if (style()->isHorizontalWritingMode()) {
    188188        int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
    189         h -= yOff;
    190         ty += yOff;
     189        paintRect.expand(0, -yOff);
     190        paintRect.move(0, yOff);
    191191    } else {
    192192        int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2;
    193         w -= xOff;
    194         tx += xOff;
    195     }
    196 
    197     paintMaskImages(paintInfo, tx, ty, w, h);
     193        paintRect.expand(-xOff, 0);
     194        paintRect.move(xOff, 0);
     195    }
     196
     197    paintMaskImages(paintInfo, paintRect);
    198198}
    199199
  • trunk/Source/WebCore/rendering/RenderFieldset.h

    r75537 r86377  
    4646
    4747    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
    48     virtual void paintMask(PaintInfo&, int tx, int ty);
     48    virtual void paintMask(PaintInfo&, IntSize);
    4949};
    5050
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r77397 r86377  
    107107   
    108108    if (paintInfo.phase == PaintPhaseMask) {
    109         paintMask(paintInfo, tx, ty);
     109        paintMask(paintInfo, IntSize(tx, ty));
    110110        return;
    111111    }
  • trunk/Source/WebCore/rendering/RenderReplica.cpp

    r72850 r86377  
    7777                                      RenderLayer::PaintLayerHaveTransparency | RenderLayer::PaintLayerAppliedTransform | RenderLayer::PaintLayerTemporaryClipRects | RenderLayer::PaintLayerPaintingReflection);
    7878    else if (paintInfo.phase == PaintPhaseMask)
    79         paintMask(paintInfo, tx, ty);
     79        paintMask(paintInfo, IntSize(tx, ty));
    8080}
    8181
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r86303 r86377  
    481481
    482482    if (paintPhase == PaintPhaseMask) {
    483         paintMask(paintInfo, tx, ty);
     483        paintMask(paintInfo, IntSize(tx, ty));
    484484        return;
    485485    }
     
    574574}
    575575
    576 void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty)
     576void RenderTable::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
    577577{
    578578    if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
    579579        return;
    580580
    581     IntRect rect(tx, ty, width(), height());
     581    IntRect rect(toPoint(paintOffset), size());
    582582    subtractCaptionRect(rect);
    583583
    584     paintMaskImages(paintInfo, rect.x(), rect.y(), rect.width(), rect.height());
     584    paintMaskImages(paintInfo, rect);
    585585}
    586586
  • trunk/Source/WebCore/rendering/RenderTable.h

    r86197 r86377  
    218218    virtual void paintObject(PaintInfo&, int tx, int ty);
    219219    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
    220     virtual void paintMask(PaintInfo&, int tx, int ty);
     220    virtual void paintMask(PaintInfo&, IntSize);
    221221    virtual void layout();
    222222    virtual void computePreferredLogicalWidths();
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r86303 r86377  
    10241024}
    10251025
    1026 void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty)
     1026void RenderTableCell::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
    10271027{
    10281028    if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
     
    10321032    if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
    10331033        return;
    1034 
    1035     int w = width();
    1036     int h = height();
    10371034   
    1038     paintMaskImages(paintInfo, tx, ty, w, h);
     1035    paintMaskImages(paintInfo, IntRect(toPoint(paintOffset), size()));
    10391036}
    10401037
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r81747 r86377  
    144144
    145145    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
    146     virtual void paintMask(PaintInfo&, int tx, int ty);
     146    virtual void paintMask(PaintInfo&, IntSize);
    147147
    148148    virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r86197 r86377  
    259259
    260260    if (paintInfo.phase == PaintPhaseMask) {
    261         paintMask(paintInfo, tx, ty);
     261        paintMask(paintInfo, IntSize(tx, ty));
    262262        return;
    263263    }
Note: See TracChangeset for help on using the changeset viewer.