Bug 773247. Don't keep looking forward for the first visible range and then just ignoring it. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 11 Oct 2012 15:45:52 -0400
changeset 109968 2efb9e5762ce533ab14c7202d46e9f5085f3a1ef
parent 109967 2ed8e070a4aef5f6f9f6f2e6d0c93bd553d3d6b7
child 109969 e0fff9d291114930cb3fbf1cecfca09ca8e47e1a
push id16305
push userbzbarsky@mozilla.com
push dateThu, 11 Oct 2012 19:46:12 +0000
treeherdermozilla-inbound@2efb9e5762ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs773247
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 773247. Don't keep looking forward for the first visible range and then just ignoring it. r=masayuki
toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
toolkit/components/typeaheadfind/nsTypeAheadFind.h
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -383,20 +383,18 @@ nsTypeAheadFind::FindItNow(nsIPresShell 
       bool usesIndependentSelection;
       if (!IsRangeVisible(presShell, presContext, returnRange,
                           aIsFirstVisiblePreferred, false,
                           getter_AddRefs(mStartPointRange), 
                           &usesIndependentSelection) ||
           (aIsLinksOnly && !isInsideLink) ||
           (mStartLinksOnlyPref && aIsLinksOnly && !isStartingLink)) {
         // ------ Failure ------
-        // Start find again from here
-        returnRange->CloneRange(getter_AddRefs(mStartPointRange));
-
-        // Collapse to end
+        // mStartPointRange got updated to the right thing already,
+        // but we stil need to collapse it to the right end.
         mStartPointRange->Collapse(aFindPrev);
 
         continue;
       }
 
       // ------ Success! -------
       // Hide old selection (new one may be on a different controller)
       if (selection) {
@@ -1133,17 +1131,16 @@ nsTypeAheadFind::IsRangeVisible(nsIPresS
 
   if (frame) {
     nsCOMPtr<nsIDOMNode> firstVisibleNode = do_QueryInterface(frame->GetContent());
 
     if (firstVisibleNode) {
       (*aFirstVisibleRange)->SelectNode(firstVisibleNode);
       frame->GetOffsets(startFrameOffset, endFrameOffset);
       (*aFirstVisibleRange)->SetStart(firstVisibleNode, startFrameOffset);
-      (*aFirstVisibleRange)->Collapse(true);  // Collapse to start
     }
   }
 
   return false;
 }
 
 already_AddRefed<nsIPresShell>
 nsTypeAheadFind::GetPresShell()
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.h
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.h
@@ -43,16 +43,18 @@ protected:
   nsresult GetWebBrowserFind(nsIDocShell *aDocShell,
                              nsIWebBrowserFind **aWebBrowserFind);
 
   void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell, 
                              bool *aIsInsideLink, bool *aIsStartingLink);
 
   void GetSelection(nsIPresShell *aPresShell, nsISelectionController **aSelCon, 
                     nsISelection **aDomSel);
+  // *aNewRange may not be collapsed.  If you want to collapse it in a
+  // particular way, you need to do it yourself.
   bool IsRangeVisible(nsIPresShell *aPresShell, nsPresContext *aPresContext,
                         nsIDOMRange *aRange, bool aMustBeVisible, 
                         bool aGetTopVisibleLeaf, nsIDOMRange **aNewRange,
                         bool *aUsesIndependentSelection);
   nsresult FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
                      bool aIsFirstVisiblePreferred, bool aFindPrev,
                      uint16_t* aResult);
   nsresult GetSearchContainers(nsISupports *aContainer,