Bug 910237 - Get rid of the nsIEditor.h #include in nsTextControlFrame.h; r=mats,ehsan
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 28 Aug 2013 19:06:00 +0000
changeset 158630 92b0f1956f2b3512d1df37f93cd036a45a858b40
parent 158629 bfe32b93a350ffee6b4b601b70308f509e7a7a5f
child 158631 a2cd23f6187aa127ef189a2322278a4e3572f471
push id407
push userlsblakk@mozilla.com
push dateTue, 03 Dec 2013 03:32:50 +0000
treeherdermozilla-release@babf8c9ebc52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, ehsan
bugs910237
milestone26.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 910237 - Get rid of the nsIEditor.h #include in nsTextControlFrame.h; r=mats,ehsan
content/html/content/src/nsTextEditorState.cpp
layout/forms/nsTextControlFrame.cpp
layout/forms/nsTextControlFrame.h
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -45,16 +45,43 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID);
 
 static nsINativeKeyBindings *sNativeInputBindings = nullptr;
 static nsINativeKeyBindings *sNativeTextAreaBindings = nullptr;
 
+class MOZ_STACK_CLASS ValueSetter
+{
+public:
+  ValueSetter(nsIEditor* aEditor)
+    : mEditor(aEditor)
+  {
+    MOZ_ASSERT(aEditor);
+  
+    // To protect against a reentrant call to SetValue, we check whether
+    // another SetValue is already happening for this editor.  If it is,
+    // we must wait until we unwind to re-enable oninput events.
+    mEditor->GetSuppressDispatchingInputEvent(&mOuterTransaction);
+  }
+  ~ValueSetter()
+  {
+    mEditor->SetSuppressDispatchingInputEvent(mOuterTransaction);
+  }
+  void Init()
+  {
+    mEditor->SetSuppressDispatchingInputEvent(true);
+  }
+
+private:
+  nsCOMPtr<nsIEditor> mEditor;
+  bool mOuterTransaction;
+};
+
 class RestoreSelectionState : public nsRunnable {
 public:
   RestoreSelectionState(nsTextEditorState *aState, nsTextControlFrame *aFrame)
     : mFrame(aFrame),
       mTextEditorState(aState)
   {
   }
 
@@ -1803,17 +1830,17 @@ nsTextEditorState::SetValue(const nsAStr
       mBoundFrame->GetText(currentValue);
     }
 
     nsWeakFrame weakFrame(mBoundFrame);
 
     // this is necessary to avoid infinite recursion
     if (!currentValue.Equals(aValue))
     {
-      nsTextControlFrame::ValueSetter valueSetter(mEditor);
+      ValueSetter valueSetter(mEditor);
 
       // \r is an illegal character in the dom, but people use them,
       // so convert windows and mac platform linebreaks to \n:
       // Unfortunately aValue is declared const, so we have to copy
       // in order to do this substitution.
       nsString newValue(aValue);
       if (aValue.FindChar(PRUnichar('\r')) != -1) {
         nsContentUtils::PlatformToDOMLineBreaks(newValue);
@@ -1897,17 +1924,16 @@ nsTextEditorState::SetValue(const nsAStr
           // If the frame was destroyed because of a flush somewhere inside
           // InsertText, mBoundFrame here will be false.  But it's also possible
           // for the frame to go away because of another reason (such as deleting
           // the existing selection -- see bug 574558), in which case we don't
           // need to reset the value here.
           if (!mBoundFrame) {
             SetValue(newValue, false, aSetValueChanged);
           }
-          valueSetter.Cancel();
           return;
         }
 
         if (!IsSingleLineTextControl()) {
           mCachedValue = newValue;
         }
 
         plaintextEditor->SetMaxTextLength(savedMaxLength);
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -5,16 +5,17 @@
 
 #include "mozilla/DebugOnly.h"
 
 #include "nsCOMPtr.h"
 #include "nsTextControlFrame.h"
 #include "nsIPlaintextEditor.h"
 #include "nsCaret.h"
 #include "nsGenericHTMLElement.h"
+#include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsIPhonetic.h"
 #include "nsTextFragment.h"
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsFormControlFrame.h" //for registering accesskeys
 
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -7,21 +7,21 @@
 #define nsTextControlFrame_h___
 
 #include "mozilla/Attributes.h"
 #include "nsContainerFrame.h"
 #include "nsIAnonymousContentCreator.h"
 #include "nsITextControlFrame.h"
 #include "nsITextControlElement.h"
 #include "nsIStatefulFrame.h"
-#include "nsIEditor.h"
 
 class nsISelectionController;
 class EditorInitializerEntryTracker;
 class nsTextEditorState;
+class nsIEditor;
 namespace mozilla {
 namespace dom {
 class Element;
 }
 }
 
 class nsTextControlFrame : public nsContainerFrame,
                            public nsIAnonymousContentCreator,
@@ -164,50 +164,16 @@ protected:
 
 public: //for methods who access nsTextControlFrame directly
   void SetValueChanged(bool aValueChanged);
   
   // called by the focus listener
   nsresult MaybeBeginSecureKeyboardInput();
   void MaybeEndSecureKeyboardInput();
 
-  class MOZ_STACK_CLASS ValueSetter {
-  public:
-    ValueSetter(nsIEditor* aEditor)
-      : mEditor(aEditor)
-      , mCanceled(false)
-    {
-      MOZ_ASSERT(aEditor);
-
-      // To protect against a reentrant call to SetValue, we check whether
-      // another SetValue is already happening for this frame.  If it is,
-      // we must wait until we unwind to re-enable oninput events.
-      mEditor->GetSuppressDispatchingInputEvent(&mOuterTransaction);
-    }
-    void Cancel() {
-      mCanceled = true;
-    }
-    void Init() {
-      mEditor->SetSuppressDispatchingInputEvent(true);
-    }
-    ~ValueSetter() {
-      mEditor->SetSuppressDispatchingInputEvent(mOuterTransaction);
-
-      if (mCanceled) {
-        return;
-      }
-    }
-
-  private:
-    nsCOMPtr<nsIEditor> mEditor;
-    bool mOuterTransaction;
-    bool mCanceled;
-  };
-  friend class ValueSetter;
-
 #define DEFINE_TEXTCTRL_FORWARDER(type, name)                                  \
   type name() {                                                                \
     nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \
     NS_ASSERTION(txtCtrl, "Content not a text control element");               \
     return txtCtrl->name();                                                    \
   }
 #define DEFINE_TEXTCTRL_CONST_FORWARDER(type, name)                            \
   type name() const {                                                          \