Bug 805697. Remove StCaretHider since it's not needed anymore. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 29 Oct 2012 17:31:26 +1300
changeset 111648 911658ea401e5267c2511a632bd8a0b3f74a7a78
parent 111647 5741971493aae1347af29282e9431d0ac469d151
child 111649 f31f3948e433e52aa36a36ab015e766993c03cc5
push id17179
push userrocallahan@mozilla.com
push dateMon, 29 Oct 2012 04:38:34 +0000
treeherdermozilla-inbound@ed720383aab3 [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. Remove StCaretHider since it's not needed anymore. r=mats
editor/libeditor/base/nsEditor.cpp
layout/base/nsCaret.h
layout/generic/nsSelection.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -26,17 +26,17 @@
 #include "mozilla/Preferences.h"        // for Preferences
 #include "mozilla/Selection.h"          // for Selection, etc
 #include "mozilla/Services.h"           // for GetObserverService
 #include "mozilla/Util.h"               // for DebugOnly
 #include "mozilla/dom/Element.h"        // for Element, nsINode::AsElement
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAString.h"                  // for nsAString_internal::Length, etc
 #include "nsCCUncollectableMarker.h"    // for nsCCUncollectableMarker
-#include "nsCaret.h"                    // for nsCaret, StCaretHider
+#include "nsCaret.h"                    // for nsCaret
 #include "nsCaseTreatment.h"
 #include "nsCharTraits.h"               // for NS_IS_HIGH_SURROGATE, etc
 #include "nsComponentManagerUtils.h"    // for do_CreateInstance
 #include "nsComputedDOMStyle.h"         // for nsComputedDOMStyle
 #include "nsContentUtils.h"             // for nsContentUtils
 #include "nsDOMString.h"                // for DOMStringIsNull
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
 #include "nsEditProperty.h"             // for nsEditProperty, etc
@@ -934,18 +934,16 @@ nsEditor::EndPlaceHolderTransaction()
       // Hide the caret here to avoid hiding it twice, once in EndUpdateViewBatch
       // and once in ScrollSelectionIntoView.
       nsRefPtr<nsCaret> caret;
       nsCOMPtr<nsIPresShell> presShell = GetPresShell();
 
       if (presShell)
         caret = presShell->GetCaret();
 
-      StCaretHider caretHider(caret);
-
       // time to turn off the batch
       EndUpdateViewBatch();
       // make sure selection is in view
 
       // After ScrollSelectionIntoView(), the pending notifications might be
       // flushed and PresShell/PresContext/Frames may be dead. See bug 418470.
       ScrollSelectionIntoView(false);
     }
@@ -4177,29 +4175,16 @@ nsresult nsEditor::EndUpdateViewBatch()
     mUpdateCount = 0;
     return NS_ERROR_FAILURE;
   }
 
   mUpdateCount--;
 
   if (0 == mUpdateCount)
   {
-    // Hide the caret with an StCaretHider. By the time it goes out
-    // of scope and tries to show the caret, reflow and selection changed
-    // notifications should've happened so the caret should have enough info
-    // to draw at the correct position.
-
-    nsRefPtr<nsCaret> caret;
-    nsCOMPtr<nsIPresShell> presShell = GetPresShell();
-
-    if (presShell)
-      caret = presShell->GetCaret();
-
-    StCaretHider caretHider(caret);
-
     // Turn selection updating and notifications back on.
 
     nsCOMPtr<nsISelection>selection;
     GetSelection(getter_AddRefs(selection));
 
     if (selection) {
       nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection));
       selPrivate->EndBatchChanges();
--- a/layout/base/nsCaret.h
+++ b/layout/base/nsCaret.h
@@ -258,38 +258,9 @@ protected:
                                               // actually drawn (anon <BR> in text control)
     int32_t               mLastContentOffset; // the offset for the last request
 
     nsFrameSelection::HINT mLastHint;        // the hint associated with the last request, see also
                                               // mLastBidiLevel below
 
 };
 
-// handy stack-based class for temporarily disabling the caret
-
-class StCaretHider
-{
-public:
-               StCaretHider(nsCaret* aSelCon)
-               : mWasVisible(false), mCaret(aSelCon)
-               {
-                 if (mCaret)
-                 {
-                   mCaret->GetCaretVisible(&mWasVisible);
-                   if (mWasVisible)
-                     mCaret->SetCaretVisible(false);
-                 }
-               }
-
-               ~StCaretHider()
-               {
-                 if (mCaret && mWasVisible)
-                   mCaret->SetCaretVisible(true);
-                 // nsCOMPtr releases mPresShell
-               }
-
-protected:
-
-    bool                    mWasVisible;
-    nsCOMPtr<nsCaret>  mCaret;
-};
-
 #endif //nsCaret_h__
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -5355,18 +5355,16 @@ Selection::ScrollIntoView(SelectionRegio
       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;
     }
 
-    StCaretHider  caretHider(caret);      // stack-based class hides and shows the caret
-
     //
     // Scroll the selection region into view.
     //
 
     nsRect rect;
     nsIFrame* frame = GetSelectionAnchorGeometry(aRegion, &rect);
     if (!frame)
       return NS_ERROR_FAILURE;