If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Right margin for an empty element will be ignored

NEW
Unassigned

Status

()

Core
Layout: Block and Inline
8 years ago
6 years ago

People

(Reporter: Daniel Kirsch, Unassigned)

Tracking

({testcase})

Trunk
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6
Build Identifier: 

When I have an empty inline element to use as distance element, the given right margin value will be ignored.

Reproducible: Always

Steps to Reproduce:
Create something like this:
<span style="margin-right:50px"></span>Using right margin for the previous sibling. I should have a 50 px distance to the left.

Actual Results:  
I don't see any distance

Expected Results:  
I expect the element to be indented by 50px to the right

As soon as I add some content for the empty element the margin will be added. When I use left-margin instead, it works as well. Adding a border does work too.

All current major browsers (IE 8, Safari 4, Chrome 4, Opera 10.5) seem to handle this correctly and add a margin.
(Reporter)

Comment 1

8 years ago
Created attachment 428426 [details]
Testcase

The testcase shows the difference between left-margin and right-margin
(Reporter)

Updated

8 years ago
Keywords: testcase
Seems like to be an very old bug. It goes back to 2004 as reported by Daniel. Confirming on OS X.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86 → All
Version: unspecified → 1.0 Branch
The immediate cause here is this code in nsLineLayout::CanPlaceFrame:

1149   // Compute right margin to use
1150   if (0 != pfd->mBounds.width) {
...
1181   }
1182   else {
1183     // Don't apply margin to empty frames.
1184     pfd->mMargin.left = pfd->mMargin.right = 0;
1185   }

Seems to me like this is bogus and we should always run the body of this if, but change the "empty frames fit" check to ignore end margins instead of including all margins.

It looks like this code was introduced as part of fixing bug 46918 and bug 3490.  I should look into what the testcases there actually looked like.
Version: 1.0 Branch → Trunk
Actually, no.  That 0!= check was added in:

3.12 <kipp@netscape.com> 1999-03-18 13:03
Spanked to collapse inline-reflow with line-layout into line-layout; fixed bugs #1278, #1990, #3527, #1670, etc.
And I don't see why the "empty frames fit" block should be there, exactly.  David, do you know whether it's needed and why?  I just checked behavior, and we do NOT want to ignore end margins for the empty frame check, in fact.  At least not if we want to end up with Safari/Opera compat here.

I guess the empty frame thing is only relevant if an empty frame comes after a frame that wouldn't have fit but was forced to fit due to being the first frame on the line, right?
Created attachment 428474 [details]
For my future reference
Sent http://lists.w3.org/Archives/Public/www-style/2010Feb/0200.html
(Reporter)

Comment 8

8 years ago
(In reply to comment #7)
> Sent http://lists.w3.org/Archives/Public/www-style/2010Feb/0200.html

Interesting case and everybody handles that different.

Updated

6 years ago
Duplicate of this bug: 741811
You need to log in before you can comment on or make changes to this bug.