Changeset 86188 in webkit


Ignore:
Timestamp:
May 10, 2011 3:45:29 PM (13 years ago)
Author:
leviw@chromium.org
Message:

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

Reviewed by Darin Adler.

Switch RenderBoxModelObject::paintNinePieceImage to use IntRect instead of four ints
https://bugs.webkit.org/show_bug.cgi?id=60586

Switch paintNinePieceImage to take an IntRect instead of four ints representing an IntRect!

No new tests as this is simply refactoring.

  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::paintMask):
  • rendering/RenderBox.cpp: (WebCore::RenderBox::paintMaskImages):
  • rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintNinePieceImage): (WebCore::RenderBoxModelObject::paintBorder):
  • rendering/RenderBoxModelObject.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86185 r86188  
     12011-05-10  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Switch RenderBoxModelObject::paintNinePieceImage to use IntRect instead of four ints
     6        https://bugs.webkit.org/show_bug.cgi?id=60586
     7
     8        Switch paintNinePieceImage to take an IntRect instead of four ints representing an IntRect!
     9
     10        No new tests as this is simply refactoring.
     11
     12        * rendering/InlineFlowBox.cpp:
     13        (WebCore::InlineFlowBox::paintMask):
     14        * rendering/RenderBox.cpp:
     15        (WebCore::RenderBox::paintMaskImages):
     16        * rendering/RenderBoxModelObject.cpp:
     17        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     18        (WebCore::RenderBoxModelObject::paintBorder):
     19        * rendering/RenderBoxModelObject.h:
     20
    1212011-05-05  Jer Noble  <jer.noble@apple.com>
    222
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r85971 r86188  
    12141214    // cases only a single call to draw is required.
    12151215    if (!prevLineBox() && !nextLineBox()) {
    1216         boxModelObject()->paintNinePieceImage(paintInfo.context, tx, ty, w, h, renderer()->style(), maskNinePieceImage, compositeOp);
     1216        boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(tx, ty, w, h), renderer()->style(), maskNinePieceImage, compositeOp);
    12171217    } else {
    12181218        // We have a mask image that spans multiple lines.
     
    12311231        GraphicsContextStateSaver stateSaver(*paintInfo.context);
    12321232        paintInfo.context->clip(IntRect(tx, ty, w, h));
    1233         boxModelObject()->paintNinePieceImage(paintInfo.context, stripX, stripY, stripWidth, stripHeight, renderer()->style(), maskNinePieceImage, compositeOp);
     1233        boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, compositeOp);
    12341234    }
    12351235   
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r86024 r86188  
    954954    if (allMaskImagesLoaded) {
    955955        paintFillLayers(paintInfo, Color(), style()->maskLayers(), tx, ty, w, h, BackgroundBleedNone, compositeOp);
    956         paintNinePieceImage(paintInfo.context, tx, ty, w, h, style(), style()->maskBoxImage(), compositeOp);
     956        paintNinePieceImage(paintInfo.context, IntRect(tx, ty, w, h), style(), style()->maskBoxImage(), compositeOp);
    957957    }
    958958   
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r84664 r86188  
    922922}
    923923
    924 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style,
     924bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const IntRect& rect, const RenderStyle* style,
    925925                                               const NinePieceImage& ninePieceImage, CompositeOperator op)
    926926{
     
    937937    // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function
    938938    // doesn't have any understanding of the zoom that is in effect on the tile.
    939     styleImage->setImageContainerSize(IntSize(w, h));
     939    styleImage->setImageContainerSize(rect.size());
    940940    IntSize imageSize = styleImage->imageSize(this, 1.0f);
    941941    int imageWidth = imageSize.width();
     
    961961    bool drawRight = rightSlice > 0 && rightWidth > 0;
    962962    bool drawBottom = bottomSlice > 0 && bottomWidth > 0;
    963     bool drawMiddle = (imageWidth - leftSlice - rightSlice) > 0 && (w - leftWidth - rightWidth) > 0 &&
    964                       (imageHeight - topSlice - bottomSlice) > 0 && (h - topWidth - bottomWidth) > 0;
     963    bool drawMiddle = (imageWidth - leftSlice - rightSlice) > 0 && (rect.width() - leftWidth - rightWidth) > 0
     964                      && (imageHeight - topSlice - bottomSlice) > 0 && (rect.height() - topWidth - bottomWidth) > 0;
    965965
    966966    RefPtr<Image> image = styleImage->image(this, imageSize);
     
    973973        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
    974974        if (drawTop)
    975             graphicsContext->drawImage(image.get(), colorSpace, IntRect(tx, ty, leftWidth, topWidth),
     975            graphicsContext->drawImage(image.get(), colorSpace, IntRect(rect.location(), IntSize(leftWidth, topWidth)),
    976976                                       IntRect(0, 0, leftSlice, topSlice), op);
    977977
     
    979979        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
    980980        if (drawBottom)
    981             graphicsContext->drawImage(image.get(), colorSpace, IntRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth),
     981            graphicsContext->drawImage(image.get(), colorSpace, IntRect(rect.x(), rect.y() + rect.height() - bottomWidth, leftWidth, bottomWidth),
    982982                                       IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
    983983
    984984        // Paint the left edge.
    985985        // Have to scale and tile into the border rect.
    986         graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(tx, ty + topWidth, leftWidth,
    987                                         h - topWidth - bottomWidth),
     986        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(rect.x(), rect.y() + topWidth, leftWidth,
     987                                        rect.height() - topWidth - bottomWidth),
    988988                                        IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
    989989                                        Image::StretchTile, (Image::TileRule)vRule, op);
     
    995995        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
    996996        if (drawTop)
    997             graphicsContext->drawImage(image.get(), colorSpace, IntRect(tx + w - rightWidth, ty, rightWidth, topWidth),
     997            graphicsContext->drawImage(image.get(), colorSpace, IntRect(rect.x() + rect.width() - rightWidth, rect.y(), rightWidth, topWidth),
    998998                                       IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
    999999
     
    10011001        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
    10021002        if (drawBottom)
    1003             graphicsContext->drawImage(image.get(), colorSpace, IntRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth),
     1003            graphicsContext->drawImage(image.get(), colorSpace, IntRect(rect.x() + rect.width() - rightWidth, rect.y() + rect.height() - bottomWidth, rightWidth, bottomWidth),
    10041004                                       IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
    10051005
    10061006        // Paint the right edge.
    1007         graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(tx + w - rightWidth, ty + topWidth, rightWidth,
    1008                                         h - topWidth - bottomWidth),
     1007        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(rect.x() + rect.width() - rightWidth, rect.y() + topWidth, rightWidth,
     1008                                        rect.height() - topWidth - bottomWidth),
    10091009                                        IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
    10101010                                        Image::StretchTile, (Image::TileRule)vRule, op);
     
    10131013    // Paint the top edge.
    10141014    if (drawTop)
    1015         graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth),
     1015        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(rect.x() + leftWidth, rect.y(), rect.width() - leftWidth - rightWidth, topWidth),
    10161016                                        IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
    10171017                                        (Image::TileRule)hRule, Image::StretchTile, op);
     
    10191019    // Paint the bottom edge.
    10201020    if (drawBottom)
    1021         graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(tx + leftWidth, ty + h - bottomWidth,
    1022                                         w - leftWidth - rightWidth, bottomWidth),
     1021        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(rect.x() + leftWidth, rect.y() + rect.height() - bottomWidth,
     1022                                        rect.width() - leftWidth - rightWidth, bottomWidth),
    10231023                                        IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
    10241024                                        (Image::TileRule)hRule, Image::StretchTile, op);
     
    10261026    // Paint the middle.
    10271027    if (drawMiddle)
    1028         graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth,
    1029                                         h - topWidth - bottomWidth),
     1028        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(rect.x() + leftWidth, rect.y() + topWidth, rect.width() - leftWidth - rightWidth,
     1029                                        rect.height() - topWidth - bottomWidth),
    10301030                                        IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
    10311031                                        (Image::TileRule)hRule, (Image::TileRule)vRule, op);
     
    13511351{
    13521352    // border-image is not affected by border-radius.
    1353     if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage()))
     1353    if (paintNinePieceImage(graphicsContext, IntRect(tx, ty, w, h), style, style->borderImage()))
    13541354        return;
    13551355
     
    15931593    // FIXME: This old version of paintBorder should be removed when all ports implement
    15941594    // GraphicsContext::clipConvexPolygon()!! This should happen soon.
    1595     if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage()))
     1595    if (paintNinePieceImage(graphicsContext, IntRect(tx, ty, w, h), style, style->borderImage()))
    15961596        return;
    15971597
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r84341 r86188  
    120120
    121121    void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    122     bool paintNinePieceImage(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
     122    bool paintNinePieceImage(GraphicsContext*, const IntRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
    123123    void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    124124    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance, InlineFlowBox* = 0, int inlineBoxWidth = 0, int inlineBoxHeight = 0, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
Note: See TracChangeset for help on using the changeset viewer.