Closed Bug 1573990 Opened 6 years ago Closed 1 year ago

z-index on `position:relative;display:inline` element also affects its {ib}-split block children.

Categories

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

defect

Tracking

()

RESOLVED INVALID
Webcompat Priority P2

People

(Reporter: dholbert, Unassigned)

References

Details

Attachments

(3 files)

Attached file testcase 1

In Firefox and Edge, it seems that z-index-affected display:inline;position:relative elements will apply their z-index to their block-level children as well, whereas in Chrome and WebKit, they don't.

I'm not sure who's right. IB splits are weird. (If we're right, we should try to get bugs filed, because we'll be the odd one out once EdgeHTML is superseded by Edgium.)

This is the root of https://github.com/webcompat/web-bugs/issues/36951

STR:

  1. load attached testcase.

Blink/WebKit results:
An orange area is visible, with Can you see this text?

Gecko/EdgeHTML results:
No orange area is visible. No text is visible.

Here's a similar testcase where I'm using filter instead of z-index on the inline-level element that has a block-level child.

In Firefox and EdgeHTML, the block-level child gets filtered as well. In Chrome and Safari, it does not (so the "Can you see this text" orange area is visible/crisp there).

dbaron, is this a behavior-difference that you're familiar with, and do you happen to remember who's correct? (or whether this is specced at all?)

Flags: needinfo?(dbaron)

I think based on the wording in the spec:

When an inline box contains an in-flow block-level box, the inline box (and its inline ancestors within the same line box) are broken around the block-level box (and any block-level siblings that are consecutive or separated only by collapsible whitespace and/or out-of-flow elements), splitting the inline box into two boxes (even if either side is empty), one on each side of the block-level box(es). The line boxes before the break and after the break are enclosed in anonymous block boxes, and the block-level box becomes a sibling of those anonymous boxes. When such an inline box is affected by relative positioning, any resulting translation also affects the block-level box contained in the inline box.

the only thing from the inline that should apply to the block is relative positioning. (I argued against that, but lost.)

Flags: needinfo?(dbaron)

So we should probably remove this line and maybe some other lines in the same rule.

I feel pretty strongly that our rendering is the correct one and that this is a bug in Chrome.
It's insane that a property only affects only some of the element's boxes, but not all.

Basically the rest of the working group thinks that the block wrapper isn't really there, and the inline just has two inline boxes that are broken in half, with the block child not really being a child of the inline. And then there's an exception to make relative positioning work.

I argued that it should be like there's a block wrapper box, but I lost that argument. And it does match what the spec says.

Fair enough, but not having a block wrapper means that the box tree becomes more complex since DOM tree children can create box tree siblings. Then again, we already sort of have that with display:contents anyway so perhaps not a big deal...
Oh well, I'm not a fan of our IBSplitSibling setup anyway - maybe we can get rid of that now?

We still need the anon block to do relative positioning, unless we want to somehow apply it to all the individual child blocks, right?

As far as the specific z-index rule goes, I looked at the history and it was first added in https://github.com/mozilla/gecko-dev/commit/3b93ffe84819ca54b2e2be7ae9af780ed6f46bdf but none of the discussion in bug 6625 mentions why it would have been added other than "yeah, this seems right to get rid of that XXXwaterson comment". So if it's not matching the spec and other UAs, and we have already tried to litigate this and lost, then we should just remove it and not waste time on it....

FWIW, we have similar rules for opacity and such that WebKit/Chromium doesn't have and which they consider a bug on their impl.

So that is an interesting question. Per spec, z-index applies to a positioned box, so it's the box tree that matters. In particular, if you have a rel pos inline with a float child, that child would not be affected by z-index on the rel pos inline, right? At least per spec... in impls it sure seems to be. :(

On the other hand, opacity is clearly defined to act on elements, not on boxes.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #9)

We still need the anon block to do relative positioning, unless we want to somehow apply it to all the individual child blocks, right?

Right, but we need to implement something like that to support CSS Alignment for blocks anyway (bug 1105571).
Fwiw, I recently tried removing the table-cell anon child just to see what it's actually needed for and the only thing that remained in the end was the alignment of the cell contents. So, if we implement bug 1105571 (without introducing an anon box obviously) then I think we can get rid of the table-cell anon box.

It seems like it should be possible to implement relative positioning without using a wrapper (again, it might be possible to re-use some code from bug 1105571 for this). I don't know about the other properties though, opacity/z-index etc seems hard to do without a wrapper.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #11)

On the other hand, opacity is clearly defined to act on elements, not on boxes.

A word of caution: the terms "element" and "box" are often interchanged rather liberally in CSS specs (especially in older specs, but also in recent ones). I would not assume that those terms are used correctly.
If we're going to make implementation decisions based on those wordings then I would recommend asking the CSSWG for the intended meaning.

<sigh>. If people can't even use the terms their own specs introduce right...

Yes, we should be filing bugs on specs that do that.

Removing "negative" from bug summary, because this is just as much of a compat-issue for positive z-index. (the sign doesn't matter)

(https://github.com/webcompat/web-bugs/issues/48945 is a case where we're bitten by a z-index:2 on an inline-level wrapper that we honor on its block-level child but Chrome does not.)

Summary: Negative z-index on `position:relative;display:inline` element also affects its {ib}-split block children. → z-index on `position:relative;display:inline` element also affects its {ib}-split block children.
Webcompat Priority: --- → P2
Severity: normal → S3
Attached image FF vs Chrome.png

Based on the test cases there isn't really much of a difference on Firefox vs Chrome now. Should we mark this as fixed?

Environment:
Operating system: Windows 10
Browsers tested: Firefox Nightly 128.0a1 (2024-05-29) / Firefox Release 126 / Chrome 125.0.6422.113

Flags: needinfo?(dholbert)

Thanks, you're right! It looks like Chrome aligned with the Firefox (and pre-Chromium Edge) behavior here.

Bisecting with testcase 1, it looks like Chrome 100 has their old behavior, whereas Chrome 101 and newer match us.

WebKit still disagrees, but it's probably reasonable to consider that a WebKit bug at this point (which Chromium/Blink inherited and then fixed).

So I think we can consider this INVALID as a Firefox bug.

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(dholbert)
Resolution: --- → INVALID

Also, I spun off bug 1899829 for webcompat issue https://webcompat.com/issues/60176 which was linked here but seems to still show a reproducible difference between Firefox vs Chrome/Safari.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: