Open Bug 376365 Opened 17 years ago Updated 2 years ago

update margin collapsing to slight rule change

Categories

(Core :: Layout: Block and Inline, defect)

defect

Tracking

()

People

(Reporter: dbaron, Unassigned)

References

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

Details

(Whiteboard: [not-ready-for-cedar])

Attachments

(1 file)

There's a slight change to the margin collapsing rules in http://lists.w3.org/Archives/Member/w3c-css-wg/2007JanMar/0535.html that's been accepted for the next draft of CSS2.1.  We should implement this.

Steps to reproduce:
 load http://dbaron.org/css/test/2007/0329-blog-examples/1

Actual results:
 hello is the same distance below the blue block as A is above it

Expected results:
 there should be a gap between hello and the blue block so hello is 50px below A
Flags: blocking1.9?
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
Attached patch suggested patchSplinter Review
I'm pretty sure that conditional fixes the bug. I'm less sure about whether it's the right place to put the conditional.
Assignee: nobody → fantasai.bugs
Status: NEW → ASSIGNED
Attachment #262698 - Flags: review?(dbaron)
My build still passes http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/microsoft/all.html with flying colors (except 005.html, of course, since the test is now wrong). I also ran the reftests and nothing new failed.
I probably should be the reviewer...

Shouldn't the fix be after "clearance = aState.mY - (currentY + topMargin);"?

+      clearance -= clearance + incomingMargin.get();

This is equivalent to "clearance = -incomingMargin.get();" Can you explain why this is correct? I don't see it. I think it would be better if we explicitly did the calculation described in Hixie's email.
> Shouldn't the fix be after "clearance = aState.mY - (currentY + topMargin);"?

That's where I thought it should go, but it didn't work there. I spent hours trying to figure out why, but my programming fu wasn't strong enough. Even setting clearance to random numbers there didn't break my testcases. -__-;; I don't understand at all.

> Can you explain why this is correct?

I can try to explain why I *think* it's correct...

The point of the spec fix is that clearance should never move an element *up*.
It only moves an element up if it's negative, hence the check for negativeness.
It also only moves the element up if it winds up overcompensating for the hypothetical margin collapse. The margin can't collapse more than the amount of the previous margin, so if the magnitude of negative clearance is more than that, then it's overcompensating, and it's overcompensating by
  |clearance| - incomingMargin
which, given that clearance is negative, is the same as
  clearance + incomingMargin
Subtract out the overcompensation, and the element no longer moves up.

That's my logic. Hyatt thinks its wrong, so maybe I'm missing something important here. Hence "suggested patch" rather than "proposed patch" and a request for dbaron's review since he's more of a margin collapsing guru than I am.
Note that, if my logic serves me correctly, if a negative margin is one (or both) of two margins collapsing, then the amount of the collapse must be non-negative. A  negative margin collapsing with a positive one is the sum of the two (no difference if they collapse or don't collapse), and two negative margins collapsing are the max of the two, i.e. the difference between not collapsing and collapsing is positive. Therefore (correct me if I'm wrong) clearance is only negative if it's compensating for a positive-positive collapse.
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
Flags: wanted1.9-
Flags: wanted1.9+
Flags: wanted-next+
Attachment #262698 - Flags: review?(dbaron) → review?(roc)
Comment on attachment 262698 [details] [diff] [review]
suggested patch

I should have transferred this review request ages ago.
Comment on attachment 262698 [details] [diff] [review]
suggested patch

I kinda forgot about this. I think it's right, though.

We should have a reftest.
Attachment #262698 - Flags: review?(roc) → review+
Do you want to land it for FF4?
I'll note that the CSS2.1 spec could get blocked on whether this fix breaks web compat, and currently only Mozilla seems capable of figuring that out within the next year or two.
Depends on: post2.0
This seems to break Acid2.
So apparently:
 * the IE folks say fixing this breaks some sites
 * the tests are actually invalid, although only unintentionally so, since "hypothetical position" is defined **relative to the parent**

So it sounds like we might fix the tests.
Sounds like this patch is not ok to go on m-c, right?  If I'm wrong, please let me know!
Whiteboard: [not-ready-for-cedar]
Depends on: 50959

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: fantasai.bugs → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: