Diff
Modified: trunk/Source/WebCore/ChangeLog (277548 => 277549)
--- trunk/Source/WebCore/ChangeLog 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/ChangeLog 2021-05-15 22:30:39 UTC (rev 277549)
@@ -1,5 +1,31 @@
2021-05-15 Alan Bujtas <[email protected]>
+ [LFC] Move block formatting geometry to its own class
+ https://bugs.webkit.org/show_bug.cgi?id=225756
+
+ Reviewed by Antti Koivisto.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/formattingContexts/block/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::geometry const):
+ * layout/formattingContexts/block/BlockFormattingContext.h:
+ (WebCore::Layout::BlockFormattingContext::Geometry::formattingContext const): Deleted.
+ (WebCore::Layout::BlockFormattingContext::geometry const): Deleted.
+ (WebCore::Layout::BlockFormattingContext::Geometry::Geometry): Deleted.
+ * layout/formattingContexts/block/BlockFormattingContextGeometry.cpp: Removed.
+ * layout/formattingContexts/block/BlockFormattingQuirks.cpp:
+ (WebCore::Layout::BlockFormattingQuirks::stretchedInFlowHeight):
+ * layout/formattingContexts/block/BlockFormattingQuirks.h:
+ (WebCore::Layout::BlockFormattingQuirks::formattingContext const):
+ (WebCore::Layout::BlockFormattingQuirks::geometry const): Deleted.
+ * layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp:
+ * layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+ * layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingQuirks.cpp:
+ (WebCore::Layout::TableWrapperQuirks::overriddenTableHeight const):
+
+2021-05-15 Alan Bujtas <[email protected]>
+
[LFC] Move base formatting quirks to its own class
https://bugs.webkit.org/show_bug.cgi?id=225757
Modified: trunk/Source/WebCore/Sources.txt (277548 => 277549)
--- trunk/Source/WebCore/Sources.txt 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/Sources.txt 2021-05-15 22:30:39 UTC (rev 277549)
@@ -1519,7 +1519,7 @@
layout/LayoutUnits.cpp
layout/Verification.cpp
layout/formattingContexts/block/BlockFormattingContext.cpp
-layout/formattingContexts/block/BlockFormattingContextGeometry.cpp
+layout/formattingContexts/block/BlockFormattingGeometry.cpp
layout/formattingContexts/block/BlockFormattingQuirks.cpp
layout/formattingContexts/block/BlockFormattingState.cpp
layout/formattingContexts/block/BlockMarginCollapse.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (277548 => 277549)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-15 22:30:39 UTC (rev 277549)
@@ -1333,6 +1333,7 @@
46EFAF121E5FB9F100E7F34B /* LowPowerModeNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
46F02A1A23737F8300106A64 /* EventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0ABCA123679AB300B45085 /* EventLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 4786356526507A3800C5E2E0 /* BlockFormattingGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 4786356426507A3700C5E2E0 /* BlockFormattingGeometry.h */; settings = {ATTRIBUTES = (Private, ); }; };
47F947DB26502F2F0087968C /* BlockFormattingQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 47F947DA26502F2F0087968C /* BlockFormattingQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 49291E4A134172C800E753DE /* ImageRenderingMode.h */; };
493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 493E5E0812D6420500020081 /* PlatformCALayerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8386,6 +8387,7 @@
46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LowPowerModeNotifier.cpp; sourceTree = "<group>"; };
46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LowPowerModeNotifier.h; sourceTree = "<group>"; };
46F91BC91FCDD0FE001599C3 /* JSWorkerNavigatorCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerNavigatorCustom.cpp; sourceTree = "<group>"; };
+ 4786356426507A3700C5E2E0 /* BlockFormattingGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockFormattingGeometry.h; sourceTree = "<group>"; };
47F947DA26502F2F0087968C /* BlockFormattingQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockFormattingQuirks.h; sourceTree = "<group>"; };
49291E4A134172C800E753DE /* ImageRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRenderingMode.h; sourceTree = "<group>"; };
493E5E0812D6420500020081 /* PlatformCALayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerClient.h; sourceTree = "<group>"; };
@@ -9944,7 +9946,7 @@
6ED8C378183BFF8C009E53BD /* BoxShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoxShape.h; sourceTree = "<group>"; };
6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
- 6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingContextGeometry.cpp; sourceTree = "<group>"; };
+ 6F0830DF20B46951008A945B /* BlockFormattingGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingGeometry.cpp; sourceTree = "<group>"; };
6F0B98B323F268EB00EEC2F2 /* LayoutInlineTextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutInlineTextBox.h; sourceTree = "<group>"; };
6F0B98B623F2690600EEC2F2 /* LayoutInlineTextBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutInlineTextBox.cpp; sourceTree = "<group>"; };
6F0CD692229ED31900C5994E /* InlineLine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLine.cpp; sourceTree = "<group>"; };
@@ -18239,7 +18241,8 @@
6FD4FE3E2470B3AD007374CC /* tablewrapper */,
115CFA6D208AFAB6001E6991 /* BlockFormattingContext.cpp */,
115CFA6C208AFAB6001E6991 /* BlockFormattingContext.h */,
- 6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */,
+ 6F0830DF20B46951008A945B /* BlockFormattingGeometry.cpp */,
+ 4786356426507A3700C5E2E0 /* BlockFormattingGeometry.h */,
6F8F460321B03BC60041AC3A /* BlockFormattingQuirks.cpp */,
47F947DA26502F2F0087968C /* BlockFormattingQuirks.h */,
115CFA79208B8D9D001E6991 /* BlockFormattingState.cpp */,
@@ -31682,6 +31685,7 @@
2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */,
115CFA6E208AFAB7001E6991 /* BlockFormattingContext.h in Headers */,
+ 4786356526507A3800C5E2E0 /* BlockFormattingGeometry.h in Headers */,
47F947DB26502F2F0087968C /* BlockFormattingQuirks.h in Headers */,
115CFA7A208B8D9D001E6991 /* BlockFormattingState.h in Headers */,
6F6DF36F264722EA0093E834 /* BlockMarginCollapse.h in Headers */,
Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "BlockFormattingGeometry.h"
#include "BlockFormattingQuirks.h"
#include "BlockFormattingState.h"
#include "BlockMarginCollapse.h"
@@ -601,6 +602,11 @@
}
}
+BlockFormattingGeometry BlockFormattingContext::geometry() const
+{
+ return BlockFormattingGeometry(*this);
+}
+
BlockMarginCollapse BlockFormattingContext::marginCollapse() const
{
return BlockMarginCollapse(*this);
Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h 2021-05-15 22:30:39 UTC (rev 277549)
@@ -39,6 +39,7 @@
namespace Layout {
class Box;
+class BlockFormattingGeometry;
class BlockFormattingQuirks;
class BlockMarginCollapse;
class FloatingContext;
@@ -55,34 +56,10 @@
const BlockFormattingState& formattingState() const { return downcast<BlockFormattingState>(FormattingContext::formattingState()); }
+ BlockFormattingGeometry geometry() const;
BlockFormattingQuirks quirks() const;
BlockMarginCollapse marginCollapse() const;
- // This class implements positioning and sizing for boxes participating in a block formatting context.
- class Geometry : public FormattingContext::Geometry {
- public:
- Geometry(const BlockFormattingContext&);
-
- ContentHeightAndMargin inFlowContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&);
- ContentWidthAndMargin inFlowContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
-
- Point staticPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&) const;
- LayoutUnit staticVerticalPosition(const Box&, const VerticalConstraints&) const;
- LayoutUnit staticHorizontalPosition(const Box&, const HorizontalConstraints&) const;
-
- IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
-
- ContentWidthAndMargin computedContentWidthAndMargin(const Box&, const HorizontalConstraints&, Optional<LayoutUnit> availableWidthFloatAvoider);
-
- private:
- ContentHeightAndMargin inFlowNonReplacedContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&);
- ContentWidthAndMargin inFlowNonReplacedContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
- ContentWidthAndMargin inFlowReplacedContentWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
-
- const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Geometry::formattingContext()); }
- };
- BlockFormattingContext::Geometry geometry() const { return Geometry(*this); }
-
protected:
struct ConstraintsPair {
ConstraintsForInFlowContent formattingContextRoot;
@@ -118,13 +95,8 @@
HashMap<const Box*, PrecomputedMarginBefore> m_precomputedMarginBeforeList;
};
-inline BlockFormattingContext::Geometry::Geometry(const BlockFormattingContext& blockFormattingContext)
- : FormattingContext::Geometry(blockFormattingContext)
-{
}
-
}
-}
SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(BlockFormattingContext, isBlockFormattingContext())
Deleted: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContextGeometry.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContextGeometry.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContextGeometry.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -1,401 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BlockFormattingContext.h"
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "BlockFormattingState.h"
-#include "FormattingContext.h"
-#include "InlineFormattingState.h"
-#include "LayoutBoxGeometry.h"
-#include "LayoutChildIterator.h"
-#include "LayoutContext.h"
-#include "LayoutInitialContainingBlock.h"
-#include "LayoutReplacedBox.h"
-#include "Logging.h"
-#include <wtf/text/TextStream.h>
-
-namespace WebCore {
-namespace Layout {
-
-ContentHeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedContentHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenVerticalValues& overriddenVerticalValues)
-{
- ASSERT(layoutBox.isInFlow() && !layoutBox.isReplacedBox());
- ASSERT(layoutBox.isOverflowVisible());
-
- auto compute = [&](const auto& overriddenVerticalValues) -> ContentHeightAndMargin {
-
- // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
- //
- // If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0.
- // If 'height' is 'auto', the height depends on whether the element has any block-level children and whether it has padding or borders:
- // The element's height is the distance from its top content edge to the first applicable of the following:
- // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
- // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin
- // does not collapse with the element's bottom margin
- // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
- // 4. zero, otherwise
- // Only children in the normal flow are taken into account (i.e., floating boxes and absolutely positioned boxes are ignored,
- // and relatively positioned boxes are considered without their offset). Note that the child box may be an anonymous block box.
-
- auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, horizontalConstraints);
- auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
- auto borderAndPaddingTop = boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0);
- auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(layoutBox);
-
- if (height)
- return { *height, nonCollapsedMargin };
-
- if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowChild())
- return { 0, nonCollapsedMargin };
-
- // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
- auto& layoutContainer = downcast<ContainerBox>(layoutBox);
- if (layoutContainer.establishesInlineFormattingContext()) {
- auto& inlineFormattingState = layoutState().establishedInlineFormattingState(layoutContainer);
- auto& lines = inlineFormattingState.lines();
- // Even empty containers generate one line.
- ASSERT(!lines.isEmpty());
- return { toLayoutUnit(lines.last().lineBoxLogicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
- }
-
- // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
- auto& lastInFlowChild = *layoutContainer.lastInFlowChild();
- if (!formattingContext().marginCollapse().marginAfterCollapsesWithParentMarginAfter(lastInFlowChild)) {
- auto& lastInFlowBoxGeometry = formattingContext().geometryForBox(lastInFlowChild);
- auto bottomEdgeOfBottomMargin = BoxGeometry::borderBoxRect(lastInFlowBoxGeometry).bottom() + lastInFlowBoxGeometry.marginAfter();
- return { bottomEdgeOfBottomMargin - borderAndPaddingTop, nonCollapsedMargin };
- }
-
- // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
- auto* inFlowChild = &lastInFlowChild;
- while (inFlowChild && formattingContext().marginCollapse().marginBeforeCollapsesWithParentMarginAfter(*inFlowChild))
- inFlowChild = inFlowChild->previousInFlowSibling();
- if (inFlowChild) {
- auto& inFlowBoxGeometry = formattingContext().geometryForBox(*inFlowChild);
- return { BoxGeometry::borderBoxTop(inFlowBoxGeometry) + inFlowBoxGeometry.borderBox().height() - borderAndPaddingTop, nonCollapsedMargin };
- }
-
- // 4. zero, otherwise
- return { 0, nonCollapsedMargin };
- };
-
- // 10.6.7 'Auto' heights for block-level formatting context boxes.
- auto isAutoHeight = !overriddenVerticalValues.height && !computedHeight(layoutBox);
- if (isAutoHeight && (layoutBox.establishesFormattingContext() && !layoutBox.establishesInlineFormattingContext()))
- return compute( OverriddenVerticalValues { contentHeightForFormattingContextRoot(downcast<ContainerBox>(layoutBox)) });
- return compute(overriddenVerticalValues);
-}
-
-ContentWidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
-{
- ASSERT(layoutBox.isInFlow());
-
- auto compute = [&]() {
-
- // 10.3.3 Block-level, non-replaced elements in normal flow
- //
- // The following constraints must hold among the used values of the other properties:
- // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
- //
- // 1. If 'width' is not 'auto' and 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width'
- // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larger than the width of the containing block, then
- // any 'auto' values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero.
- //
- // 2. If all of the above have a computed value other than 'auto', the values are said to be "over-constrained" and one of the used values will
- // have to be different from its computed value. If the 'direction' property of the containing block has the value 'ltr', the specified value
- // of 'margin-right' is ignored and the value is calculated so as to make the equality true. If the value of 'direction' is 'rtl',
- // this happens to 'margin-left' instead.
- //
- // 3. If there is exactly one value specified as 'auto', its used value follows from the equality.
- //
- // 4. If 'width' is set to 'auto', any other 'auto' values become '0' and 'width' follows from the resulting equality.
- //
- // 5. If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element with respect to the
- // edges of the containing block.
-
- auto containingBlockWidth = horizontalConstraints.logicalWidth;
- auto& containingBlockStyle = layoutBox.containingBlock().style();
- auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
-
- auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(layoutBox, containingBlockWidth);
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, horizontalConstraints);
- UsedHorizontalMargin usedHorizontalMargin;
- auto borderLeft = boxGeometry.borderLeft();
- auto borderRight = boxGeometry.borderRight();
- auto paddingLeft = boxGeometry.paddingLeft().valueOr(0);
- auto paddingRight = boxGeometry.paddingRight().valueOr(0);
-
- // #1
- if (width) {
- auto horizontalSpaceForMargin = containingBlockWidth - (computedHorizontalMargin.start.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + computedHorizontalMargin.end.valueOr(0));
- if (horizontalSpaceForMargin < 0)
- usedHorizontalMargin = { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
- }
-
- // #2
- if (width && computedHorizontalMargin.start && computedHorizontalMargin.end) {
- if (containingBlockStyle.isLeftToRightDirection()) {
- usedHorizontalMargin.start = *computedHorizontalMargin.start;
- usedHorizontalMargin.end = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight);
- } else {
- usedHorizontalMargin.end = *computedHorizontalMargin.end;
- usedHorizontalMargin.start = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
- }
- }
-
- // #3
- if (!computedHorizontalMargin.start && width && computedHorizontalMargin.end) {
- usedHorizontalMargin.end = *computedHorizontalMargin.end;
- usedHorizontalMargin.start = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
- } else if (computedHorizontalMargin.start && !width && computedHorizontalMargin.end) {
- usedHorizontalMargin = { *computedHorizontalMargin.start, *computedHorizontalMargin.end };
- width = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end);
- } else if (computedHorizontalMargin.start && width && !computedHorizontalMargin.end) {
- usedHorizontalMargin.start = *computedHorizontalMargin.start;
- usedHorizontalMargin.end = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight);
- }
-
- // #4
- if (!width) {
- usedHorizontalMargin = { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
- width = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end);
- }
-
- // #5
- if (!computedHorizontalMargin.start && !computedHorizontalMargin.end) {
- auto horizontalSpaceForMargin = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight);
- usedHorizontalMargin = { horizontalSpaceForMargin / 2, horizontalSpaceForMargin / 2 };
- }
-
- auto shouldApplyCenterAlignForBlockContent = containingBlockStyle.textAlign() == TextAlignMode::WebKitCenter && (computedHorizontalMargin.start || computedHorizontalMargin.end);
- if (shouldApplyCenterAlignForBlockContent) {
- auto borderBoxWidth = (borderLeft + paddingLeft + *width + paddingRight + borderRight);
- auto marginStart = computedHorizontalMargin.start.valueOr(0);
- auto marginEnd = computedHorizontalMargin.end.valueOr(0);
- auto centeredLogicalLeftForMarginBox = std::max((containingBlockWidth - borderBoxWidth - marginStart - marginEnd) / 2, 0_lu);
- usedHorizontalMargin.start = centeredLogicalLeftForMarginBox + marginStart;
- usedHorizontalMargin.end = containingBlockWidth - borderBoxWidth - marginStart + marginEnd;
- }
- ASSERT(width);
-
- return ContentWidthAndMargin { *width, usedHorizontalMargin };
- };
-
- auto contentWidthAndMargin = compute();
- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << contentWidthAndMargin.contentWidth << "px) margin(" << contentWidthAndMargin.usedMargin.start << "px, " << contentWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
- return contentWidthAndMargin;
-}
-
-ContentWidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedContentWidthAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
-{
- ASSERT(replacedBox.isInFlow());
-
- // 10.3.4 Block-level, replaced elements in normal flow
- //
- // 1. The used value of 'width' is determined as for inline replaced elements.
- // 2. Then the rules for non-replaced block-level elements are applied to determine the margins.
-
- // #1
- auto usedWidth = inlineReplacedContentWidthAndMargin(replacedBox, horizontalConstraints, { }, overriddenHorizontalValues).contentWidth;
- // #2
- auto nonReplacedWidthAndMargin = inFlowNonReplacedContentWidthAndMargin(replacedBox, horizontalConstraints, OverriddenHorizontalValues { usedWidth, overriddenHorizontalValues.margin });
-
- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << usedWidth << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &replacedBox << ")");
- return { usedWidth, nonReplacedWidthAndMargin.usedMargin };
-}
-
-LayoutUnit BlockFormattingContext::Geometry::staticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints) const
-{
- // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
- // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
- // The vertical distance between two sibling boxes is determined by the 'margin' properties.
- // Vertical margins between adjacent block-level boxes in a block formatting context collapse.
- if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
- auto& previousInFlowBoxGeometry = formattingContext().geometryForBox(*previousInFlowSibling);
- return BoxGeometry::borderBoxRect(previousInFlowBoxGeometry).bottom() + previousInFlowBoxGeometry.marginAfter();
- }
- return verticalConstraints.logicalTop;
-}
-
-LayoutUnit BlockFormattingContext::Geometry::staticHorizontalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints) const
-{
- // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
- // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch).
- return horizontalConstraints.logicalLeft + formattingContext().geometryForBox(layoutBox).marginStart();
-}
-
-Point BlockFormattingContext::Geometry::staticPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) const
-{
- return { staticHorizontalPosition(layoutBox, horizontalConstraints), staticVerticalPosition(layoutBox, verticalConstraints) };
-}
-
-ContentHeightAndMargin BlockFormattingContext::Geometry::inFlowContentHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenVerticalValues& overriddenVerticalValues)
-{
- ASSERT(layoutBox.isInFlow());
-
- // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
- // replaced elements in normal flow and floating replaced elements
- if (layoutBox.isReplacedBox())
- return inlineReplacedContentHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overriddenVerticalValues);
-
- ContentHeightAndMargin contentHeightAndMargin;
- if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox()) {
- // TODO: Figure out the case for the document element. Let's just complicated-case it for now.
- contentHeightAndMargin = inFlowNonReplacedContentHeightAndMargin(layoutBox, horizontalConstraints, overriddenVerticalValues);
- } else {
- // 10.6.6 Complicated cases
- // Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport).
- contentHeightAndMargin = complicatedCases(layoutBox, horizontalConstraints, overriddenVerticalValues);
- }
-
- auto quirks = formattingContext().quirks();
- if (!quirks.needsStretching(layoutBox))
- return contentHeightAndMargin;
-
- contentHeightAndMargin.contentHeight = quirks.stretchedInFlowHeight(layoutBox, contentHeightAndMargin);
-
- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << contentHeightAndMargin.contentHeight << "px) margin(" << contentHeightAndMargin.nonCollapsedMargin.before << "px, " << contentHeightAndMargin.nonCollapsedMargin.after << "px) -> layoutBox(" << &layoutBox << ")");
- return contentHeightAndMargin;
-}
-
-ContentWidthAndMargin BlockFormattingContext::Geometry::inFlowContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
-{
- ASSERT(layoutBox.isInFlow());
-
- if (!layoutBox.isReplacedBox())
- return inFlowNonReplacedContentWidthAndMargin(layoutBox, horizontalConstraints, overriddenHorizontalValues);
- return inFlowReplacedContentWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overriddenHorizontalValues);
-}
-
-ContentWidthAndMargin BlockFormattingContext::Geometry::computedContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, Optional<LayoutUnit> availableWidthFloatAvoider)
-{
- auto compute = [&] (auto constraintsForWidth, Optional<LayoutUnit> usedWidth) {
- if (layoutBox.isFloatingPositioned())
- return floatingContentWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
-
- if (layoutBox.isInFlow())
- return inFlowContentWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
-
- ASSERT_NOT_REACHED();
- return ContentWidthAndMargin { };
- };
-
- auto horizontalConstraintsForWidth = horizontalConstraints;
- if (layoutBox.style().logicalWidth().isAuto() && availableWidthFloatAvoider) {
- // While the non-auto width values should all be resolved against the containing block's width, when
- // the width is auto the available horizontal space is shrunk by neighboring floats.
- horizontalConstraintsForWidth.logicalWidth = *availableWidthFloatAvoider;
- }
- auto contentWidthAndMargin = compute(horizontalConstraintsForWidth, { });
- auto availableWidth = horizontalConstraints.logicalWidth;
- if (auto maxWidth = computedMaxWidth(layoutBox, availableWidth)) {
- auto maxWidthAndMargin = compute(horizontalConstraints, maxWidth);
- if (contentWidthAndMargin.contentWidth > maxWidthAndMargin.contentWidth)
- contentWidthAndMargin = maxWidthAndMargin;
- }
-
- auto minWidth = computedMinWidth(layoutBox, availableWidth).valueOr(0);
- auto minWidthAndMargin = compute(horizontalConstraints, minWidth);
- if (contentWidthAndMargin.contentWidth < minWidthAndMargin.contentWidth)
- contentWidthAndMargin = minWidthAndMargin;
- return contentWidthAndMargin;
-}
-
-FormattingContext::IntrinsicWidthConstraints BlockFormattingContext::Geometry::intrinsicWidthConstraints(const Box& layoutBox)
-{
- auto fixedMarginBorderAndPadding = [&](auto& layoutBox) {
- auto& style = layoutBox.style();
- return fixedValue(style.marginStart()).valueOr(0)
- + LayoutUnit { style.borderLeftWidth() }
- + fixedValue(style.paddingLeft()).valueOr(0)
- + fixedValue(style.paddingRight()).valueOr(0)
- + LayoutUnit { style.borderRightWidth() }
- + fixedValue(style.marginEnd()).valueOr(0);
- };
-
- auto computedIntrinsicWidthConstraints = [&]() -> IntrinsicWidthConstraints {
- auto logicalWidth = layoutBox.style().logicalWidth();
- // Minimum/maximum width can't be depending on the containing block's width.
- auto needsResolvedContainingBlockWidth = logicalWidth.isCalculated() || logicalWidth.isPercent() || logicalWidth.isRelative();
- if (needsResolvedContainingBlockWidth)
- return { };
-
- if (auto width = fixedValue(logicalWidth))
- return { *width, *width };
-
- if (layoutBox.isReplacedBox()) {
- auto& replacedBox = downcast<ReplacedBox>(layoutBox);
- if (replacedBox.hasIntrinsicWidth()) {
- auto replacedWidth = replacedBox.intrinsicWidth();
- return { replacedWidth, replacedWidth };
- }
- return { };
- }
-
- if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild())
- return { };
-
- if (layoutBox.isSizeContainmentBox()) {
- // The intrinsic sizes of the size containment box are determined as if the element had no content,
- // following the same logic as when sizing as if empty.
- return { };
- }
-
- if (layoutBox.establishesFormattingContext()) {
- auto intrinsicWidthConstraints = LayoutContext::createFormattingContext(downcast<ContainerBox>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
- if (logicalWidth.isMinContent())
- return { intrinsicWidthConstraints.minimum, intrinsicWidthConstraints.minimum };
- if (logicalWidth.isMaxContent())
- return { intrinsicWidthConstraints.maximum, intrinsicWidthConstraints.maximum };
- return intrinsicWidthConstraints;
- }
-
- auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
- auto& formattingState = layoutState().formattingStateForBox(layoutBox);
- for (auto& child : childrenOfType<Box>(downcast<ContainerBox>(layoutBox))) {
- if (child.isOutOfFlowPositioned() || (child.isFloatAvoider() && !child.hasFloatClear()))
- continue;
- auto childIntrinsicWidthConstraints = formattingState.intrinsicWidthConstraintsForBox(child);
- ASSERT(childIntrinsicWidthConstraints);
-
- intrinsicWidthConstraints.minimum = std::max(intrinsicWidthConstraints.minimum, childIntrinsicWidthConstraints->minimum);
- intrinsicWidthConstraints.maximum = std::max(intrinsicWidthConstraints.maximum, childIntrinsicWidthConstraints->maximum);
- }
- return intrinsicWidthConstraints;
- };
- // FIXME Check for box-sizing: border-box;
- auto intrinsicWidthConstraints = constrainByMinMaxWidth(layoutBox, computedIntrinsicWidthConstraints());
- intrinsicWidthConstraints.expand(fixedMarginBorderAndPadding(layoutBox));
- return intrinsicWidthConstraints;
-}
-
-}
-}
-
-#endif
Copied: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp (from rev 277548, trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContextGeometry.cpp) (0 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -0,0 +1,406 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BlockFormattingGeometry.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BlockFormattingState.h"
+#include "FormattingContext.h"
+#include "InlineFormattingState.h"
+#include "LayoutBoxGeometry.h"
+#include "LayoutChildIterator.h"
+#include "LayoutContext.h"
+#include "LayoutInitialContainingBlock.h"
+#include "LayoutReplacedBox.h"
+#include "Logging.h"
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+namespace Layout {
+
+BlockFormattingGeometry::BlockFormattingGeometry(const BlockFormattingContext& blockFormattingContext)
+ : FormattingContext::Geometry(blockFormattingContext)
+{
+}
+
+ContentHeightAndMargin BlockFormattingGeometry::inFlowNonReplacedContentHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenVerticalValues& overriddenVerticalValues)
+{
+ ASSERT(layoutBox.isInFlow() && !layoutBox.isReplacedBox());
+ ASSERT(layoutBox.isOverflowVisible());
+
+ auto compute = [&](const auto& overriddenVerticalValues) -> ContentHeightAndMargin {
+
+ // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
+ //
+ // If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0.
+ // If 'height' is 'auto', the height depends on whether the element has any block-level children and whether it has padding or borders:
+ // The element's height is the distance from its top content edge to the first applicable of the following:
+ // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
+ // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin
+ // does not collapse with the element's bottom margin
+ // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
+ // 4. zero, otherwise
+ // Only children in the normal flow are taken into account (i.e., floating boxes and absolutely positioned boxes are ignored,
+ // and relatively positioned boxes are considered without their offset). Note that the child box may be an anonymous block box.
+
+ auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, horizontalConstraints);
+ auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
+ auto borderAndPaddingTop = boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0);
+ auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(layoutBox);
+
+ if (height)
+ return { *height, nonCollapsedMargin };
+
+ if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowChild())
+ return { 0, nonCollapsedMargin };
+
+ // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
+ auto& layoutContainer = downcast<ContainerBox>(layoutBox);
+ if (layoutContainer.establishesInlineFormattingContext()) {
+ auto& inlineFormattingState = layoutState().establishedInlineFormattingState(layoutContainer);
+ auto& lines = inlineFormattingState.lines();
+ // Even empty containers generate one line.
+ ASSERT(!lines.isEmpty());
+ return { toLayoutUnit(lines.last().lineBoxLogicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
+ }
+
+ // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
+ auto& lastInFlowChild = *layoutContainer.lastInFlowChild();
+ if (!formattingContext().marginCollapse().marginAfterCollapsesWithParentMarginAfter(lastInFlowChild)) {
+ auto& lastInFlowBoxGeometry = formattingContext().geometryForBox(lastInFlowChild);
+ auto bottomEdgeOfBottomMargin = BoxGeometry::borderBoxRect(lastInFlowBoxGeometry).bottom() + lastInFlowBoxGeometry.marginAfter();
+ return { bottomEdgeOfBottomMargin - borderAndPaddingTop, nonCollapsedMargin };
+ }
+
+ // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
+ auto* inFlowChild = &lastInFlowChild;
+ while (inFlowChild && formattingContext().marginCollapse().marginBeforeCollapsesWithParentMarginAfter(*inFlowChild))
+ inFlowChild = inFlowChild->previousInFlowSibling();
+ if (inFlowChild) {
+ auto& inFlowBoxGeometry = formattingContext().geometryForBox(*inFlowChild);
+ return { BoxGeometry::borderBoxTop(inFlowBoxGeometry) + inFlowBoxGeometry.borderBox().height() - borderAndPaddingTop, nonCollapsedMargin };
+ }
+
+ // 4. zero, otherwise
+ return { 0, nonCollapsedMargin };
+ };
+
+ // 10.6.7 'Auto' heights for block-level formatting context boxes.
+ auto isAutoHeight = !overriddenVerticalValues.height && !computedHeight(layoutBox);
+ if (isAutoHeight && (layoutBox.establishesFormattingContext() && !layoutBox.establishesInlineFormattingContext()))
+ return compute( OverriddenVerticalValues { contentHeightForFormattingContextRoot(downcast<ContainerBox>(layoutBox)) });
+ return compute(overriddenVerticalValues);
+}
+
+ContentWidthAndMargin BlockFormattingGeometry::inFlowNonReplacedContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
+{
+ ASSERT(layoutBox.isInFlow());
+
+ auto compute = [&]() {
+
+ // 10.3.3 Block-level, non-replaced elements in normal flow
+ //
+ // The following constraints must hold among the used values of the other properties:
+ // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
+ //
+ // 1. If 'width' is not 'auto' and 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width'
+ // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larger than the width of the containing block, then
+ // any 'auto' values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero.
+ //
+ // 2. If all of the above have a computed value other than 'auto', the values are said to be "over-constrained" and one of the used values will
+ // have to be different from its computed value. If the 'direction' property of the containing block has the value 'ltr', the specified value
+ // of 'margin-right' is ignored and the value is calculated so as to make the equality true. If the value of 'direction' is 'rtl',
+ // this happens to 'margin-left' instead.
+ //
+ // 3. If there is exactly one value specified as 'auto', its used value follows from the equality.
+ //
+ // 4. If 'width' is set to 'auto', any other 'auto' values become '0' and 'width' follows from the resulting equality.
+ //
+ // 5. If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element with respect to the
+ // edges of the containing block.
+
+ auto containingBlockWidth = horizontalConstraints.logicalWidth;
+ auto& containingBlockStyle = layoutBox.containingBlock().style();
+ auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
+
+ auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(layoutBox, containingBlockWidth);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, horizontalConstraints);
+ UsedHorizontalMargin usedHorizontalMargin;
+ auto borderLeft = boxGeometry.borderLeft();
+ auto borderRight = boxGeometry.borderRight();
+ auto paddingLeft = boxGeometry.paddingLeft().valueOr(0);
+ auto paddingRight = boxGeometry.paddingRight().valueOr(0);
+
+ // #1
+ if (width) {
+ auto horizontalSpaceForMargin = containingBlockWidth - (computedHorizontalMargin.start.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + computedHorizontalMargin.end.valueOr(0));
+ if (horizontalSpaceForMargin < 0)
+ usedHorizontalMargin = { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
+ }
+
+ // #2
+ if (width && computedHorizontalMargin.start && computedHorizontalMargin.end) {
+ if (containingBlockStyle.isLeftToRightDirection()) {
+ usedHorizontalMargin.start = *computedHorizontalMargin.start;
+ usedHorizontalMargin.end = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight);
+ } else {
+ usedHorizontalMargin.end = *computedHorizontalMargin.end;
+ usedHorizontalMargin.start = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
+ }
+ }
+
+ // #3
+ if (!computedHorizontalMargin.start && width && computedHorizontalMargin.end) {
+ usedHorizontalMargin.end = *computedHorizontalMargin.end;
+ usedHorizontalMargin.start = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
+ } else if (computedHorizontalMargin.start && !width && computedHorizontalMargin.end) {
+ usedHorizontalMargin = { *computedHorizontalMargin.start, *computedHorizontalMargin.end };
+ width = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end);
+ } else if (computedHorizontalMargin.start && width && !computedHorizontalMargin.end) {
+ usedHorizontalMargin.start = *computedHorizontalMargin.start;
+ usedHorizontalMargin.end = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight);
+ }
+
+ // #4
+ if (!width) {
+ usedHorizontalMargin = { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
+ width = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end);
+ }
+
+ // #5
+ if (!computedHorizontalMargin.start && !computedHorizontalMargin.end) {
+ auto horizontalSpaceForMargin = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight);
+ usedHorizontalMargin = { horizontalSpaceForMargin / 2, horizontalSpaceForMargin / 2 };
+ }
+
+ auto shouldApplyCenterAlignForBlockContent = containingBlockStyle.textAlign() == TextAlignMode::WebKitCenter && (computedHorizontalMargin.start || computedHorizontalMargin.end);
+ if (shouldApplyCenterAlignForBlockContent) {
+ auto borderBoxWidth = (borderLeft + paddingLeft + *width + paddingRight + borderRight);
+ auto marginStart = computedHorizontalMargin.start.valueOr(0);
+ auto marginEnd = computedHorizontalMargin.end.valueOr(0);
+ auto centeredLogicalLeftForMarginBox = std::max((containingBlockWidth - borderBoxWidth - marginStart - marginEnd) / 2, 0_lu);
+ usedHorizontalMargin.start = centeredLogicalLeftForMarginBox + marginStart;
+ usedHorizontalMargin.end = containingBlockWidth - borderBoxWidth - marginStart + marginEnd;
+ }
+ ASSERT(width);
+
+ return ContentWidthAndMargin { *width, usedHorizontalMargin };
+ };
+
+ auto contentWidthAndMargin = compute();
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << contentWidthAndMargin.contentWidth << "px) margin(" << contentWidthAndMargin.usedMargin.start << "px, " << contentWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
+ return contentWidthAndMargin;
+}
+
+ContentWidthAndMargin BlockFormattingGeometry::inFlowReplacedContentWidthAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
+{
+ ASSERT(replacedBox.isInFlow());
+
+ // 10.3.4 Block-level, replaced elements in normal flow
+ //
+ // 1. The used value of 'width' is determined as for inline replaced elements.
+ // 2. Then the rules for non-replaced block-level elements are applied to determine the margins.
+
+ // #1
+ auto usedWidth = inlineReplacedContentWidthAndMargin(replacedBox, horizontalConstraints, { }, overriddenHorizontalValues).contentWidth;
+ // #2
+ auto nonReplacedWidthAndMargin = inFlowNonReplacedContentWidthAndMargin(replacedBox, horizontalConstraints, OverriddenHorizontalValues { usedWidth, overriddenHorizontalValues.margin });
+
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << usedWidth << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &replacedBox << ")");
+ return { usedWidth, nonReplacedWidthAndMargin.usedMargin };
+}
+
+LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints) const
+{
+ // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
+ // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
+ // The vertical distance between two sibling boxes is determined by the 'margin' properties.
+ // Vertical margins between adjacent block-level boxes in a block formatting context collapse.
+ if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
+ auto& previousInFlowBoxGeometry = formattingContext().geometryForBox(*previousInFlowSibling);
+ return BoxGeometry::borderBoxRect(previousInFlowBoxGeometry).bottom() + previousInFlowBoxGeometry.marginAfter();
+ }
+ return verticalConstraints.logicalTop;
+}
+
+LayoutUnit BlockFormattingGeometry::staticHorizontalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints) const
+{
+ // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
+ // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch).
+ return horizontalConstraints.logicalLeft + formattingContext().geometryForBox(layoutBox).marginStart();
+}
+
+Point BlockFormattingGeometry::staticPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) const
+{
+ return { staticHorizontalPosition(layoutBox, horizontalConstraints), staticVerticalPosition(layoutBox, verticalConstraints) };
+}
+
+ContentHeightAndMargin BlockFormattingGeometry::inFlowContentHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenVerticalValues& overriddenVerticalValues)
+{
+ ASSERT(layoutBox.isInFlow());
+
+ // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
+ // replaced elements in normal flow and floating replaced elements
+ if (layoutBox.isReplacedBox())
+ return inlineReplacedContentHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overriddenVerticalValues);
+
+ ContentHeightAndMargin contentHeightAndMargin;
+ if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox()) {
+ // TODO: Figure out the case for the document element. Let's just complicated-case it for now.
+ contentHeightAndMargin = inFlowNonReplacedContentHeightAndMargin(layoutBox, horizontalConstraints, overriddenVerticalValues);
+ } else {
+ // 10.6.6 Complicated cases
+ // Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport).
+ contentHeightAndMargin = complicatedCases(layoutBox, horizontalConstraints, overriddenVerticalValues);
+ }
+
+ auto quirks = formattingContext().quirks();
+ if (!quirks.needsStretching(layoutBox))
+ return contentHeightAndMargin;
+
+ contentHeightAndMargin.contentHeight = quirks.stretchedInFlowHeight(layoutBox, contentHeightAndMargin);
+
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << contentHeightAndMargin.contentHeight << "px) margin(" << contentHeightAndMargin.nonCollapsedMargin.before << "px, " << contentHeightAndMargin.nonCollapsedMargin.after << "px) -> layoutBox(" << &layoutBox << ")");
+ return contentHeightAndMargin;
+}
+
+ContentWidthAndMargin BlockFormattingGeometry::inFlowContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenHorizontalValues& overriddenHorizontalValues)
+{
+ ASSERT(layoutBox.isInFlow());
+
+ if (!layoutBox.isReplacedBox())
+ return inFlowNonReplacedContentWidthAndMargin(layoutBox, horizontalConstraints, overriddenHorizontalValues);
+ return inFlowReplacedContentWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overriddenHorizontalValues);
+}
+
+ContentWidthAndMargin BlockFormattingGeometry::computedContentWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, Optional<LayoutUnit> availableWidthFloatAvoider)
+{
+ auto compute = [&] (auto constraintsForWidth, Optional<LayoutUnit> usedWidth) {
+ if (layoutBox.isFloatingPositioned())
+ return floatingContentWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
+
+ if (layoutBox.isInFlow())
+ return inFlowContentWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
+
+ ASSERT_NOT_REACHED();
+ return ContentWidthAndMargin { };
+ };
+
+ auto horizontalConstraintsForWidth = horizontalConstraints;
+ if (layoutBox.style().logicalWidth().isAuto() && availableWidthFloatAvoider) {
+ // While the non-auto width values should all be resolved against the containing block's width, when
+ // the width is auto the available horizontal space is shrunk by neighboring floats.
+ horizontalConstraintsForWidth.logicalWidth = *availableWidthFloatAvoider;
+ }
+ auto contentWidthAndMargin = compute(horizontalConstraintsForWidth, { });
+ auto availableWidth = horizontalConstraints.logicalWidth;
+ if (auto maxWidth = computedMaxWidth(layoutBox, availableWidth)) {
+ auto maxWidthAndMargin = compute(horizontalConstraints, maxWidth);
+ if (contentWidthAndMargin.contentWidth > maxWidthAndMargin.contentWidth)
+ contentWidthAndMargin = maxWidthAndMargin;
+ }
+
+ auto minWidth = computedMinWidth(layoutBox, availableWidth).valueOr(0);
+ auto minWidthAndMargin = compute(horizontalConstraints, minWidth);
+ if (contentWidthAndMargin.contentWidth < minWidthAndMargin.contentWidth)
+ contentWidthAndMargin = minWidthAndMargin;
+ return contentWidthAndMargin;
+}
+
+FormattingContext::IntrinsicWidthConstraints BlockFormattingGeometry::intrinsicWidthConstraints(const Box& layoutBox)
+{
+ auto fixedMarginBorderAndPadding = [&](auto& layoutBox) {
+ auto& style = layoutBox.style();
+ return fixedValue(style.marginStart()).valueOr(0)
+ + LayoutUnit { style.borderLeftWidth() }
+ + fixedValue(style.paddingLeft()).valueOr(0)
+ + fixedValue(style.paddingRight()).valueOr(0)
+ + LayoutUnit { style.borderRightWidth() }
+ + fixedValue(style.marginEnd()).valueOr(0);
+ };
+
+ auto computedIntrinsicWidthConstraints = [&]() -> FormattingContext::IntrinsicWidthConstraints {
+ auto logicalWidth = layoutBox.style().logicalWidth();
+ // Minimum/maximum width can't be depending on the containing block's width.
+ auto needsResolvedContainingBlockWidth = logicalWidth.isCalculated() || logicalWidth.isPercent() || logicalWidth.isRelative();
+ if (needsResolvedContainingBlockWidth)
+ return { };
+
+ if (auto width = fixedValue(logicalWidth))
+ return { *width, *width };
+
+ if (layoutBox.isReplacedBox()) {
+ auto& replacedBox = downcast<ReplacedBox>(layoutBox);
+ if (replacedBox.hasIntrinsicWidth()) {
+ auto replacedWidth = replacedBox.intrinsicWidth();
+ return { replacedWidth, replacedWidth };
+ }
+ return { };
+ }
+
+ if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild())
+ return { };
+
+ if (layoutBox.isSizeContainmentBox()) {
+ // The intrinsic sizes of the size containment box are determined as if the element had no content,
+ // following the same logic as when sizing as if empty.
+ return { };
+ }
+
+ if (layoutBox.establishesFormattingContext()) {
+ auto intrinsicWidthConstraints = LayoutContext::createFormattingContext(downcast<ContainerBox>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
+ if (logicalWidth.isMinContent())
+ return { intrinsicWidthConstraints.minimum, intrinsicWidthConstraints.minimum };
+ if (logicalWidth.isMaxContent())
+ return { intrinsicWidthConstraints.maximum, intrinsicWidthConstraints.maximum };
+ return intrinsicWidthConstraints;
+ }
+
+ auto intrinsicWidthConstraints = FormattingContext::IntrinsicWidthConstraints { };
+ auto& formattingState = layoutState().formattingStateForBox(layoutBox);
+ for (auto& child : childrenOfType<Box>(downcast<ContainerBox>(layoutBox))) {
+ if (child.isOutOfFlowPositioned() || (child.isFloatAvoider() && !child.hasFloatClear()))
+ continue;
+ auto childIntrinsicWidthConstraints = formattingState.intrinsicWidthConstraintsForBox(child);
+ ASSERT(childIntrinsicWidthConstraints);
+
+ intrinsicWidthConstraints.minimum = std::max(intrinsicWidthConstraints.minimum, childIntrinsicWidthConstraints->minimum);
+ intrinsicWidthConstraints.maximum = std::max(intrinsicWidthConstraints.maximum, childIntrinsicWidthConstraints->maximum);
+ }
+ return intrinsicWidthConstraints;
+ };
+ // FIXME Check for box-sizing: border-box;
+ auto intrinsicWidthConstraints = constrainByMinMaxWidth(layoutBox, computedIntrinsicWidthConstraints());
+ intrinsicWidthConstraints.expand(fixedMarginBorderAndPadding(layoutBox));
+ return intrinsicWidthConstraints;
+}
+
+}
+}
+
+#endif
Added: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h (0 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h 2021-05-15 22:30:39 UTC (rev 277549)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FormattingContext.h"
+
+namespace WebCore {
+namespace Layout {
+
+// This class implements positioning and sizing for boxes participating in a block formatting context.
+class BlockFormattingGeometry : public FormattingContext::Geometry {
+public:
+ BlockFormattingGeometry(const BlockFormattingContext&);
+
+ ContentHeightAndMargin inFlowContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&);
+ ContentWidthAndMargin inFlowContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
+
+ Point staticPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&) const;
+ LayoutUnit staticVerticalPosition(const Box&, const VerticalConstraints&) const;
+ LayoutUnit staticHorizontalPosition(const Box&, const HorizontalConstraints&) const;
+
+ FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
+
+ ContentWidthAndMargin computedContentWidthAndMargin(const Box&, const HorizontalConstraints&, Optional<LayoutUnit> availableWidthFloatAvoider);
+
+private:
+ ContentHeightAndMargin inFlowNonReplacedContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&);
+ ContentWidthAndMargin inFlowNonReplacedContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
+ ContentWidthAndMargin inFlowReplacedContentWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverriddenHorizontalValues&);
+
+ const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Geometry::formattingContext()); }
+};
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "BlockFormattingGeometry.h"
#include "BlockFormattingState.h"
#include "LayoutBox.h"
#include "LayoutBoxGeometry.h"
@@ -97,7 +98,7 @@
bodyBoxContentHeight -= documentBoxGeometry.verticalBorder() + documentBoxGeometry.verticalPadding().valueOr(0);
// However the non-in-flow document box's vertical margins are ignored. They don't affect the body box's content height.
if (documentBox.isInFlow()) {
- auto geometry = this->geometry();
+ auto geometry = formattingContext.geometry();
auto precomputeDocumentBoxVerticalMargin = geometry.computedVerticalMargin(documentBox, geometry.constraintsForInFlowContent(initialContainingBlock, FormattingContext::EscapeReason::BodyStretchesToViewportQuirk).horizontal);
bodyBoxContentHeight -= precomputeDocumentBoxVerticalMargin.before.valueOr(0) + precomputeDocumentBoxVerticalMargin.after.valueOr(0);
}
Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.h (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.h 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.h 2021-05-15 22:30:39 UTC (rev 277549)
@@ -45,8 +45,6 @@
protected:
const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingQuirks::formattingContext()); }
- BlockFormattingContext::Geometry geometry() const { return formattingContext().geometry(); }
-
};
}
Modified: trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "BlockFormattingGeometry.h"
#include "BlockFormattingState.h"
#include "LayoutBox.h"
#include "LayoutContainerBox.h"
Modified: trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "BlockFormattingGeometry.h"
#include "BlockFormattingState.h"
#include "InvalidationState.h"
#include "LayoutBoxGeometry.h"
Modified: trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingQuirks.cpp (277548 => 277549)
--- trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingQuirks.cpp 2021-05-15 21:11:40 UTC (rev 277548)
+++ trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingQuirks.cpp 2021-05-15 22:30:39 UTC (rev 277549)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "BlockFormattingGeometry.h"
#include "LayoutState.h"
namespace WebCore {
@@ -42,9 +43,9 @@
{
if (layoutState().inQuirksMode()) {
// In quirks mode always use the content height. Note that the tables with content take computed values into account.
- return geometry().contentHeightForFormattingContextRoot(tableBox);
+ return formattingContext().geometry().contentHeightForFormattingContextRoot(tableBox);
}
- return tableBox.hasInFlowOrFloatingChild() ? geometry().contentHeightForFormattingContextRoot(tableBox) : Optional<LayoutUnit> { };
+ return tableBox.hasInFlowOrFloatingChild() ? formattingContext().geometry().contentHeightForFormattingContextRoot(tableBox) : Optional<LayoutUnit> { };
}
}