Bug 1118136 - Check if targets match before forcing dispatch selection state changed event. r=roc

This commit is contained in:
Morris Tseng 2015-01-06 22:23:00 +01:00
Родитель 411a94b05a
Коммит ff2c0dc262
1 изменённых файлов: 9 добавлений и 8 удалений

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

@ -94,7 +94,7 @@ function BrowserElementChild() {
this._isContentWindowCreated = false;
this._pendingSetInputMethodActive = [];
this._forceDispatchSelectionStateChanged = false;
this._selectionStateChangedTarget = null;
this._init();
};
@ -600,7 +600,7 @@ BrowserElementChild.prototype = {
let isMouseUp = (e.states.indexOf('mouseup') == 0);
let canPaste = this._isCommandEnabled("paste");
if (!this._forceDispatchSelectionStateChanged) {
if (this._selectionStateChangedTarget != e.target) {
// SelectionStateChanged events with the following states are not
// necessary to trigger the text dialog, bypass these events
// by default.
@ -624,14 +624,15 @@ BrowserElementChild.prototype = {
}
}
// If we select something and selection range is visible, we set the
// forceDispatchSelectionStateChanged flag as true to dispatch the
// next SelectionStateChange event so that the parent side can
// hide the text dialog.
// If we select something and selection range is visible, we cache current
// event's target to selectionStateChangedTarget.
// And dispatch the next SelectionStateChagne event if target is matched, so
// that the parent side can hide the text dialog.
// We clear selectionStateChangedTarget if selection carets are invisible.
if (e.visible && !isCollapsed) {
this._forceDispatchSelectionStateChanged = true;
this._selectionStateChangedTarget = e.target;
} else {
this._forceDispatchSelectionStateChanged = false;
this._selectionStateChangedTarget = null;
}
let zoomFactor = content.screen.width / content.innerWidth;