Text Fragments: Implement same-document navigation.
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.
Differential Revision: https://phabricator.services.mozilla.com/D209726
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1895555
gecko-commit: d00d182fcf814d5ed0f06831668932cc27b06280
gecko-reviewers: farre, dom-core