Title: [263221] trunk
Revision
263221
Author
za...@apple.com
Date
2020-06-18 10:47:01 -0700 (Thu, 18 Jun 2020)

Log Message

[LFC][BFC] Available space computation for the float avoider needs coordinate mapping
https://bugs.webkit.org/show_bug.cgi?id=213339

Reviewed by Antti Koivisto.

Source/WebCore:

The FloatConstraints position values are in formatting root coordinates but the available space
requires containing block coordinates.

Test: fast/layoutformattingcontext/float-avoider-available-horizontal-space.html

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider):

LayoutTests:

* fast/layoutformattingcontext/float-avoider-available-horizontal-space-expected.html: Added.
* fast/layoutformattingcontext/float-avoider-available-horizontal-space.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (263220 => 263221)


--- trunk/LayoutTests/ChangeLog	2020-06-18 17:45:03 UTC (rev 263220)
+++ trunk/LayoutTests/ChangeLog	2020-06-18 17:47:01 UTC (rev 263221)
@@ -1,3 +1,13 @@
+2020-06-18  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][BFC] Available space computation for the float avoider needs coordinate mapping
+        https://bugs.webkit.org/show_bug.cgi?id=213339
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/float-avoider-available-horizontal-space-expected.html: Added.
+        * fast/layoutformattingcontext/float-avoider-available-horizontal-space.html: Added.
+
 2020-06-18  Geoffrey Garen  <gga...@apple.com>
 
         inspector/canvas/create-context-webgpu.html was a flaky failure after r262904

Added: trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space-expected.html (0 => 263221)


--- trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space-expected.html	2020-06-18 17:47:01 UTC (rev 263221)
@@ -0,0 +1,19 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.first {
+  height: 100px;
+  width: 40px;
+  background-color: green;
+}
+
+.second {
+  height: 100px;
+  width: 60px;
+  position: relative;
+  top: -100px;
+  left: 40px;
+  background-color: blue;
+}
+</style>
+<div class=first></div>
+<div class=second></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space.html (0 => 263221)


--- trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space.html	2020-06-18 17:47:01 UTC (rev 263221)
@@ -0,0 +1,24 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.container {
+  width: 100px;
+  height: 100px;
+}
+
+.floatBox {
+  float: left;
+  width: 40px;
+  height: 100px;
+  background-color: green;
+}
+
+.floatAvoider {
+  overflow: hidden; 
+  height: 100%;
+  background-color: blue;
+}
+</style>
+<div class=container>
+  <div class=floatBox></div>
+  <div class=floatAvoider></div>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (263220 => 263221)


--- trunk/Source/WebCore/ChangeLog	2020-06-18 17:45:03 UTC (rev 263220)
+++ trunk/Source/WebCore/ChangeLog	2020-06-18 17:47:01 UTC (rev 263221)
@@ -1,3 +1,18 @@
+2020-06-18  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][BFC] Available space computation for the float avoider needs coordinate mapping
+        https://bugs.webkit.org/show_bug.cgi?id=213339
+
+        Reviewed by Antti Koivisto.
+
+        The FloatConstraints position values are in formatting root coordinates but the available space
+        requires containing block coordinates.
+
+        Test: fast/layoutformattingcontext/float-avoider-available-horizontal-space.html
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider):
+
 2020-06-18  Stephan Szabo  <stephan.sz...@sony.com>
 
         [PlayStation] Build fix for errors with structured bindings to const structure

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (263220 => 263221)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-06-18 17:45:03 UTC (rev 263220)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-06-18 17:47:01 UTC (rev 263221)
@@ -177,18 +177,29 @@
     // Vertical static position is not computed yet for this formatting context root, so let's just pre-compute it for now.
     precomputeVerticalPositionForBoxAndAncestors(layoutBox, constraintsPair);
 
-    auto mapLogicalTopToFormattingContextRoot = [&] {
-        auto& formattingContextRoot = root();
-        ASSERT(layoutBox.isInFormattingContextOf(formattingContextRoot));
-        auto top = geometryForBox(layoutBox).top();
-        for (auto* ancestor = &layoutBox.containingBlock(); ancestor != &formattingContextRoot; ancestor = &ancestor->containingBlock())
+    auto logicalTopInFormattingContextRootCoordinate = [&] (auto& floatAvoider) {
+        auto top = geometryForBox(floatAvoider).top();
+        for (auto* ancestor = &floatAvoider.containingBlock(); ancestor != &root(); ancestor = &ancestor->containingBlock())
             top += geometryForBox(*ancestor).top();
         return top;
     };
 
-    auto verticalPosition = mapLogicalTopToFormattingContextRoot();
+    auto floatConstraintsInContainingBlockCoordinate = [&] (auto floatConstraints) {
+        if (!floatConstraints.left && !floatConstraints.right)
+            return FloatingContext::Constraints { };
+        auto offset = LayoutSize { };
+        for (auto* ancestor = &layoutBox.containingBlock(); ancestor != &root(); ancestor = &ancestor->containingBlock())
+            offset += toLayoutSize(geometryForBox(*ancestor).topLeft());
+        if (floatConstraints.left)
+            floatConstraints.left = PointInContextRoot { *floatConstraints.left - offset };
+        if (floatConstraints.right)
+            floatConstraints.right = PointInContextRoot { *floatConstraints.right - offset };
+        return floatConstraints;
+    };
+
     // FIXME: Check if the non-yet-computed height affects this computation - and whether we have to resolve it at a later point.
-    auto constraints = floatingContext.constraints(verticalPosition, verticalPosition);
+    auto logicalTop = logicalTopInFormattingContextRootCoordinate(layoutBox);
+    auto constraints = floatConstraintsInContainingBlockCoordinate(floatingContext.constraints(logicalTop, logicalTop));
     if (!constraints.left && !constraints.right)
         return { };
     // Shrink the available space if the floats are actually intruding at this vertical position.
@@ -195,10 +206,8 @@
     auto availableWidth = constraintsPair.containingBlock.horizontal.logicalWidth;
     if (constraints.left)
         availableWidth -= constraints.left->x;
-    if (constraints.right) {
-        // FIXME: Map the logicalRight to the root's coordinate system.
+    if (constraints.right)
         availableWidth -= std::max(0_lu, constraintsPair.containingBlock.horizontal.logicalRight() - constraints.right->x);
-    }
     return availableWidth;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to