mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 696319 - Scroll window as needed when soft keyboard is up [r=mfinkle]
This commit is contained in:
parent
8d499eecc0
commit
ee3e74b6ae
@ -295,6 +295,13 @@ class GeckoSurfaceView
|
||||
GeckoAppShell.scheduleRedraw();
|
||||
GeckoAppShell.geckoEventSync();
|
||||
}
|
||||
|
||||
// if the surface changed size and we have the soft keyboard up, make sure
|
||||
// the focused input field is still in view or it might get hidden behind the
|
||||
// keyboard and be really hard to use
|
||||
if (mIMEState == IME_STATE_ENABLED) {
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent("ScrollTo:FocusedInput", null));
|
||||
}
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
|
@ -131,6 +131,7 @@ var BrowserApp = {
|
||||
Services.obs.addObserver(this, "SaveAs:PDF", false);
|
||||
Services.obs.addObserver(this, "Preferences:Get", false);
|
||||
Services.obs.addObserver(this, "Preferences:Set", false);
|
||||
Services.obs.addObserver(this, "ScrollTo:FocusedInput", false);
|
||||
|
||||
Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
|
||||
Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
|
||||
@ -435,6 +436,15 @@ var BrowserApp = {
|
||||
}
|
||||
},
|
||||
|
||||
scrollToFocusedInput: function(aBrowser) {
|
||||
let doc = aBrowser.contentDocument;
|
||||
if (!doc)
|
||||
return;
|
||||
let focused = doc.activeElement;
|
||||
if ((focused instanceof HTMLInputElement && focused.mozIsTextField(false)) || (focused instanceof HTMLTextAreaElement))
|
||||
focused.scrollIntoView(false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
let browser = this.selectedBrowser;
|
||||
if (!browser)
|
||||
@ -461,6 +471,8 @@ var BrowserApp = {
|
||||
this.getPreferences(aData);
|
||||
} else if (aTopic == "Preferences:Set") {
|
||||
this.setPreferences(aData);
|
||||
} else if (aTopic == "ScrollTo:FocusedInput") {
|
||||
this.scrollToFocusedInput(browser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user