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

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: erm.. use DEFINE_STATIC_REF 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 10530f487d080f296c199bb96fe74af669677dbe..27eabaf8cee6f4ddb17466f6b1c898035b8f4d69 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
@@ -615,8 +609,8 @@ BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
if (!value || !value->isPrimitiveValue())
return BorderImageLengthBox();
- // Get our zoom value.
float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();
+ const CSSToLengthConversionData& conversionData = cssToLengthConversionData().copyWithAdjustedZoom(zoom);
// Retrieve the primitive value.
CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value);
@@ -629,28 +623,28 @@ BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
else if (slices->top()->isPercentage())
box.setTop(Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
else if (slices->top()->getValueID() != CSSValueAuto)
- box.setTop(slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom));
+ box.setTop(slices->top()->computeLength<Length>(conversionData));
if (slices->right()->isNumber())
box.setRight(slices->right()->getDoubleValue());
else if (slices->right()->isPercentage())
box.setRight(Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
else if (slices->right()->getValueID() != CSSValueAuto)
- box.setRight(slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom));
+ box.setRight(slices->right()->computeLength<Length>(conversionData));
if (slices->bottom()->isNumber())
box.setBottom(slices->bottom()->getDoubleValue());
else if (slices->bottom()->isPercentage())
box.setBottom(Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
else if (slices->bottom()->getValueID() != CSSValueAuto)
- box.setBottom(slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom));
+ box.setBottom(slices->bottom()->computeLength<Length>(conversionData));
if (slices->left()->isNumber())
box.setLeft(slices->left()->getDoubleValue());
else if (slices->left()->isPercentage())
box.setLeft(Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
else if (slices->left()->getValueID() != CSSValueAuto)
- box.setLeft(slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom));
+ box.setLeft(slices->left()->computeLength<Length>(conversionData));
return box;
}

Powered by Google App Engine
This is Rietveld 408576698