Commit d330c6eb authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Avoid infinite background tile scale

The issue happened when an SVG background image was painted with a very
small background size rounded to zero, causing infinite tile scale and
DCHECK failure in ClipRectOp.

Bug: 1039762
Change-Id: Ia94ce2fd350b28696ef8068bd0e756bfc6d87a72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002839
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732572}
parent b756c98d
...@@ -407,7 +407,13 @@ void DrawTiledBackground(GraphicsContext& context, ...@@ -407,7 +407,13 @@ void DrawTiledBackground(GraphicsContext& context,
// generated image to be the tile size. // generated image to be the tile size.
FloatSize intrinsic_tile_size(image->Size()); FloatSize intrinsic_tile_size(image->Size());
FloatSize scale(1, 1); FloatSize scale(1, 1);
if (!image->HasIntrinsicSize()) { if (!image->HasIntrinsicSize() ||
// TODO(crbug.com/1042783): This is not checking for real empty image
// (for which we have checked and skipped the whole FillLayer), but for
// that a subpixel image size is rounded to empty, to avoid infinite tile
// scale that would be calculated in the |else| part.
// We should probably support subpixel size here.
intrinsic_tile_size.IsEmpty()) {
intrinsic_tile_size = tile_size; intrinsic_tile_size = tile_size;
} else { } else {
scale = FloatSize(tile_size.Width() / intrinsic_tile_size.Width(), scale = FloatSize(tile_size.Width() / intrinsic_tile_size.Width(),
...@@ -438,7 +444,7 @@ void DrawTiledBackground(GraphicsContext& context, ...@@ -438,7 +444,7 @@ void DrawTiledBackground(GraphicsContext& context,
// When respecting image orientation, the drawing code expects the source // When respecting image orientation, the drawing code expects the source
// rect to be in the unrotated image space, but we have computed it here in // rect to be in the unrotated image space, but we have computed it here in
// the rotated space in order to position and size the background. Undo the // the rotated space in order to position and size the background. Undo the
// src rect rotation if necessaary. // src rect rotation if necessary.
if (respect_orientation && !image->HasDefaultOrientation()) { if (respect_orientation && !image->HasDefaultOrientation()) {
visible_src_rect = CorrectSrcRectForImageOrientation(ToBitmapImage(image), visible_src_rect = CorrectSrcRectForImageOrientation(ToBitmapImage(image),
visible_src_rect); visible_src_rect);
......
...@@ -389,6 +389,9 @@ crbug.com/997202 [ Win ] external/wpt/css/css-images/image-orientation/image-ori ...@@ -389,6 +389,9 @@ crbug.com/997202 [ Win ] external/wpt/css/css-images/image-orientation/image-ori
crbug.com/1042453 [ Win ] external/wpt/css/filter-effects/idlharness.any.html [ Timeout Pass ] crbug.com/1042453 [ Win ] external/wpt/css/filter-effects/idlharness.any.html [ Timeout Pass ]
crbug.com/1042453 [ Mac ] external/wpt/css/filter-effects/idlharness.any.html [ Timeout Pass ] crbug.com/1042453 [ Mac ] external/wpt/css/filter-effects/idlharness.any.html [ Timeout Pass ]
crbug.com/1042783 external/wpt/css/css-backgrounds/background-size/background-size-near-zero-png.html [ Failure ]
crbug.com/1042783 external/wpt/css/css-backgrounds/background-size/background-size-near-zero-svg.html [ Failure ]
# ====== Paint team owned tests to here ====== # ====== Paint team owned tests to here ======
crbug.com/922249 virtual/android/fullscreen/compositor-touch-hit-rects-fullscreen-video-controls.html [ Failure Pass ] crbug.com/922249 virtual/android/fullscreen/compositor-touch-hit-rects-fullscreen-video-controls.html [ Failure Pass ]
......
<!DOCTYPE html>
<title>Color background with near-zero background-size</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-size">
<link rel="match" href="reference/background-size-near-zero-ref.html">
<div style="background-color: green;
width: 100px; height: 100px; background-size: 0.2px 0.2px">
</div>
<!DOCTYPE html>
<title>Gradient background with near-zero background-size</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-size">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-image">
<link rel="match" href="reference/background-size-near-zero-ref.html">
<div style="background-image: linear-gradient(green, green);
width: 100px; height: 100px; background-size: 0.2px 0.2px">
</div>
<!DOCTYPE html>
<title>PNG background with near-zero background-size</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-size">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-image">
<link rel="match" href="reference/background-size-near-zero-ref.html">
<div style="background-image: url(support/50x50-green.png);
width: 100px; height: 100px; background-size: 0.2px 0.2px">
</div>
<!DOCTYPE html>
<title>SVG background with near-zero background-size</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-size">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-image">
<link rel="match" href="reference/background-size-near-zero-ref.html">
<div style="background-image: url(support/50x50-green.svg);
width: 100px; height: 100px; background-size: 0.2px 0.2px">
</div>
<!DOCTYPE html>
<div style="width: 100px; height: 100px; background: green"></div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
<rect fill="green" width="50" height="50"/>
</svg>
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