Bug 840270 - Don't show a popup for select[multiple] with precise pointer input [r=jimm]

This commit is contained in:
Matt Brubeck 2013-02-17 10:01:33 -08:00
Родитель 83a7dcbda5
Коммит aa015e5e97
4 изменённых файлов: 25 добавлений и 12 удалений

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

@ -437,7 +437,7 @@ let Content = {
// target element doesn't match the current focus element, clear
// focus. This allows users to remove focus from form elements by
// taping on white space content.
if (!this.formAssistant.open(element, aEvent.clientX, aEvent.clientY)) {
if (!this.formAssistant.open(element, aEvent)) {
if (gFocusManager.focusedElement &&
gFocusManager.focusedElement != element) {
gFocusManager.focusedElement.blur();
@ -447,11 +447,6 @@ let Content = {
sendAsyncMessage("FindAssist:Hide", { });
}
// Fire mouse events on everything but selects, see bug 685197
if (element instanceof HTMLSelectElement) {
aEvent.preventDefault()
aEvent.stopPropagation()
}
this._cancelTapHighlight();
this.formAssistant.focusSync = false;
},

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

@ -104,7 +104,7 @@ FormAssistant.prototype = {
},
_open: false,
open: function formHelperOpen(aElement, aX, aY) {
open: function formHelperOpen(aElement, aEvent) {
// If the click is on an option element we want to check if the parent
// is a valid target.
if (aElement instanceof HTMLOptionElement &&
@ -113,6 +113,17 @@ FormAssistant.prototype = {
aElement = aElement.parentNode;
}
if (aElement instanceof HTMLSelectElement && aEvent) {
// Don't show the formhelper popup for multi-select boxes, except for touch.
if ((aElement.multiple || aElement.size > 1) &&
aEvent.mozInputSource != Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
return false;
}
// Don't fire mouse events on selects; see bug 685197.
aEvent.preventDefault()
aEvent.stopPropagation()
}
// The form assistant will close if a click happen:
// * outside of the scope of the form helper
// * hover a button of type=[image|submit]
@ -125,8 +136,8 @@ FormAssistant.prototype = {
// Check for plugins element
if (aElement instanceof Ci.nsIDOMHTMLEmbedElement) {
aX = aX || 0;
aY = aY || 0;
let x = (aEvent && aEvent.clientX) || 0;
let y = (aEvent && aEvent.clientY) || 0;
this._executeDelayed(function(self) {
let utils = Util.getWindowUtils(aElement.ownerDocument.defaultView);
if (utils.IMEStatus == utils.IME_STATUS_PLUGIN) {
@ -143,7 +154,7 @@ FormAssistant.prototype = {
validationMessage: null,
list: null,
rect: getBoundingContentRect(aElement),
caretRect: new Rect(aX, aY, 1, 10),
caretRect: new Rect(x, y, 1, 10),
editable: true
},
hasPrevious: false,

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

@ -12,3 +12,8 @@ xul|*:-moz-system-metric(touch-enabled) {
html|*:-moz-system-metric(touch-enabled) {
cursor: none !important;
}
/* For touch input, *all* select boxes use the SelectHelper popup. */
select option, select optgroup {
pointer-events: none;
}

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

@ -123,8 +123,10 @@ select[size][multiple],
/*background: white -moz-linear-gradient(top, rgba(115,115,115,0.5) 0, rgba(215,215,215,0.5) 3px, rgba(255,255,255,0.2) 16px);*/
}
/* Selects are handled by the form helper, see bug 685197 */
select option, select optgroup {
/* For both mouse and touch, single-selects are handled by the SelectHelper popup.
* Suppress mouse events on the popup itself. See also ../base/content/cursor.css */
select[size=1] :-moz-any(option, optgroup),
select:not([size]):not([multiple]) :-moz-any(option, optgroup) {
pointer-events: none;
}