WebKit Bugzilla
Attachment 339821 Details for
Bug 185424
: [LFC] Start using BlockMarginCollapse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185424-20180508085817.patch (text/plain), 13.29 KB, created by
zalan
on 2018-05-08 08:58:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-08 08:58:18 PDT
Size:
13.29 KB
patch
obsolete
>Subversion Revision: 231483 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9978f968a09a6e95f12bfc811c4711f7d5951d57..db2ecbf112669b3b433dcc58add7229cab8cb505 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,40 @@ >+2018-05-08 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Start using BlockMarginCollapse >+ https://bugs.webkit.org/show_bug.cgi?id=185424 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ BlockMarginCollapse could be all static. >+ >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::marginTop const): >+ (WebCore::Layout::BlockFormattingContext::marginBottom const): >+ * layout/blockformatting/BlockMarginCollapse.cpp: >+ (WebCore::Layout::isMarginTopCollapsedWithSibling): >+ (WebCore::Layout::isMarginBottomCollapsedWithSibling): >+ (WebCore::Layout::isMarginTopCollapsedWithParent): >+ (WebCore::Layout::isMarginBottomCollapsedWithParent): >+ (WebCore::Layout::collapsedMarginTopFromFirstChild): >+ (WebCore::Layout::collapsedMarginBottomFromLastChild): >+ (WebCore::Layout::nonCollapsedMarginTop): >+ (WebCore::Layout::nonCollapsedMarginBottom): >+ (WebCore::Layout::BlockMarginCollapse::marginTop): >+ (WebCore::Layout::BlockMarginCollapse::marginBottom): >+ (WebCore::Layout::BlockMarginCollapse::BlockMarginCollapse): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::marginTop const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::marginBottom const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithSibling const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithSibling const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithParent const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithParent const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginTop const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginBottom const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::collapsedMarginTopFromFirstChild const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::collapsedMarginBottomFromLastChild const): Deleted. >+ (WebCore::Layout::BlockMarginCollapse::hasAdjoiningMarginTopAndBottom const): Deleted. >+ * layout/blockformatting/BlockMarginCollapse.h: >+ > 2018-05-07 Zalan Bujtas <zalan@apple.com> > > [LFC] Add FormattingContext::layoutOutOfFlowDescendants implementation >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index d93360d180c4ceb1914bfbd9da9ebb6827a85414..47bf590996e8997204e3b3e0d0de1b5397c30ce7 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -29,6 +29,7 @@ > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > > #include "BlockFormattingState.h" >+#include "BlockMarginCollapse.h" > #include "DisplayBox.h" > #include "FloatingContext.h" > #include "FloatingState.h" >@@ -150,14 +151,14 @@ void BlockFormattingContext::computeInFlowHeight(const Box&, Display::Box&) cons > { > } > >-LayoutUnit BlockFormattingContext::marginTop(const Box&) const >+LayoutUnit BlockFormattingContext::marginTop(const Box& layoutBox) const > { >- return 0; >+ return BlockMarginCollapse::marginTop(layoutBox); > } > >-LayoutUnit BlockFormattingContext::marginBottom(const Box&) const >+LayoutUnit BlockFormattingContext::marginBottom(const Box& layoutBox) const > { >- return 0; >+ return BlockMarginCollapse::marginBottom(layoutBox); > } > > } >diff --git a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >index bd4046cdc773db4b75f17ce6fc9a52ed8caab39a..8ecfcbe3f91b1c7a7945a798bdbb358b026ac298 100644 >--- a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >@@ -55,55 +55,7 @@ static LayoutUnit marginValue(LayoutUnit currentMarginValue, LayoutUnit candidat > return currentMarginValue + candidateMarginValue; > } > >-BlockMarginCollapse::BlockMarginCollapse() >-{ >-} >- >-LayoutUnit BlockMarginCollapse::marginTop(const Box& layoutBox) const >-{ >- if (layoutBox.isAnonymous()) >- return 0; >- >- // TODO: take _hasAdjoiningMarginTopAndBottom() into account. >- if (isMarginTopCollapsedWithParent(layoutBox)) >- return 0; >- >- // Floats and out of flow positioned boxes do not collapse their margins. >- if (!isMarginTopCollapsedWithSibling(layoutBox)) >- return nonCollapsedMarginTop(layoutBox); >- >- // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, >- // unless that sibling has clearance. >- auto* previousInFlowSibling = layoutBox.previousInFlowSibling(); >- if (!previousInFlowSibling) >- return nonCollapsedMarginTop(layoutBox); >- >- auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling); >- auto marginTop = nonCollapsedMarginTop(layoutBox); >- return marginValue(marginTop, previousSiblingMarginBottom); >-} >- >-LayoutUnit BlockMarginCollapse::marginBottom(const Box& layoutBox) const >-{ >- if (layoutBox.isAnonymous()) >- return 0; >- >- // TODO: take _hasAdjoiningMarginTopAndBottom() into account. >- if (isMarginBottomCollapsedWithParent(layoutBox)) >- return 0; >- >- // Floats and out of flow positioned boxes do not collapse their margins. >- if (!isMarginBottomCollapsedWithSibling(layoutBox)) >- return nonCollapsedMarginBottom(layoutBox); >- >- // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, >- // unless that sibling has clearance. >- if (layoutBox.nextInFlowSibling()) >- return 0; >- return nonCollapsedMarginBottom(layoutBox); >-} >- >-bool BlockMarginCollapse::isMarginTopCollapsedWithSibling(const Box& layoutBox) const >+static bool isMarginTopCollapsedWithSibling(const Box& layoutBox) > { > if (layoutBox.isFloatingPositioned()) > return false; >@@ -116,7 +68,7 @@ bool BlockMarginCollapse::isMarginTopCollapsedWithSibling(const Box& layoutBox) > return layoutBox.style().top().isAuto(); > } > >-bool BlockMarginCollapse::isMarginBottomCollapsedWithSibling(const Box& layoutBox) const >+static bool isMarginBottomCollapsedWithSibling(const Box& layoutBox) > { > if (layoutBox.isFloatingPositioned()) > return false; >@@ -129,7 +81,7 @@ bool BlockMarginCollapse::isMarginBottomCollapsedWithSibling(const Box& layoutBo > return layoutBox.style().bottom().isAuto(); > } > >-bool BlockMarginCollapse::isMarginTopCollapsedWithParent(const Box& layoutBox) const >+static bool isMarginTopCollapsedWithParent(const Box& layoutBox) > { > // The first inflow child could propagate its top margin to parent. > // https://www.w3.org/TR/CSS21/box.html#collapsing-margins >@@ -162,7 +114,7 @@ bool BlockMarginCollapse::isMarginTopCollapsedWithParent(const Box& layoutBox) c > return true; > } > >-bool BlockMarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox) const >+static bool isMarginBottomCollapsedWithParent(const Box& layoutBox) > { > // last inflow box to parent. > // https://www.w3.org/TR/CSS21/box.html#collapsing-margins >@@ -198,19 +150,7 @@ bool BlockMarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox > return true; > } > >-LayoutUnit BlockMarginCollapse::nonCollapsedMarginTop(const Box& layoutBox) const >-{ >- // Non collapsed margin top includes collapsed margin from inflow first child. >- return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox)); >-} >- >-LayoutUnit BlockMarginCollapse::nonCollapsedMarginBottom(const Box& layoutBox) const >-{ >- // Non collapsed margin bottom includes collapsed margin from inflow last child. >- return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox)); >-} >- >-LayoutUnit BlockMarginCollapse::collapsedMarginTopFromFirstChild(const Box& layoutBox) const >+static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox) > { > // Check if the first child collapses its margin top. > if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild()) >@@ -224,7 +164,7 @@ LayoutUnit BlockMarginCollapse::collapsedMarginTopFromFirstChild(const Box& layo > return marginValue(firstInFlowChild.style().marginTop().value(), collapsedMarginTopFromFirstChild(firstInFlowChild)); > } > >-LayoutUnit BlockMarginCollapse::collapsedMarginBottomFromLastChild(const Box& layoutBox) const >+static LayoutUnit collapsedMarginBottomFromLastChild(const Box& layoutBox) > { > // Check if the last child propagates its margin bottom. > if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild()) >@@ -238,7 +178,19 @@ LayoutUnit BlockMarginCollapse::collapsedMarginBottomFromLastChild(const Box& la > return marginValue(lastInFlowChild.style().marginBottom().value(), collapsedMarginBottomFromLastChild(lastInFlowChild)); > } > >-bool BlockMarginCollapse::hasAdjoiningMarginTopAndBottom(const Box&) const >+static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox) >+{ >+ // Non collapsed margin top includes collapsed margin from inflow first child. >+ return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox)); >+} >+ >+static LayoutUnit nonCollapsedMarginBottom(const Box& layoutBox) >+{ >+ // Non collapsed margin bottom includes collapsed margin from inflow last child. >+ return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox)); >+} >+ >+/*static bool hasAdjoiningMarginTopAndBottom(const Box&) > { > // Two margins are adjoining if and only if: > // 1. both belong to in-flow block-level boxes that participate in the same block formatting context >@@ -251,6 +203,50 @@ bool BlockMarginCollapse::hasAdjoiningMarginTopAndBottom(const Box&) const > // zero or 'auto' computed 'height', and no in-flow children > // A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin. > return false; >+}*/ >+ >+LayoutUnit BlockMarginCollapse::marginTop(const Box& layoutBox) >+{ >+ if (layoutBox.isAnonymous()) >+ return 0; >+ >+ // TODO: take _hasAdjoiningMarginTopAndBottom() into account. >+ if (isMarginTopCollapsedWithParent(layoutBox)) >+ return 0; >+ >+ // Floats and out of flow positioned boxes do not collapse their margins. >+ if (!isMarginTopCollapsedWithSibling(layoutBox)) >+ return nonCollapsedMarginTop(layoutBox); >+ >+ // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, >+ // unless that sibling has clearance. >+ auto* previousInFlowSibling = layoutBox.previousInFlowSibling(); >+ if (!previousInFlowSibling) >+ return nonCollapsedMarginTop(layoutBox); >+ >+ auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling); >+ auto marginTop = nonCollapsedMarginTop(layoutBox); >+ return marginValue(marginTop, previousSiblingMarginBottom); >+} >+ >+LayoutUnit BlockMarginCollapse::marginBottom(const Box& layoutBox) >+{ >+ if (layoutBox.isAnonymous()) >+ return 0; >+ >+ // TODO: take _hasAdjoiningMarginTopAndBottom() into account. >+ if (isMarginBottomCollapsedWithParent(layoutBox)) >+ return 0; >+ >+ // Floats and out of flow positioned boxes do not collapse their margins. >+ if (!isMarginBottomCollapsedWithSibling(layoutBox)) >+ return nonCollapsedMarginBottom(layoutBox); >+ >+ // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, >+ // unless that sibling has clearance. >+ if (layoutBox.nextInFlowSibling()) >+ return 0; >+ return nonCollapsedMarginBottom(layoutBox); > } > > } >diff --git a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h >index 8dd229c91c9e0857f683e1a21a0407e484ba1e28..72fe57c53551a37be5395da65b1e0cd06e3aab40 100644 >--- a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h >+++ b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h >@@ -40,23 +40,8 @@ class Box; > class BlockMarginCollapse { > WTF_MAKE_ISO_ALLOCATED(BlockMarginCollapse); > public: >- BlockMarginCollapse(); >- >- LayoutUnit marginTop(const Box&) const; >- LayoutUnit marginBottom(const Box&) const; >- >-private: >- bool isMarginTopCollapsedWithSibling(const Box&) const; >- bool isMarginBottomCollapsedWithSibling(const Box&) const; >- bool isMarginTopCollapsedWithParent(const Box&) const; >- bool isMarginBottomCollapsedWithParent(const Box&) const; >- >- LayoutUnit nonCollapsedMarginTop(const Box&) const; >- LayoutUnit nonCollapsedMarginBottom(const Box&) const; >- LayoutUnit collapsedMarginTopFromFirstChild(const Box&) const; >- LayoutUnit collapsedMarginBottomFromLastChild(const Box&) const; >- >- bool hasAdjoiningMarginTopAndBottom(const Box&) const; >+ static LayoutUnit marginTop(const Box&); >+ static LayoutUnit marginBottom(const Box&); > }; > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185424
: 339821