Title: [175439] trunk
Revision
175439
Author
[email protected]
Date
2014-10-31 16:46:20 -0700 (Fri, 31 Oct 2014)

Log Message

Move -webkit-marquee-increment property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138208

Reviewed by Andreas Kling.

Move -webkit-marquee-increment property from DeprecatedStyleBuilder to
the new StyleBuilder so that it is generated from CSSPropertyNames.in.
Custom code is used to set the value due to the !length.isUndefined()
check before calling setMarqueeIncrement().

Test: fast/css/webkit-marquee-increment-bad-value.html

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyLength::setValue): Deleted.
(WebCore::ApplyPropertyLength::applyValue): Deleted.
(WebCore::ApplyPropertyLength::createHandler): Deleted.
(WebCore::ApplyPropertyMarqueeIncrement::applyValue): Deleted.
(WebCore::ApplyPropertyMarqueeIncrement::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderFunctions::applyValueWebkitMarqueeIncrement):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value-expected.txt (0 => 175439)


--- trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value-expected.txt	2014-10-31 23:46:20 UTC (rev 175439)
@@ -0,0 +1,12 @@
+Makes sure we don't crash in the StyleBuilder if bad values are used for -webkit-marquee-increment property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS No crash for 1px 2px value
+PASS No crash for url("resources/border-image.png") value
+PASS No crash for copy value
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value.html (0 => 175439)


--- trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/webkit-marquee-increment-bad-value.html	2014-10-31 23:46:20 UTC (rev 175439)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src=""
+<marquee id="myMarquee"></marquee>
+
+<script>
+description("Makes sure we don't crash in the StyleBuilder if bad values are used for -webkit-marquee-increment property.");
+
+var badValues = [
+    "1px 2px", // a list.
+    "url(\"resources/border-image.png\")", // an image url.
+    "copy", // a cursor.
+];
+
+var testElement = document.getElementById("myMarquee");
+for (var i = 0; i < badValues.length; ++i) {
+    testElement.style["-webkit-marquee-increment"] = badValues[i];
+    document.defaultView.getComputedStyle(testElement)["-webkit-marquee-increment"];
+    testPassed("No crash for " + badValues[i] + " value");
+}
+</script>
+<script src=""

Modified: trunk/Source/WebCore/ChangeLog (175438 => 175439)


--- trunk/Source/WebCore/ChangeLog	2014-10-31 23:38:12 UTC (rev 175438)
+++ trunk/Source/WebCore/ChangeLog	2014-10-31 23:46:20 UTC (rev 175439)
@@ -1,3 +1,28 @@
+2014-10-31  Chris Dumez  <[email protected]>
+
+        Move -webkit-marquee-increment property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138208
+
+        Reviewed by Andreas Kling.
+
+        Move -webkit-marquee-increment property from DeprecatedStyleBuilder to
+        the new StyleBuilder so that it is generated from CSSPropertyNames.in.
+        Custom code is used to set the value due to the !length.isUndefined()
+        check before calling setMarqueeIncrement().
+
+        Test: fast/css/webkit-marquee-increment-bad-value.html
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyLength::setValue): Deleted.
+        (WebCore::ApplyPropertyLength::applyValue): Deleted.
+        (WebCore::ApplyPropertyLength::createHandler): Deleted.
+        (WebCore::ApplyPropertyMarqueeIncrement::applyValue): Deleted.
+        (WebCore::ApplyPropertyMarqueeIncrement::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderFunctions::applyValueWebkitMarqueeIncrement):
+
 2014-10-31  Simon Fraser  <[email protected]>
 
         Brace cleanup in StyleResolver::adjustRenderStyle()

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (175438 => 175439)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-10-31 23:38:12 UTC (rev 175438)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-10-31 23:46:20 UTC (rev 175439)
@@ -413,7 +413,7 @@
 -webkit-margin-start
 -webkit-marquee
 -webkit-marquee-direction [NewStyleBuilder]
--webkit-marquee-increment
+-webkit-marquee-increment [NewStyleBuilder, Custom=Value]
 -webkit-marquee-repetition
 -webkit-marquee-speed
 -webkit-marquee-style [NewStyleBuilder, TypeName=EMarqueeBehavior, NameForMethods=MarqueeBehavior]

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (175438 => 175439)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-31 23:38:12 UTC (rev 175438)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-31 23:46:20 UTC (rev 175439)
@@ -320,73 +320,6 @@
     }
 };
 
-enum LengthAuto { AutoDisabled = 0, AutoEnabled };
-enum LengthLegacyIntrinsic { LegacyIntrinsicDisabled = 0, LegacyIntrinsicEnabled };
-enum LengthIntrinsic { IntrinsicDisabled = 0, IntrinsicEnabled };
-enum LengthNone { NoneDisabled = 0, NoneEnabled };
-enum LengthUndefined { UndefinedDisabled = 0, UndefinedEnabled };
-template <const Length& (RenderStyle::*getterFunction)() const,
-          void (RenderStyle::*setterFunction)(Length),
-          Length (*initialFunction)(),
-          LengthAuto autoEnabled = AutoDisabled,
-          LengthLegacyIntrinsic legacyIntrinsicEnabled = LegacyIntrinsicDisabled,
-          LengthIntrinsic intrinsicEnabled = IntrinsicDisabled,
-          LengthNone noneEnabled = NoneDisabled,
-          LengthUndefined noneUndefined = UndefinedDisabled>
-class ApplyPropertyLength {
-public:
-    static void setValue(RenderStyle* style, Length value) { (style->*setterFunction)(WTF::move(value)); }
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        if (noneEnabled && primitiveValue.getValueID() == CSSValueNone) {
-            if (noneUndefined)
-                setValue(styleResolver->style(), Length(Undefined));
-            else
-                setValue(styleResolver->style(), Length());
-        }
-        if (legacyIntrinsicEnabled) {
-            if (primitiveValue.getValueID() == CSSValueIntrinsic)
-                setValue(styleResolver->style(), Length(Intrinsic));
-            else if (primitiveValue.getValueID() == CSSValueMinIntrinsic)
-                setValue(styleResolver->style(), Length(MinIntrinsic));
-        }
-        if (intrinsicEnabled) {
-            if (primitiveValue.getValueID() == CSSValueWebkitMinContent)
-                setValue(styleResolver->style(), Length(MinContent));
-            else if (primitiveValue.getValueID() == CSSValueWebkitMaxContent)
-                setValue(styleResolver->style(), Length(MaxContent));
-            else if (primitiveValue.getValueID() == CSSValueWebkitFillAvailable)
-                setValue(styleResolver->style(), Length(FillAvailable));
-            else if (primitiveValue.getValueID() == CSSValueWebkitFitContent)
-                setValue(styleResolver->style(), Length(FitContent));
-        }
-
-        CSSToLengthConversionData conversionData = styleResolver->useSVGZoomRulesForLength() ?
-            styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
-            : styleResolver->state().cssToLengthConversionData();
-        if (autoEnabled && primitiveValue.getValueID() == CSSValueAuto)
-            setValue(styleResolver->style(), Length());
-        else if (primitiveValue.isLength()) {
-            Length length = primitiveValue.computeLength<Length>(conversionData);
-            length.setHasQuirk(primitiveValue.isQuirkValue());
-            setValue(styleResolver->style(), length);
-        } else if (primitiveValue.isPercentage())
-            setValue(styleResolver->style(), Length(primitiveValue.getDoubleValue(), Percent));
-        else if (primitiveValue.isCalculatedPercentageWithLength())
-            setValue(styleResolver->style(), Length(primitiveValue.cssCalcValue()->createCalculationValue(conversionData)));
-    }
-
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, getterFunction, Length, setterFunction, Length, initialFunction>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
 enum StringIdentBehavior { NothingMapsToNull = 0, MapNoneToNull, MapAutoToNull };
 template <StringIdentBehavior identBehavior, const AtomicString& (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(const AtomicString&), const AtomicString& (*initialFunction)()>
 class ApplyPropertyString {
@@ -1162,41 +1095,6 @@
     }
 };
 
-class ApplyPropertyMarqueeIncrement {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        Length marqueeLength(Undefined);
-        switch (primitiveValue.getValueID()) {
-        case CSSValueSmall:
-            marqueeLength = Length(1, Fixed); // 1px.
-            break;
-        case CSSValueNormal:
-            marqueeLength = Length(6, Fixed); // 6px. The WinIE default.
-            break;
-        case CSSValueLarge:
-            marqueeLength = Length(36, Fixed); // 36px.
-            break;
-        case CSSValueInvalid:
-            marqueeLength = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
-            break;
-        default:
-            break;
-        }
-        if (!marqueeLength.isUndefined())
-            styleResolver->style()->setMarqueeIncrement(marqueeLength);
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyLength<&RenderStyle::marqueeIncrement, &RenderStyle::setMarqueeIncrement, &RenderStyle::initialMarqueeIncrement>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
 class ApplyPropertyMarqueeRepetition {
 public:
     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
@@ -2245,7 +2143,6 @@
     setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
     setPropertyHandler(CSSPropertyWebkitHyphenateCharacter, ApplyPropertyString<MapAutoToNull, &RenderStyle::hyphenationString, &RenderStyle::setHyphenationString, &RenderStyle::initialHyphenationString>::createHandler());
     setPropertyHandler(CSSPropertyWebkitLineGrid, ApplyPropertyString<MapNoneToNull, &RenderStyle::lineGrid, &RenderStyle::setLineGrid, &RenderStyle::initialLineGrid>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitMarqueeIncrement, ApplyPropertyMarqueeIncrement::createHandler());
     setPropertyHandler(CSSPropertyWebkitMarqueeRepetition, ApplyPropertyMarqueeRepetition::createHandler());
     setPropertyHandler(CSSPropertyWebkitMarqueeSpeed, ApplyPropertyMarqueeSpeed::createHandler());
     setPropertyHandler(CSSPropertyWebkitMaskBoxImageOutset, ApplyPropertyBorderImageModifier<BorderMask, Outset>::createHandler());

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (175438 => 175439)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-10-31 23:38:12 UTC (rev 175438)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-10-31 23:46:20 UTC (rev 175439)
@@ -42,6 +42,30 @@
     styleResolver.style()->setHyphenationLimitLines(number);
 }
 
+inline void applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    Length marqueeLength(Undefined);
+    switch (primitiveValue.getValueID()) {
+    case CSSValueSmall:
+        marqueeLength = Length(1, Fixed); // 1px.
+        break;
+    case CSSValueNormal:
+        marqueeLength = Length(6, Fixed); // 6px. The WinIE default.
+        break;
+    case CSSValueLarge:
+        marqueeLength = Length(36, Fixed); // 36px.
+        break;
+    case CSSValueInvalid:
+        marqueeLength = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
+        break;
+    default:
+        break;
+    }
+    if (!marqueeLength.isUndefined())
+        styleResolver.style()->setMarqueeIncrement(marqueeLength);
+}
+
 } // namespace StyleBuilderFunctions
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to