Title: [208107] trunk/Source/WebCore
Revision
208107
Author
[email protected]
Date
2016-10-29 10:46:54 -0700 (Sat, 29 Oct 2016)

Log Message

[CSS Parser] Fix transform-origin and perspective-origin to parse as shorthands
https://bugs.webkit.org/show_bug.cgi?id=164178

Reviewed by Zalan Bujtas.

* css/CSSPropertyNames.in:
Patch the transform-origin-x/y and perspective-origin-x/y properties
to use new converters that can handle keywords.

* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertPositionComponentX):
(WebCore::StyleBuilderConverter::convertPositionComponentY):
Add the new converters. They just call convertPositionComponent method
that we already use for object-position and background-position.

* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeTransformOrigin):
(WebCore::CSSPropertyParser::consumePerspectiveOrigin):
Changed to treat the properties as shorthands and add the longhand
properties once parsed.

(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::CSSPropertyParser::parseShorthand):
* css/parser/CSSPropertyParser.h:
Move the parsing into the shorthand method, since we're still treating
these properties as shorthands.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208106 => 208107)


--- trunk/Source/WebCore/ChangeLog	2016-10-29 16:32:53 UTC (rev 208106)
+++ trunk/Source/WebCore/ChangeLog	2016-10-29 17:46:54 UTC (rev 208107)
@@ -1,5 +1,34 @@
 2016-10-29  Dave Hyatt  <[email protected]>
 
+        [CSS Parser] Fix transform-origin and perspective-origin to parse as shorthands
+        https://bugs.webkit.org/show_bug.cgi?id=164178
+
+        Reviewed by Zalan Bujtas.
+
+        * css/CSSPropertyNames.in:
+        Patch the transform-origin-x/y and perspective-origin-x/y properties
+        to use new converters that can handle keywords.
+
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertPositionComponentX):
+        (WebCore::StyleBuilderConverter::convertPositionComponentY):
+        Add the new converters. They just call convertPositionComponent method
+        that we already use for object-position and background-position.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::consumeTransformOrigin):
+        (WebCore::CSSPropertyParser::consumePerspectiveOrigin):
+        Changed to treat the properties as shorthands and add the longhand
+        properties once parsed.
+
+        (WebCore::CSSPropertyParser::parseSingleValue):
+        (WebCore::CSSPropertyParser::parseShorthand):
+        * css/parser/CSSPropertyParser.h:
+        Move the parsing into the shorthand method, since we're still treating
+        these properties as shorthands.
+
+2016-10-29  Dave Hyatt  <[email protected]>
+
         [CSS Parser] Support -webkit-background-composite
         https://bugs.webkit.org/show_bug.cgi?id=164179
 

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (208106 => 208107)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2016-10-29 16:32:53 UTC (rev 208106)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2016-10-29 17:46:54 UTC (rev 208107)
@@ -580,9 +580,9 @@
 -webkit-perspective = perspective
 perspective-origin [Longhands=perspective-origin-x|perspective-origin-y]
 -webkit-perspective-origin = perspective-origin
-perspective-origin-x [Converter=Length]
+perspective-origin-x [Converter=PositionComponentX]
 -webkit-perspective-origin-x = perspective-origin-x
-perspective-origin-y [Converter=Length]
+perspective-origin-y [Converter=PositionComponentY]
 -webkit-perspective-origin-y = perspective-origin-y
 -webkit-print-color-adjust [Inherited]
 -webkit-rtl-ordering [Inherited, Setter=setRTLOrdering, Initial=initialRTLOrdering]
@@ -628,9 +628,9 @@
 -webkit-transform = transform
 transform-origin [Longhands=transform-origin-x|transform-origin-y|transform-origin-z]
 -webkit-transform-origin = transform-origin
-transform-origin-x [Converter=Length]
+transform-origin-x [Converter=PositionComponentX]
 -webkit-transform-origin-x = transform-origin-x
-transform-origin-y [Converter=Length]
+transform-origin-y [Converter=PositionComponentY]
 -webkit-transform-origin-y = transform-origin-y
 transform-origin-z [Converter=ComputedLength<float>]
 -webkit-transform-origin-z = transform-origin-z

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (208106 => 208107)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2016-10-29 16:32:53 UTC (rev 208106)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2016-10-29 17:46:54 UTC (rev 208107)
@@ -147,6 +147,9 @@
     
     static HangingPunctuation convertHangingPunctuation(StyleResolver&, const CSSValue&);
 
+    static Length convertPositionComponentX(StyleResolver&, const CSSValue&);
+    static Length convertPositionComponentY(StyleResolver&, const CSSValue&);
+    
 private:
     friend class StyleBuilderCustom;
 
@@ -323,6 +326,16 @@
     return Length(CalculationValue::create(WTFMove(op), ValueRangeAll));
 }
 
+inline Length StyleBuilderConverter::convertPositionComponentX(StyleResolver& styleResolver, const CSSValue& value)
+{
+    return convertPositionComponent<CSSValueLeft, CSSValueRight>(styleResolver, downcast<CSSPrimitiveValue>(value));
+}
+
+inline Length StyleBuilderConverter::convertPositionComponentY(StyleResolver& styleResolver, const CSSValue& value)
+{
+    return convertPositionComponent<CSSValueTop, CSSValueBottom>(styleResolver, downcast<CSSPrimitiveValue>(value));
+}
+
 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100>
 inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& styleResolver, const CSSPrimitiveValue& value)
 {

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (208106 => 208107)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-10-29 16:32:53 UTC (rev 208106)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-10-29 17:46:54 UTC (rev 208107)
@@ -358,23 +358,35 @@
     return true;
 }
 
-static RefPtr<CSSValueList> consumeTransformOrigin(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
+bool CSSPropertyParser::consumeTransformOrigin(bool important)
 {
     RefPtr<CSSPrimitiveValue> resultX;
     RefPtr<CSSPrimitiveValue> resultY;
-    if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, resultY)) {
-        RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
-        list->append(resultX.releaseNonNull());
-        list->append(resultY.releaseNonNull());
-        RefPtr<CSSPrimitiveValue> resultZ = consumeLength(range, cssParserMode, ValueRangeAll);
+    if (consumeOneOrTwoValuedPosition(m_range, m_context.mode, UnitlessQuirk::Forbid, resultX, resultY)) {
+        RefPtr<CSSPrimitiveValue> resultZ = consumeLength(m_range, m_context.mode, ValueRangeAll);
         if (!resultZ)
-            resultZ = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PX);
-        list->append(resultZ.releaseNonNull());
-        return list;
+            resultZ = CSSValuePool::singleton().createValue(0, CSSPrimitiveValue::UnitTypes::CSS_PX);
+        addProperty(CSSPropertyTransformOriginX, CSSPropertyTransformOrigin, resultX.releaseNonNull(), important);
+        addProperty(CSSPropertyTransformOriginY, CSSPropertyTransformOrigin, resultY.releaseNonNull(), important);
+        addProperty(CSSPropertyTransformOriginZ, CSSPropertyTransformOrigin, resultZ.releaseNonNull(), important);
+        
+        return true;
     }
-    return nullptr;
+    return false;
 }
 
+bool CSSPropertyParser::consumePerspectiveOrigin(bool important)
+{
+    RefPtr<CSSPrimitiveValue> resultX;
+    RefPtr<CSSPrimitiveValue> resultY;
+    if (consumePosition(m_range, m_context.mode, UnitlessQuirk::Forbid, resultX, resultY)) {
+        addProperty(CSSPropertyPerspectiveOriginX, CSSPropertyPerspectiveOrigin, resultX.releaseNonNull(), important);
+        addProperty(CSSPropertyPerspectiveOriginY, CSSPropertyPerspectiveOrigin, resultY.releaseNonNull(), important);
+        return true;
+    }
+    return false;
+}
+
 // Methods for consuming non-shorthand properties starts here.
 static RefPtr<CSSValue> consumeWillChange(CSSParserTokenRange& range)
 {
@@ -3312,7 +3324,6 @@
         return consumeTouchAction(m_range);
 #endif
     case CSSPropertyObjectPosition:
-    case CSSPropertyPerspectiveOrigin:
         return consumePosition(m_range, m_context.mode, UnitlessQuirk::Forbid);
     case CSSPropertyWebkitLineClamp:
         return consumeLineClamp(m_range);
@@ -3475,8 +3486,6 @@
         return consumeRxOrRy(m_range);
     case CSSPropertyCursor:
         return consumeCursor(m_range, m_context, inQuirksMode());
-    case CSSPropertyTransformOrigin:
-        return consumeTransformOrigin(m_range, m_context.mode, UnitlessQuirk::Forbid);
     case CSSPropertyContent:
         return consumeContent(m_range, m_context);
     case CSSPropertyListStyleImage:
@@ -4814,6 +4823,10 @@
         return consumeBackgroundShorthand(backgroundShorthand(), important);
     case CSSPropertyWebkitMask:
         return consumeBackgroundShorthand(webkitMaskShorthand(), important);
+    case CSSPropertyTransformOrigin:
+        return consumeTransformOrigin(important);
+    case CSSPropertyPerspectiveOrigin:
+        return consumePerspectiveOrigin(important);
     case CSSPropertyGridGap: {
         RefPtr<CSSValue> rowGap = consumeLength(m_range, m_context.mode, ValueRangeNonNegative);
         RefPtr<CSSValue> columnGap = consumeLength(m_range, m_context.mode, ValueRangeNonNegative);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.h (208106 => 208107)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2016-10-29 16:32:53 UTC (rev 208106)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2016-10-29 17:46:54 UTC (rev 208107)
@@ -94,6 +94,9 @@
 
     bool consumeLegacyBreakProperty(CSSPropertyID, bool important);
 
+    bool consumeTransformOrigin(bool important);
+    bool consumePerspectiveOrigin(bool important);
+
 private:
     // Inputs:
     CSSParserTokenRange m_range;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to