Closed Bug 1570810 Opened 1 year ago Closed 4 months ago

Add GeckoView API to clear the text selection

Categories

(GeckoView :: General, enhancement)

Unspecified
All
enhancement
Not set

Tracking

(firefox69 wontfix, firefox70 fix-optional)

RESOLVED WONTFIX
Tracking Status
firefox69 --- wontfix
firefox70 --- fix-optional

People

(Reporter: rbarker, Assigned: estirling)

References

Details

(Whiteboard: [geckoview:m1909])

Currently there is no way to clear a selection from GeckoView. I believe this functionality is required to to support proper back button functionality in embedding application.s

related to bug 1570167

Priority: -- → P3
See Also: → 1570167
Summary: Add GeckoView API to clear the selection. → Add GeckoView API to clear the text selection.

Fenix will need this new API to fix a bug where the back button navigates to the previous page instead of clearing the current text selection:

https://github.com/mozilla-mobile/fenix/issues/2020.

The Fenix team considers this bug a P2 because, without this API, Fenix's back button will annoy users by navigating back a page instead of clearing the text selection like Fennec and Chrome do:

https://github.com/mozilla-mobile/fenix/issues/2020#issuecomment-520454212

Priority: P3 → P2

To be clear, they do not need this to fix the described behavior. Fenix needs to know when the CCP menu is visible and hide it when the back button is pressed. This is something the app needs to do, not GeckoView. GeckoView needs the clear selection API so that the app can clear the selection when it hides the CCP menu. But this feature is not blocking them.

Whiteboard: [geckoview:fenix:m9]

Adding this bug to GV's September sprint.

Priority: P2 → P1
Summary: Add GeckoView API to clear the text selection. → Add GeckoView API to clear the text selection
Whiteboard: [geckoview:fenix:m9] → [geckoview:m1909]
Assignee: nobody → estirling

This can be done with no additional API changes.
A SelectionActionDelegate can know if the CCP menu is visible.
As an example clearSelection in BasicSelectionActionDelegate closes the CCP menu and clears selected text. The menu was visible if mResponse is non-null at that time.

Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → WONTFIX

The current API is quite hard for us to actually use. Maybe we could make it nicer as part of this bug?

In our case we do not want to change any of the implementation and reuse BasicSelectionActionDelegate. We need to know if a text selection toolbar is showing (internally mResponse != null) and have a way to clear it (clearSelection()).

  • (1) One option would be to create those methods or make them accessible so that we can call them by going through GeckoSession and the delegate. Currently clearSelection() is protected and mResponse is not visible.

  • (2) As another option we could create our own SelectionActionDelegate implementation that delegates to a BasicSelectionActionDelegate object (which basically means implementing option 1 ourselves). But that is quite hard: BasicSelectionActionDelegate needs an Activity that doesn't always exist since it has a different lifecycle. Internally GeckoView seems to do some dance to set and clear the delegate depending on whether a session is rendered or released. Replicating this seems quite complicated and error-prone.

Sending this bug back to GV triage for discussion of Sebastian's suggestions. ^

Status: RESOLVED → REOPENED
Priority: P1 → --
Resolution: WONTFIX → ---

Closing again because Elliot says SelectionActionDelegate bug 1581161 will cover Sebastian's suggestions (comment 7).

Depends on: 1581161

Closing again because Elliot says SelectionActionDelegate bug 1581161 will cover Sebastian's suggestions (comment 7).

Status: REOPENED → RESOLVED
Closed: 5 months ago4 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.