Bug 1121335 - Choose the right selection range for drag mode, r=roc
authorPeter Chang <pchang@mozilla.com>
Fri, 23 Jan 2015 06:09:00 +0100
changeset 225640 a763a56425902b53e0d444b498180f2d2c5a6b6b
parent 225639 09f774177683000cc1c7d1c56bfacb024ff35962
child 225641 5f52e0321f3c85b9bd37d0ebb635a7b214f3e30c
push id10990
push usercbook@mozilla.com
push dateMon, 26 Jan 2015 14:06:38 +0000
treeherderfx-team@54be9bcdacd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1121335
milestone38.0a1
Bug 1121335 - Choose the right selection range for drag mode, r=roc
layout/base/SelectionCarets.cpp
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -766,18 +766,20 @@ SelectionCarets::DragSelection(const nsP
     return nsEventStatus_eConsumeNoDefault;
   }
 
   int32_t rangeCount = selection->GetRangeCount();
   if (rangeCount <= 0) {
     return nsEventStatus_eConsumeNoDefault;
   }
 
+  // Limit the drag behavior not to cross the end of last selection range
+  // when drag the start frame and vice versa
   nsRefPtr<nsRange> range = mDragMode == START_FRAME ?
-    selection->GetRangeAt(0) : selection->GetRangeAt(rangeCount - 1);
+    selection->GetRangeAt(rangeCount - 1) : selection->GetRangeAt(0);
   if (!CompareRangeWithContentOffset(range, fs, offsets, mDragMode)) {
     return nsEventStatus_eConsumeNoDefault;
   }
 
   nsIFrame* anchorFrame;
   selection->GetPrimaryFrameForAnchorNode(&anchorFrame);
   if (!anchorFrame) {
     return nsEventStatus_eConsumeNoDefault;