зеркало из https://github.com/mozilla/gecko-dev.git
Bug 854605 - (Part 2) Make private SelectionHandler functions look private. r=bnicholson
This commit is contained in:
Родитель
08fcf90495
Коммит
15936c0276
|
@ -92,20 +92,20 @@ var SelectionHandler = {
|
||||||
case "after-viewport-change": {
|
case "after-viewport-change": {
|
||||||
if (this._activeType == this.TYPE_SELECTION) {
|
if (this._activeType == this.TYPE_SELECTION) {
|
||||||
// Update the cache after the viewport changes (e.g. panning, zooming).
|
// Update the cache after the viewport changes (e.g. panning, zooming).
|
||||||
this.updateCacheForSelection();
|
this._updateCacheForSelection();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "TextSelection:Move": {
|
case "TextSelection:Move": {
|
||||||
let data = JSON.parse(aData);
|
let data = JSON.parse(aData);
|
||||||
if (this._activeType == this.TYPE_SELECTION)
|
if (this._activeType == this.TYPE_SELECTION)
|
||||||
this.moveSelection(data.handleType == this.HANDLE_TYPE_START, data.x, data.y);
|
this._moveSelection(data.handleType == this.HANDLE_TYPE_START, data.x, data.y);
|
||||||
else if (this._activeType == this.TYPE_CURSOR) {
|
else if (this._activeType == this.TYPE_CURSOR) {
|
||||||
// Send a click event to the text box, which positions the caret
|
// Send a click event to the text box, which positions the caret
|
||||||
this._sendMouseEvents(data.x, data.y);
|
this._sendMouseEvents(data.x, data.y);
|
||||||
|
|
||||||
// Move the handle directly under the caret
|
// Move the handle directly under the caret
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ var SelectionHandler = {
|
||||||
let data = JSON.parse(aData);
|
let data = JSON.parse(aData);
|
||||||
|
|
||||||
// Reverse the handles if necessary.
|
// Reverse the handles if necessary.
|
||||||
let selectionReversed = this.updateCacheForSelection(data.handleType == this.HANDLE_TYPE_START);
|
let selectionReversed = this._updateCacheForSelection(data.handleType == this.HANDLE_TYPE_START);
|
||||||
if (selectionReversed) {
|
if (selectionReversed) {
|
||||||
// Re-send mouse events to update the selection corresponding to the new handles.
|
// Re-send mouse events to update the selection corresponding to the new handles.
|
||||||
if (this._isRTL) {
|
if (this._isRTL) {
|
||||||
|
@ -127,9 +127,9 @@ var SelectionHandler = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position the handles to align with the edges of the selection.
|
// Position the handles to align with the edges of the selection.
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -198,14 +198,14 @@ var SelectionHandler = {
|
||||||
|
|
||||||
// Remove any previous selected or created ranges. Tapping anywhere on a
|
// Remove any previous selected or created ranges. Tapping anywhere on a
|
||||||
// page will create an empty range.
|
// page will create an empty range.
|
||||||
let selection = this.getSelection();
|
let selection = this._getSelection();
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
|
|
||||||
// Position the caret using a fake mouse click sent to the top-level window
|
// Position the caret using a fake mouse click sent to the top-level window
|
||||||
this._sendMouseEvents(aX, aY, false);
|
this._sendMouseEvents(aX, aY, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let selectionController = this.getSelectionController();
|
let selectionController = this._getSelectionController();
|
||||||
|
|
||||||
// Select the word nearest the caret
|
// Select the word nearest the caret
|
||||||
selectionController.wordMove(false, false);
|
selectionController.wordMove(false, false);
|
||||||
|
@ -230,10 +230,10 @@ var SelectionHandler = {
|
||||||
|
|
||||||
// Initialize the cache
|
// Initialize the cache
|
||||||
this._cache = { start: {}, end: {}};
|
this._cache = { start: {}, end: {}};
|
||||||
this.updateCacheForSelection();
|
this._updateCacheForSelection();
|
||||||
|
|
||||||
this._activeType = this.TYPE_SELECTION;
|
this._activeType = this.TYPE_SELECTION;
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
|
|
||||||
sendMessageToJava({
|
sendMessageToJava({
|
||||||
type: "TextSelection:ShowHandles",
|
type: "TextSelection:ShowHandles",
|
||||||
|
@ -244,7 +244,7 @@ var SelectionHandler = {
|
||||||
aElement.focus();
|
aElement.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelection: function sh_getSelection() {
|
_getSelection: function sh_getSelection() {
|
||||||
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
|
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
|
||||||
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selection;
|
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selection;
|
||||||
else
|
else
|
||||||
|
@ -252,13 +252,13 @@ var SelectionHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_getSelectedText: function sh_getSelectedText() {
|
_getSelectedText: function sh_getSelectedText() {
|
||||||
let selection = this.getSelection();
|
let selection = this._getSelection();
|
||||||
if (selection)
|
if (selection)
|
||||||
return selection.toString().trim();
|
return selection.toString().trim();
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectionController: function sh_getSelectionController() {
|
_getSelectionController: function sh_getSelectionController() {
|
||||||
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
|
if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
|
||||||
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;
|
return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;
|
||||||
else
|
else
|
||||||
|
@ -278,15 +278,15 @@ var SelectionHandler = {
|
||||||
if (this._activeType != this.TYPE_SELECTION)
|
if (this._activeType != this.TYPE_SELECTION)
|
||||||
this.startSelection(aElement, aX, aY);
|
this.startSelection(aElement, aX, aY);
|
||||||
|
|
||||||
let selectionController = this.getSelectionController();
|
let selectionController = this._getSelectionController();
|
||||||
selectionController.selectAll();
|
selectionController.selectAll();
|
||||||
this.updateCacheForSelection();
|
this._updateCacheForSelection();
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Moves the ends of the selection in the page. aX/aY are in top-level window
|
// Moves the ends of the selection in the page. aX/aY are in top-level window
|
||||||
// browser coordinates.
|
// browser coordinates.
|
||||||
moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) {
|
_moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) {
|
||||||
// Update the handle position as it's dragged.
|
// Update the handle position as it's dragged.
|
||||||
if (aIsStartHandle) {
|
if (aIsStartHandle) {
|
||||||
this._cache.start.x = aX;
|
this._cache.start.x = aX;
|
||||||
|
@ -338,19 +338,19 @@ var SelectionHandler = {
|
||||||
// field's text (and clicking the bottom moves the cursor to the end).
|
// field's text (and clicking the bottom moves the cursor to the end).
|
||||||
if (aY < rect.y + 1) {
|
if (aY < rect.y + 1) {
|
||||||
aY = rect.y + 1;
|
aY = rect.y + 1;
|
||||||
this.getSelectionController().scrollLine(false);
|
this._getSelectionController().scrollLine(false);
|
||||||
} else if (aY > rect.y + rect.height - 1) {
|
} else if (aY > rect.y + rect.height - 1) {
|
||||||
aY = rect.y + rect.height - 1;
|
aY = rect.y + rect.height - 1;
|
||||||
this.getSelectionController().scrollLine(true);
|
this._getSelectionController().scrollLine(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp horizontally and scroll if handle is at bounds
|
// Clamp horizontally and scroll if handle is at bounds
|
||||||
if (aX < rect.x) {
|
if (aX < rect.x) {
|
||||||
aX = rect.x;
|
aX = rect.x;
|
||||||
this.getSelectionController().scrollCharacter(false);
|
this._getSelectionController().scrollCharacter(false);
|
||||||
} else if (aX > rect.x + rect.width) {
|
} else if (aX > rect.x + rect.width) {
|
||||||
aX = rect.x + rect.width;
|
aX = rect.x + rect.width;
|
||||||
this.getSelectionController().scrollCharacter(true);
|
this._getSelectionController().scrollCharacter(true);
|
||||||
}
|
}
|
||||||
} else if (this._activeType == this.TYPE_SELECTION) {
|
} else if (this._activeType == this.TYPE_SELECTION) {
|
||||||
// Send mouse event 1px too high to prevent selection from entering the line below where it should be
|
// Send mouse event 1px too high to prevent selection from entering the line below where it should be
|
||||||
|
@ -391,7 +391,7 @@ var SelectionHandler = {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this._activeType == this.TYPE_SELECTION) {
|
if (this._activeType == this.TYPE_SELECTION) {
|
||||||
let selection = this.getSelection();
|
let selection = this._getSelection();
|
||||||
if (selection) {
|
if (selection) {
|
||||||
// Remove the listener before calling removeAllRanges() to avoid
|
// Remove the listener before calling removeAllRanges() to avoid
|
||||||
// recursively notifying the listener.
|
// recursively notifying the listener.
|
||||||
|
@ -432,7 +432,7 @@ var SelectionHandler = {
|
||||||
|
|
||||||
_pointInSelection: function sh_pointInSelection(aX, aY) {
|
_pointInSelection: function sh_pointInSelection(aX, aY) {
|
||||||
let offset = this._getViewOffset();
|
let offset = this._getViewOffset();
|
||||||
let rangeRect = this.getSelection().getRangeAt(0).getBoundingClientRect();
|
let rangeRect = this._getSelection().getRangeAt(0).getBoundingClientRect();
|
||||||
let radius = ElementTouchHelper.getTouchRadius();
|
let radius = ElementTouchHelper.getTouchRadius();
|
||||||
return (aX - offset.x > rangeRect.left - radius.left &&
|
return (aX - offset.x > rangeRect.left - radius.left &&
|
||||||
aX - offset.x < rangeRect.right + radius.right &&
|
aX - offset.x < rangeRect.right + radius.right &&
|
||||||
|
@ -442,8 +442,8 @@ var SelectionHandler = {
|
||||||
|
|
||||||
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
|
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
|
||||||
// param to decide whether the selection has been reversed.
|
// param to decide whether the selection has been reversed.
|
||||||
updateCacheForSelection: function sh_updateCacheForSelection(aIsStartHandle) {
|
_updateCacheForSelection: function sh_updateCacheForSelection(aIsStartHandle) {
|
||||||
let selection = this.getSelection();
|
let selection = this._getSelection();
|
||||||
let rects = selection.getRangeAt(0).getClientRects();
|
let rects = selection.getRangeAt(0).getClientRects();
|
||||||
let start = { x: this._isRTL ? rects[0].right : rects[0].left, y: rects[0].bottom };
|
let start = { x: this._isRTL ? rects[0].right : rects[0].left, y: rects[0].bottom };
|
||||||
let end = { x: this._isRTL ? rects[rects.length - 1].left : rects[rects.length - 1].right, y: rects[rects.length - 1].bottom };
|
let end = { x: this._isRTL ? rects[rects.length - 1].left : rects[rects.length - 1].right, y: rects[rects.length - 1].bottom };
|
||||||
|
@ -475,7 +475,7 @@ var SelectionHandler = {
|
||||||
this._contentWindow.addEventListener("blur", this, true);
|
this._contentWindow.addEventListener("blur", this, true);
|
||||||
|
|
||||||
this._activeType = this.TYPE_CURSOR;
|
this._activeType = this.TYPE_CURSOR;
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
|
|
||||||
sendMessageToJava({
|
sendMessageToJava({
|
||||||
type: "TextSelection:ShowHandles",
|
type: "TextSelection:ShowHandles",
|
||||||
|
@ -483,7 +483,7 @@ var SelectionHandler = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
positionHandles: function sh_positionHandles() {
|
_positionHandles: function sh_positionHandles() {
|
||||||
let scrollX = {}, scrollY = {};
|
let scrollX = {}, scrollY = {};
|
||||||
this._contentWindow.top.QueryInterface(Ci.nsIInterfaceRequestor).
|
this._contentWindow.top.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||||
getInterface(Ci.nsIDOMWindowUtils).getScrollXY(false, scrollX, scrollY);
|
getInterface(Ci.nsIDOMWindowUtils).getScrollXY(false, scrollX, scrollY);
|
||||||
|
@ -551,9 +551,9 @@ var SelectionHandler = {
|
||||||
// The selection is in a view (or sub-view) of the view that scrolled.
|
// The selection is in a view (or sub-view) of the view that scrolled.
|
||||||
// So we need to reposition the handles.
|
// So we need to reposition the handles.
|
||||||
if (this._activeType == this.TYPE_SELECTION) {
|
if (this._activeType == this.TYPE_SELECTION) {
|
||||||
this.updateCacheForSelection();
|
this._updateCacheForSelection();
|
||||||
}
|
}
|
||||||
this.positionHandles();
|
this._positionHandles();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (view == view.parent) {
|
if (view == view.parent) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче