Diff
Modified: trunk/Source/WebCore/ChangeLog (111630 => 111631)
--- trunk/Source/WebCore/ChangeLog 2012-03-22 00:43:05 UTC (rev 111630)
+++ trunk/Source/WebCore/ChangeLog 2012-03-22 00:58:36 UTC (rev 111631)
@@ -1,3 +1,20 @@
+2012-03-21 Luke Macpherson <[email protected]>
+
+ Use CSSPrimitiveValue::convertToLength() in a few places.
+ https://bugs.webkit.org/show_bug.cgi?id=81492
+
+ Reviewed by Eric Seidel.
+
+ No new tests - refactoring only.
+
+ CSSPrimitiveValue::convertToLength() provides the same functionality that is duplicated
+ in many places in CSSStyleSelector. This patch removes some of that code duplication.
+
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::ApplyPropertyVerticalAlign::applyValue):
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+
2012-03-21 Patrick Gansterer <[email protected]>
Build fix for ENABLE(SVG) && !ENABLE(FILTERS) after r111601.
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (111630 => 111631)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-03-22 00:43:05 UTC (rev 111630)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-03-22 00:58:36 UTC (rev 111631)
@@ -30,8 +30,9 @@
#ifndef CSSPrimitiveValueMappings_h
#define CSSPrimitiveValueMappings_h
+#include "CSSCalculationValue.h"
+#include "CSSPrimitiveValue.h"
#include "ColorSpace.h"
-#include "CSSPrimitiveValue.h"
#include "CSSValueKeywords.h"
#include "FontDescription.h"
#include "FontSmoothingMode.h"
@@ -3767,11 +3768,13 @@
}
enum LengthConversion {
+ AnyConversion = ~0,
FixedIntegerConversion = 1 << 0,
FixedFloatConversion = 1 << 1,
AutoConversion = 1 << 2,
PercentConversion = 1 << 3,
- FractionConversion = 1 << 4
+ FractionConversion = 1 << 4,
+ CalculatedConversion = 1 << 5
};
template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
@@ -3788,6 +3791,8 @@
return Length(getDoubleValue() * 100.0, Percent);
if ((supported & AutoConversion) && getIdent() == CSSValueAuto)
return Length(Auto);
+ if ((supported & CalculatedConversion) && isCalculated())
+ return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier));
return Length(Undefined);
}
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (111630 => 111631)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-03-22 00:43:05 UTC (rev 111630)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-03-22 00:58:36 UTC (rev 111631)
@@ -1563,13 +1563,7 @@
if (primitiveValue->getIdent())
return selector->style()->setVerticalAlign(*primitiveValue);
- Length length;
- if (primitiveValue->isLength())
- length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
- else if (primitiveValue->isPercentage())
- length = Length(primitiveValue->getDoubleValue(), Percent);
-
- selector->style()->setVerticalAlignLength(length);
+ selector->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()));
}
static PropertyHandler createHandler()
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (111630 => 111631)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 00:43:05 UTC (rev 111630)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 00:58:36 UTC (rev 111631)
@@ -4199,35 +4199,22 @@
return;
}
- Pair* pair = primitiveValue->getPairValue();
-
- CSSPrimitiveValue* first = pair ? static_cast<CSSPrimitiveValue*>(pair->first()) : primitiveValue;
- CSSPrimitiveValue* second = pair ? static_cast<CSSPrimitiveValue*>(pair->second()) : 0;
-
- Length firstLength, secondLength;
-
float zoomFactor = m_style->effectiveZoom();
- if (first->getIdent() == CSSValueAuto)
- firstLength = Length();
- else if (first->isLength())
- firstLength = first->computeLength<Length>(style(), m_rootElementStyle, zoomFactor);
- else if (first->isPercentage())
- firstLength = Length(first->getDoubleValue(), Percent);
- else if (first->isCalculatedPercentageWithLength())
- firstLength = Length(first->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor));
- else
- return;
+ Length firstLength;
+ Length secondLength;
- if (!second || second->getIdent() == CSSValueAuto)
+ if (Pair* pair = primitiveValue->getPairValue()) {
+ CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
+ CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
+ firstLength = first->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor);
+ secondLength = second->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor);
+ } else {
+ firstLength = primitiveValue->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor);
secondLength = Length();
- else if (second->isLength())
- secondLength = second->computeLength<Length>(style(), m_rootElementStyle, zoomFactor);
- else if (second->isPercentage())
- secondLength = Length(second->getDoubleValue(), Percent);
- else if (second->isCalculatedPercentageWithLength())
- secondLength = Length(second->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor));
- else
+ }
+
+ if (firstLength.isUndefined() || secondLength.isUndefined())
return;
b.setWidth(firstLength);