absolutely positioned element at start of relatively-positioned inline doesn't wrap to next line with the first word of that inline

NEW
Unassigned

Status

()

Core
Layout: R & A Pos
5 years ago
3 months ago

People

(Reporter: Louis Lazaris, Unassigned)

Tracking

(Depends on: 2 bugs, Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
When absolutely positioning a pseudo-element inside of an inline element that starts a new line, the pseudo-element is incorrectly positioned at the end of the previous line.

This happens inside a flow of inline text, where the inline element (such as an anchor or span) resides.

This seems to be an undesired behavior because all other modern browsers (latest Chrome, Opera, IE10 PP2) position the pseudo-element differently from Firefox 11.

Here is a JSBin that demonstrates this:

http://jsbin.com/ucokah/edit#html,live

Hover over the link to see the pseudo-element.
Created attachment 613214 [details]
reporter's testcase

(JSBin really doesn't count as a simplified testcase)
The line-break is happening inside the <a>, not before it (in terms of our resulting box tree).  You can see this pretty clearly if you put a 1px left border on the <a>.

So the containing block for the abspos element ends up being the empty inline box before the line-break (see bug 489100).

That seems to be all that's going on here; in particular, this is not related to pseudo-elements in any way; a normal child element would do the same thing.

I don't know offhand whether other browsers put the linebreak in a different place or whether they don't suffer from bug 489100.
Component: Layout: Block and Inline → Layout: R & A Pos
Depends on: 489100
QA Contact: layout.block-and-inline → layout.r-and-a-pos
(Reporter)

Comment 3

5 years ago
Latest stable Chrome and Safari put the left border on the new line, and the child element is positioned as desired. IE10 PP2 is the same.

Latest stable Opera, however, will work as originally expected with no border, but when you add the border, it behaves the same way as Firefox.

In my opinion, it seems nonsensical for the content to be on a new line while the left border is on the previous line. This doesn't happen if I throw a "br" tag in before the parent element, so why should it happen if the line break is automatically inserted?

But hey, what do I know? :)
The linebreak behavior is a bit silly, imo, yes.  The issue is that we start the parent element, then discover the kid won't fit and break before the non-fitting kid... but part of the parent did fit, so stays on the previous line.  I agree that checking for empty boxes there and not creating them would be nice; that's what Opera seems to be doing based on your description.
(Related to, but not duplicate of, bug 389587.)
Well, fixing that would fix this bug too, yes.
Depends on: 389587
Summary: Pseudo-element inside inline element not positioned correctly → auto-positioned absolutely positioned element at start of inline doesn't wrap to next line with the first word of that inline
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86_64 → All
Version: 11 Branch → unspecified
Blocks: 489207
Summary: auto-positioned absolutely positioned element at start of inline doesn't wrap to next line with the first word of that inline → absolutely positioned element at start of relatively-positioned inline doesn't wrap to next line with the first word of that inline
Duplicate of this bug: 1280857
Duplicate of this bug: 1289700
See Also: → bug 629059
You need to log in before you can comment on or make changes to this bug.