Changeset 95121 in webkit


Ignore:
Timestamp:
Sep 14, 2011 2:15:56 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=68103

Centered portions of border images don't render correctly. Make the tile scale factor have to be
explicitly passed in and modify paintNinePieceImage to compute it for all sides. The attempts to
implicitly compute the scale for the pattern based off the source and destination rects just don't
work, since the center image rects don't provide the right information to be able to infer the
scale factor.

Reviewed by Sam Weinig.

Reset all the existing fast/borders pixel results to Lion for these changes.

Source/WebCore:

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawTiledImage):

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/Image.cpp:

(WebCore::Image::drawTiled):

  • platform/graphics/Image.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintNinePieceImage):

LayoutTests:

  • platform/mac/fast/borders/bidi-002-expected.png:
  • platform/mac/fast/borders/bidi-009a-expected.png:
  • platform/mac/fast/borders/bidi-012-expected.png:
  • platform/mac/fast/borders/block-mask-overlay-image-expected.png:
  • platform/mac/fast/borders/border-antialiasing-expected.png:
  • platform/mac/fast/borders/border-color-inherit-expected.png:
  • platform/mac/fast/borders/border-fit-expected.png:
  • platform/mac/fast/borders/border-image-01-expected.png:
  • platform/mac/fast/borders/border-image-border-radius-expected.png:
  • platform/mac/fast/borders/border-image-longhand-expected.png:
  • platform/mac/fast/borders/border-image-omit-right-slice-expected.png:
  • platform/mac/fast/borders/border-image-outset-expected.png:
  • platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png:
  • platform/mac/fast/borders/border-image-repeat-expected.png:
  • platform/mac/fast/borders/border-image-rotate-transform-expected.png:
  • platform/mac/fast/borders/border-image-scale-transform-expected.png:
  • platform/mac/fast/borders/border-image-scaled-expected.png:
  • platform/mac/fast/borders/border-image-scrambled-expected.png:
  • platform/mac/fast/borders/border-image-slices-expected.png:
  • platform/mac/fast/borders/border-image-source-expected.png:
  • platform/mac/fast/borders/border-radius-circle-expected.png:
  • platform/mac/fast/borders/border-radius-constraints-expected.png:
  • platform/mac/fast/borders/border-radius-different-width-001-expected.png:
  • platform/mac/fast/borders/border-radius-groove-01-expected.png:
  • platform/mac/fast/borders/border-radius-groove-02-expected.png:
  • platform/mac/fast/borders/border-radius-groove-03-expected.png:
  • platform/mac/fast/borders/border-radius-huge-assert-expected.png:
  • platform/mac/fast/borders/border-radius-inline-flow-expected.png:
  • platform/mac/fast/borders/border-radius-inset-outset-expected.png:
  • platform/mac/fast/borders/border-radius-split-inline-expected.png:
  • platform/mac/fast/borders/border-radius-wide-border-01-expected.png:
  • platform/mac/fast/borders/border-radius-wide-border-02-expected.png:
  • platform/mac/fast/borders/border-radius-wide-border-03-expected.png:
  • platform/mac/fast/borders/border-radius-wide-border-04-expected.png:
  • platform/mac/fast/borders/border-styles-split-expected.png:
  • platform/mac/fast/borders/borderRadiusAllStylesAllCorners-expected.png:
  • platform/mac/fast/borders/borderRadiusArcs01-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed01-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed02-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed03-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed04-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed05-expected.png:
  • platform/mac/fast/borders/borderRadiusDashed06-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted01-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted02-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted03-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted04-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted05-expected.png:
  • platform/mac/fast/borders/borderRadiusDotted06-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble01-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble02-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble03-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble04-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble05-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble06-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble07-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble08-expected.png:
  • platform/mac/fast/borders/borderRadiusDouble09-expected.png:
  • platform/mac/fast/borders/borderRadiusGroove01-expected.png:
  • platform/mac/fast/borders/borderRadiusGroove02-expected.png:
  • platform/mac/fast/borders/borderRadiusInset01-expected.png:
  • platform/mac/fast/borders/borderRadiusInvalidColor-expected.png:
  • platform/mac/fast/borders/borderRadiusOutset01-expected.png:
  • platform/mac/fast/borders/borderRadiusRidge01-expected.png:
  • platform/mac/fast/borders/borderRadiusSolid01-expected.png:
  • platform/mac/fast/borders/borderRadiusSolid02-expected.png:
  • platform/mac/fast/borders/borderRadiusSolid03-expected.png:
  • platform/mac/fast/borders/borderRadiusSolid04-expected.png:
  • platform/mac/fast/borders/different-color-borders-expected.png:
  • platform/mac/fast/borders/fieldsetBorderRadius-expected.png:
  • platform/mac/fast/borders/inline-mask-overlay-image-expected.png:
  • platform/mac/fast/borders/mixed-border-styles-expected.png:
  • platform/mac/fast/borders/mixed-border-styles-radius-expected.png:
  • platform/mac/fast/borders/mixed-border-styles-radius2-expected.png:
  • platform/mac/fast/borders/outline-alpha-block-expected.png:
  • platform/mac/fast/borders/outline-alpha-inline-expected.png:
  • platform/mac/fast/borders/outline-offset-min-assert-expected.png:
  • platform/mac/fast/borders/rtl-border-01-expected.png:
  • platform/mac/fast/borders/rtl-border-02-expected.png:
  • platform/mac/fast/borders/rtl-border-03-expected.png:
  • platform/mac/fast/borders/rtl-border-04-expected.png:
  • platform/mac/fast/borders/rtl-border-05-expected.png:
  • platform/mac/fast/borders/table-borders-expected.png:
  • platform/mac/fast/borders/webkit-border-radius-expected.png:
Location:
trunk
Files:
91 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95111 r95121  
     12011-09-14  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68103
     4       
     5        Centered portions of border images don't render correctly. Make the tile scale factor have to be
     6        explicitly passed in and modify paintNinePieceImage to compute it for all sides. The attempts to
     7        implicitly compute the scale for the pattern based off the source and destination rects just don't
     8        work, since the center image rects don't provide the right information to be able to infer the
     9        scale factor.
     10
     11        Reviewed by Sam Weinig.
     12
     13        Reset all the existing fast/borders pixel results to Lion for these changes.
     14
     15        * platform/mac/fast/borders/bidi-002-expected.png:
     16        * platform/mac/fast/borders/bidi-009a-expected.png:
     17        * platform/mac/fast/borders/bidi-012-expected.png:
     18        * platform/mac/fast/borders/block-mask-overlay-image-expected.png:
     19        * platform/mac/fast/borders/border-antialiasing-expected.png:
     20        * platform/mac/fast/borders/border-color-inherit-expected.png:
     21        * platform/mac/fast/borders/border-fit-expected.png:
     22        * platform/mac/fast/borders/border-image-01-expected.png:
     23        * platform/mac/fast/borders/border-image-border-radius-expected.png:
     24        * platform/mac/fast/borders/border-image-longhand-expected.png:
     25        * platform/mac/fast/borders/border-image-omit-right-slice-expected.png:
     26        * platform/mac/fast/borders/border-image-outset-expected.png:
     27        * platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png:
     28        * platform/mac/fast/borders/border-image-repeat-expected.png:
     29        * platform/mac/fast/borders/border-image-rotate-transform-expected.png:
     30        * platform/mac/fast/borders/border-image-scale-transform-expected.png:
     31        * platform/mac/fast/borders/border-image-scaled-expected.png:
     32        * platform/mac/fast/borders/border-image-scrambled-expected.png:
     33        * platform/mac/fast/borders/border-image-slices-expected.png:
     34        * platform/mac/fast/borders/border-image-source-expected.png:
     35        * platform/mac/fast/borders/border-radius-circle-expected.png:
     36        * platform/mac/fast/borders/border-radius-constraints-expected.png:
     37        * platform/mac/fast/borders/border-radius-different-width-001-expected.png:
     38        * platform/mac/fast/borders/border-radius-groove-01-expected.png:
     39        * platform/mac/fast/borders/border-radius-groove-02-expected.png:
     40        * platform/mac/fast/borders/border-radius-groove-03-expected.png:
     41        * platform/mac/fast/borders/border-radius-huge-assert-expected.png:
     42        * platform/mac/fast/borders/border-radius-inline-flow-expected.png:
     43        * platform/mac/fast/borders/border-radius-inset-outset-expected.png:
     44        * platform/mac/fast/borders/border-radius-split-inline-expected.png:
     45        * platform/mac/fast/borders/border-radius-wide-border-01-expected.png:
     46        * platform/mac/fast/borders/border-radius-wide-border-02-expected.png:
     47        * platform/mac/fast/borders/border-radius-wide-border-03-expected.png:
     48        * platform/mac/fast/borders/border-radius-wide-border-04-expected.png:
     49        * platform/mac/fast/borders/border-styles-split-expected.png:
     50        * platform/mac/fast/borders/borderRadiusAllStylesAllCorners-expected.png:
     51        * platform/mac/fast/borders/borderRadiusArcs01-expected.png:
     52        * platform/mac/fast/borders/borderRadiusDashed01-expected.png:
     53        * platform/mac/fast/borders/borderRadiusDashed02-expected.png:
     54        * platform/mac/fast/borders/borderRadiusDashed03-expected.png:
     55        * platform/mac/fast/borders/borderRadiusDashed04-expected.png:
     56        * platform/mac/fast/borders/borderRadiusDashed05-expected.png:
     57        * platform/mac/fast/borders/borderRadiusDashed06-expected.png:
     58        * platform/mac/fast/borders/borderRadiusDotted01-expected.png:
     59        * platform/mac/fast/borders/borderRadiusDotted02-expected.png:
     60        * platform/mac/fast/borders/borderRadiusDotted03-expected.png:
     61        * platform/mac/fast/borders/borderRadiusDotted04-expected.png:
     62        * platform/mac/fast/borders/borderRadiusDotted05-expected.png:
     63        * platform/mac/fast/borders/borderRadiusDotted06-expected.png:
     64        * platform/mac/fast/borders/borderRadiusDouble01-expected.png:
     65        * platform/mac/fast/borders/borderRadiusDouble02-expected.png:
     66        * platform/mac/fast/borders/borderRadiusDouble03-expected.png:
     67        * platform/mac/fast/borders/borderRadiusDouble04-expected.png:
     68        * platform/mac/fast/borders/borderRadiusDouble05-expected.png:
     69        * platform/mac/fast/borders/borderRadiusDouble06-expected.png:
     70        * platform/mac/fast/borders/borderRadiusDouble07-expected.png:
     71        * platform/mac/fast/borders/borderRadiusDouble08-expected.png:
     72        * platform/mac/fast/borders/borderRadiusDouble09-expected.png:
     73        * platform/mac/fast/borders/borderRadiusGroove01-expected.png:
     74        * platform/mac/fast/borders/borderRadiusGroove02-expected.png:
     75        * platform/mac/fast/borders/borderRadiusInset01-expected.png:
     76        * platform/mac/fast/borders/borderRadiusInvalidColor-expected.png:
     77        * platform/mac/fast/borders/borderRadiusOutset01-expected.png:
     78        * platform/mac/fast/borders/borderRadiusRidge01-expected.png:
     79        * platform/mac/fast/borders/borderRadiusSolid01-expected.png:
     80        * platform/mac/fast/borders/borderRadiusSolid02-expected.png:
     81        * platform/mac/fast/borders/borderRadiusSolid03-expected.png:
     82        * platform/mac/fast/borders/borderRadiusSolid04-expected.png:
     83        * platform/mac/fast/borders/different-color-borders-expected.png:
     84        * platform/mac/fast/borders/fieldsetBorderRadius-expected.png:
     85        * platform/mac/fast/borders/inline-mask-overlay-image-expected.png:
     86        * platform/mac/fast/borders/mixed-border-styles-expected.png:
     87        * platform/mac/fast/borders/mixed-border-styles-radius-expected.png:
     88        * platform/mac/fast/borders/mixed-border-styles-radius2-expected.png:
     89        * platform/mac/fast/borders/outline-alpha-block-expected.png:
     90        * platform/mac/fast/borders/outline-alpha-inline-expected.png:
     91        * platform/mac/fast/borders/outline-offset-min-assert-expected.png:
     92        * platform/mac/fast/borders/rtl-border-01-expected.png:
     93        * platform/mac/fast/borders/rtl-border-02-expected.png:
     94        * platform/mac/fast/borders/rtl-border-03-expected.png:
     95        * platform/mac/fast/borders/rtl-border-04-expected.png:
     96        * platform/mac/fast/borders/rtl-border-05-expected.png:
     97        * platform/mac/fast/borders/table-borders-expected.png:
     98        * platform/mac/fast/borders/webkit-border-radius-expected.png:
     99
    11002011-09-14  Eric Carlson  <eric.carlson@apple.com>
    2101
  • trunk/Source/WebCore/ChangeLog

    r95120 r95121  
     12011-09-14  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68103
     4       
     5        Centered portions of border images don't render correctly. Make the tile scale factor have to be
     6        explicitly passed in and modify paintNinePieceImage to compute it for all sides. The attempts to
     7        implicitly compute the scale for the pattern based off the source and destination rects just don't
     8        work, since the center image rects don't provide the right information to be able to infer the
     9        scale factor.
     10
     11        Reviewed by Sam Weinig.
     12
     13        Reset all the existing fast/borders pixel results to Lion for these changes.
     14
     15        * platform/graphics/GraphicsContext.cpp:
     16        (WebCore::GraphicsContext::drawTiledImage):
     17        * platform/graphics/GraphicsContext.h:
     18        * platform/graphics/Image.cpp:
     19        (WebCore::Image::drawTiled):
     20        * platform/graphics/Image.h:
     21        * rendering/RenderBoxModelObject.cpp:
     22        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     23
    1242011-09-14  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r94897 r95121  
    502502}
    503503
    504 void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale)
     504void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect,
     505    const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale)
    505506{
    506507    if (paintingDisabled() || !image)
     
    516517        InterpolationQuality previousInterpolationQuality = imageInterpolationQuality();
    517518        setImageInterpolationQuality(InterpolationLow);
    518         image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);
     519        image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op);
    519520        setImageInterpolationQuality(previousInterpolationQuality);
    520521    } else
    521         image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);
     522        image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op);
    522523}
    523524
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r94897 r95121  
    316316                       CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
    317317        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
    318                             Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
     318                            const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
    319319                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
    320320
  • trunk/Source/WebCore/platform/graphics/Image.cpp

    r94420 r95121  
    8989}
    9090
    91 static inline FloatSize calculatePatternScale(const FloatRect& dstRect, const FloatRect& srcRect, Image::TileRule hRule, Image::TileRule vRule)
    92 {
    93     float scaleX = 1.0f, scaleY = 1.0f;
    94    
    95     if (hRule == Image::StretchTile)
    96         scaleX = dstRect.width() / srcRect.width();
    97     if (vRule == Image::StretchTile)
    98         scaleY = dstRect.height() / srcRect.height();
    99    
    100     if (hRule == Image::RepeatTile)
    101         scaleX = scaleY;
    102     if (vRule == Image::RepeatTile)
    103         scaleY = scaleX;
    104    
    105     return FloatSize(scaleX, scaleY);
    106 }
    107 
    108 
    10991void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, ColorSpace styleColorSpace, CompositeOperator op)
    11092{   
     
    152134
    153135// FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
    154 void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator op)
     136void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect,
     137    const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator op)
    155138{   
    156139    if (mayFillWithSolidColor()) {
     
    165148        vRule = RepeatTile;
    166149
    167     FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule);
    168     AffineTransform patternTransform = AffineTransform().scaleNonUniform(scale.width(), scale.height());
     150    AffineTransform patternTransform = AffineTransform().scaleNonUniform(tileScaleFactor.width(), tileScaleFactor.height());
    169151
    170152    // We want to construct the phase such that the pattern is centered (when stretch is not
    171153    // set for a particular rule).
    172     float hPhase = scale.width() * srcRect.x();
    173     float vPhase = scale.height() * srcRect.y();
     154    float hPhase = tileScaleFactor.width() * srcRect.x();
     155    float vPhase = tileScaleFactor.height() * srcRect.y();
    174156    if (hRule == Image::RepeatTile)
    175         hPhase -= fmodf(dstRect.width(), scale.width() * srcRect.width()) / 2.0f;
     157        hPhase -= fmodf(dstRect.width(), tileScaleFactor.width() * srcRect.width()) / 2.0f;
    176158    if (vRule == Image::RepeatTile)
    177         vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2.0f;
     159        vPhase -= fmodf(dstRect.height(), tileScaleFactor.height() * srcRect.height()) / 2.0f;
    178160    FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase);
    179161   
  • trunk/Source/WebCore/platform/graphics/Image.h

    r94420 r95121  
    174174    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0;
    175175    void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace, CompositeOperator);
    176     void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator);
     176    void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator);
    177177
    178178    // Supporting tiled drawing
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r94912 r95121  
    977977    // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function
    978978    // doesn't have any understanding of the zoom that is in effect on the tile.
    979     styleImage->setImageContainerSize(rect.size());
    980     LayoutSize imageSize = styleImage->imageSize(this, 1.0f);
    981     LayoutUnit imageWidth = imageSize.width();
    982     LayoutUnit imageHeight = imageSize.height();
    983 
    984     LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
    985     LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
    986     LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
    987     LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
    988 
    989     ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
    990     ENinePieceImageRule vRule = ninePieceImage.verticalRule();
    991    
    992979    LayoutUnit topOutset;
    993980    LayoutUnit rightOutset;
     
    1001988    LayoutUnit rightWithOutset = rect.maxX() + rightOutset;
    1002989    LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
    1003    
     990
     991    styleImage->setImageContainerSize(borderImageRect.size());
     992    LayoutSize imageSize = styleImage->imageSize(this, 1.0f);
     993    LayoutUnit imageWidth = imageSize.width();
     994    LayoutUnit imageHeight = imageSize.height();
     995
     996    LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
     997    LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
     998    LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
     999    LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
     1000
     1001    ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
     1002    ENinePieceImageRule vRule = ninePieceImage.verticalRule();
     1003   
    10041004    LayoutUnit topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height());
    10051005    LayoutUnit rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width());
     
    10301030    RefPtr<Image> image = styleImage->image(this, imageSize);
    10311031    ColorSpace colorSpace = style->colorSpace();
    1032 
     1032   
     1033    float destinationWidth = borderImageRect.width() - leftWidth - rightWidth;
     1034    float destinationHeight = borderImageRect.height() - topWidth - bottomWidth;
     1035   
     1036    float sourceWidth = imageWidth - leftSlice - rightSlice;
     1037    float sourceHeight = imageHeight - topSlice - bottomSlice;
     1038   
     1039    float leftSideScale = drawLeft ? (float)leftWidth / leftSlice : 1;
     1040    float rightSideScale = drawRight ? (float)rightWidth / rightSlice : 1;
     1041    float topSideScale = drawTop ? (float)topWidth / topSlice : 1;
     1042    float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1;
     1043   
    10331044    if (drawLeft) {
    10341045        // Paint the top and bottom left corners.
     
    10491060        // Have to scale and tile into the border rect.
    10501061        graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
    1051                                         borderImageRect.height() - topWidth - bottomWidth),
    1052                                         LayoutRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
    1053                                         Image::StretchTile, (Image::TileRule)vRule, op);
     1062                                        destinationHeight),
     1063                                        LayoutRect(0, topSlice, leftSlice, sourceHeight),
     1064                                        FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
    10541065    }
    10551066
     
    10701081        // Paint the right edge.
    10711082        graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
    1072                                         borderImageRect.height() - topWidth - bottomWidth),
    1073                                         LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
     1083                                        destinationHeight),
     1084                                        LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
     1085                                        FloatSize(rightSideScale, rightSideScale),
    10741086                                        Image::StretchTile, (Image::TileRule)vRule, op);
    10751087    }
     
    10771089    // Paint the top edge.
    10781090    if (drawTop)
    1079         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), borderImageRect.width() - leftWidth - rightWidth, topWidth),
    1080                                         LayoutRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
    1081                                         (Image::TileRule)hRule, Image::StretchTile, op);
     1091        graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
     1092                                        LayoutRect(leftSlice, 0, sourceWidth, topSlice),
     1093                                        FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
    10821094
    10831095    // Paint the bottom edge.
    10841096    if (drawBottom)
    10851097        graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
    1086                                         borderImageRect.width() - leftWidth - rightWidth, bottomWidth),
    1087                                         LayoutRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
     1098                                        destinationWidth, bottomWidth),
     1099                                        LayoutRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
     1100                                        FloatSize(bottomSideScale, bottomSideScale),
    10881101                                        (Image::TileRule)hRule, Image::StretchTile, op);
    10891102
    10901103    // Paint the middle.
    1091     if (drawMiddle)
    1092         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, borderImageRect.width() - leftWidth - rightWidth,
    1093                                         borderImageRect.height() - topWidth - bottomWidth),
    1094                                         LayoutRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
    1095                                         (Image::TileRule)hRule, (Image::TileRule)vRule, op);
     1104    if (drawMiddle) {
     1105        FloatSize middleScaleFactor(1, 1);
     1106        if (drawTop)
     1107            middleScaleFactor.setWidth(topSideScale);
     1108        else if (drawBottom)
     1109            middleScaleFactor.setWidth(bottomSideScale);
     1110        if (drawLeft)
     1111            middleScaleFactor.setHeight(leftSideScale);
     1112        else if (drawRight)
     1113            middleScaleFactor.setHeight(rightSideScale);
     1114           
     1115        // For "stretch" rules, just override the scale factor and replace. We only had to do this for the
     1116        // center tile, since sides don't even use the scale factor unless they have a rule other than "stretch".
     1117        // The middle however can have "stretch" specified in one axis but not the other, so we have to
     1118        // correct the scale here.
     1119        if (hRule == StretchImageRule)
     1120            middleScaleFactor.setWidth(destinationWidth / sourceWidth);
     1121           
     1122        if (vRule == StretchImageRule)
     1123            middleScaleFactor.setHeight(destinationHeight / sourceHeight);
     1124       
     1125        graphicsContext->drawTiledImage(image.get(), colorSpace,
     1126            LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
     1127            LayoutRect(leftSlice, topSlice, sourceWidth, sourceHeight),
     1128            middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op);
     1129    }
    10961130
    10971131    return true;
Note: See TracChangeset for help on using the changeset viewer.