Title: [272649] trunk
Revision
272649
Author
[email protected]
Date
2021-02-10 06:59:20 -0800 (Wed, 10 Feb 2021)

Log Message

[LFC][IFC] Pass in sane content width values to InlineContentBreaker
https://bugs.webkit.org/show_bug.cgi?id=221628
Source/WebCore:

rdar://problem/73874164

Reviewed by Antti Koivisto.

Insanely large zoom value could produce Nan letter-spacing values.
Let's tighten the inline content width values so that InlineContentBreaker can always expect valid InlineLayoutUnit values.

Test: fast/text/letter-spacing-produces-nan-width.html

* layout/inlineformatting/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::ContinuousContent::append):
* layout/inlineformatting/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::width):

LayoutTests:

Reviewed by Antti Koivisto.

* fast/text/letter-spacing-produces-nan-width-expected.txt: Added.
* fast/text/letter-spacing-produces-nan-width.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272648 => 272649)


--- trunk/LayoutTests/ChangeLog	2021-02-10 14:49:45 UTC (rev 272648)
+++ trunk/LayoutTests/ChangeLog	2021-02-10 14:59:20 UTC (rev 272649)
@@ -1,3 +1,13 @@
+2021-02-10  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Pass in sane content width values to InlineContentBreaker
+        https://bugs.webkit.org/show_bug.cgi?id=221628
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/letter-spacing-produces-nan-width-expected.txt: Added.
+        * fast/text/letter-spacing-produces-nan-width.html: Added.
+
 2021-02-10  Kimmo Kinnunen  <[email protected]>
 
         RemoteGraphicsContextGLProxy should support losing the context and should lose the context on timeouts

Added: trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width-expected.txt (0 => 272649)


--- trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width-expected.txt	2021-02-10 14:59:20 UTC (rev 272649)
@@ -0,0 +1 @@
+Pass if no crash or assert.

Added: trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width.html (0 => 272649)


--- trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/letter-spacing-produces-nan-width.html	2021-02-10 14:59:20 UTC (rev 272649)
@@ -0,0 +1,12 @@
+<style>
+div {
+  zoom: 12345678901234;
+}
+.inner {
+  letter-spacing: 0;
+}
+</style><div><div><div class=inner>Pass if no crash or assert.</div></div></div>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+</script>

Modified: trunk/Source/WebCore/ChangeLog (272648 => 272649)


--- trunk/Source/WebCore/ChangeLog	2021-02-10 14:49:45 UTC (rev 272648)
+++ trunk/Source/WebCore/ChangeLog	2021-02-10 14:59:20 UTC (rev 272649)
@@ -1,5 +1,23 @@
 2021-02-10  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Pass in sane content width values to InlineContentBreaker
+        https://bugs.webkit.org/show_bug.cgi?id=221628
+        rdar://problem/73874164
+
+        Reviewed by Antti Koivisto.
+
+        Insanely large zoom value could produce Nan letter-spacing values.
+        Let's tighten the inline content width values so that InlineContentBreaker can always expect valid InlineLayoutUnit values.
+
+        Test: fast/text/letter-spacing-produces-nan-width.html
+
+        * layout/inlineformatting/InlineContentBreaker.cpp:
+        (WebCore::Layout::InlineContentBreaker::ContinuousContent::append):
+        * layout/inlineformatting/text/TextUtil.cpp:
+        (WebCore::Layout::TextUtil::width):
+
+2021-02-10  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Add inline box vertical border/padding to enclosing top and bottom
         https://bugs.webkit.org/show_bug.cgi?id=221647
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (272648 => 272649)


--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp	2021-02-10 14:49:45 UTC (rev 272648)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp	2021-02-10 14:59:20 UTC (rev 272649)
@@ -488,7 +488,7 @@
 void InlineContentBreaker::ContinuousContent::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth, Optional<InlineLayoutUnit> collapsibleWidth)
 {
     m_runs.append({ inlineItem, logicalWidth });
-    m_logicalWidth += logicalWidth;
+    m_logicalWidth = clampTo<InlineLayoutUnit>(m_logicalWidth + logicalWidth);
     if (!collapsibleWidth) {
         m_collapsibleLogicalWidth = { };
         return;

Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (272648 => 272649)


--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2021-02-10 14:49:45 UTC (rev 272648)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2021-02-10 14:59:20 UTC (rev 272649)
@@ -47,8 +47,10 @@
 {
     RELEASE_ASSERT(from >= inlineTextItem.start());
     RELEASE_ASSERT(to <= inlineTextItem.end());
-    if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem))
-        return inlineTextItem.style().fontCascade().spaceWidth();
+    if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
+        auto spaceWidth = inlineTextItem.style().fontCascade().spaceWidth();
+        return std::isnan(spaceWidth) ? 0.0f : std::isinf(spaceWidth) ? maxInlineLayoutUnit() : spaceWidth;
+    }
     return TextUtil::width(inlineTextItem.inlineTextBox(), from, to, contentLogicalLeft);
 }
 
@@ -79,7 +81,7 @@
     if (measureWithEndSpace)
         width -= (font.spaceWidth() + font.wordSpacing());
 
-    return width;
+    return std::isnan(width) ? 0.0f : std::isinf(width) ? maxInlineLayoutUnit() : width;
 }
 
 TextUtil::SplitData TextUtil::split(const InlineTextItem& inlineTextItem, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to