Title: [288547] trunk
Revision
288547
Author
za...@apple.com
Date
2022-01-25 06:39:22 -0800 (Tue, 25 Jan 2022)

Log Message

(REGRESSION r287485) [LFC][IFC] Incorrect RTL content position when intrusive float is present
https://bugs.webkit.org/show_bug.cgi?id=235547
<rdar://87824766>

Reviewed by Antti Koivisto.

Source/WebCore:

The float box coordinates are always visual. They need to be converted to
logical to be able to properly constrain the available space on the current line.

Test: fast/inline/intrusive-float-with-rtl-content.html

* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::floatConstraints const):

LayoutTests:

* fast/inline/intrusive-float-with-rtl-content-expected.html: Added.
* fast/inline/intrusive-float-with-rtl-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288546 => 288547)


--- trunk/LayoutTests/ChangeLog	2022-01-25 14:09:03 UTC (rev 288546)
+++ trunk/LayoutTests/ChangeLog	2022-01-25 14:39:22 UTC (rev 288547)
@@ -1,3 +1,14 @@
+2022-01-25  Alan Bujtas  <za...@apple.com>
+
+        (REGRESSION r287485) [LFC][IFC] Incorrect RTL content position when intrusive float is present
+        https://bugs.webkit.org/show_bug.cgi?id=235547
+        <rdar://87824766>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/intrusive-float-with-rtl-content-expected.html: Added.
+        * fast/inline/intrusive-float-with-rtl-content.html: Added.
+
 2022-01-25  Ziran Sun  <z...@igalia.com>
 
         [css-grid] Fix grid shorthand expansion of initial values

Added: trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content-expected.html (0 => 288547)


--- trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content-expected.html	2022-01-25 14:39:22 UTC (rev 288547)
@@ -0,0 +1,8 @@
+<style>
+div {
+  width: 100px;
+  height: 220px;
+  background-color: green;
+}
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content.html (0 => 288547)


--- trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/intrusive-float-with-rtl-content.html	2022-01-25 14:39:22 UTC (rev 288547)
@@ -0,0 +1,95 @@
+<style>
+body {
+  font-family: Ahem;
+  font-size: 20px;
+  position: relative;
+}
+
+.container {
+  width: 100px;
+  height: 20px;
+  background-color: green;
+}
+
+.floatBox {
+  float: left;
+  width: 20px;
+  height: 20px;
+  background-color: green;
+}
+
+.content {
+  direction: rtl;
+  color: red;
+}
+
+.ref {
+    position: absolute;
+    top: 0px;
+    color: green;
+    white-space: pre;
+}
+</style>
+<div class=container>
+  <div class=floatBox></div>
+  <div class=content>X</div>
+</div>
+<div class=ref>    X</div>
+
+<div class=container>
+  <div class=floatBox style="float: right;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 20px;">   X </div>
+
+<div class=container>
+  <div class=floatBox style="float: right; width: 40px;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 40px;">  X  </div>
+
+<div class=container>
+  <div class=floatBox></div>
+  <div class=floatBox style="float: right; width: 60px;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 60px;"> X   </div>
+
+<div class=container style="height: 40px;">
+  <div class=floatBox></div>
+  <div class=floatBox style="float: right; width: 80px;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 100px;">    X</div>
+
+<div class=container>
+  <div class=floatBox style="float: right;"></div>
+  <div class=content style="border-right: 20px solid green;">X</div>
+</div>
+<div class=ref style="top: 120px;">   X </div>
+
+<div class=container>
+  <div class=floatBox style="float: right;"></div>
+  <div class=content style="border-right: 40px solid green;">X</div>
+</div>
+<div class=ref style="top: 140px;">  X  </div>
+
+<div class=container>
+  <div class=floatBox style="float: right;"></div>
+  <div class=content style="border-left: 40px solid green; border-right: 40px solid green;">X</div>
+</div>
+<div class=ref style="top: 160px;">  X  </div>
+
+<div class=container>
+  <div class=floatBox></div>
+  <div class=floatBox style="float: right; width: 20px;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 180px;">   X </div>
+
+<div class=container>
+  <div class=floatBox style="width: 40px;"></div>
+  <div class=floatBox style="float: right; width: 40px;"></div>
+  <div class=content>X</div>
+</div>
+<div class=ref style="top: 200px;">  X  </div>

Modified: trunk/Source/WebCore/ChangeLog (288546 => 288547)


--- trunk/Source/WebCore/ChangeLog	2022-01-25 14:09:03 UTC (rev 288546)
+++ trunk/Source/WebCore/ChangeLog	2022-01-25 14:39:22 UTC (rev 288547)
@@ -1,3 +1,19 @@
+2022-01-25  Alan Bujtas  <za...@apple.com>
+
+        (REGRESSION r287485) [LFC][IFC] Incorrect RTL content position when intrusive float is present
+        https://bugs.webkit.org/show_bug.cgi?id=235547
+        <rdar://87824766>
+
+        Reviewed by Antti Koivisto.
+
+        The float box coordinates are always visual. They need to be converted to
+        logical to be able to properly constrain the available space on the current line.
+
+        Test: fast/inline/intrusive-float-with-rtl-content.html
+
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::floatConstraints const):
+
 2022-01-25  Youenn Fablet  <you...@apple.com>
 
         Add a WebShare policy quirk for Twitter

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (288546 => 288547)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-01-25 14:09:03 UTC (rev 288546)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-01-25 14:39:22 UTC (rev 288547)
@@ -570,7 +570,19 @@
 
     // Check for intruding floats and adjust logical left/available width for this line accordingly.
     auto floatingContext = FloatingContext { formattingContext(), *floatingState };
-    auto constraints = floatingContext.constraints(toLayoutUnit(lineLogicalRect.top()), toLayoutUnit(lineLogicalRect.bottom()));
+    auto toLogicalFloatPosition = [&] (const auto& constraints) -> FloatingContext::Constraints {
+        if (root().style().isLeftToRightDirection())
+            return constraints;
+        auto logicalConstraints = FloatingContext::Constraints { };
+        auto borderBoxWidth = layoutState().geometryForBox(root()).borderBoxWidth();
+        if (constraints.left)
+            logicalConstraints.right = PointInContextRoot { borderBoxWidth - constraints.left->x, constraints.left->y };
+        if (constraints.right)
+            logicalConstraints.left = PointInContextRoot { borderBoxWidth - constraints.right->x, constraints.right->y };
+        return logicalConstraints;
+    };
+    auto constraints = toLogicalFloatPosition(floatingContext.constraints(toLayoutUnit(lineLogicalRect.top()), toLayoutUnit(lineLogicalRect.bottom())));
+
     // Check if these values actually constrain the line.
     if (constraints.left && constraints.left->x <= lineLogicalRect.left())
         constraints.left = { };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to