Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: Source/core/css/CSSToStyleMap.cpp

Issue 64293008: Wrap CSS length conversion arguments in an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: bool for useEffectiveZoom instead of -1 magic number Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/CSSToStyleMap.cpp
diff --git a/Source/core/css/CSSToStyleMap.cpp b/Source/core/css/CSSToStyleMap.cpp
index eecea918e21133161adb170cd8abbf9f00bbc6c5..4175b3288e85f139fb8855ece2726b79d5cfc497 100644
--- a/Source/core/css/CSSToStyleMap.cpp
+++ b/Source/core/css/CSSToStyleMap.cpp
@@ -47,9 +47,9 @@ const RenderStyle* CSSToStyleMap::style() const
return m_state.style();
}
-const RenderStyle* CSSToStyleMap::rootElementStyle() const
+const CSSToLengthConversionData& CSSToStyleMap::cssToLengthConversionData() const
{
- return m_state.rootElementStyle();
+ return m_state.cssToLengthConversionData();
}
bool CSSToStyleMap::useSVGZoomRules() const
@@ -205,16 +205,14 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value
return;
}
- float zoomFactor = style()->effectiveZoom();
-
Length firstLength;
Length secondLength;
if (Pair* pair = primitiveValue->getPairValue()) {
- firstLength = pair->first()->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
- secondLength = pair->second()->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
+ firstLength = pair->first()->convertToLength<AnyConversion>(cssToLengthConversionData());
+ secondLength = pair->second()->convertToLength<AnyConversion>(cssToLengthConversionData());
} else {
- firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
+ firstLength = primitiveValue->convertToLength<AnyConversion>(cssToLengthConversionData());
secondLength = Length();
}
@@ -231,8 +229,6 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer,
if (!value->isPrimitiveValue())
return;
- float zoomFactor = style()->effectiveZoom();
-
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
@@ -242,11 +238,11 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer,
Length length;
if (primitiveValue->isLength())
- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
+ length = primitiveValue->computeLength<Length>(cssToLengthConversionData());
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor));
+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(cssToLengthConversionData()));
else if (primitiveValue->isViewportPercentageLength())
length = primitiveValue->viewportPercentageLength();
else
@@ -262,8 +258,6 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer,
if (!value->isPrimitiveValue())
return;
- float zoomFactor = style()->effectiveZoom();
-
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
@@ -273,11 +267,11 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer,
Length length;
if (primitiveValue->isLength())
- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
+ length = primitiveValue->computeLength<Length>(cssToLengthConversionData());
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor));
+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(cssToLengthConversionData()));
else if (primitiveValue->isViewportPercentageLength())
length = primitiveValue->viewportPercentageLength();
else
@@ -610,14 +604,14 @@ void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag
image.setFill(borderImageSlice->m_fill);
}
-static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier)
+static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSSToLengthConversionData& conversionData)
{
if (value.isNumber())
return value.getDoubleValue();
if (value.isPercentage())
return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
if (value.getValueID() != CSSValueAuto)
- return value.computeLength<Length>(currentStyle, rootStyle, multiplier);
+ return value.computeLength<Length>(conversionData);
return Length(Auto);
}
@@ -630,11 +624,12 @@ BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
Quad* slices = toCSSPrimitiveValue(value)->getQuadValue();
// Set up a border image length box to represent our image slices.
+ const CSSToLengthConversionData& conversionData = cssToLengthConversionData().copyWithAdjustedZoom(zoom);
return BorderImageLengthBox(
- toBorderImageLength(*slices->top(), style(), rootElementStyle(), zoom),
- toBorderImageLength(*slices->right(), style(), rootElementStyle(), zoom),
- toBorderImageLength(*slices->bottom(), style(), rootElementStyle(), zoom),
- toBorderImageLength(*slices->left(), style(), rootElementStyle(), zoom));
+ toBorderImageLength(*slices->top(), conversionData),
+ toBorderImageLength(*slices->right(), conversionData),
+ toBorderImageLength(*slices->bottom(), conversionData),
+ toBorderImageLength(*slices->left(), conversionData));
}
void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image) const

Powered by Google App Engine
This is Rietveld 408576698