Diff
Modified: trunk/LayoutTests/ChangeLog (274645 => 274646)
--- trunk/LayoutTests/ChangeLog 2021-03-18 14:44:01 UTC (rev 274645)
+++ trunk/LayoutTests/ChangeLog 2021-03-18 15:43:55 UTC (rev 274646)
@@ -1,3 +1,15 @@
+2021-03-18 Rob Buis <[email protected]>
+
+ Use double division
+ https://bugs.webkit.org/show_bug.cgi?id=223366
+
+ Reviewed by Zalan Bujtas.
+
+ Add test for this.
+
+ * fast/css/aspect-ratio-division-crash-expected.txt: Added.
+ * fast/css/aspect-ratio-division-crash.html: Added.
+
2021-03-18 Frédéric Wang <[email protected]>
Nullptr crash in RenderStyle::shapeOutside()
Added: trunk/LayoutTests/fast/css/aspect-ratio-division-crash-expected.txt (0 => 274646)
--- trunk/LayoutTests/fast/css/aspect-ratio-division-crash-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/aspect-ratio-division-crash-expected.txt 2021-03-18 15:43:55 UTC (rev 274646)
@@ -0,0 +1,2 @@
+Test passes if it does not crash.
+
Added: trunk/LayoutTests/fast/css/aspect-ratio-division-crash.html (0 => 274646)
--- trunk/LayoutTests/fast/css/aspect-ratio-division-crash.html (rev 0)
+++ trunk/LayoutTests/fast/css/aspect-ratio-division-crash.html 2021-03-18 15:43:55 UTC (rev 274646)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+Test passes if it does not crash.
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<div style="width: 100px; aspect-ratio: 1/80;"></div>
Modified: trunk/Source/WebCore/ChangeLog (274645 => 274646)
--- trunk/Source/WebCore/ChangeLog 2021-03-18 14:44:01 UTC (rev 274645)
+++ trunk/Source/WebCore/ChangeLog 2021-03-18 15:43:55 UTC (rev 274646)
@@ -1,3 +1,21 @@
+2021-03-18 Rob Buis <[email protected]>
+
+ Use double division
+ https://bugs.webkit.org/show_bug.cgi?id=223366
+
+ Reviewed by Zalan Bujtas.
+
+ Use double instead of LayoutUnit division since
+ LayoutUnit resolution is not high enough to support
+ near-zero values.
+
+ Test: fast/css/aspect-ratio-division-crash.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::inlineSizeFromAspectRatio):
+ * rendering/RenderBox.h:
+ (WebCore::RenderBox::blockSizeFromAspectRatio):
+
2021-03-18 Frédéric Wang <[email protected]>
Nullptr crash in RenderStyle::shapeOutside()
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (274645 => 274646)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-03-18 14:44:01 UTC (rev 274645)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-03-18 15:43:55 UTC (rev 274646)
@@ -2487,12 +2487,12 @@
setMarginEnd(computedValues.m_margins.m_end);
}
-static LayoutUnit inlineSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, LayoutUnit aspectRatio, BoxSizing boxSizing, LayoutUnit blockSize)
+static LayoutUnit inlineSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit blockSize)
{
if (boxSizing == BoxSizing::BorderBox)
- return blockSize * aspectRatio;
+ return LayoutUnit(blockSize * aspectRatio);
- return ((blockSize - borderPaddingBlockSum) * aspectRatio) + borderPaddingInlineSum;
+ return LayoutUnit((blockSize - borderPaddingBlockSum) * aspectRatio) + borderPaddingInlineSum;
}
void RenderBox::computeLogicalWidthInFragment(LogicalExtentComputedValues& computedValues, RenderFragmentContainer* fragment) const
Modified: trunk/Source/WebCore/rendering/RenderBox.h (274645 => 274646)
--- trunk/Source/WebCore/rendering/RenderBox.h 2021-03-18 14:44:01 UTC (rev 274645)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2021-03-18 15:43:55 UTC (rev 274646)
@@ -707,11 +707,11 @@
LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const;
std::pair<LayoutUnit, LayoutUnit> computeMinMaxLogicalWidthFromAspectRatio() const;
- static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, LayoutUnit aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
+ static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
{
if (boxSizing == BoxSizing::BorderBox)
- return inlineSize / aspectRatio;
- return ((inlineSize - borderPaddingInlineSum) / aspectRatio) + borderPaddingBlockSum;
+ return LayoutUnit(inlineSize / aspectRatio);
+ return LayoutUnit((inlineSize - borderPaddingInlineSum) / aspectRatio) + borderPaddingBlockSum;
}
void computePreferredLogicalWidths(const Length& minWidth, const Length& maxWidth, LayoutUnit borderAndPadding);