Commit b76e918d authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Fix resolution of 'auto' in SVGLengthContext::ResolveLengthPair

If one of the Lengths was 'auto' while the other was a percentage or
calc(...), the 'auto' Length would resolve to the corresponding viewport
dimension (i.e like if it was 100%) rather than 0.

Fixed: 1131324
Change-Id: Iec4e406d74b29551f417ab32caf3ef6cc627909b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426483Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#809844}
parent 489d9189
...@@ -202,9 +202,16 @@ FloatPoint SVGLengthContext::ResolveLengthPair( ...@@ -202,9 +202,16 @@ FloatPoint SVGLengthContext::ResolveLengthPair(
const Length& y_length, const Length& y_length,
const ComputedStyle& style) const { const ComputedStyle& style) const {
FloatSize viewport_size; FloatSize viewport_size;
if (x_length.IsPercentOrCalc() || y_length.IsPercentOrCalc()) if (x_length.IsPercentOrCalc() || y_length.IsPercentOrCalc()) {
DetermineViewport(viewport_size); DetermineViewport(viewport_size);
// If either |x_length| or |y_length| is 'auto', set that viewport dimension
// to zero so that the corresponding Length resolves to zero. This matches
// the behavior of ValueForLength() below.
if (x_length.IsAuto())
viewport_size.SetWidth(0);
else if (y_length.IsAuto())
viewport_size.SetHeight(0);
}
float zoom = style.EffectiveZoom(); float zoom = style.EffectiveZoom();
return FloatPoint(ValueForLength(x_length, zoom, viewport_size.Width()), return FloatPoint(ValueForLength(x_length, zoom, viewport_size.Width()),
ValueForLength(y_length, zoom, viewport_size.Height())); ValueForLength(y_length, zoom, viewport_size.Height()));
......
...@@ -9,15 +9,25 @@ ...@@ -9,15 +9,25 @@
<g stroke="red" stroke-width="100"> <g stroke="red" stroke-width="100">
<g transform="translate(50, 50)"> <g transform="translate(50, 50)">
<rect/> <rect/>
<rect width="10"/>
<rect height="10"/>
<rect width="10%"/>
<rect height="10%"/>
<rect width="0" height="10"/> <rect width="0" height="10"/>
<rect width="-10" height="10"/> <rect width="-10" height="10"/>
<rect height="0" width="10"/> <rect height="0" width="10"/>
<rect height="-10" width="10"/> <rect height="-10" width="10"/>
<rect style="width: 0"/> <rect style="width: 0"/>
<rect style="width: 10px"/>
<rect style="width: 10%"/>
<rect style="width: calc(10%+10px)"/>
<rect style="width: 0" height="10"/> <rect style="width: 0" height="10"/>
<rect style="width: -10px"/> <rect style="width: -10px"/>
<rect style="width: -10px" height="10"/> <rect style="width: -10px" height="10"/>
<rect style="height: 0"/> <rect style="height: 0"/>
<rect style="height: 10px"/>
<rect style="height: 10%"/>
<rect style="height: calc(10%+10px)"/>
<rect style="height: 0" width="10"/> <rect style="height: 0" width="10"/>
<rect style="height: -10px"/> <rect style="height: -10px"/>
<rect style="height: -10px" width="10"/> <rect style="height: -10px" width="10"/>
......
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