Open Bug 1455893 Opened 6 years ago Updated 5 months ago

Cannot select elements across shadow boundaries.

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

People

(Reporter: emilio, Assigned: sefeng)

References

(Depends on 3 open bugs, Blocks 3 open bugs)

Details

Attachments

(1 file)

STR:

 * Go to https://wpt.fyi/css/cssom/interfaces.html
 * Try selecting content from the warning message that says:

> Data below are intended for web platform implementers and do not contain useful metrics for evaluation or comparison of web platform features. Also note that tested Edge and Safari are not pre-release versions (#109, #110).

   and moving it into the results table.

Expected:

 * I can select text across shadow DOM boundaries.

Actual:

 * The selection is chomped to the table contents inside the Shadow Root.
Component: Audio/Video: Playback → DOM
Depends on: 1455894
This is a spec issue too. As far as I know, Gecko works like Webkit, since that is per current spec.
Priority: -- → P3
Component: DOM → DOM: Core & HTML
See Also: → 1741051

I am going to spend some time in the shadow dom cross boundary selecton proposal and see what we can do.

Assignee: nobody → sefeng

Looks like STR is outdated, so I attached a new testcase.

Severity: normal → S3
Duplicate of this bug: 1843725

Is this still being worked on? Otherwise consider unassigning it.

Flags: needinfo?(sefeng)

Yeah, I am working on this

Flags: needinfo?(sefeng)

Any gut feeling yet how complex fixing this is? Any context here is appreciated.

Flags: needinfo?(sefeng)

Implementing the spec to return the ranges that have the correct start and end nodes is easy, though making the actual selection work (ie. the blue selection background) is hard.

Mostly due the selection code has the assumption that no shadow DOM is involved. For example ContentIterator doesn't iterate elements in shadow DOM, range gets confused for its common ancestor. Lots of assertions had the same assumption so it's hard to fix them. Slotted contents makes the entire thing more complicated.

Plus the same code has been used not only by selection but also editor stuff, which adds another level of complexity.

So far I've implemented the spec and made the visual selection works for some fairly complex shadow trees. I am fixing test failures related to editor and slotted contents. Fixed lots of them already, but still have a decent number of failures to go.

Hope this provides some context :)

Flags: needinfo?(sefeng)

Hope this provides some context :)

It did, thanks.

Btw., be aware that the clipboard-code might need refinement too.

Blocks: 1860292
Depends on: 1867058
Depends on: 1867059
Depends on: 1867060
Depends on: 1867145
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: