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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190883
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-10-12 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ 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>
+
+ Reviewed by Darin Adler.
+
+ * 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.
+
2015-10-12 Brent Fulgham <bfulgham@apple.com>
[Win] Unreviewed gardening
.box {
height: 100px;
width: 100px;
- margin: 10px;
display: inline-block;
background-color: red;
}
- .border {
+ .border-20 {
border: 20px solid;
}
+ .border-40 {
+ border: solid;
+ border-top: 0px;
+ border-right: 40px;
+ border-bottom: 40px;
+ border-left: 0px;
+ }
.no-border {
border: 0px none;
}
.border-image-100-intrinsic-slice {
border-image: url('resources/svg-border-100x100-intrinsic.svg') 20 fill;
}
+ .border-image-140-intrinsic {
+ border-image: url('resources/svg-border-140x140-intrinsic.svg') 0 fill;
+ }
.border-image-140-intrinsic-slice {
border-image: url('resources/svg-border-140x140-intrinsic.svg') 20 fill;
}
</head>
<body>
<div class="box no-border border-image-100-intrinsic"></div>
- <div class="box border border-image-100-intrinsic"></div>
+ <div class="box border-20 border-image-100-intrinsic"></div>
+ <div class="box no-border border-image-100-intrinsic-slice"></div>
+ <div class="box border-20 border-image-100-intrinsic-slice"></div>
+ <br>
+ <div class="box no-border border-image-100-intrinsic"></div>
+ <div class="box border-20 border-image-100-intrinsic"></div>
<div class="box no-border border-image-100-intrinsic-slice"></div>
- <div class="box border border-image-100-intrinsic-slice"></div>
+ <div class="box border-20 border-image-140-intrinsic-slice"></div>
<br>
<div class="box no-border border-image-100-intrinsic"></div>
- <div class="box border border-image-100-intrinsic"></div>
+ <div class="box border-20 border-image-100-intrinsic"></div>
+ <div class="box no-border border-image-100-intrinsic-slice"></div>
+ <div class="box border-20 border-image-140-intrinsic-slice"></div>
+ <br>
<div class="box no-border border-image-100-intrinsic"></div>
- <div class="box border border-image-140-intrinsic-slice"></div>
+ <div class="box border-20"></div>
+ <div class="box no-border border-image-100-intrinsic-slice"></div>
+ <div class="box border-40 border-image-100-intrinsic"></div>
</body>
.box {
height: 100px;
width: 100px;
- margin: 10px;
display: inline-block;
background-color: red;
}
- .border {
+ .border-20 {
border: 20px solid;
}
.no-border {
.border-image-100-intrinsic-slice {
border-image: url('resources/svg-border-100x100-intrinsic.svg') 20 fill;
}
+ .border-image-100-viewbox {
+ border-image: url('resources/svg-border-100x100-viewbox.svg') 0 fill;
+ }
+ .border-image-100-viewbox-slice {
+ border-image: url('resources/svg-border-100x100-viewbox.svg') 20 fill;
+ }
+ .border-image-100-relative {
+ border-image: url('resources/svg-border-100x100-relative.svg') 0 fill;
+ }
+ .border-image-100-relative-slice {
+ border-image: url('resources/svg-border-100x100-relative.svg') 20 fill;
+ }
.border-image-no-intrinsic {
border-image: url('resources/svg-border-no-intrinsic.svg') 0 fill;
}
</head>
<body>
<div class="box no-border border-image-100-intrinsic"></div>
- <div class="box border border-image-100-intrinsic"></div>
+ <div class="box border-20 border-image-100-intrinsic"></div>
<div class="box no-border border-image-100-intrinsic-slice"></div>
- <div class="box border border-image-100-intrinsic-slice"></div>
+ <div class="box border-20 border-image-100-intrinsic-slice"></div>
+ <br>
+ <div class="box no-border border-image-100-viewbox"></div>
+ <div class="box border-20 border-image-100-viewbox"></div>
+ <div class="box no-border border-image-100-viewbox-slice"></div>
+ <div class="box border-20 border-image-100-viewbox-slice"></div>
+ <br>
+ <div class="box no-border border-image-100-relative"></div>
+ <div class="box border-20 border-image-100-relative"></div>
+ <div class="box no-border border-image-100-relative-slice"></div>
+ <div class="box border-20 border-image-100-relative-slice"></div>
<br>
<div class="box no-border border-image-no-intrinsic"></div>
- <div class="box border border-image-no-intrinsic"></div>
+ <div class="box border-20"></div>
<div class="box no-border border-image-no-intrinsic-slice"></div>
- <div class="box border border-image-no-intrinsic-slice"></div>
+ <div class="box border-20 border-image-no-intrinsic-slice"></div>
</body>
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <rect width="100%" height="100%" fill="lime"/>
+ <rect x="10%" y="10%" width="80%" height="80%" fill="none" stroke="black" stroke-width="4%"/>
+</svg>
\ No newline at end of file
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
+ <rect width="100" height="100" fill="lime"/>
+ <rect x="10" y="10" width="80" height="80" fill="none" stroke="black" stroke-width="4px"/>
+</svg>
\ No newline at end of file
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="140" height="140">
- <defs>
- <g id="border-image">
- <rect width="100" height="100" fill="lime"/>
- <rect x="10" y="10" width="80" height="80" fill="none" stroke="black" stroke-width="4px"/>
- </g>
- <clipPath id="top-left">
- <rect x="0" y="0" width="20" height="20"/>
- </clipPath>
- <clipPath id="left">
- <rect x="0" y="0" width="20" height="100"/>
- </clipPath>
- <clipPath id="bottom-left">
- <rect x="0" y="0" width="20" height="20"/>
- </clipPath>
- <clipPath id="top-right">
- <rect x="0" y="0" width="20" height="20"/>
- </clipPath>
- <clipPath id="right">
- <rect x="0" y="0" width="20" height="100"/>
- </clipPath>
- <clipPath id="bottom-right">
- <rect x="0" y="0" width="20" height="20"/>
- </clipPath>
- <clipPath id="top">
- <rect x="0" y="0" width="100" height="20"/>
- </clipPath>
- <clipPath id="bottom">
- <rect x="0" y="0" width="100" height="20"/>
- </clipPath>
- <clipPath id="middle">
- <rect x="0" y="0" width="100" height="100"/>
- </clipPath>
- </defs>
-
- <!-- draw left side -->
- <use x="0" y="0" xlink:href="#border-image" clip-path="url(#top-left)"/>
- <use x="0" y="20" xlink:href="#border-image" clip-path="url(#left)"/>
- <use x="0" y="120" xlink:href="#border-image" clip-path="url(#bottom-left)"/>
-
- <!-- draw right side -->
- <use x="120" y="0" xlink:href="#border-image" clip-path="url(#top-right)"/>
- <use x="120" y="20" xlink:href="#border-image" clip-path="url(#right)"/>
- <use x="120" y="120" xlink:href="#border-image" clip-path="url(#bottom-right)"/>
-
- <!-- draw top and bottom sides -->
- <use x="20" y="0" xlink:href="#border-image" clip-path="url(#top)"/>
- <use x="20" y="120" xlink:href="#border-image" clip-path="url(#bottom)"/>
-
- <!-- draw middle -->
- <use x="20" y="20" xlink:href="#border-image" clip-path="url(#middle)"/>
-</svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="140" height="140">
+ <rect width="100%" height="100%" fill="lime"/>
+ <rect x="10%" y="10%" width="80%" height="80%" fill="none" stroke="black" stroke-width="4%"/>
+</svg>
+2015-10-12 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ 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>
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2015-10-12 Simon Fraser <simon.fraser@apple.com>
Clip-path transitions sometimes trigger endless animation timers
return LayoutSize(size.width(), solutionHeight);
}
-bool RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot, LayoutSize& imageSize) const
+LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
{
// A generated image without a fixed size, will always return the container size as intrinsic size.
- if (image->isGeneratedImage() && image->usesImageContainerSize()) {
- imageSize = LayoutSize(positioningAreaSize.width(), positioningAreaSize.height());
- return true;
- }
+ if (image->isGeneratedImage() && image->usesImageContainerSize())
+ return LayoutSize(positioningAreaSize.width(), positioningAreaSize.height());
Length intrinsicWidth;
Length intrinsicHeight;
ASSERT(!intrinsicWidth.isPercentOrCalculated());
ASSERT(!intrinsicHeight.isPercentOrCalculated());
- imageSize = LayoutSize(intrinsicWidth.value(), intrinsicHeight.value());
- LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0);
- if (shouldScaleOrNot == ScaleByEffectiveZoom)
- imageSize.scale(style().effectiveZoom());
- imageSize.clampToMinimumSize(minimumSize);
+ LayoutSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value());
+ LayoutSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
- if (!imageSize.isEmpty())
- return true;
+ if (shouldScaleOrNot == ScaleByEffectiveZoom)
+ resolvedSize.scale(style().effectiveZoom());
+ resolvedSize.clampToMinimumSize(minimumSize);
// If the image has one of either an intrinsic width or an intrinsic height:
// * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
// * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
// establishes the coordinate system for the 'background-position' property.
- if (imageSize.width() > 0 || imageSize.height() > 0) {
- imageSize = resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, imageSize.width(), imageSize.height());
- return true;
- }
+ if (resolvedSize.width() > 0 || resolvedSize.height() > 0)
+ return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedSize.width(), resolvedSize.height());
// If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
// largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
// establishes the coordinate system for the 'background-position' property.
- if (!intrinsicRatio.isEmpty()) {
- imageSize = resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
- return false;
- }
+ if (!intrinsicRatio.isEmpty())
+ return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
// If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
// establishes the coordinate system for the 'background-position' property.
- imageSize = positioningAreaSize;
- return false;
+ return positioningAreaSize;
}
LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer& fillLayer, const LayoutSize& positioningAreaSize) const
LayoutSize imageIntrinsicSize;
if (image) {
- calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom, imageIntrinsicSize);
+ imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScaleFactor());
} else
imageIntrinsicSize = positioningAreaSize;
rectWithOutsets.expand(style.imageOutsets(ninePieceImage));
LayoutRect destination = LayoutRect(snapRectToDevicePixels(rectWithOutsets, deviceScaleFactor));
- LayoutSize source;
- bool intrinsicSource = calculateImageIntrinsicDimensions(styleImage, destination.size(), DoNotScaleByEffectiveZoom, source);
+ LayoutSize source = calculateImageIntrinsicDimensions(styleImage, destination.size(), DoNotScaleByEffectiveZoom);
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
styleImage->setContainerSizeForRenderer(this, source, style.effectiveZoom());
- ninePieceImage.paint(graphicsContext, this, style, destination, source, intrinsicSource, deviceScaleFactor, op);
+ ninePieceImage.paint(graphicsContext, this, style, destination, source, deviceScaleFactor, op);
return true;
}
void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRemoveInsert = false);
enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffectiveZoom };
- bool calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot, LayoutSize& imageSize) const;
+ LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
private:
LayoutUnit computedCSSPadding(const Length&) const;
// until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box.
LayoutUnit bulletWidth = style().fontMetrics().ascent() / LayoutUnit(2);
LayoutSize defaultBulletSize(bulletWidth, bulletWidth);
- LayoutSize imageSize;
- calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom, imageSize);
+ LayoutSize imageSize = calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom);
m_image->setContainerSizeForRenderer(this, imageSize, style().effectiveZoom());
return;
}
std::unique_ptr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const
{
- LayoutSize imageSize;
- m_renderer.calculateImageIntrinsicDimensions(styleImage, m_referenceBoxLogicalSize, RenderImage::ScaleByEffectiveZoom, imageSize);
+ LayoutSize imageSize = m_renderer.calculateImageIntrinsicDimensions(styleImage, m_referenceBoxLogicalSize, RenderImage::ScaleByEffectiveZoom);
styleImage->setContainerSizeForRenderer(&m_renderer, imageSize, m_renderer.style().effectiveZoom());
const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
return destinationRects[piece].isEmpty() || sourceRects[piece].isEmpty();
}
-Vector<FloatRect> NinePieceImage::computeIntrinsicRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
+Vector<FloatRect> NinePieceImage::computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
{
FloatRect inner = outer;
inner.move(slices.left(), slices.top());
return rects;
}
-Vector<FloatRect> NinePieceImage::computeNonIntrinsicRects(const Vector<FloatRect>& intrinsicRects, const LayoutBoxExtent& slices)
-{
- Vector<FloatRect> rects(MaxPiece);
-
- for (ImagePiece piece = MinPiece; piece < MaxPiece; ++piece) {
- if (isEmptyPieceRect(piece, slices))
- continue;
- rects[piece] = FloatRect(FloatPoint(), intrinsicRects[piece].size());
- }
-
- return rects;
-}
-
-FloatSize NinePieceImage::computeIntrinsicSideTileScale(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
+FloatSize NinePieceImage::computeSideTileScale(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
{
ASSERT(!isCornerPiece(piece) && !isMiddlePiece(piece));
if (isEmptyPieceRect(piece, destinationRects, sourceRects))
return FloatSize(scale, scale);
}
-FloatSize NinePieceImage::computeIntrinsicMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+FloatSize NinePieceImage::computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
{
FloatSize scale(1, 1);
if (isEmptyPieceRect(MiddlePiece, destinationRects, sourceRects))
return scale;
}
-Vector<FloatSize> NinePieceImage::computeIntrinsicTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+Vector<FloatSize> NinePieceImage::computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
{
Vector<FloatSize> scales(MaxPiece, FloatSize(1, 1));
- scales[TopPiece] = computeIntrinsicSideTileScale(TopPiece, destinationRects, sourceRects);
- scales[RightPiece] = computeIntrinsicSideTileScale(RightPiece, destinationRects, sourceRects);
- scales[BottomPiece] = computeIntrinsicSideTileScale(BottomPiece, destinationRects, sourceRects);
- scales[LeftPiece] = computeIntrinsicSideTileScale(LeftPiece, destinationRects, sourceRects);
+ scales[TopPiece] = computeSideTileScale(TopPiece, destinationRects, sourceRects);
+ scales[RightPiece] = computeSideTileScale(RightPiece, destinationRects, sourceRects);
+ scales[BottomPiece] = computeSideTileScale(BottomPiece, destinationRects, sourceRects);
+ scales[LeftPiece] = computeSideTileScale(LeftPiece, destinationRects, sourceRects);
- scales[MiddlePiece] = computeIntrinsicMiddleTileScale(scales, destinationRects, sourceRects, hRule, vRule);
+ scales[MiddlePiece] = computeMiddleTileScale(scales, destinationRects, sourceRects, hRule, vRule);
return scales;
}
-Vector<FloatSize> NinePieceImage::computeNonIntrinsicTileScales()
-{
- return Vector<FloatSize>(MaxPiece, FloatSize(1, 1));
-}
-
-void NinePieceImage::paint(GraphicsContext& graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, bool intrinsicSource, float deviceScaleFactor, CompositeOperator op) const
+void NinePieceImage::paint(GraphicsContext& graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator op) const
{
StyleImage* styleImage = image();
ASSERT(styleImage && styleImage->isLoaded());
scaleSlicesIfNeeded(destination.size(), destinationSlices, deviceScaleFactor);
- Vector<FloatRect> destinationRects = computeIntrinsicRects(destination, destinationSlices, deviceScaleFactor);
- Vector<FloatRect> sourceRects;
- Vector<FloatSize> tileScales;
-
- if (intrinsicSource) {
- sourceRects = computeIntrinsicRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
- tileScales = computeIntrinsicTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
- } else {
- sourceRects = computeNonIntrinsicRects(destinationRects, sourceSlices);
- tileScales = computeNonIntrinsicTileScales();
- }
+ Vector<FloatRect> destinationRects = computeNineRects(destination, destinationSlices, deviceScaleFactor);
+ Vector<FloatRect> sourceRects = computeNineRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
+ Vector<FloatSize> tileScales = computeTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
RefPtr<Image> image = styleImage->image(renderer, source);
ColorSpace colorSpace = style.colorSpace();
static bool isEmptyPieceRect(ImagePiece, const LayoutBoxExtent& slices);
static bool isEmptyPieceRect(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
- static Vector<FloatRect> computeIntrinsicRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor);
- static Vector<FloatRect> computeNonIntrinsicRects(const Vector<FloatRect>& intrinsicRects, const LayoutBoxExtent& slices);
+ static Vector<FloatRect> computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor);
static void scaleSlicesIfNeeded(const LayoutSize&, LayoutBoxExtent& slices, float deviceScaleFactor);
- static FloatSize computeIntrinsicSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
- static FloatSize computeIntrinsicMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
- static Vector<FloatSize> computeIntrinsicTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
- static Vector<FloatSize> computeNonIntrinsicTileScales();
+ static FloatSize computeSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
+ static FloatSize computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
+ static Vector<FloatSize> computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
- void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, bool intrinsicSource, float deviceScaleFactor, CompositeOperator) const;
+ void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator) const;
private:
DataRef<NinePieceImageData> m_data;