Closed Bug 1809505 Opened 3 years ago Closed 1 year ago

Style containment not working well with counters on pseudo-elements

Categories

(Core :: Layout: Generated Content, Lists, and Counters, defect)

defect

Tracking

()

RESOLVED FIXED
137 Branch
Tracking Status
firefox137 --- fixed

People

(Reporter: Oriol, Assigned: emilio)

References

Details

Attachments

(3 files, 1 obsolete file)

Attached file style-containment.html (obsolete) —

Load attached testcase.

Expected:

[::before=0]
  1. [::before=1][::after=1]
  [::before=0]    <-- Here
    1. [::before=1][::after=1]
  [::after=1]
  2. [::before=2][::after=2]
[::after=2]

Actual:

[::before=0]
  1. [::before=1][::after=1]
  [::before=1]    <-- Here
    1. [::before=1][::after=1]
  [::after=1]
  2. [::before=2][::after=2]
[::after=2]

Also, layout is not stable. if then I run

var div = document.querySelector("div");
div.style.display = "none";
div.offsetLeft;
div.style.display = "";

it becomes

[::before=0]
  1. [::before=1][::after=1]
  [::before=2]    <-- Here
    1. [::before=1][::after=1]
  [::after=1]
  2. [::before=2][::after=2]
[::after=2]
Attached file style-containment.html

I forgot about https://drafts.csswg.org/css-contain/#containment-style

the counter() and counters() value of the content property is not itself scoped, and can refer to counters established outside of the subtree.

So the initial result is actually good. I'm attaching a better testcase with counters().

[::before=0]
  1. [::before=1][::after=1]
  [::before=1]
    1. [::before=1.1][::after=1.1]
  [::after=1.1]
  2. [::before=2][::after=2]
[::after=2]

But when I run the JS, it wrongly becomes

[::before=0]
  1. [::before=1][::after=1]
  [::before=2]
    1. [::before=2.1][::after=2.1]
  [::after=2.1]
  2. [::before=2][::after=2]
[::after=2]
Attachment #9311606 - Attachment is obsolete: true

Reproduced on nightly 110

Severity: -- → S2
Severity: S2 → S3

Martin, do you have cycles to take a look at this? No big deal if not but it seems it might not be too hard to address.

Flags: needinfo?(mrobinson)

Sure. I can take a look at this failure.

Flags: needinfo?(mrobinson)

Please accept my apologies for dropping the ball on this issue. I think that I may not have time to tackle it in the short term. :(

Duplicate of this bug: 1934755

emilio, maybe you can pick this up if/when you have cycles? Sounded like in comment 3 like it might be a relatively straightforward fix. (We just got what-seems-to-be-a-dupe filed in bug 1934755, so it seems to be something that folks have stumbled over in the wild in at least that one instance.)

Flags: needinfo?(emilio)

The binary search gives us the first node after the insertion point.

We want the preceding one.

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Flags: needinfo?(emilio)

This was useful for debugging.

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/50765 for changes under testing/web-platform/tests
Pushed by amarc@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/8bca57a930cc Fix ContainStyleScope::GetPrecedingElementInGenConList. r=jwatt
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: