Modified: trunk/Source/WebCore/ChangeLog (249954 => 249955)
--- trunk/Source/WebCore/ChangeLog 2019-09-17 15:01:23 UTC (rev 249954)
+++ trunk/Source/WebCore/ChangeLog 2019-09-17 15:57:15 UTC (rev 249955)
@@ -1,5 +1,26 @@
2019-09-17 Zalan Bujtas <za...@apple.com>
+ [LFC[MarginCollapsing] MarginCollapse::estimatedMarginBefore should take pre-computed non-collapsed margin values.
+ https://bugs.webkit.org/show_bug.cgi?id=201848
+ <rdar://problem/55419419>
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for using constraint values instead of querying the display tree for containing block geometry information.
+ See webkit.org/b/201795
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues):
+
+2019-09-17 Zalan Bujtas <za...@apple.com>
+
[First-letter] Use WeakPtr for the first-letter insertion point.
https://bugs.webkit.org/show_bug.cgi?id=201842
<rdar://problem/51373788>
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (249954 => 249955)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-09-17 15:01:23 UTC (rev 249954)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-09-17 15:57:15 UTC (rev 249955)
@@ -231,7 +231,10 @@
void BlockFormattingContext::computeEstimatedVerticalPosition(const Box& layoutBox)
{
- auto estimatedMarginBefore = marginCollapse().estimatedMarginBefore(layoutBox);
+ auto usedHorizontalValues = UsedHorizontalValues { geometryForBox(*layoutBox.containingBlock()).contentBoxWidth() };
+ auto computedVerticalMargin = geometry().computedVerticalMargin(layoutBox, usedHorizontalValues);
+ auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
+ auto estimatedMarginBefore = marginCollapse().estimatedMarginBefore(layoutBox, usedNonCollapsedMargin);
setEstimatedMarginBefore(layoutBox, estimatedMarginBefore);
auto& displayBox = formattingState().displayBox(layoutBox);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (249954 => 249955)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2019-09-17 15:01:23 UTC (rev 249954)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2019-09-17 15:57:15 UTC (rev 249955)
@@ -100,10 +100,10 @@
// This class implements margin collapsing for block formatting context.
class MarginCollapse {
public:
- UsedVerticalMargin::CollapsedValues collapsedVerticalValues(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
+ UsedVerticalMargin::CollapsedValues collapsedVerticalValues(const Box&, UsedVerticalMargin::NonCollapsedValues);
- EstimatedMarginBefore estimatedMarginBefore(const Box&);
- LayoutUnit marginBeforeIgnoringCollapsingThrough(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
+ EstimatedMarginBefore estimatedMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues);
+ LayoutUnit marginBeforeIgnoringCollapsingThrough(const Box&, UsedVerticalMargin::NonCollapsedValues);
void updateMarginAfterForPreviousSibling(const Box&) const;
void updatePositiveNegativeMarginValues(const Box&);
@@ -126,8 +126,8 @@
enum class MarginType { Before, After };
PositiveAndNegativeVerticalMargin::Values positiveNegativeValues(const Box&, MarginType);
- PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginBefore(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
- PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginAfter(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
+ PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues);
+ PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginAfter(const Box&, UsedVerticalMargin::NonCollapsedValues);
bool hasClearance(const Box&) const;
LayoutState& layoutState() { return m_blockFormattingContext.layoutState(); }
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (249954 => 249955)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-09-17 15:01:23 UTC (rev 249954)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-09-17 15:57:15 UTC (rev 249955)
@@ -528,7 +528,7 @@
return positiveNegativeMarginAfter(layoutBox, nonCollapsedMargin);
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore(const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
+PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
auto firstChildCollapsedMarginBefore = [&]() -> PositiveAndNegativeVerticalMargin::Values {
if (!marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutBox))
@@ -558,7 +558,7 @@
return computedPositiveAndNegativeMargin(collapsedMarginBefore, nonCollapsedBefore);
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter(const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
+PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
auto lastChildCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values {
if (!marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutBox))
@@ -577,7 +577,7 @@
return computedPositiveAndNegativeMargin(lastChildCollapsedMarginAfter(), nonCollapsedAfter);
}
-EstimatedMarginBefore BlockFormattingContext::MarginCollapse::estimatedMarginBefore(const Box& layoutBox)
+EstimatedMarginBefore BlockFormattingContext::MarginCollapse::estimatedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin)
{
if (layoutBox.isAnonymous())
return { };
@@ -587,19 +587,16 @@
ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
ASSERT(!layoutBox.replaced());
- auto usedValues = UsedHorizontalValues { formattingContext().geometryForBox(*layoutBox.containingBlock()).contentBoxWidth() };
- auto computedVerticalMargin = formattingContext().geometry().computedVerticalMargin(layoutBox, usedValues);
- auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto marginsCollapseThrough = this->marginsCollapseThrough(layoutBox);
- auto positiveNegativeMarginBefore = this->positiveNegativeMarginBefore(layoutBox, nonCollapsedMargin);
+ auto positiveNegativeMarginBefore = this->positiveNegativeMarginBefore(layoutBox, usedNonCollapsedMargin);
auto collapsedMarginBefore = marginValue(!marginsCollapseThrough ? positiveNegativeMarginBefore
- : computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter(layoutBox, nonCollapsedMargin)));
+ : computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter(layoutBox, usedNonCollapsedMargin)));
- return { nonCollapsedMargin.before, collapsedMarginBefore, marginsCollapseThrough };
+ return { usedNonCollapsedMargin.before, collapsedMarginBefore, marginsCollapseThrough };
}
-LayoutUnit BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough(const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
+LayoutUnit BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
ASSERT(!layoutBox.isAnonymous());
ASSERT(layoutBox.isBlockLevelBox());
@@ -622,7 +619,7 @@
blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter });
}
-UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
+UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
if (layoutBox.isAnonymous())
return { };