Title: [101237] trunk/Source/WebCore
Revision
101237
Author
macpher...@chromium.org
Date
2011-11-28 02:02:46 -0800 (Mon, 28 Nov 2011)

Log Message

Implement CSS hyphenate-limit properties in CSSStyleApplyProperty
https://bugs.webkit.org/show_bug.cgi?id=73107

Reviewed by Andreas Kling.

Covered by existing tests under fast/css (parsing-hyphenate-limit-lines.html, parsing-hyphenate-limit.html, text/hyphenate-limit-lines.html)

* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyNumber::setValue):
(WebCore::ApplyPropertyNumber::applyValue):
(WebCore::ApplyPropertyNumber::createHandler):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101236 => 101237)


--- trunk/Source/WebCore/ChangeLog	2011-11-28 10:00:41 UTC (rev 101236)
+++ trunk/Source/WebCore/ChangeLog	2011-11-28 10:02:46 UTC (rev 101237)
@@ -1,3 +1,20 @@
+2011-11-28  Luke Macpherson   <macpher...@chromium.org>
+
+        Implement CSS hyphenate-limit properties in CSSStyleApplyProperty
+        https://bugs.webkit.org/show_bug.cgi?id=73107
+
+        Reviewed by Andreas Kling.
+
+        Covered by existing tests under fast/css (parsing-hyphenate-limit-lines.html, parsing-hyphenate-limit.html, text/hyphenate-limit-lines.html)
+
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::ApplyPropertyNumber::setValue):
+        (WebCore::ApplyPropertyNumber::applyValue):
+        (WebCore::ApplyPropertyNumber::createHandler):
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+
 2011-11-28  Taiju TSUIKI  <t...@chromium.org>
 
         [Inspector][FileSystem]: Capture DOMFileSystem object.

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (101236 => 101237)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-28 10:00:41 UTC (rev 101236)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-28 10:02:46 UTC (rev 101237)
@@ -141,6 +141,28 @@
     }
 };
 
+template <typename NumberType, NumberType (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(NumberType), NumberType (*initialFunction)(), int idMapsToMinusOne = CSSValueAuto>
+class ApplyPropertyNumber {
+public:
+    static void setValue(RenderStyle* style, NumberType value) { (style->*setterFunction)(value); }
+    static void applyValue(CSSStyleSelector* selector, CSSValue* value)
+    {
+        if (!value->isPrimitiveValue())
+            return;
+
+        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+        if (primitiveValue->getIdent() == idMapsToMinusOne)
+            setValue(selector->style(), -1);
+        else
+            setValue(selector->style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER));
+    }
+    static PropertyHandler createHandler()
+    {
+        PropertyHandler handler = ApplyPropertyDefaultBase<NumberType, getterFunction, NumberType, setterFunction, NumberType, initialFunction>::createHandler();
+        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+    }
+};
+
 template <StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)(), CSSPropertyID property>
 class ApplyPropertyStyleImage {
 public:
@@ -1153,6 +1175,10 @@
     setPropertyHandler(CSSPropertyWebkitHighlight, ApplyPropertyString<MapNoneToNull, &RenderStyle::highlight, &RenderStyle::setHighlight, &RenderStyle::initialHighlight>::createHandler());
     setPropertyHandler(CSSPropertyWebkitHyphenateCharacter, ApplyPropertyString<MapAutoToNull, &RenderStyle::hyphenationString, &RenderStyle::setHyphenationString, &RenderStyle::initialHyphenationString>::createHandler());
 
+    setPropertyHandler(CSSPropertyWebkitHyphenateLimitAfter, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitAfter, &RenderStyle::setHyphenationLimitAfter, &RenderStyle::initialHyphenationLimitAfter>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitHyphenateLimitBefore, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitBefore, &RenderStyle::setHyphenationLimitBefore, &RenderStyle::initialHyphenationLimitBefore>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitHyphenateLimitLines, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitLines, &RenderStyle::setHyphenationLimitLines, &RenderStyle::initialHyphenationLimitLines, CSSValueNoLimit>::createHandler());
+
     setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyDefault<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (101236 => 101237)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-28 10:00:41 UTC (rev 101236)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-28 10:02:46 UTC (rev 101237)
@@ -3524,30 +3524,6 @@
     case CSSPropertyWebkitHyphens:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(hyphens, Hyphens);
         return;
-    case CSSPropertyWebkitHyphenateLimitAfter: {
-        HANDLE_INHERIT_AND_INITIAL(hyphenationLimitAfter, HyphenationLimitAfter);
-        if (primitiveValue->getIdent() == CSSValueAuto)
-            m_style->setHyphenationLimitAfter(-1);
-        else
-            m_style->setHyphenationLimitAfter(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER));
-        return;
-    }
-    case CSSPropertyWebkitHyphenateLimitBefore: {
-        HANDLE_INHERIT_AND_INITIAL(hyphenationLimitBefore, HyphenationLimitBefore);
-        if (primitiveValue->getIdent() == CSSValueAuto)
-            m_style->setHyphenationLimitBefore(-1);
-        else
-            m_style->setHyphenationLimitBefore(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER));
-        return;
-    }
-    case CSSPropertyWebkitHyphenateLimitLines: {
-        HANDLE_INHERIT_AND_INITIAL(hyphenationLimitLines, HyphenationLimitLines);
-        if (primitiveValue->getIdent() == CSSValueNoLimit)
-            m_style->setHyphenationLimitLines(-1);
-        else
-            m_style->setHyphenationLimitLines(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER));
-        return;
-    }
     case CSSPropertyWebkitLocale: {
         HANDLE_INHERIT_AND_INITIAL(locale, Locale);
         if (primitiveValue->getIdent() == CSSValueAuto)
@@ -4003,6 +3979,9 @@
     case CSSPropertyWebkitFlowFrom:
     case CSSPropertyWebkitHighlight:
     case CSSPropertyWebkitHyphenateCharacter:
+    case CSSPropertyWebkitHyphenateLimitAfter:
+    case CSSPropertyWebkitHyphenateLimitBefore:
+    case CSSPropertyWebkitHyphenateLimitLines:
     case CSSPropertyWebkitTextCombine:
     case CSSPropertyWebkitTextEmphasisPosition:
     case CSSPropertyWebkitTextEmphasisStyle:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to