Bug 656373: Turn off Form Assistant zooming, panning and next/prev on tablets [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2011-05-17 11:55:05 +02:00
Родитель 686c7e5fe6
Коммит a3edc919fb
4 изменённых файлов: 42 добавлений и 14 удалений

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

@ -172,7 +172,8 @@ pref("signon.expireMasterPassword", false);
pref("signon.SignonFileName", "signons.txt");
/* form helper */
pref("formhelper.enabled", true);
// 0 = disabled, 1 = enabled, 2 = dynamic depending on screen size
pref("formhelper.mode", 2);
pref("formhelper.autozoom", true);
pref("formhelper.autozoom.caret", true);
pref("formhelper.restore", false);

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

@ -161,6 +161,13 @@ let Util = {
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
},
isTablet: function isTablet() {
// See the tablet_panel_minwidth from mobile/themes/core/defines.inc
let tablet_panel_minwidth = 124;
let dpmm = Util.getWindowUtils(window).displayDPI / 25.4;
return (window.innerWidth / dpmm <= tablet_panel_minwidth);
},
isPortrait: function isPortrait() {
#ifdef MOZ_PLATFORM_MAEMO
return (screen.width <= screen.height);

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

@ -675,6 +675,12 @@ var FormHelperUI = {
// Listen some events to show/hide arrows
Elements.browsers.addEventListener("PanBegin", this, false);
Elements.browsers.addEventListener("PanFinished", this, false);
// Dynamically enabled/disabled the form helper if needed depending on
// the size of the screen
let mode = Services.prefs.getIntPref("formhelper.mode");
let state = (mode == 2) ? !Util.isTablet() : !!mode;
Services.prefs.setBoolPref("formhelper.enabled", state);
},
_currentBrowser: null,
@ -792,22 +798,34 @@ var FormHelperUI = {
},
receiveMessage: function formHelperReceiveMessage(aMessage) {
if (!this._open && aMessage.name != "FormAssist:Show" && aMessage.name != "FormAssist:Hide")
let allowedMessages = ["FormAssist:Show", "FormAssist:Hide", "FormAssist:AutoComplete"];
if (!this._open && allowedMessages.indexOf(aMessage.name) == -1)
return;
let json = aMessage.json;
switch (aMessage.name) {
case "FormAssist:Show":
// if the user has manually disabled the Form Assistant UI we still
// want to show a UI for <select /> element but not managed by
// FormHelperUI
this.enabled ? this.show(json.current, json.hasPrevious, json.hasNext)
: SelectHelperUI.show(json.current.choices, json.current.title);
// want to show a UI for <select /> element and still want to show
// autocomplete suggestions but not managed by FormHelperUI
if (this.enabled) {
this.show(json.current, json.hasPrevious, json.hasNext)
} else if (json.current.choices) {
SelectHelperUI.show(json.current.choices, json.current.title);
} else {
this._currentElementRect = Rect.fromRect(json.current.rect);
this._currentBrowser = getBrowser();
this._updateSuggestionsFor(json.current);
}
break;
case "FormAssist:Hide":
this.enabled ? this.hide()
: SelectHelperUI.hide();
if (this.enabled) {
this.hide();
} else {
SelectHelperUI.hide();
ContentPopupHelper.popup = null;
}
break;
case "FormAssist:Resize":

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

@ -179,10 +179,12 @@ FormAssistant.prototype = {
return false;
}
// If form assistant is disabled but the element is a type of choice list
// we still want to show the simple select list
// There is some case where we still want some data to be send to the
// parent process even if form assistant is disabled:
// - the element is a choice list
// - the element has autocomplete suggestions
this._enabled = Services.prefs.getBoolPref("formhelper.enabled");
if (!this._enabled && !this._isSelectElement(aElement))
if (!this._enabled && !this._isSelectElement(aElement) && !this._isAutocomplete(aElement))
return this.close();
if (this._enabled) {
@ -210,7 +212,7 @@ FormAssistant.prototype = {
receiveMessage: function receiveMessage(aMessage) {
let currentElement = this.currentElement;
if ((!this._enabled && !getWrapperForElement(currentElement)) || !currentElement)
if ((!this._enabled && !this._isAutocomplete(currentElement) && !getWrapperForElement(currentElement)) || !currentElement)
return;
let json = aMessage.json;
@ -729,8 +731,8 @@ FormAssistant.prototype = {
maxLength: element.maxLength,
type: (element.getAttribute("type") || "").toLowerCase(),
choices: choices,
isAutocomplete: this._isAutocomplete(this.currentElement),
list: this._getListSuggestions(this.currentElement),
isAutocomplete: this._isAutocomplete(element),
list: this._getListSuggestions(element),
rect: this._getRect(),
caretRect: this._getCaretRect()
},