Title: [271948] trunk
Revision
271948
Author
[email protected]
Date
2021-01-27 06:13:56 -0800 (Wed, 27 Jan 2021)

Log Message

Handle zero aspect-ratio width/height
https://bugs.webkit.org/show_bug.cgi?id=220970

Patch by Rob Buis <[email protected]> on 2021-01-27
Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

Treat aspect-ratio with zero width and/or height internally
as auto, but when serializing maintain the original input.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* rendering/style/RenderStyleConstants.cpp:
(WebCore::operator<<):
* rendering/style/RenderStyleConstants.h:
* style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueAspectRatio):

LayoutTests:

Enable some tests that pass now.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271947 => 271948)


--- trunk/LayoutTests/ChangeLog	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/LayoutTests/ChangeLog	2021-01-27 14:13:56 UTC (rev 271948)
@@ -1,3 +1,14 @@
+2021-01-27  Rob Buis  <[email protected]>
+
+        Handle zero aspect-ratio width/height
+        https://bugs.webkit.org/show_bug.cgi?id=220970
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Enable some tests that pass now.
+
+        * TestExpectations:
+
 2021-01-27  Manuel Rego Casasnovas  <[email protected]>
 
         Upstream to WPT Shadow DOM tests related to :focus pseudo-class

Modified: trunk/LayoutTests/TestExpectations (271947 => 271948)


--- trunk/LayoutTests/TestExpectations	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/LayoutTests/TestExpectations	2021-01-27 14:13:56 UTC (rev 271948)
@@ -4458,14 +4458,6 @@
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/table-element-001.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-001.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-002.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-004.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-006.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-007.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-008.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-009.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/zero-or-infinity-010.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-003.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (271947 => 271948)


--- trunk/Source/WebCore/ChangeLog	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/Source/WebCore/ChangeLog	2021-01-27 14:13:56 UTC (rev 271948)
@@ -1,3 +1,21 @@
+2021-01-27  Rob Buis  <[email protected]>
+
+        Handle zero aspect-ratio width/height
+        https://bugs.webkit.org/show_bug.cgi?id=220970
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Treat aspect-ratio with zero width and/or height internally
+        as auto, but when serializing maintain the original input.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * rendering/style/RenderStyleConstants.cpp:
+        (WebCore::operator<<):
+        * rendering/style/RenderStyleConstants.h:
+        * style/StyleBuilderCustom.h:
+        (WebCore::Style::BuilderCustom::applyValueAspectRatio):
+
 2021-01-27  Antti Koivisto  <[email protected]>
 
         Implement visibility based resource load scheduling for low priority resources

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (271947 => 271948)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-01-27 14:13:56 UTC (rev 271948)
@@ -3472,12 +3472,13 @@
             switch (style.aspectRatioType()) {
             case AspectRatioType::Auto:
                 return cssValuePool.createIdentifierValue(CSSValueAuto);
+            case AspectRatioType::AutoZero:
             case AspectRatioType::AutoAndRatio:
             case AspectRatioType::Ratio: {
                 auto ratioList = CSSValueList::createSlashSeparated();
                 ratioList->append(cssValuePool.createValue(style.aspectRatioWidth(), CSSUnitType::CSS_NUMBER));
                 ratioList->append(cssValuePool.createValue(style.aspectRatioHeight(), CSSUnitType::CSS_NUMBER));
-                if (style.aspectRatioType() == AspectRatioType::Ratio)
+                if (style.aspectRatioType() != AspectRatioType::AutoAndRatio)
                     return ratioList;
                 auto list = CSSValueList::createSpaceSeparated();
                 list->append(cssValuePool.createIdentifierValue(CSSValueAuto));

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp (271947 => 271948)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2021-01-27 14:13:56 UTC (rev 271948)
@@ -93,6 +93,7 @@
     case AspectRatioType::Auto: ts << "auto"; break;
     case AspectRatioType::Ratio: ts << "ratio"; break;
     case AspectRatioType::AutoAndRatio: ts << "autoandratio"; break;
+    case AspectRatioType::AutoZero: ts << "autozero"; break;
     }
     return ts;
 }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (271947 => 271948)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2021-01-27 14:13:56 UTC (rev 271948)
@@ -519,7 +519,8 @@
 enum class AspectRatioType : uint8_t {
     Auto,
     Ratio,
-    AutoAndRatio
+    AutoAndRatio,
+    AutoZero
 };
 
 enum class WordBreak : uint8_t {

Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (271947 => 271948)


--- trunk/Source/WebCore/style/StyleBuilderCustom.h	2021-01-27 14:03:16 UTC (rev 271947)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h	2021-01-27 14:13:56 UTC (rev 271948)
@@ -1179,9 +1179,14 @@
         return;
     }
 
-    builderState.style().setAspectRatioType(AspectRatioType::Ratio);
     ASSERT(list.length() == 2);
-    builderState.style().setAspectRatio(downcast<CSSPrimitiveValue>(list.item(0))->doubleValue(), downcast<CSSPrimitiveValue>(list.item(1))->doubleValue());
+    auto width = downcast<CSSPrimitiveValue>(list.item(0))->doubleValue();
+    auto height = downcast<CSSPrimitiveValue>(list.item(1))->doubleValue();
+    if (!width || !height)
+        builderState.style().setAspectRatioType(AspectRatioType::AutoZero);
+    else
+        builderState.style().setAspectRatioType(AspectRatioType::Ratio);
+    builderState.style().setAspectRatio(width, height);
 }
 
 inline void BuilderCustom::applyValueWebkitTextEmphasisStyle(BuilderState& builderState, CSSValue& value)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to