Title: [272835] trunk/Source/WebCore
Revision
272835
Author
da...@apple.com
Date
2021-02-13 11:13:12 -0800 (Sat, 13 Feb 2021)

Log Message

Improve computed style handling in degenerate grid cases, sizes and lengths of zero
https://bugs.webkit.org/show_bug.cgi?id=221856

Reviewed by Anders Carlsson.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForImageSliceSide): Handle "auto", which can come up with sizes of zero.
(WebCore::valueForNinePieceImage): Simplify by not putting Ref<> results into RefPtr<> locals.
(WebCore::valueForGridTrackList): Clamp insertion point to the actual size of the tracks,
since it can be set to an arbitrary larger value.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272834 => 272835)


--- trunk/Source/WebCore/ChangeLog	2021-02-13 19:07:16 UTC (rev 272834)
+++ trunk/Source/WebCore/ChangeLog	2021-02-13 19:13:12 UTC (rev 272835)
@@ -1,3 +1,16 @@
+2021-02-12  Darin Adler  <da...@apple.com>
+
+        Improve computed style handling in degenerate grid cases, sizes and lengths of zero
+        https://bugs.webkit.org/show_bug.cgi?id=221856
+
+        Reviewed by Anders Carlsson.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForImageSliceSide): Handle "auto", which can come up with sizes of zero.
+        (WebCore::valueForNinePieceImage): Simplify by not putting Ref<> results into RefPtr<> locals.
+        (WebCore::valueForGridTrackList): Clamp insertion point to the actual size of the tracks,
+        since it can be set to an arbitrary larger value.
+
 2021-02-13  Zalan Bujtas  <za...@apple.com>
 
         [LFC][Integration] Not every inline box contributes to line overflow

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (272834 => 272835)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-02-13 19:07:16 UTC (rev 272834)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-02-13 19:13:12 UTC (rev 272835)
@@ -108,7 +108,7 @@
     // a calculation that combines a percentage and a number.
     if (length.isPercent())
         return CSSValuePool::singleton().createValue(length.percent(), CSSUnitType::CSS_PERCENTAGE);
-    if (length.isFixed())
+    if (length.isAuto() || length.isFixed())
         return CSSValuePool::singleton().createValue(length.value(), CSSUnitType::CSS_NUMBER);
 
     // Calculating the actual length currently in use would require most of the code from RenderBoxModelObject::paintNinePieceImage.
@@ -227,23 +227,14 @@
     if (!image.hasImage())
         return CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
 
-    // Image first.
     RefPtr<CSSValue> imageValue;
     if (image.image())
         imageValue = image.image()->cssValue();
 
-    // Create the image slice.
-    RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
-
-    // Create the border area slices.
-    RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
-
-    // Create the border outset.
-    RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
-
-    // Create the repeat rules.
-    RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
-
+    auto imageSlices = valueForNinePieceImageSlice(image);
+    auto borderSlices = valueForNinePieceImageQuad(image.borderSlices());
+    auto outset = valueForNinePieceImageQuad(image.outset());
+    auto repeat = valueForNinePieceImageRepeat(image);
     return createBorderImageValue(WTFMove(imageValue), WTFMove(imageSlices), WTFMove(borderSlices), WTFMove(outset), WTFMove(repeat));
 }
 
@@ -1031,7 +1022,7 @@
     }
 
     // Add the line names and track sizes that precede the auto repeat().
-    unsigned autoRepeatInsertionPoint = isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint();
+    int autoRepeatInsertionPoint = std::clamp<int>(isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint(), 0, trackSizes.size());
     populateGridTrackList(list.get(), collector, trackSizes, getTrackSize, 0, autoRepeatInsertionPoint);
 
     // Add a CSSGridAutoRepeatValue with the contents of the auto repeat().
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to