Open Bug 1948211 Opened 1 month ago Updated 18 days ago

Creating text-fragment does not work across lines on this testcase. Chrome allowd you to create.

Categories

(Core :: DOM: Navigation, defect)

defect

Tracking

()

ASSIGNED

People

(Reporter: mayankleoboy1, Assigned: jjaschke)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

Attached file p5.js

Enable dom.text_fragments.create_text_fragment.enabled
Open attached testcase
Scroll to the bottom
See text like this:

 * This is a list of languages that we have added so far.
 * If you have just added a new language (yay!), add its key to the list below

Select both the lines and right click

AR: Highlight link to copy option appears
ER: Option does not appear

If you individually select each line, the option appears for both.

Profile: https://share.firefox.dev/411vbQd
So this does not fall into the bucket of "takes more than 5 seconds to compute"

is this a dupe of bug 1948202 ?

See Also: → 1948202

No, not necessarily. This is plain text, so there should be no block boundaries.
I'd have to debug this to find out what's going on.

Infact you dont have to open the attached document. Selecting the two lines in comment 0 also do not trigger the creation of text-fragment.

Summary: Creating text-fragment does not work across lines on this testcase → Creating text-fragment does not work across lines on this testcase. Chrome allowd you to create.

When creating a text fragment from a range, the range
needs to be expanded to the nearest word boundaries.
This is done by first moving the range boundary inwards by one word,
and then outwards by one word.
If the range boundary is a special char, the algorithm would jump to the
end of the next word and then back to the beginning of the word:

|* test
* test|
* |test

This patch makes sure that the range boundary is not moving inwards.

Assignee: nobody → jjaschke
Status: NEW → ASSIGNED

For range-based matching, the previous matches were determined incorrectly:
The start match must be matched until the end of the start of the target range,
and the end match must be matched until the end of the end of the target rage.

Before this change, the start of the target range was always considered as a
match to eliminate, therefore producing wrong results.

Duplicate of this bug: 1948506

I assume this requires dom.text_fragments.create_text_fragment.enabled = true.

Severity: -- → S3
Attachment #9466493 - Attachment is obsolete: true

This needs more work, because the logic for extending range boundaries to word boundaries is more complex than anticipated, and I'll likely have to switch back to using the DOM tree here. Therefore, I moved part 2 of this patch set (which is standalone) into its own bug (bug 1951362), so that it can land in the meantime.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: