Changeset 190883 in webkit


Ignore:
Timestamp:
Oct 12, 2015 12:51:11 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION(r184895): border-image should always slice the SVG image to nine pieces when drawing it in the container element
https://bugs.webkit.org/show_bug.cgi?id=149901
<rdar://problem/21995596>

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-10-12
Reviewed by Darin Adler.

Source/WebCore:

The nine-pieces algorithm should be applied to the border-image regardless
whether the image has an intrinsic size or not. It is not guaranteed to have
a meaningful border-image in all the cases of non-intrinsic size images. But
it should work as expected in most of the cases.

  • rendering/RenderBoxModelObject.cpp:
  • rendering/RenderBoxModelObject.h:

(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
Revert the changes which were added to return whether the image has
intrinsic size or not.

(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
Size of the image is now the return value of calculateImageIntrinsicDimensions().

  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::updateContent):

  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::ShapeOutsideInfo::createShapeForImage):
Size of the image is now the return value of calculateImageIntrinsicDimensions().

  • rendering/style/NinePieceImage.cpp:
  • rendering/style/NinePieceImage.h:

(WebCore::NinePieceImage::paint):
Delete the logic for the non-intrinsic case. Both intrinsic and non-intrinsic
cases will be treated the same.

(WebCore::NinePieceImage::computeNineRects):
(WebCore::NinePieceImage::computeSideTileScale):
(WebCore::NinePieceImage::computeMiddleTileScale):
(WebCore::NinePieceImage::computeTileScales):
(WebCore::NinePieceImage::computeIntrinsicRects): Deleted.
(WebCore::NinePieceImage::computeIntrinsicSideTileScale): Deleted.
(WebCore::NinePieceImage::computeIntrinsicMiddleTileScale): Deleted.
(WebCore::NinePieceImage::computeIntrinsicTileScales): Deleted.
Remove *Intrinsic* from the name of the functions.

(WebCore::NinePieceImage::computeNonIntrinsicRects): Deleted.
(WebCore::NinePieceImage::computeNonIntrinsicTileScales): Deleted.
Delete the *NonIntrinsic* functions.

LayoutTests:

  • fast/borders/border-image-fill-no-intrinsic-size-expected.html:
  • fast/borders/border-image-fill-no-intrinsic-size.html:
  • fast/borders/resources/svg-border-100x100-relative.svg: Added.
  • fast/borders/resources/svg-border-100x100-viewbox.svg: Added.
  • fast/borders/resources/svg-border-140x140-intrinsic.svg:

New test cases for relative lengths border images were added. The relative
lengths can be specified by using percentage lengths or adding viewBox to
the root element.

One of the non-intrinsic image-borders must be removed from this test.
The SVG image in the expected file has to be scaled by (100 / 140), which
can be done. But run-webkit-tests found a very slight difference between
the actual and the result files.

Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190880 r190883  
     12015-10-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(r184895): border-image should always slice the SVG image to nine pieces when drawing it in the container element
     4        https://bugs.webkit.org/show_bug.cgi?id=149901
     5        <rdar://problem/21995596>
     6
     7        Reviewed by Darin Adler.
     8
     9        * fast/borders/border-image-fill-no-intrinsic-size-expected.html:
     10        * fast/borders/border-image-fill-no-intrinsic-size.html:
     11        * fast/borders/resources/svg-border-100x100-relative.svg: Added.
     12        * fast/borders/resources/svg-border-100x100-viewbox.svg: Added.
     13        * fast/borders/resources/svg-border-140x140-intrinsic.svg:
     14        New test cases for relative lengths border images were added. The relative
     15        lengths can be specified by using percentage lengths or adding viewBox to
     16        the root element.
     17       
     18        One of the non-intrinsic image-borders must be removed from this test.
     19        The SVG image in the expected file has to be scaled by (100 / 140), which
     20        can be done. But run-webkit-tests found a very slight difference between
     21        the actual and the result files.       
     22
    1232015-10-12  Brent Fulgham  <bfulgham@apple.com>
    224
  • trunk/LayoutTests/fast/borders/border-image-fill-no-intrinsic-size-expected.html

    r184895 r190883  
    55      height: 100px;
    66      width: 100px;
    7       margin: 10px;
    87      display: inline-block;
    98      background-color: red;
    109    }
    11     .border {
     10    .border-20 {
    1211      border: 20px solid;
     12    }
     13    .border-40 {
     14      border: solid;
     15      border-top: 0px;
     16      border-right: 40px;
     17      border-bottom: 40px;
     18      border-left: 0px;     
    1319    }
    1420    .no-border {
     
    2127       border-image: url('resources/svg-border-100x100-intrinsic.svg') 20 fill;
    2228    }
     29    .border-image-140-intrinsic {
     30       border-image: url('resources/svg-border-140x140-intrinsic.svg') 0 fill;
     31    }
    2332    .border-image-140-intrinsic-slice {
    2433       border-image: url('resources/svg-border-140x140-intrinsic.svg') 20 fill;
     
    2837<body>
    2938  <div class="box no-border border-image-100-intrinsic"></div>
    30   <div class="box border    border-image-100-intrinsic"></div>
     39  <div class="box border-20 border-image-100-intrinsic"></div>
    3140  <div class="box no-border border-image-100-intrinsic-slice"></div>
    32   <div class="box border    border-image-100-intrinsic-slice"></div>
     41  <div class="box border-20 border-image-100-intrinsic-slice"></div>
    3342  <br>
    3443  <div class="box no-border border-image-100-intrinsic"></div>
    35   <div class="box border    border-image-100-intrinsic"></div>
     44  <div class="box border-20 border-image-100-intrinsic"></div>
     45  <div class="box no-border border-image-100-intrinsic-slice"></div>
     46  <div class="box border-20 border-image-140-intrinsic-slice"></div>
     47  <br>
    3648  <div class="box no-border border-image-100-intrinsic"></div>
    37   <div class="box border    border-image-140-intrinsic-slice"></div>
     49  <div class="box border-20 border-image-100-intrinsic"></div>
     50  <div class="box no-border border-image-100-intrinsic-slice"></div>
     51  <div class="box border-20 border-image-140-intrinsic-slice"></div>
     52  <br>
     53  <div class="box no-border border-image-100-intrinsic"></div>
     54  <div class="box border-20"></div>
     55  <div class="box no-border border-image-100-intrinsic-slice"></div>
     56  <div class="box border-40 border-image-100-intrinsic"></div>
    3857</body>
  • trunk/LayoutTests/fast/borders/border-image-fill-no-intrinsic-size.html

    r184895 r190883  
    55      height: 100px;
    66      width: 100px;
    7       margin: 10px;
    87      display: inline-block;
    98      background-color: red;
    109    }
    11     .border {
     10    .border-20 {
    1211      border: 20px solid;
    1312    }
     
    2120       border-image: url('resources/svg-border-100x100-intrinsic.svg') 20 fill;
    2221    }
     22    .border-image-100-viewbox {
     23       border-image: url('resources/svg-border-100x100-viewbox.svg') 0 fill;
     24    }
     25    .border-image-100-viewbox-slice {
     26       border-image: url('resources/svg-border-100x100-viewbox.svg') 20 fill;
     27    }
     28    .border-image-100-relative {
     29       border-image: url('resources/svg-border-100x100-relative.svg') 0 fill;
     30    }
     31    .border-image-100-relative-slice {
     32       border-image: url('resources/svg-border-100x100-relative.svg') 20 fill;
     33    }
    2334    .border-image-no-intrinsic {
    2435       border-image: url('resources/svg-border-no-intrinsic.svg') 0 fill;
     
    3142<body>
    3243  <div class="box no-border border-image-100-intrinsic"></div>
    33   <div class="box border    border-image-100-intrinsic"></div>
     44  <div class="box border-20 border-image-100-intrinsic"></div>
    3445  <div class="box no-border border-image-100-intrinsic-slice"></div>
    35   <div class="box border    border-image-100-intrinsic-slice"></div>
     46  <div class="box border-20 border-image-100-intrinsic-slice"></div>
     47  <br>
     48  <div class="box no-border border-image-100-viewbox"></div>
     49  <div class="box border-20 border-image-100-viewbox"></div>
     50  <div class="box no-border border-image-100-viewbox-slice"></div>
     51  <div class="box border-20 border-image-100-viewbox-slice"></div>
     52  <br>
     53  <div class="box no-border border-image-100-relative"></div>
     54  <div class="box border-20 border-image-100-relative"></div>
     55  <div class="box no-border border-image-100-relative-slice"></div>
     56  <div class="box border-20 border-image-100-relative-slice"></div>
    3657  <br>
    3758  <div class="box no-border border-image-no-intrinsic"></div>
    38   <div class="box border    border-image-no-intrinsic"></div>
     59  <div class="box border-20"></div>
    3960  <div class="box no-border border-image-no-intrinsic-slice"></div>
    40   <div class="box border    border-image-no-intrinsic-slice"></div>
     61  <div class="box border-20 border-image-no-intrinsic-slice"></div>
    4162</body>
  • trunk/LayoutTests/fast/borders/resources/svg-border-140x140-intrinsic.svg

    r184895 r190883  
    1 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="140" height="140">
    2   <defs>
    3     <g id="border-image">
    4       <rect width="100" height="100" fill="lime"/>
    5       <rect x="10" y="10" width="80" height="80" fill="none" stroke="black" stroke-width="4px"/>
    6     </g>
    7     <clipPath id="top-left">
    8       <rect x="0" y="0" width="20" height="20"/>
    9     </clipPath>
    10     <clipPath id="left">
    11       <rect x="0" y="0" width="20" height="100"/>
    12     </clipPath>
    13     <clipPath id="bottom-left">
    14       <rect x="0" y="0" width="20" height="20"/>
    15     </clipPath>
    16     <clipPath id="top-right">
    17       <rect x="0" y="0" width="20" height="20"/>
    18     </clipPath>
    19     <clipPath id="right">
    20       <rect x="0" y="0" width="20" height="100"/>
    21     </clipPath>
    22     <clipPath id="bottom-right">
    23       <rect x="0" y="0" width="20" height="20"/>
    24     </clipPath>
    25     <clipPath id="top">
    26       <rect x="0" y="0" width="100" height="20"/>
    27     </clipPath>
    28     <clipPath id="bottom">
    29       <rect x="0" y="0" width="100" height="20"/>
    30     </clipPath>
    31     <clipPath id="middle">
    32       <rect x="0" y="0" width="100" height="100"/>
    33     </clipPath>
    34   </defs>
    35  
    36   <!-- draw left side -->
    37   <use x="0" y="0" xlink:href="#border-image" clip-path="url(#top-left)"/>
    38   <use x="0" y="20" xlink:href="#border-image" clip-path="url(#left)"/>
    39   <use x="0" y="120" xlink:href="#border-image" clip-path="url(#bottom-left)"/>
    40  
    41   <!-- draw right side -->
    42   <use x="120" y="0" xlink:href="#border-image" clip-path="url(#top-right)"/>
    43   <use x="120" y="20" xlink:href="#border-image" clip-path="url(#right)"/>
    44   <use x="120" y="120" xlink:href="#border-image" clip-path="url(#bottom-right)"/>
    45  
    46   <!-- draw top and bottom sides -->
    47   <use x="20" y="0" xlink:href="#border-image" clip-path="url(#top)"/>
    48   <use x="20" y="120" xlink:href="#border-image" clip-path="url(#bottom)"/>
    49  
    50   <!-- draw middle -->
    51   <use x="20" y="20" xlink:href="#border-image" clip-path="url(#middle)"/>
     1<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="140" height="140">
     2  <rect width="100%" height="100%" fill="lime"/>
     3  <rect x="10%" y="10%" width="80%" height="80%" fill="none" stroke="black" stroke-width="4%"/>
    524</svg>
  • trunk/Source/WebCore/ChangeLog

    r190879 r190883  
     12015-10-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(r184895): border-image should always slice the SVG image to nine pieces when drawing it in the container element
     4        https://bugs.webkit.org/show_bug.cgi?id=149901
     5        <rdar://problem/21995596>
     6
     7        Reviewed by Darin Adler.
     8
     9        The nine-pieces algorithm should be applied to the border-image regardless
     10        whether the image has an intrinsic size or not. It is not guaranteed to have
     11        a meaningful border-image in all the cases of non-intrinsic size images. But
     12        it should work as expected in most of the cases.
     13
     14        * rendering/RenderBoxModelObject.cpp:
     15        * rendering/RenderBoxModelObject.h:
     16        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
     17        Revert the changes which were added to return whether the image has
     18        intrinsic size or not.
     19       
     20        (WebCore::RenderBoxModelObject::calculateFillTileSize):
     21        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     22        Size of the image is now the return value of calculateImageIntrinsicDimensions().
     23       
     24        * rendering/RenderListMarker.cpp:
     25        (WebCore::RenderListMarker::updateContent):
     26        * rendering/shapes/ShapeOutsideInfo.cpp:
     27        (WebCore::ShapeOutsideInfo::createShapeForImage):
     28        Size of the image is now the return value of calculateImageIntrinsicDimensions().
     29       
     30        * rendering/style/NinePieceImage.cpp:
     31        * rendering/style/NinePieceImage.h:
     32        (WebCore::NinePieceImage::paint):
     33        Delete the logic for the non-intrinsic case. Both intrinsic and non-intrinsic
     34        cases will be treated the same.
     35
     36        (WebCore::NinePieceImage::computeNineRects):
     37        (WebCore::NinePieceImage::computeSideTileScale):
     38        (WebCore::NinePieceImage::computeMiddleTileScale):
     39        (WebCore::NinePieceImage::computeTileScales):
     40        (WebCore::NinePieceImage::computeIntrinsicRects): Deleted.
     41        (WebCore::NinePieceImage::computeIntrinsicSideTileScale): Deleted.
     42        (WebCore::NinePieceImage::computeIntrinsicMiddleTileScale): Deleted.
     43        (WebCore::NinePieceImage::computeIntrinsicTileScales): Deleted.
     44        Remove *Intrinsic* from the name of the functions.
     45
     46        (WebCore::NinePieceImage::computeNonIntrinsicRects): Deleted.
     47        (WebCore::NinePieceImage::computeNonIntrinsicTileScales): Deleted.
     48        Delete the *NonIntrinsic* functions.
     49
    1502015-10-12  Simon Fraser  <simon.fraser@apple.com>
    251
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r190834 r190883  
    898898}
    899899
    900 bool RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot, LayoutSize& imageSize) const
     900LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
    901901{
    902902    // A generated image without a fixed size, will always return the container size as intrinsic size.
    903     if (image->isGeneratedImage() && image->usesImageContainerSize()) {
    904         imageSize = LayoutSize(positioningAreaSize.width(), positioningAreaSize.height());
    905         return true;
    906     }
     903    if (image->isGeneratedImage() && image->usesImageContainerSize())
     904        return LayoutSize(positioningAreaSize.width(), positioningAreaSize.height());
    907905
    908906    Length intrinsicWidth;
     
    914912    ASSERT(!intrinsicHeight.isPercentOrCalculated());
    915913
    916     imageSize = LayoutSize(intrinsicWidth.value(), intrinsicHeight.value());
    917     LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0);
     914    LayoutSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value());
     915    LayoutSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
     916
    918917    if (shouldScaleOrNot == ScaleByEffectiveZoom)
    919         imageSize.scale(style().effectiveZoom());
    920     imageSize.clampToMinimumSize(minimumSize);
    921 
    922     if (!imageSize.isEmpty())
    923         return true;
     918        resolvedSize.scale(style().effectiveZoom());
     919    resolvedSize.clampToMinimumSize(minimumSize);
    924920
    925921    // If the image has one of either an intrinsic width or an intrinsic height:
     
    927923    // * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
    928924    //   establishes the coordinate system for the 'background-position' property.
    929     if (imageSize.width() > 0 || imageSize.height() > 0) {
    930         imageSize = resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, imageSize.width(), imageSize.height());
    931         return true;
    932     }
     925    if (resolvedSize.width() > 0 || resolvedSize.height() > 0)
     926        return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedSize.width(), resolvedSize.height());
    933927
    934928    // If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
    935929    // largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
    936930    // establishes the coordinate system for the 'background-position' property.
    937     if (!intrinsicRatio.isEmpty()) {
    938         imageSize = resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
    939         return false;
    940     }
     931    if (!intrinsicRatio.isEmpty())
     932        return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
    941933
    942934    // If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
    943935    // establishes the coordinate system for the 'background-position' property.
    944     imageSize = positioningAreaSize;
    945     return false;
     936    return positioningAreaSize;
    946937}
    947938
     
    953944    LayoutSize imageIntrinsicSize;
    954945    if (image) {
    955         calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom, imageIntrinsicSize);
     946        imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
    956947        imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScaleFactor());
    957948    } else
     
    12641255    LayoutRect destination = LayoutRect(snapRectToDevicePixels(rectWithOutsets, deviceScaleFactor));
    12651256
    1266     LayoutSize source;
    1267     bool intrinsicSource = calculateImageIntrinsicDimensions(styleImage, destination.size(), DoNotScaleByEffectiveZoom, source);
     1257    LayoutSize source = calculateImageIntrinsicDimensions(styleImage, destination.size(), DoNotScaleByEffectiveZoom);
    12681258
    12691259    // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
    12701260    styleImage->setContainerSizeForRenderer(this, source, style.effectiveZoom());
    12711261
    1272     ninePieceImage.paint(graphicsContext, this, style, destination, source, intrinsicSource, deviceScaleFactor, op);
     1262    ninePieceImage.paint(graphicsContext, this, style, destination, source, deviceScaleFactor, op);
    12731263    return true;
    12741264}
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r190834 r190883  
    294294
    295295    enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffectiveZoom };
    296     bool calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot, LayoutSize& imageSize) const;
     296    LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
    297297
    298298private:
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r190685 r190883  
    14271427        LayoutUnit bulletWidth = style().fontMetrics().ascent() / LayoutUnit(2);
    14281428        LayoutSize defaultBulletSize(bulletWidth, bulletWidth);
    1429         LayoutSize imageSize;
    1430         calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom, imageSize);
     1429        LayoutSize imageSize = calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom);
    14311430        m_image->setContainerSizeForRenderer(this, imageSize, style().effectiveZoom());
    14321431        return;
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r184895 r190883  
    149149std::unique_ptr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const
    150150{
    151     LayoutSize imageSize;
    152     m_renderer.calculateImageIntrinsicDimensions(styleImage, m_referenceBoxLogicalSize, RenderImage::ScaleByEffectiveZoom, imageSize);
     151    LayoutSize imageSize = m_renderer.calculateImageIntrinsicDimensions(styleImage, m_referenceBoxLogicalSize, RenderImage::ScaleByEffectiveZoom);
    153152    styleImage->setContainerSizeForRenderer(&m_renderer, imageSize, m_renderer.style().effectiveZoom());
    154153
  • trunk/Source/WebCore/rendering/style/NinePieceImage.cpp

    r189144 r190883  
    114114}
    115115
    116 Vector<FloatRect> NinePieceImage::computeIntrinsicRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
     116Vector<FloatRect> NinePieceImage::computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
    117117{
    118118    FloatRect inner = outer;
     
    138138}
    139139
    140 Vector<FloatRect> NinePieceImage::computeNonIntrinsicRects(const Vector<FloatRect>& intrinsicRects, const LayoutBoxExtent& slices)
    141 {
    142     Vector<FloatRect> rects(MaxPiece);
    143 
    144     for (ImagePiece piece = MinPiece; piece < MaxPiece; ++piece) {
    145         if (isEmptyPieceRect(piece, slices))
    146             continue;
    147         rects[piece] = FloatRect(FloatPoint(), intrinsicRects[piece].size());
    148     }
    149 
    150     return rects;
    151 }
    152 
    153 FloatSize NinePieceImage::computeIntrinsicSideTileScale(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
     140FloatSize NinePieceImage::computeSideTileScale(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
    154141{
    155142    ASSERT(!isCornerPiece(piece) && !isMiddlePiece(piece));
     
    166153}
    167154
    168 FloatSize NinePieceImage::computeIntrinsicMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
     155FloatSize NinePieceImage::computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
    169156{
    170157    FloatSize scale(1, 1);
     
    191178}
    192179
    193 Vector<FloatSize> NinePieceImage::computeIntrinsicTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
     180Vector<FloatSize> NinePieceImage::computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
    194181{
    195182    Vector<FloatSize> scales(MaxPiece, FloatSize(1, 1));
    196183
    197     scales[TopPiece]    = computeIntrinsicSideTileScale(TopPiece,    destinationRects, sourceRects);
    198     scales[RightPiece]  = computeIntrinsicSideTileScale(RightPiece,  destinationRects, sourceRects);
    199     scales[BottomPiece] = computeIntrinsicSideTileScale(BottomPiece, destinationRects, sourceRects);
    200     scales[LeftPiece]   = computeIntrinsicSideTileScale(LeftPiece,   destinationRects, sourceRects);
    201 
    202     scales[MiddlePiece] = computeIntrinsicMiddleTileScale(scales, destinationRects, sourceRects, hRule, vRule);
     184    scales[TopPiece]    = computeSideTileScale(TopPiece,    destinationRects, sourceRects);
     185    scales[RightPiece]  = computeSideTileScale(RightPiece,  destinationRects, sourceRects);
     186    scales[BottomPiece] = computeSideTileScale(BottomPiece, destinationRects, sourceRects);
     187    scales[LeftPiece]   = computeSideTileScale(LeftPiece,   destinationRects, sourceRects);
     188
     189    scales[MiddlePiece] = computeMiddleTileScale(scales, destinationRects, sourceRects, hRule, vRule);
    203190    return scales;
    204191}
    205192
    206 Vector<FloatSize> NinePieceImage::computeNonIntrinsicTileScales()
    207 {
    208     return Vector<FloatSize>(MaxPiece, FloatSize(1, 1));
    209 }
    210 
    211 void NinePieceImage::paint(GraphicsContext& graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source,  bool intrinsicSource, float deviceScaleFactor, CompositeOperator op) const
     193void NinePieceImage::paint(GraphicsContext& graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator op) const
    212194{
    213195    StyleImage* styleImage = image();
     
    219201    scaleSlicesIfNeeded(destination.size(), destinationSlices, deviceScaleFactor);
    220202
    221     Vector<FloatRect> destinationRects = computeIntrinsicRects(destination, destinationSlices, deviceScaleFactor);
    222     Vector<FloatRect> sourceRects;
    223     Vector<FloatSize> tileScales;
    224 
    225     if (intrinsicSource) {
    226         sourceRects = computeIntrinsicRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
    227         tileScales = computeIntrinsicTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
    228     } else {
    229         sourceRects = computeNonIntrinsicRects(destinationRects, sourceSlices);
    230         tileScales = computeNonIntrinsicTileScales();
    231     }
     203    Vector<FloatRect> destinationRects = computeNineRects(destination, destinationSlices, deviceScaleFactor);
     204    Vector<FloatRect> sourceRects = computeNineRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
     205    Vector<FloatSize> tileScales = computeTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
    232206
    233207    RefPtr<Image> image = styleImage->image(renderer, source);
  • trunk/Source/WebCore/rendering/style/NinePieceImage.h

    r189144 r190883  
    197197    static bool isEmptyPieceRect(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
    198198
    199     static Vector<FloatRect> computeIntrinsicRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor);
    200     static Vector<FloatRect> computeNonIntrinsicRects(const Vector<FloatRect>& intrinsicRects, const LayoutBoxExtent& slices);
     199    static Vector<FloatRect> computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor);
    201200
    202201    static void scaleSlicesIfNeeded(const LayoutSize&, LayoutBoxExtent& slices, float deviceScaleFactor);
    203202
    204     static FloatSize computeIntrinsicSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
    205     static FloatSize computeIntrinsicMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
    206     static Vector<FloatSize> computeIntrinsicTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
    207     static Vector<FloatSize> computeNonIntrinsicTileScales();
    208 
    209     void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, bool intrinsicSource, float deviceScaleFactor, CompositeOperator) const;
     203    static FloatSize computeSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
     204    static FloatSize computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
     205    static Vector<FloatSize> computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
     206
     207    void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator) const;
    210208
    211209private:
Note: See TracChangeset for help on using the changeset viewer.