Title: [246482] trunk/Source/WebCore
Revision
246482
Author
[email protected]
Date
2019-06-16 13:15:02 -0700 (Sun, 16 Jun 2019)

Log Message

[LFC][Floats] Add bottom value to FloatingState::Constraints
https://bugs.webkit.org/show_bug.cgi?id=198889
<rdar://problem/51776730>

Reviewed by Antti Koivisto.

Constraints::left/right->y indicates where this particular constrain ends. This is going to be used by inline layout to figure where
the next line should go (vertical position).

* layout/floats/FloatingState.cpp:
(WebCore::Layout::FloatingState::constraints const):
* layout/floats/FloatingState.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (246481 => 246482)


--- trunk/Source/WebCore/ChangeLog	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/ChangeLog	2019-06-16 20:15:02 UTC (rev 246482)
@@ -1,5 +1,20 @@
 2019-06-16  Zalan Bujtas  <[email protected]>
 
+        [LFC][Floats] Add bottom value to FloatingState::Constraints
+        https://bugs.webkit.org/show_bug.cgi?id=198889
+        <rdar://problem/51776730>
+
+        Reviewed by Antti Koivisto.
+
+        Constraints::left/right->y indicates where this particular constrain ends. This is going to be used by inline layout to figure where
+        the next line should go (vertical position).
+
+        * layout/floats/FloatingState.cpp:
+        (WebCore::Layout::FloatingState::constraints const):
+        * layout/floats/FloatingState.h:
+
+2019-06-16  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Ignore descent when in limited/full quirks mode
         https://bugs.webkit.org/show_bug.cgi?id=198893
         <rdar://problem/51780634>

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (246481 => 246482)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2019-06-16 20:15:02 UTC (rev 246482)
@@ -59,6 +59,7 @@
     Point() = default;
     Point(LayoutUnit, LayoutUnit);
     Point(LayoutPoint);
+    void move(LayoutSize);
     void moveBy(LayoutPoint);
     operator LayoutPoint() const { return { x, y }; }
 };
@@ -79,6 +80,12 @@
 {
 }
 
+inline void Point::move(LayoutSize offset)
+{
+    x += offset.width();
+    y += offset.height();
+}
+
 inline void Point::moveBy(LayoutPoint offset)
 {
     x += offset.x();

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (246481 => 246482)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-06-16 20:15:02 UTC (rev 246482)
@@ -148,8 +148,10 @@
     auto containingBlockContentBoxRight = containingBlockRight - containingBlockDisplayBox.borderRight() + containingBlockDisplayBox.paddingRight().valueOr(0);
 
     // Shrink the available space if the floats are actually intruding at this vertical position.
-    availableWidth -= (std::max<LayoutUnit>(0, constraints.left.valueOr(PositionInContextRoot { 0 }) - containingBlockContentBoxLeft)
-        + std::max<LayoutUnit>(0, containingBlockContentBoxRight - constraints.right.valueOr(PositionInContextRoot { containingBlockContentBoxRight })));
+    if (constraints.left)
+        availableWidth -= std::max<LayoutUnit>(0, constraints.left->x - containingBlockContentBoxLeft);
+    if (constraints.right)
+        availableWidth -= std::max<LayoutUnit>(0, containingBlockContentBoxRight - constraints.right->x);
     return availableWidth;
 }
 

Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (246481 => 246482)


--- trunk/Source/WebCore/layout/floats/FloatingState.cpp	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp	2019-06-16 20:15:02 UTC (rev 246482)
@@ -119,9 +119,12 @@
     // 3. Convert left/right positions back to formattingContextRoot's cooridnate system.
     auto coordinateMappingIsRequired = &root() != &formattingContextRoot;
     auto adjustedPosition = Point { 0, verticalPosition };
+    LayoutSize adjustingDelta;
 
-    if (coordinateMappingIsRequired)
+    if (coordinateMappingIsRequired) {
         adjustedPosition = FormattingContext::mapPointToAncestor(m_layoutState, adjustedPosition, downcast<Container>(formattingContextRoot), downcast<Container>(root()));
+        adjustingDelta = { adjustedPosition.x, adjustedPosition.y - verticalPosition };
+    }
 
     Constraints constraints;
     for (int index = m_floats.size() - 1; index >= 0; --index) {
@@ -138,9 +141,9 @@
             continue;
 
         if (floatItem.isLeftPositioned())
-            constraints.left = PositionInContextRoot { rect.right() };
+            constraints.left = PointInContextRoot { rect.right(), rect.bottom() };
         else
-            constraints.right = PositionInContextRoot { rect.left() };
+            constraints.right = PointInContextRoot { rect.left(), rect.bottom() };
 
         if (constraints.left && constraints.right)
             break;
@@ -148,12 +151,11 @@
 
     if (coordinateMappingIsRequired) {
         if (constraints.left)
-            constraints.left = PositionInContextRoot { *constraints.left - adjustedPosition.x };
+            constraints.left->move(-adjustingDelta);
 
         if (constraints.right)
-            constraints.right = PositionInContextRoot { *constraints.right - adjustedPosition.x };
+            constraints.right->move(-adjustingDelta);
     }
-
     return constraints;
 }
 

Modified: trunk/Source/WebCore/layout/floats/FloatingState.h (246481 => 246482)


--- trunk/Source/WebCore/layout/floats/FloatingState.h	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/layout/floats/FloatingState.h	2019-06-16 20:15:02 UTC (rev 246482)
@@ -60,8 +60,8 @@
     Optional<PositionInContextRoot> bottom(const Box& formattingContextRoot) const;
 
     struct Constraints {
-        Optional<PositionInContextRoot> left;
-        Optional<PositionInContextRoot> right;
+        Optional<PointInContextRoot> left;
+        Optional<PointInContextRoot> right;
     };
     Constraints constraints(PositionInContextRoot verticalPosition, const Box& formattingContextRoot) const;
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (246481 => 246482)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-06-16 20:04:31 UTC (rev 246481)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-06-16 20:15:02 UTC (rev 246482)
@@ -230,23 +230,23 @@
         auto lineLogicalLeft = lineHorizontalConstraint.logicalTopLeft.x();
         auto floatConstraints = m_floatingState.constraints({ lineLogicalTop }, m_formattingRoot);
         // Check if these constraints actually put limitation on the line.
-        if (floatConstraints.left && *floatConstraints.left <= formattingRootDisplayBox.contentBoxLeft())
+        if (floatConstraints.left && floatConstraints.left->x <= formattingRootDisplayBox.contentBoxLeft())
             floatConstraints.left = { };
 
-        if (floatConstraints.right && *floatConstraints.right >= formattingRootDisplayBox.contentBoxRight())
+        if (floatConstraints.right && floatConstraints.right->x >= formattingRootDisplayBox.contentBoxRight())
             floatConstraints.right = { };
 
         if (floatConstraints.left && floatConstraints.right) {
-            ASSERT(*floatConstraints.left < *floatConstraints.right);
-            availableWidth = *floatConstraints.right - *floatConstraints.left;
-            lineLogicalLeft = *floatConstraints.left;
+            ASSERT(floatConstraints.left->x < floatConstraints.right->x);
+            availableWidth = floatConstraints.right->x - floatConstraints.left->x;
+            lineLogicalLeft = floatConstraints.left->x;
         } else if (floatConstraints.left) {
-            ASSERT(*floatConstraints.left > lineLogicalLeft);
-            availableWidth -= (*floatConstraints.left - lineLogicalLeft);
-            lineLogicalLeft = *floatConstraints.left;
+            ASSERT(floatConstraints.left->x > lineLogicalLeft);
+            availableWidth -= (floatConstraints.left->x - lineLogicalLeft);
+            lineLogicalLeft = floatConstraints.left->x;
         } else if (floatConstraints.right) {
-            ASSERT(*floatConstraints.right > lineLogicalLeft);
-            availableWidth = *floatConstraints.right - lineLogicalLeft;
+            ASSERT(floatConstraints.right->x > lineLogicalLeft);
+            availableWidth = floatConstraints.right->x - lineLogicalLeft;
         }
         lineHorizontalConstraint.availableLogicalWidth = availableWidth;
         lineHorizontalConstraint.logicalTopLeft.setX(lineLogicalLeft);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to