Bug 907271 - Fix startSelection() processing re: new text SelectionListener(), r=margaret

This commit is contained in:
Mark Capella 2013-08-28 20:44:03 -04:00
parent ce7b214309
commit 3d2add4681

View File

@ -78,7 +78,7 @@ var SelectionHandler = {
} else if (this._activeType == this.TYPE_CURSOR) {
// attachCaret() is called in the "Gesture:SingleTap" handler in BrowserEventHandler
// We're guaranteed to call this first, because this observer was added last
this._closeSelection();
this._deactivate();
}
break;
}
@ -159,7 +159,7 @@ var SelectionHandler = {
case "compositionend":
if (this._activeType == this.TYPE_CURSOR) {
this._closeSelection();
this._deactivate();
}
break;
}
@ -216,25 +216,25 @@ var SelectionHandler = {
this._closeSelection();
this._initTargetInfo(aElement);
this._activeType = this.TYPE_SELECTION;
// Clear any existing selection from the document
this._contentWindow.getSelection().removeAllRanges();
if (!this._domWinUtils.selectAtPoint(aX, aY, Ci.nsIDOMWindowUtils.SELECT_WORDNOSPACE)) {
this._closeSelection();
this._deactivate();
return;
}
let selection = this._getSelection();
// If the range didn't have any text, let's bail
if (!selection || selection.rangeCount == 0) {
this._closeSelection();
this._deactivate();
return;
}
// Add a listener to end the selection if it's removed programatically
selection.QueryInterface(Ci.nsISelectionPrivate).addSelectionListener(this);
this._activeType = this.TYPE_SELECTION;
// Initialize the cache
this._cache = { start: {}, end: {}};
@ -498,16 +498,23 @@ var SelectionHandler = {
if (this._activeType == this.TYPE_NONE)
return;
if (this._activeType == this.TYPE_SELECTION) {
let selection = this._getSelection();
if (selection) {
// Remove our listener before we clear the selection
selection.QueryInterface(Ci.nsISelectionPrivate).removeSelectionListener(this);
// Clear selection without clearing the anchorNode or focusNode
selection.collapseToStart();
}
}
if (this._activeType == this.TYPE_SELECTION)
this._clearSelection();
this._deactivate();
},
_clearSelection: function sh_clearSelection() {
let selection = this._getSelection();
if (selection) {
// Remove our listener before we clear the selection
selection.QueryInterface(Ci.nsISelectionPrivate).removeSelectionListener(this);
// Clear selection without clearing the anchorNode or focusNode
selection.collapseToStart();
}
},
_deactivate: function sh_deactivate() {
this._activeType = this.TYPE_NONE;
sendMessageToJava({ type: "TextSelection:HideHandles" });