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