Background image should clamp to minimum size(1, 1) after scale.

While one of the values of background-size is auto we have to use the
appropriate scale to maintain our aspect ratio. In this step we might
end up getting new image width or height as zero. In this case we should
clamp to minimum value as 1.

BUG=424048

Review URL: https://codereview.chromium.org/659913003

git-svn-id: svn://svn.chromium.org/blink/trunk@185238 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c40cc61a
......@@ -279,6 +279,8 @@ crbug.com/316147 [ Win ] http/tests/history/back-to-post.html [ Failure Pass ]
crbug.com/341435 http/tests/images/image-with-origin-header.html [ Pass Timeout ]
crbug.com/424048 [ Win Android Mac ] fast/backgrounds/size/zero.html [ NeedsRebaseline ]
crbug.com/248938 virtual/threaded/animations/3d/transform-origin-vs-functions.html [ Pass Failure ]
crbug.com/248938 [ Linux Win ] virtual/threaded/animations/animation-border-overflow.html [ Pass Timeout ]
crbug.com/248938 virtual/threaded/animations/animation-direction-normal.html [ Pass ImageOnlyFailure Timeout ]
......
<!DOCTYPE html>
<html>
<head>
<style>
div {
background: green;
}
</style>
</head>
<body>
<div>This text should have green background.<div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
background: url('resources/bgimg1x50.png') repeat-x left top;
background-size: auto 100%;
}
</style>
</head>
<body>
<div>This text should have green background.<div>
</body>
</html>
......@@ -5,7 +5,7 @@
Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=15750">REGRESSION(r27173): Web Inspector freezes beneath Image::drawPattern()</a> Bug</i>.
</p>
<p>
There should be four empty squares with black borders. WebKit should not hang or assert.
There should be three empty squares with black borders and the last one should have blue background. WebKit should not hang or assert.
</p>
<div style="background-size: 0 0;"></div>
<div style="background-size: 0 32px;"></div>
......
......@@ -14,10 +14,11 @@ layer at (0,0) size 800x600
text run at (550,0) width 29: " Bug"
RenderText {#text} at (579,0) size 4x19
text run at (579,0) width 4: "."
RenderBlock {P} at (0,36) size 784x20
RenderText {#text} at (0,0) size 548x19
text run at (0,0) width 548: "There should be four empty squares with black borders. WebKit should not hang or assert."
RenderBlock {DIV} at (8,72) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,186) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,300) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,414) size 106x106 [border: (3px solid #000000)]
RenderBlock {P} at (0,36) size 784x40
RenderText {#text} at (0,0) size 772x39
text run at (0,0) width 772: "There should be three empty squares with black borders and the last one should have blue background. WebKit should not hang"
text run at (0,20) width 56: "or assert."
RenderBlock {DIV} at (8,92) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,206) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,320) size 106x106 [border: (3px solid #000000)]
RenderBlock {DIV} at (8,434) size 106x106 [border: (3px solid #000000)]
......@@ -830,11 +830,19 @@ IntSize BoxPainter::calculateFillTileSize(const RenderBoxModelObject& obj, const
// If one of the values is auto we have to use the appropriate
// scale to maintain our aspect ratio.
if (layerWidth.isAuto() && !layerHeight.isAuto()) {
if (imageIntrinsicSize.height())
tileSize.setWidth(imageIntrinsicSize.width() * tileSize.height() / imageIntrinsicSize.height());
if (imageIntrinsicSize.height()) {
LayoutUnit adjustedWidth = imageIntrinsicSize.width() * tileSize.height() / imageIntrinsicSize.height();
if (imageIntrinsicSize.width() >= 1 && adjustedWidth < 1)
adjustedWidth = 1;
tileSize.setWidth(adjustedWidth);
}
} else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
if (imageIntrinsicSize.width())
tileSize.setHeight(imageIntrinsicSize.height() * tileSize.width() / imageIntrinsicSize.width());
if (imageIntrinsicSize.width()) {
LayoutUnit adjustedHeight = imageIntrinsicSize.height() * tileSize.width() / imageIntrinsicSize.width();
if (imageIntrinsicSize.height() >= 1 && adjustedHeight < 1)
adjustedHeight = 1;
tileSize.setHeight(adjustedHeight);
}
} else if (layerWidth.isAuto() && layerHeight.isAuto()) {
// If both width and height are auto, use the image's intrinsic size.
tileSize = imageIntrinsicSize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment