Commit 8f3214f0 authored by Jamie Nicol's avatar Jamie Nicol
Browse files

Bug 1783542 - Disable SurfaceControl only when magnifier is active. r=geckoview-reviewers,owlish

Rather than when a selection is active. Originally we chose to disable
SurfaceControl whenever a selection was active, as it is then likely
the magnifiers may be shown soon, but it reduced the amount of times
we switch between SurfaceControl being enabled and disabled when the
selection is frequently modified.

However, that has 2 issues: First, the magnifier can be shown when
dragging a single caret in a form, rather than just when a selection
is active. With the original fix, the magnifier did not work in this
case. And second, we encountered a bug when the widget is resized at
the same time as SurfaceControl is toggled, where we end up rendering
the page at the wrong size.

This patch therefore makes us only disable SurfaceControl when the
magnifier is actually being shown. This may cause us to enable or
disable it more frequently, but that doesn't appear to be a big deal.

Differential Revision: https://phabricator.services.mozilla.com/D154086
parent a97d8ed5
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -910,10 +910,6 @@ public class GeckoSession {

            delegate.onShowActionRequest(GeckoSession.this, selection);

            // We have a selection, meaning we may need to show the magnifier soon. The magnifier
            // does not work when using the SurfaceControl rendering path, so temporarily block it.
            mCompositor.blockSurfaceControl();

          } else if ("GeckoView:HideSelectionAction".equals(event)) {
            final String reasonString = message.getString("reason");
            final int reason;
@@ -925,14 +921,16 @@ public class GeckoSession {
              reason = SelectionActionDelegate.HIDE_REASON_ACTIVE_SCROLL;
            } else if ("visibilitychange".equals(reasonString)) {
              reason = SelectionActionDelegate.HIDE_REASON_NO_SELECTION;
              // The selection has been dismissed, meaning we can allow SurfaceControl again.
              mCompositor.allowSurfaceControl();
            } else {
              throw new IllegalArgumentException();
            }

            delegate.onHideAction(GeckoSession.this, reason);
          } else if ("GeckoView:ShowMagnifier".equals(event)) {
            // The magnifier does not work when using the SurfaceControl rendering path, so
            // temporarily block it.
            mCompositor.blockSurfaceControl();

            final GeckoBundle ptBundle = message.getBundle("clientPoint");
            if (ptBundle == null) {
              throw new IllegalArgumentException("Invalid argument");
@@ -946,6 +944,8 @@ public class GeckoSession {

            GeckoSession.this.getMagnifier().show(new PointF(origin[0], origin[1]));
          } else if ("GeckoView:HideMagnifier".equals(event)) {
            // The magnifier has been hidden, meaning we can re-enable SurfaceControl.
            mCompositor.allowSurfaceControl();
            GeckoSession.this.getMagnifier().dismiss();
          }
        }