Bug 1899567 - Text Fragments: Ensure that the start element directly follows the prefix. r=dom-core,avandolder

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.

Differential Revision: https://phabricator.services.mozilla.com/D212004
This commit is contained in:
Jan-Niklas Jaeschke 2024-05-29 16:54:40 +00:00
parent 393a8cde54
commit 1163f16bba
2 changed files with 1 additions and 5 deletions

View file

@ -469,8 +469,7 @@ RefPtr<nsRange> FragmentDirective::FindRangeForTextDirective(
// (In this case, we found a prefix but it was followed by something other
// than a matching text so well continue searching for the next instance
// of prefix.)
if (potentialMatch->GetStartContainer() !=
matchRange->GetStartContainer()) {
if (potentialMatch->StartRef() != matchRange->StartRef()) {
continue;
}
}

View file

@ -1,3 +0,0 @@
[find-range-from-text-directive.html]
[match doesn't immediately follow prefix.]
expected: FAIL