Closed Bug 1895555 Opened 26 days ago Closed 16 days ago

Text-Fragments: Implement same-document navigation

Categories

(Core :: DOM: Navigation, task)

task

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This bug tracks the implementation of handling text fragments for same-document navigations.

Same-document navigation follows a different code path than normal navigation
and was therefore not covered in the initial implementation for text fragments.
Same-document navigation does not set a URI in the Document, which
is the way cross-document navigation would parse text directives from the URL.

Instead, nsDocShell::ScrollToAnchor() is called via
nsDocShell::InternalLoad()-> nsDocShell::HandleSameDocumentNavigation().
This code path needs to parse and remove the fragment directive from the new
fragment to be able to find text fragments and to allow for element-id fallback.
nsDocShell::ScrollToAnchor() needs to start an attempt to scroll to the text fragment
if it exists. It must not, however, clear the uninvoked text directives, because a
same-document navigation could happen before the document is fully loaded,
hence the target text might not be part of the DOM tree.

As per spec, a second attempt to scroll to the text fragment is done after the load
is completed. This is done by Document::ScrollToRef(), which is called by
nsDocumentViewer::LoadComplete() after the load has finished.
This call will clear the uninvoked directives.

Pushed by jjaschke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d00d182fcf81
Text Fragments: Implement same-document navigation. r=farre,dom-core
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/46343 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 16 days ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: