Closed Bug 1994763 Opened 7 months ago Closed 3 months ago

Copying multiple lines from `<details>` causes everything in it to be copied

Categories

(Core :: DOM: Serializers, defect)

defect

Tracking

()

VERIFIED FIXED
149 Branch
Tracking Status
firefox149 --- verified
firefox150 --- verified

People

(Reporter: dshin, Assigned: edgar)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:300

Attachments

(2 files)

Discovered this while trying to copy CSSWG resolution chat log. Confirmed via mozregression --launch 2025-10-16 -a summary.html

STR:

  1. Load attached testcase
  2. Select & copy a single line of A
  3. Paste it somewhere to verify its content
  4. Select & copy multiple lines of A
  5. Paste it somewhere to verify its content

Expected: Both Step 3 and 5 pastes what was selected visually
Actual: Step 5 pastes the content of the entire details element

This is pretty bad as far as how user-facing functionality is impaired, but considering that details isn't that common, it seems excessive to say S2. Saying S3.

Severity: -- → S3
See Also: → 1990203
Blocks: 1990203
See Also: 1990203

<details> use the shadow tree, https://searchfox.org/firefox-main/rev/b67c6262ecbe7d4c9385a1bd335fd7dd1d3f887d/dom/html/HTMLDetailsElement.cpp#94, this is an issue of serializing a shadow DOM selection. The way we compute the flatten tree ancestors and offsets for serializing seems wrong, https://searchfox.org/firefox-main/rev/b67c6262ecbe7d4c9385a1bd335fd7dd1d3f887d/dom/serializers/nsDocumentEncoder.cpp#1415-1420.

Assignee: nobody → echen
Component: DOM: Selection → DOM: Serializers
User Story: (updated)

The issue is about the UAWidget, there is no issue on normal shadow DOM. nsContentUtils::GetFlattenedTreeAncestorsAndOffsets() ignores the shadowRoot for UAWidget while compute the ancestor, due to https://searchfox.org/firefox-main/rev/f9d8702e26624ab46a35bf6561a7c8143c6f246a/dom/base/nsINode.cpp#4166-4168, but it doesn't do the same while compute the offset. And https://searchfox.org/firefox-main/rev/f9d8702e26624ab46a35bf6561a7c8143c6f246a/dom/serializers/nsDocumentEncoder.cpp#1256 might also need to ignore the UAWidget.

Blocks: 2012410
Depends on: 1978714
Attachment #9535195 - Attachment description: WIP: Bug 1994763 - Do not serialize UAWidget content; → Bug 1994763 - Ignore UAWidget when computing the offset iin nsContentUtils::GetFlattenedTreeAncestorsAndOffsets();
Pushed by echen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d7693f55e44a https://hg.mozilla.org/integration/autoland/rev/9b38501a7c6f Ignore UAWidget when computing the offset iin nsContentUtils::GetFlattenedTreeAncestorsAndOffsets(); r=masayuki
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b27319d90e9a https://hg.mozilla.org/integration/autoland/rev/68096a67ac9b Revert "Bug 1994763 - Ignore UAWidget when computing the offset iin nsContentUtils::GetFlattenedTreeAncestorsAndOffsets(); r=masayuki" for causing mochitest failures @ test_htmlcopyencoder_details
Pushed by echen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a5fa838aeac5 https://hg.mozilla.org/integration/autoland/rev/d384019d54d8 Ignore UAWidget when computing the offset iin nsContentUtils::GetFlattenedTreeAncestorsAndOffsets(); r=masayuki
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Blocks: 1590379
Flags: needinfo?(echen)
Duplicate of this bug: 2012410
No longer blocks: 2012410
QA Whiteboard: [qa-triage-done-c150/b149] [qa-ver-needed-c150/b49]
QA Whiteboard: [qa-triage-done-c150/b149] [qa-ver-needed-c150/b49] → [qa-triage-done-c150/b149] [qa-ver-needed-c150/b149]
QA Contact: dlucaci

Reproduced with Firefox 146.0a1 (2025-10-16) on macOS 15 ARM.
Verified as fixed with Firefox 150.0a1 (20260303095635) and Firefox 149.0b3 (20260302093328) on macOS 15 ARM, Windows 10 and Ubuntu 22.04.

Status: RESOLVED → VERIFIED
Has STR: --- → yes
QA Whiteboard: [qa-triage-done-c150/b149] [qa-ver-needed-c150/b149] → [qa-triage-done-c150/b149] [qa-ver-done-c150/b149]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: