Implement first version of Text Fragments
Categories
(Core :: DOM: Navigation, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox126 | --- | fixed |
People
(Reporter: jjaschke, Assigned: jjaschke)
References
(Blocks 3 open bugs)
Details
Attachments
(6 files, 1 obsolete file)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
This bug tracks the initial implementation for Text Fragments to not mess up the meta bug 1753933.
Assignee | ||
Comment 1•1 year ago
|
||
This patch also adds the empty shell of the FragmentDirective
class to the Document
.
Assignee | ||
Comment 2•1 year ago
|
||
This patch provides functions to extract the fragment directive from a url / a hash
into an array of TextDirective
s
as well as to create a fragment directive string from given text directives.
The algorithms are implemented as a rust crate.
Interface functions and data structures which are accessible from C++
are provided in lib.rs
.
The actual implementation (using pure rust types)
lives in fragment_directive_impl.rs
, tests live in test.rs
.
The implementation currently only supports text directives.
Other future directive types are not considered and will be ignored.
The main function, parse_fragment_directive()
takes a url / a url hash
as parameter and returns (as out parameter) a struct which contains the stripped input url,
the fragment directive string, and an array of parsed text directive objects.
Additionally, there are functions that create a full fragment directive string
from a list of text directives as well as a function that creates
a single text directive string from a text directive.
The TextDirective
class, which is shared with C++, contains four
string elements for the prefix, start, end and suffix elements.
These strings are percent-decoded and do not contain identifiers
(like the -
that indicates it being a prefix or suffix).
All elements besides start
can be empty.
The implemented algorithms are used in the following patches.
Depends on D195684
Assignee | ||
Comment 3•1 year ago
|
||
Main part of this patch is an implementation of the algorithm defined
in the spec 0.
The algorithm takes an array of TextDirective
(which is the result of
the fragment directive parser implemented in part 2 of this bug)
and converts it into an array of nsRange
s.
The algorithm is not optimized for performance yet.
Instead it follows the spec very closely.
Therefore, it may for now only be seen as a baseline to a faster nsFind
based approach.
The algorithm differs from the spec, using a standard nsString::Find()
instead of the mentioned collator-based search, i.e.
performing a case-sensitive and locale-independent search.
Depends on D195685
Assignee | ||
Comment 4•1 year ago
|
||
This patch implements the ::target-text
pseudo element.
Similarly to the Custom Highlight API, this is done implementing
a new Selection type.
Depends on D195686
Assignee | ||
Comment 5•1 year ago
|
||
This patch integrates the algorithm to find a text fragment range
into the document loading mechanism.
Unlike described in the spec, the fragment directive is not stripped
from the URL in the Session History Entry, instead it is stripped when
setting the URI into the Document using Document::SetURI()
,
as well as when accessing the URL through Location
.
The PresShell
class is extended by a new method which sets the
ranges created from the text directives into the FrameSelection as
TargetText selection and scrolls it into view.
Security restrictions like force load at top and cross-origin iframes
are not yet considered in this patch.
Depends on D195687
Assignee | ||
Comment 6•1 year ago
|
||
This test sets the pref dom.text_fragments.enabled
to true for
web-platform tests in
- /scroll-to-text-fragment
- / css/css-pseudo (which contains various tests for
::target-text
Depends on D195688
Assignee | ||
Comment 7•1 year ago
|
||
This patch introduces a new webidl api called document.fragmentDirective.createTextFragment()
,
which allows web apps to create a text directive string from a given range.
Optionally, the api accepts a boolean parameter to force the text directive to use start and end
(i.e. the result looks like this: text=prefix-,start,end,-suffix
),
otherwise it will only use start (i.e. text=prefix-,start,-suffix
).
This API is not spec'd yet [0] and is subject to change.
Currently it mainly serves the purpose of testing the underlying algorithm
that can create a text directive from a range, which is the main part of this patch.
This algorithm uses the find-range-from-text-directive algorithm implemented in part 3
of this bug to iteratively expand the text directive (expanding prefix and suffix,
and if forceRangeBased
is true also start and end) until the created text directive
is the first search result.
This algorithm may not be very efficient because
a) the find-range-from-text-directive algorithm is not performance-optimized yet and
b) it is called in a loop, each time doing a full search of the document.
This patch also contains a few mozilla-specific web-platform tests that test
the new algorithm.
[0] https://github.com/WICG/scroll-to-text-fragment/issues/160
Depends on D195690
Updated•10 months ago
|
Comment 9•8 months ago
|
||
Backed out for causing build bustages in Document.h
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/workspace/obj-build/dist/include/mozilla/dom/Document.h:4100:40: error: declaration of 'mozilla::dom::FragmentDirective* mozilla::dom::Document::FragmentDirective()' [-fpermissive]
Comment 11•8 months ago
|
||
Comment 12•8 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c3e3c81f9ceb
https://hg.mozilla.org/mozilla-central/rev/27c76e65cf58
https://hg.mozilla.org/mozilla-central/rev/bb88c4d09e82
https://hg.mozilla.org/mozilla-central/rev/839bc1b11a2c
https://hg.mozilla.org/mozilla-central/rev/51890598ecb4
https://hg.mozilla.org/mozilla-central/rev/2110f57e928c
Comment 13•8 months ago
|
||
Backed out 6 changesets (Bug 1867939) for causing a top crash in nightly Bug 1889393
Backout link central: https://hg.mozilla.org/mozilla-central/rev/cfb42711da4589f5ede0032644a6d577d66aa468
Comment 14•8 months ago
|
||
Comment 15•8 months ago
|
||
Backed out for causing wpt failures in target-text-010.html.
- Backout link
- Push with failures
- Failure Log
- Failure line: TEST-UNEXPECTED-PASS | /css/css-pseudo/target-text-010.html | Testing http://web-platform.test:8000/css/css-pseudo/target-text-010.html == http://web-platform.test:8000/css/css-pseudo/target-text-five-words-ref.html
Comment 16•8 months ago
|
||
Comment 17•8 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/72fd96c52665
https://hg.mozilla.org/mozilla-central/rev/73ecb30d1c88
https://hg.mozilla.org/mozilla-central/rev/6a93f2b9da54
https://hg.mozilla.org/mozilla-central/rev/de9babe5fda2
https://hg.mozilla.org/mozilla-central/rev/5ad5bd073009
https://hg.mozilla.org/mozilla-central/rev/11e85bb40828
Updated•8 months ago
|
Assignee | ||
Updated•8 months ago
|
Updated•6 months ago
|
Updated•4 months ago
|
Description
•