Title: [207556] trunk/Source/WebCore
Revision
207556
Author
hy...@apple.com
Date
2016-10-19 12:19:27 -0700 (Wed, 19 Oct 2016)

Log Message

[CSS Parser] Fix background-position parsing
https://bugs.webkit.org/show_bug.cgi?id=163681

Reviewed by Dean Jackson.

The new parser has a more efficient parsed representation of background positions. When
background-position is "center" or when no length unit is specified for a dimension,
then rather than creating a pair, the new parser makes a singleton primitive value.

Patch the StyleBuilder code to handle this case, resolving center to (left,50%) or
(top,50%) as appropriate and also handling top/left without any associated length.

* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207555 => 207556)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 19:07:28 UTC (rev 207555)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 19:19:27 UTC (rev 207556)
@@ -1,3 +1,21 @@
+2016-10-19  Dave Hyatt  <hy...@apple.com>
+
+        [CSS Parser] Fix background-position parsing
+        https://bugs.webkit.org/show_bug.cgi?id=163681
+
+        Reviewed by Dean Jackson.
+
+        The new parser has a more efficient parsed representation of background positions. When
+        background-position is "center" or when no length unit is specified for a dimension,
+        then rather than creating a pair, the new parser makes a singleton primitive value.
+
+        Patch the StyleBuilder code to handle this case, resolving center to (left,50%) or
+        (top,50%) as appropriate and also handling top/left without any associated length.
+
+        * css/CSSToStyleMap.cpp:
+        (WebCore::CSSToStyleMap::mapFillXPosition):
+        (WebCore::CSSToStyleMap::mapFillYPosition):
+
 2016-10-19  Antoine Quint  <grao...@apple.com>
 
         [Modern Media Controls] Media Controller: click-to-start support

Modified: trunk/Source/WebCore/css/CSSToStyleMap.cpp (207555 => 207556)


--- trunk/Source/WebCore/css/CSSToStyleMap.cpp	2016-10-19 19:07:28 UTC (rev 207555)
+++ trunk/Source/WebCore/css/CSSToStyleMap.cpp	2016-10-19 19:19:27 UTC (rev 207556)
@@ -238,6 +238,15 @@
     if (pair) {
         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX || propertyID == CSSPropertyWebkitMaskPositionX);
         primitiveValue = pair->second();
+    } else if (primitiveValue->isValueID()) {
+        if (primitiveValue->valueID() == CSSValueCenter) {
+            layer.setBackgroundXOrigin(Edge::Left);
+            layer.setXPosition(Length(50, Percent));
+        } else {
+            layer.setBackgroundXOrigin(*primitiveValue);
+            layer.setXPosition(Length());
+        }
+        return;
     }
 
     Length length;
@@ -270,6 +279,15 @@
     if (pair) {
         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
         primitiveValue = pair->second();
+    } else if (primitiveValue->isValueID()) {
+        if (primitiveValue->valueID() == CSSValueCenter) {
+            layer.setBackgroundYOrigin(Edge::Top);
+            layer.setYPosition(Length(50, Percent));
+        } else {
+            layer.setBackgroundYOrigin(*primitiveValue);
+            layer.setYPosition(Length());
+        }
+        return;
     }
 
     Length length;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to