Bug 805697. There is no point in checking for the existence of a caret in the presshell --- it will always have one, and it wouldn't matter if it didn't. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 29 Oct 2012 17:31:45 +1300
changeset 119589 f31f3948e433e52aa36a36ab015e766993c03cc5
parent 119588 911658ea401e5267c2511a632bd8a0b3f74a7a78
child 119590 bf45387fc47cbad4cae24d2e2b8723ebb67aff40
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs805697
milestone19.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 805697. There is no point in checking for the existence of a caret in the presshell --- it will always have one, and it wouldn't matter if it didn't. r=mats
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -5319,80 +5319,70 @@ Selection::ScrollIntoViewInternal(Select
 }
 
 nsresult
 Selection::ScrollIntoView(SelectionRegion aRegion,
                           nsIPresShell::ScrollAxis aVertical,
                           nsIPresShell::ScrollAxis aHorizontal,
                           int32_t aFlags)
 {
-  nsresult result;
   if (!mFrameSelection)
     return NS_OK;//nothing to do
 
   if (mFrameSelection->GetBatching())
     return NS_OK;
 
   if (!(aFlags & Selection::SCROLL_SYNCHRONOUS))
     return PostScrollSelectionIntoViewEvent(aRegion, aFlags,
       aVertical, aHorizontal);
 
-  //
-  // Shut the caret off before scrolling to avoid
-  // leaving caret turds on the screen!
-  //
   nsCOMPtr<nsIPresShell> presShell;
-  result = GetPresShell(getter_AddRefs(presShell));
+  nsresult result = GetPresShell(getter_AddRefs(presShell));
   if (NS_FAILED(result) || !presShell)
     return result;
-  nsRefPtr<nsCaret> caret = presShell->GetCaret();
-  if (caret)
-  {
-    // Now that text frame character offsets are always valid (though not
-    // necessarily correct), the worst that will happen if we don't flush here
-    // is that some callers might scroll to the wrong place.  Those should
-    // either manually flush if they're in a safe position for it or use the
-    // async version of this method.
-    if (aFlags & Selection::SCROLL_DO_FLUSH) {
-      presShell->FlushPendingNotifications(Flush_Layout);
-
-      // Reget the presshell, since it might have gone away.
-      result = GetPresShell(getter_AddRefs(presShell));
-      if (NS_FAILED(result) || !presShell)
-        return result;
-    }
-
-    //
-    // Scroll the selection region into view.
-    //
-
-    nsRect rect;
-    nsIFrame* frame = GetSelectionAnchorGeometry(aRegion, &rect);
-    if (!frame)
-      return NS_ERROR_FAILURE;
-
-    // Scroll vertically to get the caret into view, but only if the container
-    // is perceived to be scrollable in that direction (i.e. there is a visible
-    // vertical scrollbar or the scroll range is at least one device pixel)
-    aVertical.mOnlyIfPerceivedScrollableDirection = true;
-
-
-    uint32_t flags = 0;
-    if (aFlags & Selection::SCROLL_FIRST_ANCESTOR_ONLY) {
-      flags |= nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY;
-    }
-    if (aFlags & Selection::SCROLL_OVERFLOW_HIDDEN) {
-      flags |= nsIPresShell::SCROLL_OVERFLOW_HIDDEN;
-    }
-
-    presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal,
-      flags);
-    return NS_OK;
-  }
-  return result;
+
+  // Now that text frame character offsets are always valid (though not
+  // necessarily correct), the worst that will happen if we don't flush here
+  // is that some callers might scroll to the wrong place.  Those should
+  // either manually flush if they're in a safe position for it or use the
+  // async version of this method.
+  if (aFlags & Selection::SCROLL_DO_FLUSH) {
+    presShell->FlushPendingNotifications(Flush_Layout);
+
+    // Reget the presshell, since it might have gone away.
+    result = GetPresShell(getter_AddRefs(presShell));
+    if (NS_FAILED(result) || !presShell)
+      return result;
+  }
+
+  //
+  // Scroll the selection region into view.
+  //
+
+  nsRect rect;
+  nsIFrame* frame = GetSelectionAnchorGeometry(aRegion, &rect);
+  if (!frame)
+    return NS_ERROR_FAILURE;
+
+  // Scroll vertically to get the caret into view, but only if the container
+  // is perceived to be scrollable in that direction (i.e. there is a visible
+  // vertical scrollbar or the scroll range is at least one device pixel)
+  aVertical.mOnlyIfPerceivedScrollableDirection = true;
+
+  uint32_t flags = 0;
+  if (aFlags & Selection::SCROLL_FIRST_ANCESTOR_ONLY) {
+    flags |= nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY;
+  }
+  if (aFlags & Selection::SCROLL_OVERFLOW_HIDDEN) {
+    flags |= nsIPresShell::SCROLL_OVERFLOW_HIDDEN;
+  }
+
+  presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal,
+    flags);
+  return NS_OK;
 }
 
 
 
 NS_IMETHODIMP
 Selection::AddSelectionListener(nsISelectionListener* aNewListener)
 {
   if (!aNewListener)