Bug 1106800 - Rename Selection Cache Handle Names, r=margaret
authorMark Capella <markcapella@twcny.rr.com>
Tue, 30 Dec 2014 16:42:17 -0500
changeset 247554 5f6fb643ebee868ee6dc2f81800958f373bde94c
parent 247553 120ddf617de1a21c604b1f82474732751a91d359
child 247555 edccc126caae2f70cfd6b3ed8487d90383908ec0
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1106800
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1106800 - Rename Selection Cache Handle Names, r=margaret
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -322,17 +322,17 @@ var SelectionHandler = {
       return false;
     }
 
     // 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: {}};
+    this._cache = { anchorPt: {}, focusPt: {}};
     this._updateCacheForSelection();
 
     let scroll = this._getScrollPos();
     // Figure out the distance between the selection and the click
     let positions = this._getHandlePositions(scroll);
 
     if (aOptions.mode == this.SELECT_AT_POINT && !this._selectionNearClick(scroll.X + aOptions.x,
                                                                       scroll.Y + aOptions.y,
@@ -846,40 +846,40 @@ var SelectionHandler = {
     // Constrain text selection within editable elements.
     let targetIsEditable = this._targetElement instanceof Ci.nsIDOMNSEditableElement;
     if (targetIsEditable && (caretPos.offsetNode != this._targetElement)) {
       return;
     }
 
     // Update the cache as the handle is dragged (keep the cache in client coordinates).
     if (aIsStartHandle) {
-      this._cache.start.x = aX;
-      this._cache.start.y = aY;
+      this._cache.anchorPt.x = aX;
+      this._cache.anchorPt.y = aY;
     } else {
-      this._cache.end.x = aX;
-      this._cache.end.y = aY;
+      this._cache.focusPt.x = aX;
+      this._cache.focusPt.y = aY;
     }
 
     let selection = this._getSelection();
 
     // The handles work the same on both LTR and RTL pages, but the anchor/focus nodes
     // are reversed, so we need to reverse the logic to extend the selection.
     if ((aIsStartHandle && !this._isRTL) || (!aIsStartHandle && this._isRTL)) {
       if (targetIsEditable) {
-        let anchorX = this._isRTL ? this._cache.start.x : this._cache.end.x;
+        let anchorX = this._isRTL ? this._cache.anchorPt.x : this._cache.focusPt.x;
         this._moveSelectionInEditable(anchorX, aX, caretPos);
       } else {
         let focusNode = selection.focusNode;
         let focusOffset = selection.focusOffset;
         selection.collapse(caretPos.offsetNode, caretPos.offset);
         selection.extend(focusNode, focusOffset);
       }
     } else {
       if (targetIsEditable) {
-        let anchorX = this._isRTL ? this._cache.end.x : this._cache.start.x;
+        let anchorX = this._isRTL ? this._cache.focusPt.x : this._cache.anchorPt.x;
         this._moveSelectionInEditable(anchorX, aX, caretPos);
       } else {
         selection.extend(caretPos.offsetNode, caretPos.offset);
       }
     }
   },
 
   _moveCaret: function sh_moveCaret(aX, aY) {
@@ -1055,24 +1055,24 @@ var SelectionHandler = {
       // nsISelection object exists, but there's nothing actually selected
       throw "Failed to update cache for invalid selection";
     }
 
     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 selectionReversed = false;
-    if (this._cache.start) {
+    if (this._cache.anchorPt) {
       // If the end moved past the old end, but we're dragging the start handle, then that handle should become the end handle (and vice versa)
-      selectionReversed = (aIsStartHandle && (end.y > this._cache.end.y || (end.y == this._cache.end.y && end.x > this._cache.end.x))) ||
-                          (!aIsStartHandle && (start.y < this._cache.start.y || (start.y == this._cache.start.y && start.x < this._cache.start.x)));
+      selectionReversed = (aIsStartHandle && (end.y > this._cache.focusPt.y || (end.y == this._cache.focusPt.y && end.x > this._cache.focusPt.x))) ||
+                          (!aIsStartHandle && (start.y < this._cache.anchorPt.y || (start.y == this._cache.anchorPt.y && start.x < this._cache.anchorPt.x)));
     }
 
-    this._cache.start = start;
-    this._cache.end = end;
+    this._cache.anchorPt = start;
+    this._cache.focusPt = end;
 
     return selectionReversed;
   },
 
   _getHandlePositions: function sh_getHandlePositions(scroll) {
     // the checkHidden function tests to see if the given point is hidden inside an
     // iframe/subdocument. this is so that if we select some text inside an iframe and
     // scroll the iframe so the selection is out of view, we hide the handles rather
@@ -1097,33 +1097,33 @@ var SelectionHandler = {
       // divide by the pixel ratio
       let x = cursor.left / window.devicePixelRatio;
       let y = (cursor.top + cursor.height) / window.devicePixelRatio;
       return [{ handle: this.HANDLE_TYPE_CARET,
                 left: x + scroll.X,
                 top: y + scroll.Y,
                 hidden: checkHidden(x, y) }];
     } else {
-      let sx = this._cache.start.x;
-      let sy = this._cache.start.y;
-      let ex = this._cache.end.x;
-      let ey = this._cache.end.y;
+      let anchorX = this._cache.anchorPt.x;
+      let anchorY = this._cache.anchorPt.y;
+      let focusX = this._cache.focusPt.x;
+      let focusY = this._cache.focusPt.y;
 
       // Translate coordinates to account for selections in sub-frames. We can't cache
       // this because the top-level page may have scrolled since selection started.
       let offset = this._getViewOffset();
 
       return  [{ handle: this.HANDLE_TYPE_ANCHOR,
-                 left: sx + offset.x + scroll.X,
-                 top: sy + offset.y + scroll.Y,
-                 hidden: checkHidden(sx, sy) },
+                 left: anchorX + offset.x + scroll.X,
+                 top: anchorY + offset.y + scroll.Y,
+                 hidden: checkHidden(anchorX, anchorY) },
                { handle: this.HANDLE_TYPE_FOCUS,
-                 left: ex + offset.x + scroll.X,
-                 top: ey + offset.y + scroll.Y,
-                 hidden: checkHidden(ex, ey) }];
+                 left: focusX + offset.x + scroll.X,
+                 top: focusY + offset.y + scroll.Y,
+                 hidden: checkHidden(focusX, focusY) }];
     }
   },
 
   // Position handles, but avoid superfluous re-positioning (helps during
   // "TextSelection:LayerReflow", "scroll" of top-level document, etc).
   _positionHandlesOnChange: function() {
     // Helper function to compare position messages
     let samePositions = function(aPrev, aCurr) {