Closed Bug 33784 Opened 25 years ago Closed 2 years ago

[MARGIN-C]margins not collapsed at cell or body edges in quirks mode (top margin compat)

Categories

(Core :: CSS Parsing and Computation, defect, P3)

x86
Windows 98
defect

Tracking

()

RESOLVED WONTFIX
Future

People

(Reporter: shashi, Unassigned)

References

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

Details

(4 keywords, Whiteboard: WONTFIX?)

Attachments

(4 files, 1 obsolete file)

After the page loads, look at the black table cell containing the white text 
"Welcome". This cell is huge :-)

You may want to take a look at one of the demos at the site 
(http://www.narain.com/gecko/css/football.html). Because of this bug, the entire 
layout of the page is ruined.

The code used within these table cells look something like this:

<div class="someclass"><p>Some Text</p></div>

On a side note...these pages have always rendered correctly with past builds. 
This bug only showed up a few weeks ago.
Priority: P3 → P1
Target Milestone: --- → M15
Changing component
Assignee: troy → karnaze
Component: Layout → HTMLTables
QA Contact: petersen → chrisd
are you seeing this with m15?
this smells of bug 28920.  marking dup of it.


*** This bug has been marked as a duplicate of 28920 ***
Status: UNCONFIRMED → RESOLVED
Closed: 25 years ago
Resolution: --- → DUPLICATE
This is not a duplicate.  Doron, please be more careful when marking bugs
dupliate.  Without a minimized test case or similar evidence to prove it's
exactly the same problem, you shouldn't dup a bug.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
We need a minimized test case for this.  Any takers?
Reducing severity, critical is reserved for more serious bugs than this.
Severity: critical → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: helpwanted
i'll make it
Keywords: makingtest
my bad. The offending code is <div class="section"><p>Welcome</p></div>

The <P></P> causes line breakes, removing em fixes the bug. Since it is in a
table, it looked to me like a dupe. Seems to however work only now if a DIV is
included.

Adding testcase
Attached file minimised testcase (deleted) —
Keywords: testcase
What is shown in the attachement is not a bug per the CSS spec. It can be fixed 
by adding the following to the stylesheet:

   div.section > p { margin: 0; }

...or just removing the <p> tags inside the table cell (on the original page).
I'm not marking this INVALID, though, since Shashi doesn't like it when I 
do that. ;-)
Ian ---

As you can see, the "Footworld World" page looks absolutely hideous with current 
Moz builds. I designed this page back in the summer of 1997...6 months after the 
release of the CSS1 specs. This page has stood the test of time by being 
viewable to IE3/4/5, NN4, and even Moz. Something happened around early-March 
that caused my pages to become grotesque.

<soapbox>
The bottom-line is that my code is valid and has been since the early days of 
CSS. I see no reason why I should change my code, which has lasted for 3 years, 
just because Moz suddenly decides to interpret it differently.
</soapbox>

Judging from the "solution" you provide, it seems that <p>'s are given margins 
larger than "0" by default and thus causing my cells to look huge. Is my 
understanding correct here??? If it is correct, then why have the margins been 
set to larger than "0"??? The default should be "0" unless I specify otherwise 
on my stylesheet (which over-rides the default).
<soapbox> <!-- ignore this bit please... -->
You cannot rely on user agents rendering pages in a given way. User agents are
free to use any sort of default stylesheet they like, and users are free to 
use whatever default user stylesheet they like too.
</soapbox>

The default margins on paragraphs has always been 1em -- try it. It just so
happens that a *bug* in legacy browsers has caused margins inside cells to be
collapsed at the edges. This should not ever happen, according to CSS1.

The fix to your page is simple, mind you. Just remove the <p> tags. The text is
already inside a <div>, so the paragraph tags are redundant. (That page is not
using very semantic markup anyway, so there is no loss.)
Summary: Table cells are extraordinarily large → margins not collapsed at cell edges in quirks mode
Whiteboard: WONTFIX?
Attached patch patch to fix the bug (obsolete) (deleted) — Splinter Review
The 2nd attachment adds a rule to quirk.css which easily fixes the problem. Are 
there other rules that need to be added? I'm replacing "WONTFIX" in the status 
field to "fix-in-hand".
Status: NEW → ASSIGNED
Whiteboard: WONTFIX? → fix-in-hand
Target Milestone: M15 → M18
is this fix still any good? do we want it togo in?  It's been a while since this
bug was touched.
Marking mozilla0.8 (I need to re-test the patch).
Target Milestone: M18 → mozilla0.8
The patch (which was checked in 2000-12-21) causes problems, see bug 63983.
There are already two rules in quirk.css that is supposed to collapse margins:

 75 /* Quirk: collapse top margin of BODY and TD and bottom margin of TD */
 76 
 77 body > :first-node, td > :first-node {
 78   margin-top: 0;
 79 }
 80 
 81 td > :last-node {
 82   margin-bottom: 0;
 83 }

The problem with the selectors above is that they only take care of immediate
children of td and body. Changing it to:

    body > :first-node, td > :first-node,
    body > :first-node > :first-node, td > :first-node > :first-node {
      margin-top: 0;
    }
    
    td > :last-node,
    td > :last-node > :last-node {
      margin-bottom: 0;
    }

fixes this bug and bug 63983, but it is not a general solution to the problem,
which I think cannot be expressed in CSS. Although you can add "> :first-node"
to any level you desire, what you need is to recurse to *any* level, which
is probably easier and more efficient to do in C++.
Marc, I have backed out the patch because it caused bug 63785. Please look at 
the comments in that bug and here and decide what we should do. I marked this 
bug mozilla0.8 only because there was an existing patch.
Assignee: karnaze → attinasi
Status: ASSIGNED → NEW
Mats Palmgren just pointed out what I think would be an acceptable solution -
invent a new selector, say :first-descendant and :last-descendant (although I
don't like those terms) and use that instead.
Summary: margins not collapsed at cell edges in quirks mode → [MARGIN-C]margins not collapsed at cell edges in quirks mode
That's wrong.  It would have to be :first-descendant-of(TD),
:first-descendant-of(BODY), etc.
I'd suggest putting this off for now, unless there is a
top100 site we need to worry about.

setting severity to Normal, clearing fix-in-hand, Accepting and moving to future.
Status: NEW → ASSIGNED
Whiteboard: fix-in-hand
Target Milestone: mozilla0.8 → Future
David: That wouldn't work.

   div { margin: 1em; }

   <td>
    <div>
     <div>
      <div>
       no margins
      </div>
     </div>
    </div>
   </td>

(Also, it would have to be :-moz-...)
But this would be in the UA stylesheet so the author div rule would override it.
 Or would you want there to be no margins in that case?
*** Bug 72172 has been marked as a duplicate of this bug. ***
QA contact update
QA Contact: chrisd → amar
--> P3 for future bugs
Priority: P1 → P3
*** Bug 47051 has been marked as a duplicate of this bug. ***
*** Bug 96966 has been marked as a duplicate of this bug. ***
*** Bug 98809 has been marked as a duplicate of this bug. ***
An alternative solution would be to make the 'margin' and 'margin-*' properties
"shorthand" properties, in a sense, that both set the margin and set
-moz-margin-top-ignore and -moz-margin-bottom-ignore to 'none'. 
'-moz-margin-top-ignore' and '-moz-margin-bottom-ignore' could then be set to
'if-edge' in ua.css and the block layout code could figure out when to do the
ignoring.
Attached file additional testcases (deleted) —
Blocks: 99765
Attachment #11037 - Attachment is obsolete: true
Well... maybe once we've solved some of our more urgent and much more serious CSS1 
and CSS2 bugs? ;-) Do we really want to fix this at all?
Keywords: compat
Whiteboard: WONTFIX?
*** Bug 104000 has been marked as a duplicate of this bug. ***
*** Bug 29447 has been marked as a duplicate of this bug. ***
Blocks: 147312
No longer blocks: 147312
*** Bug 147312 has been marked as a duplicate of this bug. ***
*** Bug 158837 has been marked as a duplicate of this bug. ***
*** Bug 161029 has been marked as a duplicate of this bug. ***
*** Bug 162374 has been marked as a duplicate of this bug. ***
*** Bug 162811 has been marked as a duplicate of this bug. ***
*** Bug 179841 has been marked as a duplicate of this bug. ***
*** Bug 44264 has been marked as a duplicate of this bug. ***
There's a good bit of discussion of this bug in bug 44264, and a little in other
of the duplicates, such as bug 179841.  Taking this bug, since the solution is
most likely in the style system, if we come up with one, although it's not high
priority.
Assignee: attinasi → dbaron
Status: ASSIGNED → NEW
Component: Layout: Tables → Style System
QA Contact: amar → ian
Status: NEW → ASSIGNED
An extension of the idea in comment 30 is to change our quirk so that instead of 
the masses of CSS rules in quirk.css, we just changed the margins of <p>, etc, to 
be in a different set of units, e.g., _moz_quirky_em, which we then say acts like
an 'em' in all cases except in quirks mode at the top of a block.
Summary: [MARGIN-C]margins not collapsed at cell edges in quirks mode → [MARGIN-C]margins not collapsed at cell/body edges in quirks mode
*** Bug 181093 has been marked as a duplicate of this bug. ***
Blocks: 38655
Blocks: 191428
Blocks: 61949
*** Bug 199795 has been marked as a duplicate of this bug. ***
*** Bug 65893 has been marked as a duplicate of this bug. ***
*** Bug 198585 has been marked as a duplicate of this bug. ***
*** Bug 75878 has been marked as a duplicate of this bug. ***
Attached file Testcase #3 (deleted) —
Here is another case which came up in bug 209193:
<td><form><input type="hidden"></form><div>DIV</div></td>

See also bug 172902
*** Bug 209193 has been marked as a duplicate of this bug. ***
The solution proposed in comment 20 would not fix the bug for many of the cases
where margins collapsing through an element are involved.
*** Bug 194793 has been marked as a duplicate of this bug. ***
My preferred fix for this would be that described in comment 43.
Summary: [MARGIN-C]margins not collapsed at cell/body edges in quirks mode → [MARGIN-C]margins not collapsed at cell or body edges in quirks mode
Blocks: 215531
Summary: [MARGIN-C]margins not collapsed at cell or body edges in quirks mode → [MARGIN-C]margins not collapsed at cell or body edges in quirks mode (top margin compat)
*** Bug 219301 has been marked as a duplicate of this bug. ***
*** Bug 62249 has been marked as a duplicate of this bug. ***
*** Bug 96966 has been marked as a duplicate of this bug. ***
*** Bug 228547 has been marked as a duplicate of this bug. ***
*** Bug 231290 has been marked as a duplicate of this bug. ***
Blocks: 56362
*** Bug 243554 has been marked as a duplicate of this bug. ***
*** Bug 269327 has been marked as a duplicate of this bug. ***
*** Bug 269007 has been marked as a duplicate of this bug. ***
*** Bug 295026 has been marked as a duplicate of this bug. ***
QA Contact: ian → style-system
Blocks: 339694
Fixing this properly would allow us to remove the rules in quirks.css that sort of do this, which would probably yield a performance gain.
Keywords: perf
Blocks: 376184
This but also affects bottom-alignment in tables where one cell has a <p> tag. See attachment "testcase 4" for example.
Blocks: 372632
Blocks: 373298
Depends on: 50959
Assignee: dbaron → nobody
No assignee, updating the status.
Status: ASSIGNED → NEW
No assignee, updating the status.
No assignee, updating the status.

The steps to reproduce are not clear enough for me to determine whether this bug still occurs or not.
There are a few test cases, but no references to how the bad behavior was/is and how it should be.

Emilio, could you help me with clear instructions for one of the test cases so reconfirm it (if the case).
Thanks.

Flags: needinfo?(emilio)

We render the test-cases the same way as other browsers. Given that I don't think we'll spend time changing margin-collapsing in quirks mode unless there's a very good reason to do that.

Flags: needinfo?(emilio)

Emilio,
I am for wont-fixing this bug report (like Hixie suggested in #c11) for reasons you give.
We should not spend a lot of time on quirks mode rendering.

Status: NEW → RESOLVED
Closed: 25 years ago2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: