Closed Bug 616722 Opened 14 years ago Closed 12 years ago

-moz-column-count on parent element with border causes its margins to collapse with the kids' margins

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: GPHemsley, Assigned: MatsPalmgren_bugz)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: css3, testcase)

Attachments

(6 files, 1 obsolete file)

Attached file Reduced testcase
Not sure if this is related to bug 388666.

If you have a parent element (e.g. <div>) with '-moz-column-count' set to something higher than 0, the margins of the (last?) child element (e.g. <p>) will bleed through, even if the parent element's margins are 0.

This does not appear to happen with Safari (which, of course, uses '-webkit-column-count').
Yeah, this seems like a bug.

Presumably the problem here is that the border ends up on the columnset, not on the columns themselves or something?
Summary: -moz-column-count on parent element cause margins on child to bleed through → -moz-column-count on parent element with border causes its margins to collapse with the kids' margins
(In reply to comment #1)
> Yeah, this seems like a bug.
> 
> Presumably the problem here is that the border ends up on the columnset, not on
> the columns themselves or something?

I'm not sure that it is directly related to the borders, though. Removing them (and using, e.g., a background color to demarcate the two divs) actually makes things worse, as I understand it. Without the borders, the margins collapse on both divs.

Here's a new testcase that shows that.
Attachment #495268 - Attachment is obsolete: true
> Without the borders, the margins collapse on both divs.

See <http://www.w3.org/TR/CSS2/box.html#collapsing-margins>.
Comment on attachment 495268 [details]
Reduced testcase

(In reply to comment #3)
> > Without the borders, the margins collapse on both divs.
> 
> See <http://www.w3.org/TR/CSS2/box.html#collapsing-margins>.

Yeah, I thought I might've been mistaken. I take it you're referring to this part?

"The bottom margin of an in-flow block-level element with a 'height' of 'auto' is adjoining to its last in-flow block-level child's bottom margin if the element has no bottom padding or border."
Attachment #495268 - Attachment is obsolete: false
Attached patch Patch rev. 1 (diff -w) (obsolete) — Splinter Review
Change nsBlockFrame::BlockIsMarginRoot() to return separate values
for top/bottom.  Currently there is a special handling for blocks where
the parent frame is a ColumnSetFrame that currently returns false
unconditionally -- make that return true if there is a non-zero
border+padding instead.
Assignee: nobody → matspal
status2.0: --- → ?
Keywords: css3, testcase
Attached file Testcase #3
Here's an interesting edge case.  When the column is empty, (how) should the
margin self-collapse...  when there's one column? more than one column?

My patch makes the height of the one column case 20px, ie. like a normal
block would do.  The three column case has 0px height.  I would expect it
to be 20px.
Bug 388666 is a different issue. It's about the margin-top of the first child of a multi column element that is not being rendered if the multi-column element has a border-top.

This issue is about the the margin-bottom of the last-child of a multi-column element (that has border-bottom) which apparently collapses with the margin-bottom of the multi-column element.

The spec says that "a multi-column element establishes a new block formatting context". See the bottom of section 2, The multi-column model:
http://www.w3.org/TR/2011/CR-css3-multicol-20110412/#the-multi-column-model

That means the margins of a multi-column element do not collapse with themselves nor with the margins of their descendants.

Gecko and WebKit apparently do not implement the spec. Microsoft claims to implement the spec in IE10 Preview 1.
Depends on: 672043
Blocks: 698783
Attached file Testcase #4
Attached patch Patch rev. 2Splinter Review
Make ColumnSetFrame a block margin root.  Make the first column a margin root at the top edge, and the last column at the bottom.  (The 368020-1 test change is
to account for its margin which previously was ignored)

https://tbpl.mozilla.org/?usebuildbot=1&tree=Try&rev=f0cde7c76d05
Attachment #495318 - Attachment is obsolete: true
Attachment #644312 - Flags: review?(roc)
Comment on attachment 644313 [details] [diff] [review]
Patch rev. 2 (diff -w)

Review of attachment 644313 [details] [diff] [review]:
-----------------------------------------------------------------

::: inbound-opt.9b8e56ada40e/layout/generic/nsBlockFrame.cpp
@@ +7020,5 @@
>  }
>  
> +void
> +nsBlockFrame::IsMarginRoot(bool* aTopMarginRoot,
> +                                bool* aBottomMarginRoot)

Fix indent
Attachment #644313 - Flags: review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/8ad2c23374bc
Flags: in-testsuite+
Target Milestone: --- → mozilla17
https://hg.mozilla.org/mozilla-central/rev/8ad2c23374bc
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 787310
No longer depends on: 787310
Blocks: 814811
status2.0: ? → ---
No longer blocks: 814811
Depends on: 814811
Depends on: 823451
No longer depends on: 823451
Attachment #644312 - Flags: review?(roc)
Depends on: 974837
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: