зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475325 - Hide selection action in some scenarios; r=droeh
Hide the selection action toolbar when the session is unfocused, or when changing the selection action delegate. Differential Revision: https://phabricator.services.mozilla.com/D5807 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8e04fc97a0
Коммит
f5ce114ffa
|
@ -101,12 +101,14 @@ class GeckoViewSelectionActionContent extends GeckoViewContentModule {
|
|||
debug `onEnable`;
|
||||
addEventListener("mozcaretstatechanged", this, { mozSystemGroup: true });
|
||||
addEventListener("pagehide", this, { capture: true, mozSystemGroup: true });
|
||||
addEventListener("deactivate", this, { mozSystemGroup: true });
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
debug `onDisable`;
|
||||
removeEventListener("mozcaretstatechanged", this, { mozSystemGroup: true });
|
||||
removeEventListener("pagehide", this, { capture: true, mozSystemGroup: true });
|
||||
removeEventListener("deactivate", this, { mozSystemGroup: true });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +116,8 @@ class GeckoViewSelectionActionContent extends GeckoViewContentModule {
|
|||
* (mozcaretstatechanged and pagehide) events.
|
||||
*/
|
||||
handleEvent(aEvent) {
|
||||
if (aEvent.type === "pagehide") {
|
||||
// Hide any selection actions on page hide.
|
||||
if (aEvent.type === "pagehide" || aEvent.type === "deactivate") {
|
||||
// Hide any selection actions on page hide or deactivate.
|
||||
aEvent = {
|
||||
reason: "visibilitychange",
|
||||
caretVisibile: false,
|
||||
|
|
|
@ -1615,6 +1615,13 @@ public final class GeckoSession extends LayerSession
|
|||
* @param delegate SelectionActionDelegate instance or null to unset.
|
||||
*/
|
||||
public void setSelectionActionDelegate(@Nullable SelectionActionDelegate delegate) {
|
||||
if (getSelectionActionDelegate() != null) {
|
||||
// When the delegate is changed or cleared, make sure onHideAction is called
|
||||
// one last time to hide any existing selection action UI. Gecko doesn't keep
|
||||
// track of the old delegate, so we can't rely on Gecko to do that for us.
|
||||
getSelectionActionDelegate().onHideAction(
|
||||
this, GeckoSession.SelectionActionDelegate.HIDE_REASON_NO_SELECTION);
|
||||
}
|
||||
mSelectionActionDelegate.setDelegate(delegate, this);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче