Closed Bug 1949691 Opened 27 days ago Closed 21 days ago

Text-Fragments: Creating text fragment doesn't respect invisible content

Categories

(Core :: DOM: Selection, defect)

defect

Tracking

()

RESOLVED FIXED
137 Branch
Tracking Status
firefox137 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

Details

Attachments

(1 file)

Example:

  • Set dom.text_fragments.create_text_fragment.enabled=true
  • Open:
    data: text/html,<p>text with <span style="display:none">display:none</span> content</p>
  • Select all (CTRL+A)
  • Open context menu, "Copy Link to Highlight¨

Expected:
data: text/html,<p>text with <span style="display:none">display:none</span> content</p>#:~:text=text with content

Actual results:
data: text/html,text with <span style="display:none">display:none</span> content#:~:text=text with display%3Anone content

This happens because nsRange::ToString() is used to get range contents, which ignores display:none, visibility: hidden, et al.

Using nsRange::ToString() simply concatenates all text nodes (see 0).
However, for creating text fragments only visible text nodes should be considered.
This patch implements a function that only considers visible text nodes
by reusing some utility functions defined in the text fragments spec (1, 2).

Assignee: nobody → jjaschke
Status: NEW → ASSIGNED
Pushed by jjaschke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1d1a9c02d162 Text Fragments: Only use visible content when stringifying ranges. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: