- Revision
- 110484
- Author
- macpher...@chromium.org
- Date
- 2012-03-12 14:54:35 -0700 (Mon, 12 Mar 2012)
Log Message
Remove CSSStyleSelector's convertToLength method and use CSSPrimitiveValue's version directly.
https://bugs.webkit.org/show_bug.cgi?id=80484
Reviewed by Julien Chaffraix.
No new tests / code cleanup only.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::convertToLength):
* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyClip::convertToLength):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (110483 => 110484)
--- trunk/Source/WebCore/ChangeLog 2012-03-12 21:52:14 UTC (rev 110483)
+++ trunk/Source/WebCore/ChangeLog 2012-03-12 21:54:35 UTC (rev 110484)
@@ -1,3 +1,19 @@
+2012-03-12 Luke Macpherson <macpher...@chromium.org>
+
+ Remove CSSStyleSelector's convertToLength method and use CSSPrimitiveValue's version directly.
+ https://bugs.webkit.org/show_bug.cgi?id=80484
+
+ Reviewed by Julien Chaffraix.
+
+ No new tests / code cleanup only.
+
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::convertToLength):
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::ApplyPropertyClip::convertToLength):
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+
2012-03-12 Stephen White <senorbla...@chromium.org>
[chromium] Restore canvas2D acceleration after context loss.
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (110483 => 110484)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-03-12 21:52:14 UTC (rev 110483)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-03-12 21:54:35 UTC (rev 110484)
@@ -3710,18 +3710,28 @@
}
}
-enum LengthConversion { UnsupportedConversion = 0, FixedConversion = 1, AutoConversion = 2, PercentConversion = 4, FractionConversion = 8};
+enum LengthConversion {
+ FixedIntegerConversion = 1 << 0,
+ FixedFloatConversion = 1 << 1,
+ AutoConversion = 1 << 2,
+ PercentConversion = 1 << 3,
+ FractionConversion = 1 << 4
+};
+
template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
{
- if ((supported & FixedConversion) && isLength())
+ if (((supported & FixedIntegerConversion) || (supported & FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
+ return Length(Undefined);
+ if ((supported & FixedIntegerConversion) && isLength())
return computeLength<Length>(style, rootStyle, multiplier, computingFontSize);
+ if ((supported & FixedFloatConversion) && isLength())
+ return Length(computeLength<double>(style, rootStyle, multiplier), Fixed);
if ((supported & PercentConversion) && isPercentage())
return Length(getDoubleValue(), Percent);
if ((supported & FractionConversion) && isNumber())
return Length(getDoubleValue() * 100.0, Percent);
if ((supported & AutoConversion) && getIdent() == CSSValueAuto)
return Length(Auto);
- ASSERT_NOT_REACHED();
return Length(Undefined);
}
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (110483 => 110484)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-03-12 21:52:14 UTC (rev 110483)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-03-12 21:54:35 UTC (rev 110484)
@@ -221,7 +221,7 @@
private:
static Length convertToLength(CSSStyleSelector* selector, CSSPrimitiveValue* value)
{
- return value->convertToLength<FixedConversion | PercentConversion | FractionConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
+ return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
}
public:
static void applyInheritValue(CSSStyleSelector* selector)
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (110483 => 110484)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-12 21:52:14 UTC (rev 110483)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-12 21:54:35 UTC (rev 110484)
@@ -2528,40 +2528,14 @@
// -------------------------------------------------------------------------------------
// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
-static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, bool toFloat, double multiplier = 1)
-{
- // This function is tolerant of a null style value. The only place style is used is in
- // length measurements, like 'ems' and 'px'. And in those cases style is only used
- // when the units are EMS or EXS. So we will just fail in those cases.
- Length l;
- if (!primitiveValue) {
- l = Length(Undefined);
- } else {
- if (!style && primitiveValue->isFontRelativeLength()) {
- l = Length(Undefined);
- } else if (primitiveValue->isLength()) {
- if (toFloat)
- l = Length(primitiveValue->computeLength<double>(style, rootStyle, multiplier), Fixed);
- else
- l = primitiveValue->computeLength<Length>(style, rootStyle, multiplier);
- } else if (primitiveValue->isPercentage())
- l = Length(primitiveValue->getDoubleValue(), Percent);
- else if (primitiveValue->isNumber())
- l = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
- else
- l = Length(Undefined);
- }
- return l;
-}
-
Length CSSStyleSelector::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
{
- return convertToLength(primitiveValue, style, rootStyle, false, multiplier);
+ return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
}
Length CSSStyleSelector::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
{
- return convertToLength(primitiveValue, style, rootStyle, true, multiplier);
+ return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
}
template <bool applyFirst>
@@ -3490,7 +3464,7 @@
break;
}
} else {
- Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, 1);
+ Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle);
if (!marqueeLength.isUndefined())
m_style->setMarqueeIncrement(marqueeLength);
}