Commit b7f42c43 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Fix propagation of 'width' and 'height' in HTMLImageFallbackHelper

Use CSSValue::Create(const Length&, ...) to produce values in unzoomed
coordinates. This handles for instance calc(...) expressions correctly.

Bug: 860204
Change-Id: I30e639c38dc49795d44a5e28cc1bf01734543730
Reviewed-on: https://chromium-review.googlesource.com/1126307Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#573893}
parent 065270ef
<!DOCTYPE html>
<div style="background-color: blue; width: 100px; height: 100px">
<img src="nonexisting" style="width: 18px; height: 100px">
</div>
<!DOCTYPE html>
<div style="width: 264px">
<img src="nonexisting" style="width: calc(50% - 32px); height: 100px; background-color: blue">
</div>
......@@ -134,20 +134,12 @@ scoped_refptr<ComputedStyle> HTMLImageFallbackHelper::CustomStyleForAltText(
CSSValueInlineBlock);
place_holder->SetInlineStyleProperty(CSSPropertyPointerEvents,
CSSValueNone);
CSSPrimitiveValue::UnitType unit =
new_style->Height().IsPercent()
? CSSPrimitiveValue::UnitType::kPercentage
: CSSPrimitiveValue::UnitType::kPixels;
// The width and height reported by computed style are zoomed, but when
// setting the width and height CSS properties we want pre-zoomed sizes.
float scale_factor = unit == CSSPrimitiveValue::UnitType::kPixels
? new_style->EffectiveZoom()
: 1.0f;
place_holder->SetInlineStyleProperty(
CSSPropertyHeight, new_style->Height().Value() / scale_factor, unit);
CSSPropertyHeight,
*CSSValue::Create(new_style->Height(), new_style->EffectiveZoom()));
place_holder->SetInlineStyleProperty(
CSSPropertyWidth, new_style->Width().Value() / scale_factor, unit);
CSSPropertyWidth,
*CSSValue::Create(new_style->Width(), new_style->EffectiveZoom()));
// 16px for the image and 2px for its top/left border/padding offset.
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