Title: [176111] trunk/Source/WebCore
Revision
176111
Author
[email protected]
Date
2014-11-13 18:16:19 -0800 (Thu, 13 Nov 2014)

Log Message

Move 'image-resolution' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138715

Reviewed by Andreas Kling.

Move 'image-resolution' CSS property from DeprecatedStyleBuilder to
the new StyleBuilder by using custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyImageResolution::applyInheritValue): Deleted.
(WebCore::ApplyPropertyImageResolution::applyInitialValue): Deleted.
(WebCore::ApplyPropertyImageResolution::applyValue): Deleted.
(WebCore::ApplyPropertyImageResolution::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderFunctions::applyInheritImageResolution):
(WebCore::StyleBuilderFunctions::applyInitialImageResolution):
(WebCore::StyleBuilderFunctions::applyValueImageResolution):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176110 => 176111)


--- trunk/Source/WebCore/ChangeLog	2014-11-14 01:15:34 UTC (rev 176110)
+++ trunk/Source/WebCore/ChangeLog	2014-11-14 02:16:19 UTC (rev 176111)
@@ -1,3 +1,27 @@
+2014-11-13  Chris Dumez  <[email protected]>
+
+        Move 'image-resolution' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138715
+
+        Reviewed by Andreas Kling.
+
+        Move 'image-resolution' CSS property from DeprecatedStyleBuilder to
+        the new StyleBuilder by using custom code.
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyImageResolution::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyImageResolution::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyImageResolution::applyValue): Deleted.
+        (WebCore::ApplyPropertyImageResolution::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderFunctions::applyInheritImageResolution):
+        (WebCore::StyleBuilderFunctions::applyInitialImageResolution):
+        (WebCore::StyleBuilderFunctions::applyValueImageResolution):
+
 2014-11-13  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r176106.

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (176110 => 176111)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-14 01:15:34 UTC (rev 176110)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-14 02:16:19 UTC (rev 176111)
@@ -172,7 +172,7 @@
 #endif
 image-rendering [Inherited, NewStyleBuilder]
 #if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION
-image-resolution [Inherited]
+image-resolution [Inherited, NewStyleBuilder, Custom=All]
 #endif
 left [NewStyleBuilder, Initial=initialOffset, Converter=LengthOrAuto]
 letter-spacing [Inherited, NewStyleBuilder, Converter=Spacing]

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (176110 => 176111)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-14 01:15:34 UTC (rev 176110)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-14 02:16:19 UTC (rev 176111)
@@ -1388,55 +1388,6 @@
     }
 };
 
-#if ENABLE(CSS_IMAGE_RESOLUTION)
-class ApplyPropertyImageResolution {
-public:
-    static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
-    {
-        ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(propertyID, styleResolver);
-        ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInheritValue(propertyID, styleResolver);
-        ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(propertyID, styleResolver);
-    }
-
-    static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
-    {
-        ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(propertyID, styleResolver);
-        ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInitialValue(propertyID, styleResolver);
-        ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(propertyID, styleResolver);
-    }
-
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSValueList>(*value))
-            return;
-        CSSValueList& valueList = downcast<CSSValueList>(*value);
-        ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
-        ImageResolutionSnap snap = RenderStyle::initialImageResolutionSnap();
-        double resolution = RenderStyle::initialImageResolution();
-        for (size_t i = 0; i < valueList.length(); ++i) {
-            CSSValue& item = *valueList.itemWithoutBoundsCheck(i);
-            if (!is<CSSPrimitiveValue>(item))
-                continue;
-            CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(item);
-            if (primitiveValue.getValueID() == CSSValueFromImage)
-                source = ImageResolutionFromImage;
-            else if (primitiveValue.getValueID() == CSSValueSnap)
-                snap = ImageResolutionSnapPixels;
-            else
-                resolution = primitiveValue.getDoubleValue(CSSPrimitiveValue::CSS_DPPX);
-        }
-        styleResolver->style()->setImageResolutionSource(source);
-        styleResolver->style()->setImageResolutionSnap(snap);
-        styleResolver->style()->setImageResolution(resolution);
-    }
-
-    static PropertyHandler createHandler()
-    {
-        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
-    }
-};
-#endif
-
 const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
 {
     static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
@@ -1475,9 +1426,6 @@
     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
     setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
-#if ENABLE(CSS_IMAGE_RESOLUTION)
-    setPropertyHandler(CSSPropertyImageResolution, ApplyPropertyImageResolution::createHandler());
-#endif
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeightForIOSTextAutosizing::createHandler());
 #else

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (176110 => 176111)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-14 01:15:34 UTC (rev 176110)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-14 02:16:19 UTC (rev 176111)
@@ -233,6 +233,41 @@
     return true;
 }
 
+#if ENABLE(CSS_IMAGE_RESOLUTION)
+inline void applyInheritImageResolution(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setImageResolutionSource(styleResolver.parentStyle()->imageResolutionSource());
+    styleResolver.style()->setImageResolutionSnap(styleResolver.parentStyle()->imageResolutionSnap());
+    styleResolver.style()->setImageResolution(styleResolver.parentStyle()->imageResolution());
+}
+
+inline void applyInitialImageResolution(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setImageResolutionSource(RenderStyle::initialImageResolutionSource());
+    styleResolver.style()->setImageResolutionSnap(RenderStyle::initialImageResolutionSnap());
+    styleResolver.style()->setImageResolution(RenderStyle::initialImageResolution());
+}
+
+inline void applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value)
+{
+    ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
+    ImageResolutionSnap snap = RenderStyle::initialImageResolutionSnap();
+    double resolution = RenderStyle::initialImageResolution();
+    for (auto& item : downcast<CSSValueList>(value)) {
+        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(item.get());
+        if (primitiveValue.getValueID() == CSSValueFromImage)
+            source = ImageResolutionFromImage;
+        else if (primitiveValue.getValueID() == CSSValueSnap)
+            snap = ImageResolutionSnapPixels;
+        else
+            resolution = primitiveValue.getDoubleValue(CSSPrimitiveValue::CSS_DPPX);
+    }
+    styleResolver.style()->setImageResolutionSource(source);
+    styleResolver.style()->setImageResolutionSnap(snap);
+    styleResolver.style()->setImageResolution(resolution);
+}
+#endif // ENABLE(CSS_IMAGE_RESOLUTION)
+
 inline void applyInheritSize(StyleResolver&) { }
 inline void applyInitialSize(StyleResolver&) { }
 inline void applyValueSize(StyleResolver& styleResolver, CSSValue& value)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to