Bug 729373 - Move focus to chrome when overscrolling up with keyboard. r=cpeterson

This commit is contained in:
Eitan Isaacson 2012-03-07 19:24:38 -05:00
Родитель b40c86ca32
Коммит 56e683c816
2 изменённых файлов: 38 добавлений и 0 удалений

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

@ -973,6 +973,13 @@ abstract public class GeckoApp
mBrowserToolbar.show(); mBrowserToolbar.show();
} }
}); });
} else if (event.equals("ToggleChrome:Focus")) {
mMainHandler.post(new Runnable() {
public void run() {
mBrowserToolbar.setVisibility(View.VISIBLE);
mBrowserToolbar.requestFocusFromTouch();
}
});
} else if (event.equals("DOMFullScreen:Start")) { } else if (event.equals("DOMFullScreen:Start")) {
mDOMFullScreen = true; mDOMFullScreen = true;
} else if (event.equals("DOMFullScreen:Stop")) { } else if (event.equals("DOMFullScreen:Stop")) {
@ -1788,6 +1795,7 @@ abstract public class GeckoApp
GeckoAppShell.registerGeckoEventListener("DOMFullScreen:Stop", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("DOMFullScreen:Stop", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("ToggleChrome:Focus", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Permissions:Data", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Downloads:Done", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext); GeckoAppShell.registerGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);
@ -2160,6 +2168,7 @@ abstract public class GeckoApp
GeckoAppShell.unregisterGeckoEventListener("Toast:Show", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Focus", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Permissions:Data", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Downloads:Done", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext); GeckoAppShell.unregisterGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);

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

@ -1563,6 +1563,10 @@ Tab.prototype = {
}; };
sendMessageToJava(message); sendMessageToJava(message);
this.overscrollController = new OverscrollController(this);
this.browser.contentWindow.controllers
.insertControllerAt(0, this.overscrollController);
let flags = Ci.nsIWebProgress.NOTIFY_STATE_ALL | let flags = Ci.nsIWebProgress.NOTIFY_STATE_ALL |
Ci.nsIWebProgress.NOTIFY_LOCATION | Ci.nsIWebProgress.NOTIFY_LOCATION |
Ci.nsIWebProgress.NOTIFY_SECURITY; Ci.nsIWebProgress.NOTIFY_SECURITY;
@ -1611,6 +1615,9 @@ Tab.prototype = {
if (!this.browser) if (!this.browser)
return; return;
this.browser.controllers.contentWindow
.removeController(this.overscrollController);
this.browser.removeProgressListener(this); this.browser.removeProgressListener(this);
this.browser.removeEventListener("DOMContentLoaded", this, true); this.browser.removeEventListener("DOMContentLoaded", this, true);
this.browser.removeEventListener("DOMLinkAdded", this, true); this.browser.removeEventListener("DOMLinkAdded", this, true);
@ -4322,3 +4329,25 @@ var CharacterEncoding = {
} }
}; };
function OverscrollController(aTab) {
this.tab = aTab;
}
OverscrollController.prototype = {
supportsCommand : function supportsCommand(aCommand) {
if (aCommand != "cmd_linePrevious" && aCommand != "cmd_scrollPageUp")
return false;
return (this.tab.viewport.y == 0);
},
isCommandEnabled : function isCommandEnabled(aCommand) {
return this.supportsCommand(aCommand);
},
doCommand : function doCommand(aCommand){
sendMessageToJava({ gecko: { type: "ToggleChrome:Focus" } });
},
onEvent : function onEvent(aEvent) { }
};