Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[embedlite-components] Add support for select all in text selection. …
…Contributes to JB#48016
  • Loading branch information
denexter committed Feb 27, 2020
1 parent fb6497d commit 3b82171
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jsscripts/SelectionHandler.js
Expand Up @@ -19,6 +19,7 @@ function SelectionHandler() {
addMessageListener("Browser:SelectionMoveStart", this);
addMessageListener("Browser:SelectionMove", this);
addMessageListener("Browser:SelectionMoveEnd", this);
addMessageListener("Browser:SelectionSelectAll", this);
addMessageListener("Browser:SelectionUpdate", this);
addMessageListener("Browser:SelectionClose", this);
addMessageListener("Browser:SelectionCopy", this);
Expand All @@ -42,6 +43,7 @@ function SelectionHandler() {
removeMessageListener("Browser:SelectionMoveStart", this);
removeMessageListener("Browser:SelectionMove", this);
removeMessageListener("Browser:SelectionMoveEnd", this);
removeMessageListener("Browser:SelectionSelectAll", this);
removeMessageListener("Browser:SelectionUpdate", this);
removeMessageListener("Browser:SelectionClose", this);
removeMessageListener("Browser:SelectionCopy", this);
Expand Down Expand Up @@ -186,6 +188,25 @@ function SelectionHandler() {
// Update the position of our selection monocles
this._updateSelectionUI("update", true, true);
}

/*
* Selection monocle start move event handler
*/
this._onSelectionSelectAll = function _onSelectionSelectAll(aMsg) {
if (!this._contentWindow) {
this._onFail("_onSelectionSelectAll was called without proper view set up");
return;
}

if (this._targetElement instanceof Ci.nsIDOMNSEditableElement) {
this._targetElement.select()
} else if (this._contentWindow) {
this._contentWindow.getSelection().selectAllChildren(this._contentWindow.document.body);
}

// Update the position of our selection monocles
this._updateSelectionUI("end", true, true);
}

/*
* Selection monocle move event handler
Expand Down Expand Up @@ -546,6 +567,10 @@ function SelectionHandler() {
this._onSelectionMoveEnd(json);
break;

case "Browser:SelectionSelectAll":
this._onSelectionSelectAll(json);
break;

case "Browser:SelectionCopy":
this._onSelectionCopy(json);
break;
Expand Down

0 comments on commit 3b82171

Please sign in to comment.