Bug 1396951 - 3. Move GeckoAppShell.viewSizeChanged() to GeckoLayerClient; r=rbarker

Let `GeckoLayerClient` directly deal with scroll-to-input on resize,
instead of going through `GeckoAppShell` and relying on
`getLayerView()`. This is a necessary fix to let us remove
`getLayerView()`, and in a follow-up bug we should actually fix
scroll-to-input to work on any GeckoView.

MozReview-Commit-ID: 1xsHh2vg08M

--HG--
extra : rebase_source : 3061623d3ed0309fff42c6dc66d0246e1d3000a3
This commit is contained in:
Jim Chen 2017-09-22 14:35:23 -04:00
Родитель d4b6b64543
Коммит a6188cfc76
4 изменённых файлов: 15 добавлений и 18 удалений

Просмотреть файл

@ -1584,21 +1584,6 @@ public class GeckoAppShell
return HardwareUtils.isTablet();
}
private static boolean sImeWasEnabledOnLastResize = false;
public static void viewSizeChanged() {
GeckoView v = (GeckoView) getLayerView();
if (v == null) {
return;
}
boolean imeIsEnabled = v.isIMEEnabled();
if (imeIsEnabled && !sImeWasEnabledOnLastResize) {
// The IME just came up after not being up, so let's scroll
// to the focused input.
EventDispatcher.getInstance().dispatch("ScrollTo:FocusedInput", null);
}
sImeWasEnabledOnLastResize = imeIsEnabled;
}
@WrapForJNI(calledFrom = "gecko")
private static double[] getCurrentNetworkInformation() {
return GeckoNetworkManager.getInstance().getCurrentInformation();

Просмотреть файл

@ -751,7 +751,8 @@ public class GeckoView extends LayerView {
mInputConnectionListener.onKeyMultiple(keyCode, repeatCount, event);
}
/* package */ boolean isIMEEnabled() {
@Override
public boolean isIMEEnabled() {
return mInputConnectionListener != null &&
mInputConnectionListener.isIMEEnabled();
}

Просмотреть файл

@ -33,6 +33,7 @@ class GeckoLayerClient implements LayerView.Listener
private IntSize mWindowSize;
private boolean mForceRedraw;
private boolean mImeWasEnabledOnLastResize;
/* The current viewport metrics.
* This is volatile so that we can read and write to it from different threads.
@ -153,7 +154,13 @@ class GeckoLayerClient implements LayerView.Listener
// the following call also sends gecko a message, which will be processed after the resize
// message above has updated the viewport. this message ensures that if we have just put
// focus in a text field, we scroll the content so that the text field is in view.
GeckoAppShell.viewSizeChanged();
final boolean imeIsEnabled = mView.isIMEEnabled();
if (imeIsEnabled && !mImeWasEnabledOnLastResize) {
// The IME just came up after not being up, so let's scroll
// to the focused input.
EventDispatcher.getInstance().dispatch("ScrollTo:FocusedInput", null);
}
mImeWasEnabledOnLastResize = imeIsEnabled;
}
return true;
}

Просмотреть файл

@ -824,5 +824,9 @@ public class LayerView extends FrameLayout {
if (isCompositorReady()) {
mCompositor.setDefaultClearColor(mDefaultClearColor);
}
}
}
public boolean isIMEEnabled() {
return false;
}
}