Bug 696319 - Scroll window as needed when soft keyboard is up [r=mfinkle]

Send an event to scroll to the focused input field when the
soft keyboard comes up. Ensure that this happens *after* the
viewport change event is sent to Gecko, so that Gecko actually
knows that browser viewport is smaller and doesn't just no-op
the scroll request.
This commit is contained in:
Kartikaya Gupta 2011-12-03 22:59:27 -05:00
parent e5c4a68d11
commit ca310383d4
7 changed files with 29 additions and 1 deletions

View File

@ -1572,4 +1572,10 @@ public class GeckoAppShell
accessibilityManager.sendAccessibilityEvent(event);
}
public static void viewSizeChanged() {
if (mInputConnection != null && mInputConnection.isIMEEnabled()) {
sendEventToGecko(new GeckoEvent("ScrollTo:FocusedInput", ""));
}
}
}

View File

@ -911,6 +911,10 @@ public class GeckoInputConnection
return false;
}
public boolean isIMEEnabled() {
// make sure this picks up PASSWORD and PLUGIN states as well
return mIMEState != IME_STATE_DISABLED;
}
public void notifyIME(int type, int state) {

View File

@ -85,6 +85,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
private static final long MIN_VIEWPORT_CHANGE_DELAY = 350L;
private long mLastViewportChangeTime;
private boolean mPendingViewportAdjust;
private boolean mViewportSizeChanged;
public GeckoSoftwareLayerClient(Context context) {
mContext = context;
@ -227,6 +228,11 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
render();
}
@Override
public void viewportSizeChanged() {
mViewportSizeChanged = true;
}
@Override
public void render() {
adjustViewportWithThrottling();
@ -266,6 +272,10 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
GeckoEvent event = new GeckoEvent("Viewport:Change", viewportMetrics.toJSON());
GeckoAppShell.sendEventToGecko(event);
if (mViewportSizeChanged) {
mViewportSizeChanged = false;
GeckoAppShell.viewSizeChanged();
}
mLastViewportChangeTime = System.currentTimeMillis();
}

View File

@ -44,6 +44,7 @@ public abstract class LayerClient {
private LayerController mLayerController;
public abstract void geometryChanged();
public abstract void viewportSizeChanged();
protected abstract void render();
public LayerController getLayerController() { return mLayerController; }

View File

@ -162,6 +162,9 @@ public class LayerController {
mViewportMetrics.setSize(size);
setForceRedraw();
if (mLayerClient != null)
mLayerClient.viewportSizeChanged();
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged(false);
mView.requestRender();

View File

@ -142,6 +142,8 @@ public class PlaceholderLayerClient extends LayerClient {
@Override
public void geometryChanged() { /* no-op */ }
@Override
public void viewportSizeChanged() { /* no-op */ }
@Override
public void render() { /* no-op */ }
@Override

View File

@ -518,8 +518,10 @@ var BrowserApp = {
if (!doc)
return;
let focused = doc.activeElement;
if ((focused instanceof HTMLInputElement && focused.mozIsTextField(false)) || (focused instanceof HTMLTextAreaElement))
if ((focused instanceof HTMLInputElement && focused.mozIsTextField(false)) || (focused instanceof HTMLTextAreaElement)) {
focused.scrollIntoView(false);
BrowserApp.getTabForBrowser(aBrowser).sendViewportUpdate();
}
},
getDrawMetadata: function getDrawMetadata() {