Bug 1011059 - Use editor rather than selection controller to select all; r=margaret

This commit is contained in:
Jim Chen 2014-06-16 11:54:57 -04:00
parent 418c4d6dfa
commit c8b355cd23

View File

@ -401,7 +401,12 @@ var SelectionHandler = {
}
// Else default to selectALL Document
this._getSelectionController().selectAll();
let editor = this._getEditor();
if (editor) {
editor.selectAll();
} else {
this._getSelectionController().selectAll();
}
// Selection is entire HTMLHtmlElement, remove any trailing document whitespace
let selection = this._getSelection();
@ -712,6 +717,17 @@ var SelectionHandler = {
return selection.toString().trim();
},
_getEditor: function sh_getEditor() {
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement) {
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor;
}
return this._contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession)
.getEditorForWindow(this._contentWindow);
},
_getSelectionController: function sh_getSelectionController() {
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;