Changeset 143646 in webkit


Ignore:
Timestamp:
Feb 21, 2013 1:11:22 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r143419.
http://trac.webkit.org/changeset/143419
https://bugs.webkit.org/show_bug.cgi?id=110507

Broke border-image on Mac (Requested by jpfau on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-02-21

Source/WebCore:

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawTiledImage):

  • platform/graphics/GraphicsContext.h:

(GraphicsContext):

  • platform/graphics/Image.cpp:

(WebCore::Image::drawTiled):

  • platform/graphics/Image.h:

(Image):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintNinePieceImage):

LayoutTests:

  • fast/borders/border-image-02.html: Removed.
  • platform/chromium-linux/fast/borders/border-image-02-expected.png: Removed.
  • platform/chromium/TestExpectations:
  • platform/chromium/fast/borders/border-image-02-expected.txt: Removed.
  • platform/efl/TestExpectations:
  • platform/gtk/fast/borders/border-image-02-expected.png: Removed.
  • platform/gtk/fast/borders/border-image-02-expected.txt: Removed.
  • platform/mac-wk2/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/qt/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
5 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143645 r143646  
     12013-02-21  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r143419.
     4        http://trac.webkit.org/changeset/143419
     5        https://bugs.webkit.org/show_bug.cgi?id=110507
     6
     7        Broke border-image on Mac (Requested by jpfau on #webkit).
     8
     9        * fast/borders/border-image-02.html: Removed.
     10        * platform/chromium-linux/fast/borders/border-image-02-expected.png: Removed.
     11        * platform/chromium/TestExpectations:
     12        * platform/chromium/fast/borders/border-image-02-expected.txt: Removed.
     13        * platform/efl/TestExpectations:
     14        * platform/gtk/fast/borders/border-image-02-expected.png: Removed.
     15        * platform/gtk/fast/borders/border-image-02-expected.txt: Removed.
     16        * platform/mac-wk2/TestExpectations:
     17        * platform/mac/TestExpectations:
     18        * platform/qt/TestExpectations:
     19        * platform/win/TestExpectations:
     20
    1212013-02-21  Filip Pizlo  <fpizlo@apple.com>
    222
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r143643 r143646  
    20342034crbug.com/11001 http/tests/history/back-to-post.php [ Timeout ]
    20352035
    2036 # Needs baseline after 14185
    2037 webkit.org/b/14185 [ Android Win Mac ] fast/borders/border-image-02.html [ Missing ]
    2038 
    20392036# WebKit 45086:45111
    20402037crbug.com/15270 fast/js/excessive-comma-usage.html [ Failure ]
     
    29292926
    29302927webkit.org/b/67915 [ Android ] fast/borders/borderRadiusDashed06.html [ ImageOnlyFailure ]
    2931 
    2932 # Needs rebaseline after bug 14185
    2933 webkit.org/b/14185 fast/borders/border-image-rotate-transform.html [ ImageOnlyFailure ]
    29342928
    29352929webkit.org/b/95365 fast/loader/reload-zero-byte-plugin.html
  • trunk/LayoutTests/platform/efl/TestExpectations

    r143643 r143646  
    671671webkit.org/b/105542 fast/canvas/canvas-blend-image.html [ Skip ]
    672672webkit.org/b/105542 fast/canvas/canvas-blend-solid.html [ Skip ]
    673 
    674 # Needs baseline after 14185
    675 webkit.org/b/14185 fast/borders/border-image-02.html [ Missing ]
    676673
    677674#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r143419 r143646  
    253253fast/dom/StyleSheet/detached-stylesheet-without-wrapper.html
    254254
    255 # Needs baseline after bug 14185
    256 fast/borders/border-image-02.html
    257 
    258255# All spatial navigation tests fail on Mac WK2
    259256webkit.org/b/96438 fast/spatial-navigation
  • trunk/LayoutTests/platform/mac/TestExpectations

    r143643 r143646  
    11071107svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg
    11081108
    1109 # Needs baseline after 14185
    1110 webkit.org/b/14185 fast/borders/border-image-02.html [ Missing ]
    1111 
    11121109# Unknown failures.
    11131110http/tests/multipart/invalid-image-data-standalone.html
  • trunk/LayoutTests/platform/qt/TestExpectations

    r143643 r143646  
    16851685fast/block/positioning/absolute-in-inline-rtl-3.html
    16861686fast/block/positioning/absolute-in-inline-rtl.html
    1687 fast/borders/border-image-02.html
    16881687fast/borders/border-image-omit-right-slice.html
    16891688fast/borders/borderRadiusAllStylesAllCorners.html
  • trunk/LayoutTests/platform/win/TestExpectations

    r143643 r143646  
    25562556webkit.org/b/9221 fast/css/resize-corner-tracking-transformed-iframe.html [ Missing ]
    25572557
    2558 # Needs baseline after 14185
    2559 webkit.org/b/14185 fast/borders/border-image-02.html [ Missing ]
    2560 
    25612558# Temporarily skip inspector tests which are now failing on the bots due to some configuration problem
    25622559inspector
  • trunk/Source/WebCore/ChangeLog

    r143644 r143646  
     12013-02-21  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r143419.
     4        http://trac.webkit.org/changeset/143419
     5        https://bugs.webkit.org/show_bug.cgi?id=110507
     6
     7        Broke border-image on Mac (Requested by jpfau on #webkit).
     8
     9        * platform/graphics/GraphicsContext.cpp:
     10        (WebCore::GraphicsContext::drawTiledImage):
     11        * platform/graphics/GraphicsContext.h:
     12        (GraphicsContext):
     13        * platform/graphics/Image.cpp:
     14        (WebCore::Image::drawTiled):
     15        * platform/graphics/Image.h:
     16        (Image):
     17        * rendering/RenderBoxModelObject.cpp:
     18        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     19
    1202013-02-21  Tom Sepez  <tsepez@chromium.org>
    221
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r143419 r143646  
    515515
    516516void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect,
    517     const FloatPoint& patternPhase, const AffineTransform& patternTransform, CompositeOperator op, bool useLowQualityScale)
     517    const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale)
    518518{
    519519    if (paintingDisabled() || !image)
    520520        return;
     521
     522    if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
     523        // Just do a scale.
     524        drawImage(image, styleColorSpace, dest, srcRect, op);
     525        return;
     526    }
    521527
    522528    if (useLowQualityScale) {
    523529        InterpolationQuality previousInterpolationQuality = imageInterpolationQuality();
    524530        setImageInterpolationQuality(InterpolationLow);
    525         image->drawTiled(this, dest, srcRect, patternPhase, patternTransform, styleColorSpace, op);
     531        image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op);
    526532        setImageInterpolationQuality(previousInterpolationQuality);
    527533    } else
    528         image->drawTiled(this, dest, srcRect, patternPhase, patternTransform, styleColorSpace, op);
     534        image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op);
    529535}
    530536
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r143419 r143646  
    328328        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
    329329            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false, BlendMode = BlendModeNormal);
    330         void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, const FloatPoint& patternPhase, const AffineTransform& patternTransform, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
     330        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
     331                            const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
     332                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
    331333
    332334        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal);
  • trunk/Source/WebCore/platform/graphics/Image.cpp

    r143419 r143646  
    144144// FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
    145145void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect,
    146     const FloatPoint& patternPhase, const AffineTransform &patternTransform, ColorSpace styleColorSpace, CompositeOperator op)
     146    const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator op)
    147147{   
    148148    if (mayFillWithSolidColor()) {
     
    150150        return;
    151151    }
     152   
     153    // FIXME: We do not support 'round' or 'space' yet. For now just map them to 'repeat'.
     154    if (hRule == RoundTile || hRule == SpaceTile)
     155        hRule = RepeatTile;
     156    if (vRule == RoundTile || vRule == SpaceTile)
     157        vRule = RepeatTile;
     158
     159    AffineTransform patternTransform = AffineTransform().scaleNonUniform(tileScaleFactor.width(), tileScaleFactor.height());
     160
     161    // We want to construct the phase such that the pattern is centered (when stretch is not
     162    // set for a particular rule).
     163    float hPhase = tileScaleFactor.width() * srcRect.x();
     164    float vPhase = tileScaleFactor.height() * srcRect.y();
     165    float scaledTileWidth = tileScaleFactor.width() * srcRect.width();
     166    float scaledTileHeight = tileScaleFactor.height() * srcRect.height();
     167    if (hRule == Image::RepeatTile)
     168        hPhase -= (dstRect.width() - scaledTileWidth) / 2;
     169    if (vRule == Image::RepeatTile)
     170        vPhase -= (dstRect.height() - scaledTileHeight) / 2;
     171    FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase);
    152172   
    153173    drawPattern(ctxt, srcRect, patternTransform, patternPhase, styleColorSpace, op, dstRect);
  • trunk/Source/WebCore/platform/graphics/Image.h

    r143419 r143646  
    202202    void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace,
    203203        CompositeOperator , BlendMode);
    204     void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatPoint& patternPhase, const AffineTransform& patternTransform, ColorSpace styleColorSpace, CompositeOperator);
     204    void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator);
    205205
    206206    // Supporting tiled drawing
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r143419 r143646  
    12681268    RenderView* renderView = view();
    12691269
    1270     enum { TopTile, CenterTile, BottomTile, LeftTile = TopTile, RightTile = BottomTile };
    1271     int sliceX[3];
    1272     int sliceY[3];
    1273 
    12741270    float imageScaleFactor = styleImage->imageScaleFactor();
    1275     sliceY[TopTile] = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight, renderView)) * imageScaleFactor;
    1276     sliceX[RightTile] = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth, renderView)) * imageScaleFactor;
    1277     sliceY[BottomTile] = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight, renderView)) * imageScaleFactor;
    1278     sliceX[LeftTile] = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth, renderView)) * imageScaleFactor;
    1279     sliceY[CenterTile] = max(0, imageHeight - sliceY[TopTile] - sliceY[BottomTile]);
    1280     sliceX[CenterTile] = max(0, imageWidth - sliceX[LeftTile] - sliceX[RightTile]);
     1271    int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight, renderView)) * imageScaleFactor;
     1272    int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth, renderView)) * imageScaleFactor;
     1273    int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight, renderView)) * imageScaleFactor;
     1274    int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth, renderView)) * imageScaleFactor;
    12811275
    12821276    ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
    12831277    ENinePieceImageRule vRule = ninePieceImage.verticalRule();
    12841278
    1285     int widthY[3];
    1286     int widthX[3];
    1287     widthY[TopTile] = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), sliceY[TopTile], borderImageRect.height(), renderView);
    1288     widthX[RightTile] = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), sliceX[RightTile], borderImageRect.width(), renderView);
    1289     widthY[BottomTile] = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), sliceY[BottomTile], borderImageRect.height(), renderView);
    1290     widthX[LeftTile] = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), sliceX[LeftTile], borderImageRect.width(), renderView);
     1279    int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height(), renderView);
     1280    int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width(), renderView);
     1281    int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height(), renderView);
     1282    int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width(), renderView);
    12911283   
    12921284    // Reduce the widths if they're too large.
     
    12941286    // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all W are reduced by
    12951287    // multiplying them by f.
    1296     int borderSideWidth = max(1, widthX[LeftTile] + widthX[RightTile]);
    1297     int borderSideHeight = max(1, widthY[TopTile] + widthY[BottomTile]);
     1288    int borderSideWidth = max(1, leftWidth + rightWidth);
     1289    int borderSideHeight = max(1, topWidth + bottomWidth);
    12981290    float borderSideScaleFactor = min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight);
    12991291    if (borderSideScaleFactor < 1) {
    1300         widthY[TopTile] *= borderSideScaleFactor;
    1301         widthX[RightTile] *= borderSideScaleFactor;
    1302         widthY[BottomTile] *= borderSideScaleFactor;
    1303         widthX[LeftTile] *= borderSideScaleFactor;
    1304     }
    1305 
    1306     widthY[CenterTile] = max(0, borderImageRect.height() - widthY[TopTile] - widthY[BottomTile]);
    1307     widthX[CenterTile] = max(0, borderImageRect.width() - widthX[LeftTile] - widthX[RightTile]);
    1308 
    1309     // 1. Scale to 'border-image-width'.
    1310     // - The two images for the top and bottom edges are made as tall as the top and bottom border image area parts,
    1311     //   respectively, and their width is scaled proportionally.
    1312     // - The images for the left and right edge are made as wide as the left and right border image area parts,
    1313     //   respectively, and their height is scaled proportionally.
    1314     // - The corner images are scaled to be as wide and as tall as the two border-image edges they are part of.
    1315 
    1316     // We're implementing the standard using two variables for every row and column:
    1317     // "stretch" is the amount of scaling needed to make the source tile exactly fit the destination
    1318     // "scale" is the scaling applied to the middle row and column respecting border-image-repeat. Be careful,
    1319     // because scaleX is scaling in X direction, but applies to a column.
    1320     // Also, when a row or column doesn't need to be drawn, we're using 0.0 only, and not INF, as the spec does.
    1321     float stretchX[3];
    1322     float stretchY[3];
    1323     float scaleX[3];
    1324     float scaleY[3];
    1325     stretchX[LeftTile] = sliceX[LeftTile] ? static_cast<float>(widthX[LeftTile]) / sliceX[LeftTile] : 0.0;
    1326     stretchX[RightTile] = sliceX[RightTile] ? static_cast<float>(widthX[RightTile]) / sliceX[RightTile] : 0.0;
    1327     stretchX[CenterTile] = sliceX[CenterTile] ? static_cast<float>(widthX[CenterTile]) / sliceX[CenterTile] : 0.0;
    1328     stretchY[TopTile] = sliceY[TopTile] ? static_cast<float>(widthY[TopTile]) / sliceY[TopTile] : 0.0;
    1329     stretchY[BottomTile] = sliceY[BottomTile] ? static_cast<float>(widthY[BottomTile]) / sliceY[BottomTile] : 0.0;
    1330     stretchY[CenterTile] = sliceY[CenterTile] ? static_cast<float>(widthY[CenterTile]) / sliceY[CenterTile] : 0.0;
    1331 
    1332     scaleX[TopTile] = stretchY[TopTile];
    1333     scaleX[BottomTile] = stretchY[BottomTile];
    1334     scaleY[LeftTile] = stretchX[LeftTile];
    1335     scaleY[RightTile] = stretchX[RightTile];
    1336 
    1337     // The middle image's width is scaled by the same factor as the top image unless that factor is zero or infinity,
    1338     // in which case the scaling factor of the bottom is substituted, and failing that, the width is not scaled.
    1339     // The height of the middle image is scaled by the same factor as the left image unless that factor is zero or infinity,
    1340     // in which case the scaling factor of the right image is substituted, and failing that, the height is not scaled.
    1341     if (scaleX[TopTile])
    1342         scaleX[CenterTile] = scaleX[TopTile];
    1343     else if (scaleX[BottomTile])
    1344         scaleX[CenterTile] = scaleX[BottomTile];
    1345     else
    1346         scaleX[CenterTile] = 1.0f;
    1347     if (scaleY[LeftTile])
    1348         scaleY[CenterTile] = scaleY[LeftTile];
    1349     else if (scaleY[RightTile])
    1350         scaleY[CenterTile] = scaleY[RightTile];
    1351     else
    1352         scaleY[CenterTile] = 1.0f;
    1353 
    1354     // Scale to 'border-image-repeat'.
    1355     switch (hRule) {
    1356     case StretchImageRule:
    1357         // If the first keyword is 'stretch', the top, middle and bottom images are further scaled to be as wide
    1358         // as the middle part of the border image area. The height is not changed any further.
    1359         scaleX[TopTile] = stretchX[CenterTile];
    1360         scaleX[CenterTile] = stretchX[CenterTile];
    1361         scaleX[BottomTile] = stretchX[CenterTile];
    1362         break;
    1363     case RoundImageRule:
    1364         // If the first keyword is 'round', the top, middle and bottom images are resized in width,
    1365         // so that exactly a whole number of them fit in the middle part of the border-image area,
    1366         // exactly as for 'round' in the 'background-repeat' property.
    1367         scaleX[TopTile] = stretchX[CenterTile] / max(1.0f, roundf(stretchX[CenterTile] / scaleX[TopTile]));
    1368         scaleX[CenterTile] = stretchX[CenterTile] / max(1.0f, roundf(stretchX[CenterTile] / scaleX[CenterTile]));
    1369         scaleX[BottomTile] = stretchX[CenterTile] / max(1.0f, roundf(stretchX[CenterTile] / scaleX[BottomTile]));
    1370         break;
    1371     case SpaceImageRule:
    1372         // FIXME: We do not support 'space' yet. For now map it to 'repeat'.
    1373     case RepeatImageRule:
    1374         // If the first keyword is 'repeat' or 'space', the top, middle, and bottom images are not changed any further.
    1375         break;
    1376     }
    1377     // The effects of 'stretch', 'round', 'repeat', and 'space' for the second keyword are analogous,
    1378     // acting on the height of the left, middle and right images.
    1379     switch (vRule) {
    1380     case StretchImageRule:
    1381         // If the first keyword is 'stretch', the top, middle and bottom images are further scaled to be as wide
    1382         // as the middle part of the border image area. The height is not changed any further.
    1383         scaleY[LeftTile] = stretchY[CenterTile];
    1384         scaleY[CenterTile] = stretchY[CenterTile];
    1385         scaleY[RightTile] = stretchY[CenterTile];
    1386         break;
    1387     case RoundImageRule:
    1388         // If the first keyword is 'round', the top, middle and bottom images are resized in width,
    1389         // so that exactly a whole number of them fit in the middle part of the border-image area,
    1390         // exactly as for 'round' in the 'background-repeat' property.
    1391         scaleY[LeftTile] = stretchY[CenterTile] / max(1.0f, roundf(stretchY[CenterTile] / scaleY[LeftTile]));
    1392         scaleY[CenterTile] = stretchY[CenterTile] / max(1.0f, roundf(stretchY[CenterTile] / scaleY[CenterTile]));
    1393         scaleY[RightTile] = stretchY[CenterTile] / max(1.0f, roundf(stretchY[CenterTile] / scaleY[RightTile]));
    1394         break;
    1395     case SpaceImageRule:
    1396         // FIXME: We do not support 'space' yet. For now map it to 'repeat'.
    1397     case RepeatImageRule:
    1398         // If the first keyword is 'repeat' or 'space', the top, middle, and bottom images are not changed any further.
    1399         break;
    1400     }
     1292        topWidth *= borderSideScaleFactor;
     1293        rightWidth *= borderSideScaleFactor;
     1294        bottomWidth *= borderSideScaleFactor;
     1295        leftWidth *= borderSideScaleFactor;
     1296    }
     1297
     1298    bool drawLeft = leftSlice > 0 && leftWidth > 0;
     1299    bool drawTop = topSlice > 0 && topWidth > 0;
     1300    bool drawRight = rightSlice > 0 && rightWidth > 0;
     1301    bool drawBottom = bottomSlice > 0 && bottomWidth > 0;
     1302    bool drawMiddle = ninePieceImage.fill() && (imageWidth - leftSlice - rightSlice) > 0 && (borderImageRect.width() - leftWidth - rightWidth) > 0
     1303                      && (imageHeight - topSlice - bottomSlice) > 0 && (borderImageRect.height() - topWidth - bottomWidth) > 0;
    14011304
    14021305    RefPtr<Image> image = styleImage->image(this, imageSize);
    14031306    ColorSpace colorSpace = style->colorSpace();
    1404 
    1405     // If the first keyword is 'repeat', the top, middle, and bottom images are centered horizontally in
    1406     // their respective areas. Otherwise the images are placed at the left edge of their respective parts
    1407     // of the border-image area.
    1408     // If the second keyword is 'repeat', the left, middle, and right images are centered vertically in their
    1409     // respective areas. Otherwise the images are placed at the top edge of their respective parts of the
    1410     // border-image area.
    1411     for (int j = 0; j < 3; j++) {
    1412         if (!stretchY[j])
    1413             continue;
    1414         for (int i = 0; i < 3; i++) {
    1415             if (!stretchX[i])
    1416                 continue;
    1417             if (i == CenterTile && j == CenterTile && !ninePieceImage.fill())
    1418                 continue;
    1419 
    1420             // This somewhat weird size computation is necessary because left and right tile may overlap.
    1421             IntRect destRect(borderImageRect.x() + (i == LeftTile ? 0 : i == CenterTile ? widthX[LeftTile] : borderImageRect.width() - widthX[RightTile]),
    1422                 borderImageRect.y() + (j == TopTile ? 0 : j == CenterTile ? widthY[TopTile] : borderImageRect.height() - widthY[BottomTile]), widthX[i], widthY[j]);
    1423 
    1424             IntRect srcRect(i == LeftTile ? 0 : i == CenterTile ? sliceX[LeftTile] : imageWidth - sliceX[RightTile],
    1425                 j == TopTile ? 0 : j == CenterTile ? sliceY[TopTile] : imageHeight - sliceY[BottomTile], sliceX[i], sliceY[j]);
    1426 
    1427             if ((i == CenterTile && hRule != StretchImageRule) || (j == CenterTile && vRule != StretchImageRule)) {
    1428                 // We want to construct the phase such that the pattern is centered (when stretch is not
    1429                 // set for a particular rule).
    1430                 AffineTransform transform;
    1431 
    1432                 transform.translate(destRect.x(), destRect.y());
    1433                 if (i == CenterTile && hRule == RepeatImageRule)
    1434                     transform.translate((destRect.width() - scaleX[j] * sliceX[i]) / 2, 0);
    1435                 if (j == CenterTile && vRule == RepeatImageRule)
    1436                     transform.translate(0, (destRect.height() - scaleY[i] * sliceY[j]) / 2);
    1437                 transform.scaleNonUniform(i == CenterTile ? scaleX[j] : stretchX[i], j == CenterTile ? scaleY[i] : stretchY[j]);
    1438                 transform.translate(-srcRect.x(), -srcRect.y());
    1439 
    1440                 graphicsContext->drawTiledImage(image.get(), colorSpace, destRect, srcRect, FloatPoint(), transform, op);
    1441             } else
    1442                 graphicsContext->drawImage(image.get(), colorSpace, destRect, srcRect, op);
    1443         }
     1307   
     1308    float destinationWidth = borderImageRect.width() - leftWidth - rightWidth;
     1309    float destinationHeight = borderImageRect.height() - topWidth - bottomWidth;
     1310   
     1311    float sourceWidth = imageWidth - leftSlice - rightSlice;
     1312    float sourceHeight = imageHeight - topSlice - bottomSlice;
     1313   
     1314    float leftSideScale = drawLeft ? (float)leftWidth / leftSlice : 1;
     1315    float rightSideScale = drawRight ? (float)rightWidth / rightSlice : 1;
     1316    float topSideScale = drawTop ? (float)topWidth / topSlice : 1;
     1317    float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1;
     1318   
     1319    if (drawLeft) {
     1320        // Paint the top and bottom left corners.
     1321
     1322        // The top left corner rect is (tx, ty, leftWidth, topWidth)
     1323        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
     1324        if (drawTop)
     1325            graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.location(), IntSize(leftWidth, topWidth)),
     1326                                       LayoutRect(0, 0, leftSlice, topSlice), op);
     1327
     1328        // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
     1329        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
     1330        if (drawBottom)
     1331            graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth),
     1332                                       LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
     1333
     1334        // Paint the left edge.
     1335        // Have to scale and tile into the border rect.
     1336        if (sourceHeight > 0)
     1337            graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
     1338                                            destinationHeight),
     1339                                            IntRect(0, topSlice, leftSlice, sourceHeight),
     1340                                            FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
     1341    }
     1342
     1343    if (drawRight) {
     1344        // Paint the top and bottom right corners
     1345        // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
     1346        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
     1347        if (drawTop)
     1348            graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y(), rightWidth, topWidth),
     1349                                       LayoutRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
     1350
     1351        // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
     1352        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
     1353        if (drawBottom)
     1354            graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth),
     1355                                       LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
     1356
     1357        // Paint the right edge.
     1358        if (sourceHeight > 0)
     1359            graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
     1360                                            destinationHeight),
     1361                                            IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
     1362                                            FloatSize(rightSideScale, rightSideScale),
     1363                                            Image::StretchTile, (Image::TileRule)vRule, op);
     1364    }
     1365
     1366    // Paint the top edge.
     1367    if (drawTop && sourceWidth > 0)
     1368        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
     1369                                        IntRect(leftSlice, 0, sourceWidth, topSlice),
     1370                                        FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
     1371
     1372    // Paint the bottom edge.
     1373    if (drawBottom && sourceWidth > 0)
     1374        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
     1375                                        destinationWidth, bottomWidth),
     1376                                        IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
     1377                                        FloatSize(bottomSideScale, bottomSideScale),
     1378                                        (Image::TileRule)hRule, Image::StretchTile, op);
     1379
     1380    // Paint the middle.
     1381    if (drawMiddle) {
     1382        FloatSize middleScaleFactor(1, 1);
     1383        if (drawTop)
     1384            middleScaleFactor.setWidth(topSideScale);
     1385        else if (drawBottom)
     1386            middleScaleFactor.setWidth(bottomSideScale);
     1387        if (drawLeft)
     1388            middleScaleFactor.setHeight(leftSideScale);
     1389        else if (drawRight)
     1390            middleScaleFactor.setHeight(rightSideScale);
     1391           
     1392        // For "stretch" rules, just override the scale factor and replace. We only had to do this for the
     1393        // center tile, since sides don't even use the scale factor unless they have a rule other than "stretch".
     1394        // The middle however can have "stretch" specified in one axis but not the other, so we have to
     1395        // correct the scale here.
     1396        if (hRule == StretchImageRule)
     1397            middleScaleFactor.setWidth(destinationWidth / sourceWidth);
     1398           
     1399        if (vRule == StretchImageRule)
     1400            middleScaleFactor.setHeight(destinationHeight / sourceHeight);
     1401       
     1402        graphicsContext->drawTiledImage(image.get(), colorSpace,
     1403            IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
     1404            IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
     1405            middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op);
    14441406    }
    14451407
Note: See TracChangeset for help on using the changeset viewer.