Commit cb584c99 authored by Stephen Chenney's avatar Stephen Chenney Committed by Commit Bot

Account for zoom in fallback image sizing

The code that set the size of the container for the fallback image
is using the missing image's style's width and height, setting it
directly on the replaced container. But the style's sizes are zoomed
while the replaced container style should be pre-zoom. Fix it.

R=pdr@chromium.org
BUG=813417

Change-Id: I230f45442dfbd5936e820633bcf85f387a0a82fb
Reviewed-on: https://chromium-review.googlesource.com/956502Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542153}
parent 2cc853c1
<!DOCTYPE html>
<style>
body {
zoom: 200%;
}
</style>
<img src="https://www.example.com/doesntexist.png" style="width: 32px; height: 32px; background: orange;"/></p>
Blocked access to external URL https://www.example.com/doesntexist.png
Blocked access to external URL https://www.example.com/doesntexist.png
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x120
LayoutBlockFlow {HTML} at (0,0) size 800x120
LayoutBlockFlow {BODY} at (16,16) size 768x72
LayoutBlockFlow (anonymous) at (0,0) size 768x72
LayoutBlockFlow {IMG} at (0,0) size 64x64 [bgcolor=#FFA500]
LayoutBlockFlow {P} at (0,104) size 768x0
layer at (16,16) size 64x64 clip at (18,18) size 60x60
LayoutBlockFlow {SPAN} at (0,0) size 64x64 [border: (2px solid #C0C0C0)]
LayoutImage (floating) {IMG} at (4,4) size 32x32
LayoutInline {SPAN} at (0,0) size 0x0
Blocked access to external URL https://www.example.com/doesntexist.png
Blocked access to external URL https://www.example.com/doesntexist.png
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x121
LayoutBlockFlow {HTML} at (0,0) size 800x121
LayoutBlockFlow {BODY} at (16,16) size 768x73
LayoutBlockFlow (anonymous) at (0,0) size 768x73
LayoutBlockFlow {IMG} at (0,0) size 64x64 [bgcolor=#FFA500]
LayoutBlockFlow {P} at (0,105) size 768x0
layer at (16,16) size 64x64 clip at (18,18) size 60x60
LayoutBlockFlow {SPAN} at (0,0) size 64x64 [border: (2px solid #C0C0C0)]
LayoutImage (floating) {IMG} at (4,4) size 32x32
LayoutInline {SPAN} at (0,0) size 0x0
...@@ -138,10 +138,16 @@ scoped_refptr<ComputedStyle> HTMLImageFallbackHelper::CustomStyleForAltText( ...@@ -138,10 +138,16 @@ scoped_refptr<ComputedStyle> HTMLImageFallbackHelper::CustomStyleForAltText(
new_style->Height().IsPercent() new_style->Height().IsPercent()
? CSSPrimitiveValue::UnitType::kPercentage ? CSSPrimitiveValue::UnitType::kPercentage
: CSSPrimitiveValue::UnitType::kPixels; : CSSPrimitiveValue::UnitType::kPixels;
place_holder->SetInlineStyleProperty(CSSPropertyHeight,
new_style->Height().Value(), unit); // The width and height reported by computed style are zoomed, but when
place_holder->SetInlineStyleProperty(CSSPropertyWidth, // setting the width and height CSS properties we want pre-zoomed sizes.
new_style->Width().Value(), unit); float scale_factor = unit == CSSPrimitiveValue::UnitType::kPixels
? new_style->EffectiveZoom()
: 1.0f;
place_holder->SetInlineStyleProperty(
CSSPropertyHeight, new_style->Height().Value() / scale_factor, unit);
place_holder->SetInlineStyleProperty(
CSSPropertyWidth, new_style->Width().Value() / scale_factor, unit);
// 16px for the image and 2px for its top/left border/padding offset. // 16px for the image and 2px for its top/left border/padding offset.
int pixels_for_alt_image = 18; int pixels_for_alt_image = 18;
......
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