Commit f13747ae authored by Luna Lu's avatar Luna Lu Committed by Commit Bot

Bug fix: max-downscaling-image policy should respect device pixel ratio

When the device pixel ratio is > 1, image with (device_pixel_ratio *
container_size * max_downscaling_ratio) pixels should be allowed by
max-downscaling-image policy.

BUG:858897

Change-Id: Ic85e79e487c77296556c69b5dc5872e85b22d23e
Reviewed-on: https://chromium-review.googlesource.com/1170853Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Reviewed-by: default avatarLuna Lu <loonybear@chromium.org>
Commit-Queue: Luna Lu <loonybear@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582705}
parent 3cea15a1
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x525
LayoutBlockFlow {HTML} at (0,0) size 800x525
LayoutBlockFlow {BODY} at (8,8) size 784x509
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x411
LayoutBlockFlow {HTML} at (0,0) size 600x411
LayoutBlockFlow {BODY} at (8,8) size 584x395
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,241) size 4x19
text run at (256,241) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,241) size 4x19
text run at (388,241) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,241) size 4x19
text run at (519,241) width 4: " "
LayoutImage {IMG} at (0,261) size 129x129
LayoutText {#text} at (0,0) size 0x0
<!DOCTYPE html>
<body>
<iframe id="simple" src="resources/frame-with-max-downscaling-image-test-images-edge-cases.html"
allow="max-downscaling-image 'none'" width="600" height="500">
</iframe>
</body>
<!DOCTYPE html>
<body>
<img src="green-256x256.jpg">
<img src="green-256x256.jpg" width="128" height="128" >
<img src="green-256x256.jpg" width="127" height="127" >
<img src="green-256x256.jpg" width="129" height="129" >
</body>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x524
LayoutBlockFlow {HTML} at (0,0) size 800x524
LayoutBlockFlow {BODY} at (8,8) size 784x508
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x409
LayoutBlockFlow {HTML} at (0,0) size 600x409
LayoutBlockFlow {BODY} at (8,8) size 584x393
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,242) size 4x18
text run at (256,242) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,242) size 4x18
text run at (388,242) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,242) size 4x18
text run at (519,242) width 4: " "
LayoutImage {IMG} at (0,260) size 129x129
LayoutText {#text} at (0,0) size 0x0
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x524
LayoutBlockFlow {HTML} at (0,0) size 800x524
LayoutBlockFlow {BODY} at (8,8) size 784x508
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x409
LayoutBlockFlow {HTML} at (0,0) size 600x409
LayoutBlockFlow {BODY} at (8,8) size 584x393
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,242) size 4x18
text run at (256,242) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,242) size 4x18
text run at (388,242) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,242) size 4x18
text run at (519,242) width 4: " "
LayoutImage {IMG} at (0,260) size 129x129
LayoutText {#text} at (0,0) size 0x0
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x524
LayoutBlockFlow {HTML} at (0,0) size 800x524
LayoutBlockFlow {BODY} at (8,8) size 784x508
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x409
LayoutBlockFlow {HTML} at (0,0) size 600x409
LayoutBlockFlow {BODY} at (8,8) size 584x393
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,242) size 4x18
text run at (256,242) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,242) size 4x18
text run at (388,242) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,242) size 4x18
text run at (519,242) width 4: " "
LayoutImage {IMG} at (0,260) size 129x129
LayoutText {#text} at (0,0) size 0x0
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x525
LayoutBlockFlow {HTML} at (0,0) size 800x525
LayoutBlockFlow {BODY} at (8,8) size 784x509
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x411
LayoutBlockFlow {HTML} at (0,0) size 600x411
LayoutBlockFlow {BODY} at (8,8) size 584x395
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,241) size 4x19
text run at (256,241) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,241) size 4x19
text run at (388,241) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,241) size 4x19
text run at (519,241) width 4: " "
LayoutImage {IMG} at (0,261) size 129x129
LayoutText {#text} at (0,0) size 0x0
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x525
LayoutBlockFlow {HTML} at (0,0) size 800x525
LayoutBlockFlow {BODY} at (8,8) size 784x509
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 604x504
LayoutIFrame {IFRAME} at (0,0) size 604x504 [border: (2px inset #EEEEEE)]
layer at (0,0) size 600x500
LayoutView at (0,0) size 600x500
layer at (0,0) size 600x411
LayoutBlockFlow {HTML} at (0,0) size 600x411
LayoutBlockFlow {BODY} at (8,8) size 584x395
LayoutImage {IMG} at (0,0) size 256x256
LayoutText {#text} at (256,241) size 4x19
text run at (256,241) width 4: " "
LayoutImage {IMG} at (260,128) size 128x128
LayoutText {#text} at (388,241) size 4x19
text run at (388,241) width 4: " "
LayoutImage {IMG} at (392,129) size 127x127
LayoutText {#text} at (519,241) size 4x19
text run at (519,241) width 4: " "
LayoutImage {IMG} at (0,261) size 129x129
LayoutText {#text} at (0,0) size 0x0
......@@ -87,10 +87,10 @@ bool CheckForMaxDownscalingImagePolicy(const LocalFrame& frame,
if (layout_width > 0 && layout_height > 0 && image_width > 0 &&
image_height > 0) {
double device_pixel_ratio = frame.DevicePixelRatio();
if (LayoutUnit(image_width / kmax_downscaling_ratio * device_pixel_ratio) >
layout_width ||
LayoutUnit(image_height / kmax_downscaling_ratio * device_pixel_ratio) >
layout_height)
if (LayoutUnit(image_width / (kmax_downscaling_ratio *
device_pixel_ratio)) > layout_width ||
LayoutUnit(image_height / (kmax_downscaling_ratio *
device_pixel_ratio)) > layout_height)
return true;
}
return false;
......
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