WebKit Bugzilla
Attachment 342365 Details for
Bug 186461
: [LFC] MarginCollapse functions should be able to resolve non-fixed margin values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186461-20180609082527.patch (text/plain), 9.90 KB, created by
zalan
on 2018-06-09 08:25:28 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-06-09 08:25:28 PDT
Size:
9.90 KB
patch
obsolete
>Subversion Revision: 232659 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ed51febcab4ee6f6bdb7fffdc28bc49e132871f3..75c4ddd4a6da6606215da5e8a94b13e4e3752d1f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2018-06-09 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] MarginCollapse functions should be able to resolve non-fixed margin values >+ https://bugs.webkit.org/show_bug.cgi?id=186461 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We need the containing block's computed width to resolve vertical and horizontal margins. >+ >+ * layout/blockformatting/BlockFormattingContext.h: >+ * layout/blockformatting/BlockMarginCollapse.cpp: >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild): >+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom): >+ (WebCore::Layout::collapsedMarginTopFromFirstChild): Deleted. >+ (WebCore::Layout::nonCollapsedMarginTop): Deleted. >+ > 2018-06-08 Wenson Hsieh <wenson_hsieh@apple.com> > > [WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1) >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index 857fe152a1906ebdeaa4784f60bd7518bff93db1..6d8e212153bbc00abb9b3f3bdf8d8bfe5ed34e41 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -77,15 +77,21 @@ private: > // This class implements margin collapsing for block formatting context. > class MarginCollapse { > public: >- static LayoutUnit marginTop(const Box&); >- static LayoutUnit marginBottom(const Box&); >+ static LayoutUnit marginTop(const LayoutContext&, const Box&); >+ static LayoutUnit marginBottom(const LayoutContext&, const Box&); > > static bool isMarginBottomCollapsedWithParent(const Box&); > static bool isMarginTopCollapsedWithParentMarginBottom(const Box&); > > private: >- static LayoutUnit collapsedMarginBottomFromLastChild(const Box&); >- static LayoutUnit nonCollapsedMarginBottom(const Box&); >+ static LayoutUnit collapsedMarginBottomFromLastChild(const LayoutContext&, const Box&); >+ static LayoutUnit nonCollapsedMarginBottom(const LayoutContext&, const Box&); >+ >+ static LayoutUnit computedNonCollapsedMarginTop(const LayoutContext&, const Box&); >+ static LayoutUnit computedNonCollapsedMarginBottom(const LayoutContext&, const Box&); >+ >+ static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutContext&, const Box&); >+ static LayoutUnit nonCollapsedMarginTop(const LayoutContext&, const Box&); > }; > }; > >diff --git a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >index acf5a9ea409f37c8bf0f47180b7c6be0e368b9ca..1db8ee1d71ceb6977542a09ee397d8c826288329 100644 >--- a/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp >@@ -111,7 +111,7 @@ static bool isMarginTopCollapsedWithParent(const Box& layoutBox) > return true; > } > >-static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild(const LayoutContext& layoutContext, const Box& layoutBox) > { > // Check if the first child collapses its margin top. > if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild()) >@@ -122,13 +122,13 @@ static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox) > return 0; > > // Collect collapsed margin top recursively. >- return marginValue(firstInFlowChild.style().marginTop().value(), collapsedMarginTopFromFirstChild(firstInFlowChild)); >+ return marginValue(computedNonCollapsedMarginTop(layoutContext, firstInFlowChild), collapsedMarginTopFromFirstChild(layoutContext, firstInFlowChild)); > } > >-static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox) > { > // Non collapsed margin top includes collapsed margin from inflow first child. >- return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox)); >+ return marginValue(computedNonCollapsedMarginTop(layoutContext, layoutBox), collapsedMarginTopFromFirstChild(layoutContext, layoutBox)); > } > > /*static bool hasAdjoiningMarginTopAndBottom(const Box&) >@@ -145,8 +145,17 @@ static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox) > // A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin. > return false; > }*/ >+LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).top; >+} >+ >+LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).bottom; >+} > >-LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const LayoutContext& layoutContext, const Box& layoutBox) > { > if (layoutBox.isAnonymous()) > return 0; >@@ -157,20 +166,20 @@ LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const Box& layoutBo > > // Floats and out of flow positioned boxes do not collapse their margins. > if (!isMarginTopCollapsedWithSibling(layoutBox)) >- return nonCollapsedMarginTop(layoutBox); >+ return nonCollapsedMarginTop(layoutContext, 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); >+ return nonCollapsedMarginTop(layoutContext, layoutBox); > >- auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling); >- auto marginTop = nonCollapsedMarginTop(layoutBox); >+ auto previousSiblingMarginBottom = nonCollapsedMarginBottom(layoutContext, *previousInFlowSibling); >+ auto marginTop = nonCollapsedMarginTop(layoutContext, layoutBox); > return marginValue(marginTop, previousSiblingMarginBottom); > } > >-LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const LayoutContext& layoutContext, const Box& layoutBox) > { > if (layoutBox.isAnonymous()) > return 0; >@@ -181,13 +190,13 @@ LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const Box& layou > > // Floats and out of flow positioned boxes do not collapse their margins. > if (!isMarginBottomCollapsedWithSibling(layoutBox)) >- return nonCollapsedMarginBottom(layoutBox); >+ return nonCollapsedMarginBottom(layoutContext, 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); >+ return nonCollapsedMarginBottom(layoutContext, layoutBox); > } > > bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox) >@@ -231,7 +240,7 @@ bool BlockFormattingContext::MarginCollapse::isMarginTopCollapsedWithParentMargi > return false; > } > >-LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const LayoutContext& layoutContext, const Box& layoutBox) > { > // Check if the last child propagates its margin bottom. > if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild()) >@@ -242,13 +251,13 @@ LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLast > return 0; > > // Collect collapsed margin bottom recursively. >- return marginValue(lastInFlowChild.style().marginBottom().value(), collapsedMarginBottomFromLastChild(lastInFlowChild)); >+ return marginValue(computedNonCollapsedMarginBottom(layoutContext, lastInFlowChild), collapsedMarginBottomFromLastChild(layoutContext, lastInFlowChild)); > } > >-LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const Box& layoutBox) >+LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox) > { > // Non collapsed margin bottom includes collapsed margin from inflow last child. >- return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox)); >+ return marginValue(computedNonCollapsedMarginBottom(layoutContext, layoutBox), collapsedMarginBottomFromLastChild(layoutContext, layoutBox)); > } > > }
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 186461
: 342365 |
342366