Closed Bug 1483798 Opened 6 years ago Closed 3 years ago

getComputedStyle should return an empty style for elements outside the flattened tree

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: smaug, Assigned: emilio)

References

Details

Attachments

(1 file, 3 obsolete files)

No description provided.
and this can be resolved as failing for now, since it matches other engines.
This is expected, for now, and matches other engines. I planned on fixing this as part of the effort of getting to a common getComputedStyle behavior across engines. But I don't think this blocks shipping Shadow DOM since it matches them. I'll fix this once we ship Shadow DOM.
Summary: getComputedStyle-detached-subtree.html fails when Shadow DOM is enabled → getComputedStyle should return an empty style for elements outside the flattened tree.
Attachment #9001561 - Flags: review?(emilio)
oh, you had changed this bug while I was updating wpt results.
Summary: getComputedStyle should return an empty style for elements outside the flattened tree. → getComputedStyle-detached-subtree.html fails when Shadow DOM is enabled
Attachment #9001561 - Flags: review?(emilio) → review+
Works for me. I'll file another.
I'll make the testing changes elsewhere
Summary: getComputedStyle-detached-subtree.html fails when Shadow DOM is enabled → getComputedStyle should return an empty style for elements outside the flattened tree
Priority: -- → P3

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:smaug, could you have a look please?

Flags: needinfo?(bugs)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED

The underlying issue (getComputedStyle outside of the flattened tree returning styles) is not fixed though.

Status: RESOLVED → REOPENED
Flags: needinfo?(bugs)
Resolution: FIXED → ---
Attachment #9001561 - Attachment is obsolete: true
Blocks: 1550838
See Also: → 1550838
No longer blocks: 1550838

As per spec. This could cause wrong styles to be returned because we
fill the bloom filter based on flat tree ancestors, which was ultimately
the root cause of bug 1737131.

Assignee: nobody → emilio

This test was relying on querying the computed style of elements outside
of the tree (which could cause bogus results like bug 1737131).

In this case, it worked out for what the test wanted to assert, but
after the previous patch it no longer does (those elements effectively
do not have styles).

Fix the test in a similar fashion, to make sure we've opened all the
menus at least once so that we hit this code:

https://searchfox.org/mozilla-central/rev/42522adc3fbf4b98a3070d5aa5c56bee9c083ec4/toolkit/content/widgets/menupopup.js#88-96

and the elements are slotted.

This is a more generic fix for
https://phabricator.services.mozilla.com/D131080 that we might want to
take instead. I'm not aware of other tests triggering the same issue but
this causes behavior to be a bit more predictable.

Context: We have tests that query the style of menupopups/menuitems that
are not in the flat tree (that is, that are children of a shadow host,
but are not slotted). That makes no sense, because the flat tree is how
we determine where to inherit from (so the styles that we were returning
before this bug are wrong, they just happen to work for that particular
test).

Panels and menupopups have some lazy initialization code that before
this patch left a shadow root attached to the element but no slot.
Instead, don't even bother to create a shadow root (and do that lazily
as well). It's a bit more predictable behavior, and is also less work
during startup, so should be a win.

Blocks: 1741089

Comment on attachment 9250608 [details]
Bug 1483798 - Don't make menupopups and panels leave unslotted children. r=Gijs,mconley,bgrins

Revision D131081 was moved to bug 1741089. Setting attachment 9250608 [details] to obsolete.

Attachment #9250608 - Attachment is obsolete: true
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5aa4d866a171 Avoid returning the computed styles of nodes that aren't in the flat tree. r=xidorn
Status: REOPENED → RESOLVED
Closed: 6 years ago3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Regressions: 1741612
Attachment #9250607 - Attachment is obsolete: true
Blocks: 1784943
See Also: → 1792860
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: