Diff
Modified: trunk/Source/WebCore/ChangeLog (178511 => 178512)
--- trunk/Source/WebCore/ChangeLog 2015-01-15 16:45:12 UTC (rev 178511)
+++ trunk/Source/WebCore/ChangeLog 2015-01-15 17:20:44 UTC (rev 178512)
@@ -1,3 +1,20 @@
+2015-01-15 Chris Dumez <[email protected]>
+
+ Get rid of custom StyleBuilder code for 'line-height' CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=140462
+
+ Reviewed by Antti Koivisto.
+
+ Get rid of custom StyleBuilder code for 'line-height' CSS property by
+ using a conditional converter.
+
+ * css/CSSPropertyNames.in:
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::convertLineHeight):
+ * css/StyleBuilderCustom.h:
+ (WebCore::StyleBuilderCustom::applyValueLineHeight):
+ (WebCore::StyleBuilderCustom::convertLineHeight): Deleted.
+
2015-01-15 Antti Koivisto <[email protected]>
Rename Font to FontCascade
Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (178511 => 178512)
--- trunk/Source/WebCore/css/CSSPropertyNames.in 2015-01-15 16:45:12 UTC (rev 178511)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in 2015-01-15 17:20:44 UTC (rev 178512)
@@ -121,7 +121,7 @@
#if defined(ENABLE_IOS_TEXT_AUTOSIZING) && ENABLE_IOS_TEXT_AUTOSIZING
line-height [Inherited, Custom=All]
#else
-line-height [Inherited, Getter=specifiedLineHeight, Custom=Value]
+line-height [Inherited, Getter=specifiedLineHeight, ConditionalConverter=LineHeight]
#endif
// Keep this in between the highest priority props and the lower ones.
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (178511 => 178512)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2015-01-15 16:45:12 UTC (rev 178511)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2015-01-15 17:20:44 UTC (rev 178512)
@@ -123,6 +123,7 @@
static Color convertSVGColor(StyleResolver&, CSSValue&);
static EGlyphOrientation convertGlyphOrientation(StyleResolver&, CSSValue&);
static EGlyphOrientation convertGlyphOrientationOrAuto(StyleResolver&, CSSValue&);
+ static Optional<Length> convertLineHeight(StyleResolver&, CSSValue&, float multiplier = 1.f);
private:
friend class StyleBuilderCustom;
@@ -1211,6 +1212,29 @@
return convertGlyphOrientation(styleResolver, value);
}
+inline Optional<Length> StyleBuilderConverter::convertLineHeight(StyleResolver& styleResolver, CSSValue& value, float multiplier)
+{
+ auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+ if (primitiveValue.getValueID() == CSSValueNormal)
+ return RenderStyle::initialLineHeight();
+
+ if (primitiveValue.isLength()) {
+ Length length = primitiveValue.computeLength<Length>(StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(styleResolver));
+ if (multiplier != 1.f)
+ length = Length(length.value() * multiplier, Fixed);
+ return length;
+ }
+ if (primitiveValue.isPercentage()) {
+ // FIXME: percentage should not be restricted to an integer here.
+ return Length((styleResolver.style()->computedFontSize() * primitiveValue.getIntValue()) / 100, Fixed);
+ }
+ if (primitiveValue.isNumber()) {
+ // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
+ return Length(primitiveValue.getDoubleValue() * multiplier * 100.0, Percent);
+ }
+ return Nullopt;
+}
+
} // namespace WebCore
#endif // StyleBuilderConverter_h
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (178511 => 178512)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2015-01-15 16:45:12 UTC (rev 178511)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2015-01-15 17:20:44 UTC (rev 178512)
@@ -116,9 +116,6 @@
// Custom handling of value setting only.
static void applyValueBaselineShift(StyleResolver&, CSSValue&);
static void applyValueDirection(StyleResolver&, CSSValue&);
-#if !ENABLE(IOS_TEXT_AUTOSIZING)
- static void applyValueLineHeight(StyleResolver&, CSSValue&);
-#endif
static void applyValueVerticalAlign(StyleResolver&, CSSValue&);
#if ENABLE(DASHBOARD_SUPPORT)
static void applyValueWebkitDashboardRegion(StyleResolver&, CSSValue&);
@@ -134,7 +131,6 @@
private:
static void resetEffectiveZoom(StyleResolver&);
- static bool convertLineHeight(StyleResolver&, const CSSValue&, Length&, float multiplier = 1.f);
static Length mmLength(double mm);
static Length inchLength(double inch);
@@ -606,32 +602,6 @@
DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Slice)
DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width)
-inline bool StyleBuilderCustom::convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier)
-{
- auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
- if (primitiveValue.getValueID() == CSSValueNormal) {
- length = RenderStyle::initialLineHeight();
- return true;
- }
- if (primitiveValue.isLength()) {
- length = primitiveValue.computeLength<Length>(StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(styleResolver));
- if (multiplier != 1.f)
- length = Length(length.value() * multiplier, Fixed);
- return true;
- }
- if (primitiveValue.isPercentage()) {
- // FIXME: percentage should not be restricted to an integer here.
- length = Length((styleResolver.style()->computedFontSize() * primitiveValue.getIntValue()) / 100, Fixed);
- return true;
- }
- if (primitiveValue.isNumber()) {
- // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
- length = Length(primitiveValue.getDoubleValue() * multiplier * 100.0, Percent);
- return true;
- }
- return false;
-}
-
#if ENABLE(IOS_TEXT_AUTOSIZING)
inline void StyleBuilderCustom::applyInheritLineHeight(StyleResolver& styleResolver)
@@ -648,26 +618,15 @@
inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
{
- Length lineHeight;
float multiplier = styleResolver.style()->textSizeAdjust().isPercentage() ? styleResolver.style()->textSizeAdjust().multiplier() : 1.f;
- if (!convertLineHeight(styleResolver, value, lineHeight, multiplier))
+ Optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier);
+ if (!lineHeight)
return;
- styleResolver.style()->setLineHeight(lineHeight);
- styleResolver.style()->setSpecifiedLineHeight(lineHeight);
+ styleResolver.style()->setLineHeight(lineHeight.value());
+ styleResolver.style()->setSpecifiedLineHeight(lineHeight.value());
}
-#else
-
-inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
-{
- Length lineHeight;
- if (!convertLineHeight(styleResolver, value, lineHeight))
- return;
-
- styleResolver.style()->setLineHeight(lineHeight);
-}
-
#endif
inline void StyleBuilderCustom::applyInheritOutlineStyle(StyleResolver& styleResolver)