Summary: | Interoperability issue in margin collapsing with overflow:hidden elements | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Sergio Villar Senin <svillar> | ||||||||||||||||
Component: | Layout and Rendering | Assignee: | Sergio Villar Senin <svillar> | ||||||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||||||
Severity: | Normal | CC: | bfulgham, cdumez, changseok, esprehn+autocc, ews-watchlist, glenn, kondapallykalyan, mmaxfield, pdr, simon.fraser, thorton, webkit-bug-importer, zalan | ||||||||||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||||||||||
Version: | WebKit Nightly Build | ||||||||||||||||||
Hardware: | Unspecified | ||||||||||||||||||
OS: | Unspecified | ||||||||||||||||||
Bug Depends on: | 229759 | ||||||||||||||||||
Bug Blocks: | |||||||||||||||||||
Attachments: |
|
Description
Sergio Villar Senin
2021-04-05 08:18:46 PDT
"A non visual overflow in theory creates a new formatting context" what do you mean by "in theory"? (this is already fixed in LFC see Box::establishesBlockFormattingContext() and BlockFormattingContext::MarginCollapse functions) (In reply to zalan from comment #1) > "A non visual overflow in theory creates a new formatting context" > what do you mean by "in theory"? > (this is already fixed in LFC see Box::establishesBlockFormattingContext() > and BlockFormattingContext::MarginCollapse functions) Well I meant that it indeed should create a new one, I was not putting anything in doubt :). Great that it's fixed in LFC. Does it still work properly when the body has a non visual overflow? I've several other test cases I created that showcase differences between WebKit and other engines, how could I test that with LFC? (In reply to Sergio Villar Senin from comment #2) > (In reply to zalan from comment #1) > > "A non visual overflow in theory creates a new formatting context" > > what do you mean by "in theory"? > > (this is already fixed in LFC see Box::establishesBlockFormattingContext() > > and BlockFormattingContext::MarginCollapse functions) > > Well I meant that it indeed should create a new one, I was not putting > anything in doubt :). > > Great that it's fixed in LFC. Does it still work properly when the body has > a non visual overflow? > > I've several other test cases I created that showcase differences between > WebKit and other engines, how could I test that with LFC? It's in a bit of flux atm. :( Could you upload those tests here and I'll check them out? Created attachment 425171 [details]
Extra case 1
There are 3 containers. The first two look the same in WK, but not in the other engines. The 3rd case is another case in which WK collapses margins while other engines don't
Created attachment 425172 [details]
Extra case 2
Works fine in ToT.
It does not work if we modify the code so that non visible overflows create formatting contexts. The fact that the <body> is the one with the overflow:hidden is important, see "Extra case 3".
Created attachment 425173 [details]
Extra case 3
Almost equal to "Extra case 2". The difference is that the overflow:hidden is not the <body>.
This example works fine in ToT *and* also if we modify the code to include non visual overflows as creators of new formatting contexts.
(In reply to zalan from comment #3) > (In reply to Sergio Villar Senin from comment #2) > > (In reply to zalan from comment #1) > > > "A non visual overflow in theory creates a new formatting context" > > > what do you mean by "in theory"? > > > (this is already fixed in LFC see Box::establishesBlockFormattingContext() > > > and BlockFormattingContext::MarginCollapse functions) > > > > Well I meant that it indeed should create a new one, I was not putting > > anything in doubt :). > > > > Great that it's fixed in LFC. Does it still work properly when the body has > > a non visual overflow? > > > > I've several other test cases I created that showcase differences between > > WebKit and other engines, how could I test that with LFC? > It's in a bit of flux atm. :( Could you upload those tests here and I'll > check them out? Done. Just ping me on Slack/mail etc... if you need more info (also I might not have explained myself correctly). (In reply to Sergio Villar Senin from comment #7) > (In reply to zalan from comment #3) > > (In reply to Sergio Villar Senin from comment #2) > > > (In reply to zalan from comment #1) > > > > "A non visual overflow in theory creates a new formatting context" > > > > what do you mean by "in theory"? > > > > (this is already fixed in LFC see Box::establishesBlockFormattingContext() > > > > and BlockFormattingContext::MarginCollapse functions) > > > > > > Well I meant that it indeed should create a new one, I was not putting > > > anything in doubt :). > > > > > > Great that it's fixed in LFC. Does it still work properly when the body has > > > a non visual overflow? > > > > > > I've several other test cases I created that showcase differences between > > > WebKit and other engines, how could I test that with LFC? > > It's in a bit of flux atm. :( Could you upload those tests here and I'll > > check them out? > > Done. Just ping me on Slack/mail etc... if you need more info (also I might > not have explained myself correctly). Thanks a lot! Will look into this later today and let you know. Created attachment 425229 [details]
Safari-Chrome-LFC
So it looks LFC collapses these margins properly.
(In reply to zalan from comment #9) > Created attachment 425229 [details] > Safari-Chrome-LFC > > So it looks LFC collapses these margins properly. and all the other cases are working as well. (In reply to zalan from comment #10) > (In reply to zalan from comment #9) > > Created attachment 425229 [details] > > Safari-Chrome-LFC > > > > So it looks LFC collapses these margins properly. > and all the other cases are working as well. Nice! BTW this is the patch I was working on: @@ -497,7 +497,8 @@ bool RenderBlock::isSelfCollapsingBlock() const if (logicalHeight() > 0 || isTable() || borderAndPaddingLogicalHeight() || style().logicalMinHeight().isPositive() - || style().marginBeforeCollapse() == MarginCollapse::Separate || style().marginAfterCollapse() == MarginCollapse::Separate) + || style().marginBeforeCollapse() == MarginCollapse::Separate || style().marginAfterCollapse() == MarginCollapse::Separate + || createsNewFormattingContext()) return false; @@ -4675,7 +4675,7 @@ bool RenderBox::shrinkToAvoidFloats() const bool RenderBox::createsNewFormattingContext() const { - return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() + return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() || !style().isOverflowVisible() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isDocumentElementRenderer() || isRenderFragmentedFlow() || isRenderFragmentContainer() || isGridItem() || style().specifiesColumns() || style().columnSpan() == ColumnSpan::All || style().display() == DisplayType::FlowRoot; This fixes all the cases except the ones involving <body>. As I mentioned the problem is that style().isOverflowVisible() is not exactly what we want. We need something like https://webkit-search.igalia.com/webkit/source/Source/WebCore/layout/layouttree/LayoutBox.cpp#391 which you added in r240213. I wonder what's the plan from the LFC POV. Is it OK to share code with the good-old-layout system and LFC? Would it be better to reimplement it so it does not taint LFC? (In reply to Sergio Villar Senin from comment #11) > (In reply to zalan from comment #10) > > (In reply to zalan from comment #9) > > > Created attachment 425229 [details] > > > Safari-Chrome-LFC > > > > > > So it looks LFC collapses these margins properly. > > and all the other cases are working as well. > > Nice! > > BTW this is the patch I was working on: > > @@ -497,7 +497,8 @@ bool RenderBlock::isSelfCollapsingBlock() const > if (logicalHeight() > 0 > || isTable() || borderAndPaddingLogicalHeight() > || style().logicalMinHeight().isPositive() > - || style().marginBeforeCollapse() == MarginCollapse::Separate || > style().marginAfterCollapse() == MarginCollapse::Separate) > + || style().marginBeforeCollapse() == MarginCollapse::Separate || > style().marginAfterCollapse() == MarginCollapse::Separate > + || createsNewFormattingContext()) > return false; > > @@ -4675,7 +4675,7 @@ bool RenderBox::shrinkToAvoidFloats() const > > bool RenderBox::createsNewFormattingContext() const > { > - return isInlineBlockOrInlineTable() || > isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || > isFlexItemIncludingDeprecated() > + return isInlineBlockOrInlineTable() || > isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || > isFlexItemIncludingDeprecated() || !style().isOverflowVisible() > || isTableCell() || isTableCaption() || isFieldset() || > isWritingModeRoot() || isDocumentElementRenderer() || > isRenderFragmentedFlow() || isRenderFragmentContainer() > || isGridItem() || style().specifiesColumns() || > style().columnSpan() == ColumnSpan::All || style().display() == > DisplayType::FlowRoot; > > This fixes all the cases except the ones involving <body>. As I mentioned > the problem is that style().isOverflowVisible() is not exactly what we want. > We need something like > https://webkit-search.igalia.com/webkit/source/Source/WebCore/layout/ > layouttree/LayoutBox.cpp#391 which you added in r240213. > > I wonder what's the plan from the LFC POV. Is it OK to share code with the > good-old-layout system and LFC? Would it be better to reimplement it so it > does not taint LFC? I don't think it's worth templatizing it (or share this logic through some other means) I'd just reimplement it in RenderElement (or wherever it is applicable). Created attachment 436524 [details]
Patch
Created attachment 436800 [details]
Patch
Comment on attachment 436800 [details]
Patch
Please do not combine 2 different fixes in one patch. It makes regression tracking more involved.
(In reply to zalan from comment #16) > Comment on attachment 436800 [details] > Patch > > Please do not combine 2 different fixes in one patch. It makes regression > tracking more involved. I've created https://bugs.webkit.org/show_bug.cgi?id=229759 for the extra isRenderFragmentContainer() removal. (In reply to zalan from comment #16) > Comment on attachment 436800 [details] > Patch > > Please do not combine 2 different fixes in one patch. It makes regression > tracking more involved. Now that bug 229759 landed I'm landing this one. Committed r282085 (241385@main): <https://commits.webkit.org/241385@main> |