Title: [268099] trunk/Source/WebCore
Revision
268099
Author
[email protected]
Date
2020-10-06 17:23:17 -0700 (Tue, 06 Oct 2020)

Log Message

[LFC] FormattingContext::Geometry::contentHeightForFormattingContextRoot should take a const ContainerBox&
https://bugs.webkit.org/show_bug.cgi?id=217404

Reviewed by Simon Fraser.

A formatting context root is always a Layout::ContainerBox (and not just a Layout::Box).

* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::complicatedCases const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268098 => 268099)


--- trunk/Source/WebCore/ChangeLog	2020-10-07 00:23:14 UTC (rev 268098)
+++ trunk/Source/WebCore/ChangeLog	2020-10-07 00:23:17 UTC (rev 268099)
@@ -1,3 +1,25 @@
+2020-10-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] FormattingContext::Geometry::contentHeightForFormattingContextRoot should take a const ContainerBox&
+        https://bugs.webkit.org/show_bug.cgi?id=217404
+
+        Reviewed by Simon Fraser.
+
+        A formatting context root is always a Layout::ContainerBox (and not just a Layout::Box).
+
+        * layout/FormattingContext.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry const):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::complicatedCases const):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry const):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createLayoutBox):
+
 2020-10-06  Devin Rousso  <[email protected]>
 
         CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support

Modified: trunk/Source/WebCore/layout/FormattingContext.h (268098 => 268099)


--- trunk/Source/WebCore/layout/FormattingContext.h	2020-10-07 00:23:14 UTC (rev 268098)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2020-10-07 00:23:17 UTC (rev 268099)
@@ -154,7 +154,7 @@
 
         FormattingContext::IntrinsicWidthConstraints constrainByMinMaxWidth(const Box&, IntrinsicWidthConstraints) const;
 
-        LayoutUnit contentHeightForFormattingContextRoot(const Box&) const;
+        LayoutUnit contentHeightForFormattingContextRoot(const ContainerBox&) const;
 
         ConstraintsForOutOfFlowContent constraintsForOutOfFlowContent(const ContainerBox&);
         ConstraintsForInFlowContent constraintsForInFlowContent(const ContainerBox&, Optional<EscapeReason> = WTF::nullopt);
@@ -174,8 +174,8 @@
         VerticalGeometry outOfFlowReplacedVerticalGeometry(const ReplacedBox&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
         HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const ReplacedBox&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideHorizontalValues&);
 
-        VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const Box&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
-        HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&);
+        VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const ContainerBox&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
+        HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(const ContainerBox&, const HorizontalConstraints&, const OverrideHorizontalValues&);
 
         ContentHeightAndMargin floatingReplacedHeightAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideVerticalValues&) const;
         ContentWidthAndMargin floatingReplacedWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideHorizontalValues&);

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (268098 => 268099)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-10-07 00:23:14 UTC (rev 268098)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-10-07 00:23:17 UTC (rev 268099)
@@ -168,10 +168,10 @@
     return { };
 }
 
-LayoutUnit FormattingContext::Geometry::contentHeightForFormattingContextRoot(const Box& layoutBox) const
+LayoutUnit FormattingContext::Geometry::contentHeightForFormattingContextRoot(const ContainerBox& formattingContextRoot) const
 {
-    ASSERT(layoutBox.establishesFormattingContext());
-    ASSERT(isHeightAuto(layoutBox) || layoutBox.establishesTableFormattingContext() || layoutBox.isTableCell());
+    ASSERT(formattingContextRoot.establishesFormattingContext());
+    ASSERT(isHeightAuto(formattingContextRoot) || formattingContextRoot.establishesTableFormattingContext() || formattingContextRoot.isTableCell());
 
     // 10.6.7 'Auto' heights for block formatting context roots
 
@@ -182,32 +182,31 @@
     // In addition, if the element has any floating descendants whose bottom margin edge is below the element's bottom content edge,
     // then the height is increased to include those edges. Only floats that participate in this block formatting context are taken
     // into account, e.g., floats inside absolutely positioned descendants or other floats are not.
-    if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild())
+    if (!formattingContextRoot.hasInFlowOrFloatingChild())
         return { };
 
     auto& layoutState = this->layoutState();
     auto& formattingContext = this->formattingContext();
-    auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
+    auto& boxGeometry = formattingContext.geometryForBox(formattingContextRoot);
     auto borderAndPaddingTop = boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0);
     auto top = borderAndPaddingTop;
     auto bottom = borderAndPaddingTop;
-    auto& formattingRootContainer = downcast<ContainerBox>(layoutBox);
-    if (formattingRootContainer.establishesInlineFormattingContext()) {
-        auto& lines = layoutState.establishedInlineFormattingState(formattingRootContainer).lines();
+    if (formattingContextRoot.establishesInlineFormattingContext()) {
+        auto& lines = layoutState.establishedInlineFormattingState(formattingContextRoot).lines();
         // Even empty containers generate one line. 
         ASSERT(!lines.isEmpty());
         top = lines.first().logicalTop();
         bottom = lines.last().logicalBottom();
-    } else if (formattingRootContainer.establishesFlexFormattingContext()) {
-        auto& lines = layoutState.establishedFlexFormattingState(formattingRootContainer).lines();
+    } else if (formattingContextRoot.establishesFlexFormattingContext()) {
+        auto& lines = layoutState.establishedFlexFormattingState(formattingContextRoot).lines();
         ASSERT(!lines.isEmpty());
         // FIXME: Move flex over to layout geometry.
         top = lines.first().top();
         bottom = lines.last().bottom();
-    } else if (formattingRootContainer.establishesBlockFormattingContext() || formattingRootContainer.establishesTableFormattingContext()) {
-        if (formattingRootContainer.hasInFlowChild()) {
-            auto& firstBoxGeometry = formattingContext.geometryForBox(*formattingRootContainer.firstInFlowChild(), EscapeReason::NeedsGeometryFromEstablishedFormattingContext);
-            auto& lastBoxGeometry = formattingContext.geometryForBox(*formattingRootContainer.lastInFlowChild(), EscapeReason::NeedsGeometryFromEstablishedFormattingContext);
+    } else if (formattingContextRoot.establishesBlockFormattingContext() || formattingContextRoot.establishesTableFormattingContext()) {
+        if (formattingContextRoot.hasInFlowChild()) {
+            auto& firstBoxGeometry = formattingContext.geometryForBox(*formattingContextRoot.firstInFlowChild(), EscapeReason::NeedsGeometryFromEstablishedFormattingContext);
+            auto& lastBoxGeometry = formattingContext.geometryForBox(*formattingContextRoot.lastInFlowChild(), EscapeReason::NeedsGeometryFromEstablishedFormattingContext);
             top = firstBoxGeometry.logicalRectWithMargin().top();
             bottom = lastBoxGeometry.logicalRectWithMargin().bottom();
         }
@@ -214,17 +213,17 @@
     } else
         ASSERT_NOT_REACHED();
 
-    auto& floatingState = layoutState.establishedFormattingState(formattingRootContainer).floatingState();
-    auto floatBottom = floatingState.bottom(formattingRootContainer);
+    auto& floatingState = layoutState.establishedFormattingState(formattingContextRoot).floatingState();
+    auto floatBottom = floatingState.bottom(formattingContextRoot);
     if (floatBottom) {
         bottom = std::max<LayoutUnit>(*floatBottom, bottom);
-        auto floatTop = floatingState.top(formattingRootContainer);
+        auto floatTop = floatingState.top(formattingContextRoot);
         ASSERT(floatTop);
         top = std::min<LayoutUnit>(*floatTop, top);
     }
+    auto computedHeight = bottom - top;
 
-    auto computedHeight = bottom - top;
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height] -> content height for formatting context root -> height(" << computedHeight << "px) layoutBox("<< &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height] -> content height for formatting context root -> height(" << computedHeight << "px) layoutBox("<< &formattingContextRoot << ")");
     return computedHeight;
 }
 
@@ -351,7 +350,7 @@
     return std::min(std::max(intrinsicWidthConstraints.minimum, availableWidth), intrinsicWidthConstraints.maximum);
 }
 
-VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
+VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(const ContainerBox& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
     ASSERT(verticalConstraints.logicalHeight);
@@ -470,7 +469,7 @@
     return { *top, *bottom, { *height, usedVerticalMargin } };
 }
 
-HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(const ContainerBox& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
     
@@ -840,7 +839,7 @@
             height = bottom - top;
         } else {
             ASSERT(layoutBox.establishesFormattingContext());
-            height = contentHeightForFormattingContextRoot(layoutBox);
+            height = contentHeightForFormattingContextRoot(downcast<ContainerBox>(layoutBox));
         }
     }
 
@@ -902,7 +901,7 @@
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
     if (!layoutBox.isReplacedBox())
-        return outOfFlowNonReplacedVerticalGeometry(layoutBox, horizontalConstraints, verticalConstraints, overrideVerticalValues);
+        return outOfFlowNonReplacedVerticalGeometry(downcast<ContainerBox>(layoutBox), horizontalConstraints, verticalConstraints, overrideVerticalValues);
     return outOfFlowReplacedVerticalGeometry(downcast<ReplacedBox>(layoutBox), horizontalConstraints, verticalConstraints, overrideVerticalValues);
 }
 
@@ -911,7 +910,7 @@
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
     if (!layoutBox.isReplacedBox())
-        return outOfFlowNonReplacedHorizontalGeometry(layoutBox, horizontalConstraints, overrideHorizontalValues);
+        return outOfFlowNonReplacedHorizontalGeometry(downcast<ContainerBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
     return outOfFlowReplacedHorizontalGeometry(downcast<ReplacedBox>(layoutBox), horizontalConstraints, verticalConstraints, overrideHorizontalValues);
 }
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (268098 => 268099)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-10-07 00:23:14 UTC (rev 268098)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-10-07 00:23:17 UTC (rev 268099)
@@ -107,7 +107,7 @@
     // 10.6.7 'Auto' heights for block-level formatting context boxes.
     auto isAutoHeight = !overrideVerticalValues.height && !computedHeight(layoutBox);
     if (isAutoHeight && (layoutBox.establishesFormattingContext() && !layoutBox.establishesInlineFormattingContext()))
-        return compute( OverrideVerticalValues { contentHeightForFormattingContextRoot(layoutBox) });
+        return compute( OverrideVerticalValues { contentHeightForFormattingContextRoot(downcast<ContainerBox>(layoutBox)) });
     return compute(overrideVerticalValues);
 }
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (268098 => 268099)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-10-07 00:23:14 UTC (rev 268098)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-10-07 00:23:17 UTC (rev 268099)
@@ -200,6 +200,7 @@
         if (is<RenderLineBreak>(renderer)) {
             clonedStyle.setDisplay(DisplayType::Inline);
             clonedStyle.setFloating(Float::No);
+            clonedStyle.setPosition(PositionType::Static);
             childLayoutBox = &createLineBreakBox(downcast<RenderLineBreak>(childRenderer).isWBR(), WTFMove(clonedStyle));
         } else if (is<RenderTable>(renderer)) {
             // Construct the principal table wrapper box (and not the table box itself).
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to