Closed Bug 1899567 Opened 1 month ago Closed 1 month ago

Text-Fragments: Check if a start element is directly adjacent to the prefix is wrong if both are in the same node

Categories

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

defect

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In the case where a text fragment has a prefix element, the start element must be following directly (only whitespace / invisible content is allowed).
This line in FragmentDirective::FindRangeForTextDirective() indicates that this check is currently wrong, as it only checks that prefix and start have the same start node. It needs to check for the StartOffset as well, or should be changed to use nsRange::StartRef() instead.

This should fix the last remaining failed WPT in find-range-from-text-directive.html.

Summary: Text-Fragments: Check if a start element is directly adjacent.o the prefix is wrong if both are in the same node → Text-Fragments: Check if a start element is directly adjacent to the prefix is wrong if both are in the same node

The start element of a text directive must follow the prefix directly,
only whitespace or invisible content is allowed in between.

The check for this only compared the start boundary
parent nodes of the ranges used for searching,
therefore allowing arbitrary text between prefix and start,
as long as they are in the same text node.

This patch fixes this by using nsRange::StartRef() instead,
which compares RangeBoundary objects instead,
thus also taking the offsets into account.

Pushed by jjaschke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a82cf8a3a53f
Text Fragments: Ensure that the start element directly follows the prefix. r=dom-core,avandolder
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: