Closed Bug 1879579 Opened 8 months ago Closed 8 months ago

CompareTreePosition uses flat tree order for DOM operations, which seems unexpected.

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox122 --- wontfix
firefox123 --- wontfix
firefox124 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

So bug 1837540 introduced nsContentUtils::CompareTreePosition which reuses nsLayoutUtils::CompareTreePosition. However I don't think these should do the same.

nsLayoutUtils::CompareTreePosition uses the flat tree, mostly because it needs to for quotes and counters.

However it's weird that nsContentUtils::CompareTreePosition does that. It doesn't match the semantics of nsContentUtils::PositionIsBefore, and it seems likely that it's causing subtle correctness issues in presence of shadow DOM.

Maybe we should have a single CompareTreePosition that takes a template parameter or something enum class TreeKind { Light, Flat } or so.

Yeah, I think we should be always clear on what kind of tree we're considering.
When nsContentUtils::CompareTreePosition was created it just moved some existing nsLayoutUtils::CompareTreePosition usage inside it.

Set release status flags based on info from the regressing bug 1837540

:avandolder, since you are the author of the regressor, bug 1837540, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(avandolder)

It should be easy to construct a test-case that causes incorrect behavior (pre-existing) with something like:

<form>
  <some-component-with-two-slots>
    <input slot="second-slot">
    <input slot="first-slot">
  </some-component-with-two-slots>
</form>
Assignee: nobody → emilio
Flags: needinfo?(avandolder)
Blocks: 1874040
Regressed by: 1874040
No longer regressed by: 1837540

Err, wrong field, similar bug # :)

Regressed by: 1837540
No longer regressed by: 1874040

Make TreeOrderedArray support what the form controls stuff needs, and
use it instead of custom nsContentUtils stuff.

Attached file test-case
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1acc95286189 Clean up CompareTreePosition and related code. r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/44533 for changes under testing/web-platform/tests
Upstream PR was closed without merging
Attachment #9379271 - Attachment description: Bug 1879579 - Clean up CompareTreePosition and related code. r=smaug,avandolder,#dom-core → Bug 1879579 - Clean up CompareTreePosition and related code. r=smaug
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/37ec3180a6cb Clean up CompareTreePosition and related code. r=smaug
Flags: needinfo?(emilio)
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: