Commit 3069e05e authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Chromium LUCI CQ

Simplify ConvertValueFromPercentageToUserUnits in svg_length_context.cc

We know what viewport dimension to use up front, so we can just pass
that directly rather than calling DimensionForLengthMode().

Change-Id: I59484a91ae986a5b3b0b47352886c450dcd828d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624667
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842733}
parent d1880e4a
...@@ -50,11 +50,10 @@ static inline float DimensionForLengthMode(SVGLengthMode mode, ...@@ -50,11 +50,10 @@ static inline float DimensionForLengthMode(SVGLengthMode mode,
return 0; return 0;
} }
static float ConvertValueFromPercentageToUserUnits( static float ConvertValueFromPercentageToUserUnits(const SVGLength& value,
const SVGLength& value, float viewport_dimension) {
const FloatSize& viewport_size) { return CSSPrimitiveValue::ClampToCSSLengthRange(
return CSSPrimitiveValue::ClampToCSSLengthRange(value.ScaleByPercentage( value.ScaleByPercentage(viewport_dimension));
DimensionForLengthMode(value.UnitMode(), viewport_size)));
} }
static const ComputedStyle* ComputedStyleForLengthResolving( static const ComputedStyle* ComputedStyleForLengthResolving(
...@@ -168,12 +167,13 @@ FloatRect SVGLengthContext::ResolveRectangle(const SVGElement* context, ...@@ -168,12 +167,13 @@ FloatRect SVGLengthContext::ResolveRectangle(const SVGElement* context,
const SVGLength& height) { const SVGLength& height) {
DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type); DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type);
if (type != SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { if (type != SVGUnitTypes::kSvgUnitTypeUserspaceonuse) {
const FloatSize& viewport_size = viewport.Size();
return FloatRect( return FloatRect(
ConvertValueFromPercentageToUserUnits(x, viewport_size) + viewport.X(), ConvertValueFromPercentageToUserUnits(x, viewport.Width()) +
ConvertValueFromPercentageToUserUnits(y, viewport_size) + viewport.Y(), viewport.X(),
ConvertValueFromPercentageToUserUnits(width, viewport_size), ConvertValueFromPercentageToUserUnits(y, viewport.Height()) +
ConvertValueFromPercentageToUserUnits(height, viewport_size)); viewport.Y(),
ConvertValueFromPercentageToUserUnits(width, viewport.Width()),
ConvertValueFromPercentageToUserUnits(height, viewport.Height()));
} }
SVGLengthContext length_context(context); SVGLengthContext length_context(context);
......
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