This patch removes the pref `dom.text_fragments.create_text_fragment.enabled`,
which is not required anymore now that the feature has shipped.
If a user wants to disable text fragments, this can be done using
the pref `dom.text_fragments.enabled`, which now controls the feature in its entirety.
Differential Revision: https://phabricator.services.mozilla.com/D274758
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
Other browsers provide the "copy link to highlight" context menu entry if the user right-clicks
onto an existing highlight (without selection). In this case, the created link contains all highlights
on the page. If a selection exists as well, it should take precedence.
This patch adapts to this behavior. When the context menu is opened, it is determined
whether there is a selection or an existing highlight range at the given point.
This has the side-effect that the "Copy Link to Highlight" option only shows up
if the user right-clicks on a selection or an existing highlight, but not anywhere else
(this also aligns behavior to Chrome).
Differential Revision: https://phabricator.services.mozilla.com/D259730
This reverts commit 0c72c07170.
Revert "Bug 1948246 - Text Fragments: Don't show context menu entry for "Copy Link to Highlight" in view-source pages. r=Gijs"
This reverts commit 7dde84499e.
Other browsers provide the "copy link to highlight" context menu entry if the user right-clicks
onto an existing highlight (without selection). In this case, the created link contains all highlights
on the page. If a selection exists as well, it should take precedence.
This patch adapts to this behavior. When the context menu is opened, it is determined
whether there is a selection or an existing highlight range at the given point.
This has the side-effect that the "Copy Link to Highlight" option only shows up
if the user right-clicks on a selection or an existing highlight, but not anywhere else
(this also aligns behavior to Chrome).
Differential Revision: https://phabricator.services.mozilla.com/D259730
This reverts commit 942e756723.
Revert "Bug 1948246 - Text Fragments: Don't show context menu entry for "Copy Link to Highlight" in view-source pages. r=Gijs"
This reverts commit 33fbb17c75.
Other browsers provide the "copy link to highlight" context menu entry if the user right-clicks
onto an existing highlight (without selection). In this case, the created link contains all highlights
on the page. If a selection exists as well, it should take precedence.
This patch adapts to this behavior. When the context menu is opened, it is determined
whether there is a selection or an existing highlight range at the given point.
This has the side-effect that the "Copy Link to Highlight" option only shows up
if the user right-clicks on a selection or an existing highlight, but not anywhere else
(this also aligns behavior to Chrome).
Differential Revision: https://phabricator.services.mozilla.com/D259730
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.
Differential Revision: https://phabricator.services.mozilla.com/D256800
Before this patch, the 5 second timeout was applied
to each range individually. In some edge cases,
the number of ranges could be large. And even if
creating a text directive for a single range was
very fast, the accumulated time for all ranges
could exceed the 5 second limit.
This patch changes the watchdog to run
globally instead of per range, therefore
cutting off the whole process of creating
a text directive after 5 seconds.
It is not feasible to create a test case for
the timeout watchdog, hence there are
no changed tests.
Differential Revision: https://phabricator.services.mozilla.com/D252946
Before this patch, the C++ code was responsible
for creating a single text directive from a single
range. Accumulating the text directives into a
text fragment was done in the JS code.
This patch moves the responsibility of creating
the text fragment to the C++ code, which simplifies
the JS code, and improves the performance.
This is a prerequisite for the second patch, which
will make the timeout for creating text fragments
global for all ranges, instead of per range.
Differential Revision: https://phabricator.services.mozilla.com/D252945
Similarly to the last part, this commit attempts to clean up the FragmentDirective class and have it serve more as an Interface than the implementation.
The new class TextDirectiveFinder encapsules the find code. It is instantiated lazily using unique pointers and removed when all text directives are invoked.
Differential Revision: https://phabricator.services.mozilla.com/D225535
This commit moves all utility helper functions,
which used to be free functions in `FragmentDirective.cpp`,
into a class `TextDirectiveUtil` as static functions.
Also, the logging macro has been renamed and moved into the header,
to allow using it from several files.
Differential Revision: https://phabricator.services.mozilla.com/D225534
Similarly to the last part, this commit attempts to clean up the FragmentDirective class and have it serve more as an Interface than the implementation.
The new class TextDirectiveFinder encapsules the find code. It is instantiated lazily using unique pointers and removed when all text directives are invoked.
Differential Revision: https://phabricator.services.mozilla.com/D225535
This commit moves all utility helper functions,
which used to be free functions in `FragmentDirective.cpp`,
into a class `TextDirectiveUtil` as static functions.
Also, the logging macro has been renamed and moved into the header,
to allow using it from several files.
Differential Revision: https://phabricator.services.mozilla.com/D225534
Originally, the algorithm was designed to be capable of dealing with full URLs
and finding the fragment in it.
However, all usages of the parser use a `Ref` from an `nsIURI`,
so checking for full URLs is not necessary.
Simplifying this makes the algorithm easier to understand and makes it also parse edge cases like `#:~:text=#` correctly
(which is invalid wrt the URL spec, but should work regardless).
Differential Revision: https://phabricator.services.mozilla.com/D218051
User involvement as defined in the spec is not implemented in Gecko yet.
Therefore, the changes introduced in Bug 1888756 disallowed scrolling to text directives if the load was triggered by the user, eg. by pasting a link with a text fragment into the url bar.
This patch checks if the triggering principal of the load is the system principal.
This is equivalent to the "browser UI" value of user involvement.
Differential Revision: https://phabricator.services.mozilla.com/D214409