Bug 960866 part.2 Remove nsEditor::mInIMEMode r=ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 12 Feb 2014 22:02:55 +0900
changeset 186591 41d17ebf8454c296b26991963887db13ae0758c5
parent 186590 184e8ed6ca48a07b9136cfccba9be86c4f2a6dae
child 186592 984a2e65a52f7c22056381683e3b103644d1e137
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs960866
milestone30.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 960866 part.2 Remove nsEditor::mInIMEMode r=ehsan
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/text/nsPlaintextEditor.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -139,17 +139,16 @@ nsEditor::nsEditor()
 ,  mUpdateCount(0)
 ,  mPlaceHolderBatch(0)
 ,  mAction(EditAction::none)
 ,  mIMETextOffset(0)
 ,  mIMEBufferLength(0)
 ,  mDirection(eNone)
 ,  mDocDirtyState(-1)
 ,  mSpellcheckCheckboxState(eTriUnset)
-,  mInIMEMode(false)
 ,  mIsIMEComposing(false)
 ,  mShouldTxnSetSelection(true)
 ,  mDidPreDestroy(false)
 ,  mDidPostCreate(false)
 ,  mDispatchInputEvent(true)
 {
 }
 
@@ -962,17 +961,19 @@ nsEditor::EndPlaceHolderTransaction()
       else  
       {
         // in the future we will check to make sure undo is off here,
         // since that is the only known case where the placeholdertxn would disappear on us.
         // For now just removing the assert.
       }
       // notify editor observers of action but if composing, it's done by
       // text event handler.
-      if (!mInIMEMode) NotifyEditorObservers();
+      if (!mComposition) {
+        NotifyEditorObservers();
+      }
     }
   }
   mPlaceHolderBatch--;
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -2025,27 +2026,26 @@ nsEditor::EnsureComposition(mozilla::Wid
   }
 }
 
 nsresult
 nsEditor::BeginIMEComposition(WidgetCompositionEvent* aCompositionEvent)
 {
   MOZ_ASSERT(!mComposition, "There is composition already");
   EnsureComposition(aCompositionEvent);
-  mInIMEMode = true;
   if (mPhonetic) {
     mPhonetic->Truncate(0);
   }
   return NS_OK;
 }
 
 void
 nsEditor::EndIMEComposition()
 {
-  NS_ENSURE_TRUE_VOID(mInIMEMode); // nothing to do
+  NS_ENSURE_TRUE_VOID(mComposition); // nothing to do
 
   // commit the IME transaction..we can get at it via the transaction mgr.
   // Note that this means IME won't work without an undo stack!
   if (mTxnMgr) {
     nsCOMPtr<nsITransaction> txn = mTxnMgr->PeekUndoStack();
     nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
     if (plcTxn) {
       DebugOnly<nsresult> rv = plcTxn->Commit();
@@ -2053,17 +2053,16 @@ nsEditor::EndIMEComposition()
                    "nsIAbsorbingTransaction::Commit() failed");
     }
   }
 
   /* reset the data we need to construct a transaction */
   mIMETextNode = nullptr;
   mIMETextOffset = 0;
   mIMEBufferLength = 0;
-  mInIMEMode = false;
   mIsIMEComposing = false;
   mComposition = nullptr;
 
   // notify editor observers of action
   NotifyEditorObservers();
 }
 
 
@@ -2085,17 +2084,17 @@ nsEditor::ForceCompositionEnd()
   if (!ps) {
     return NS_ERROR_NOT_AVAILABLE;
   }
   nsPresContext* pc = ps->GetPresContext();
   if (!pc) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  if (!mInIMEMode) {
+  if (!mComposition) {
     // XXXmnakano see bug 558976, ResetInputState() has two meaning which are
     // "commit the composition" and "cursor is moved".  This method name is
     // "ForceCompositionEnd", so, ResetInputState() should be used only for the
     // former here.  However, ResetInputState() is also used for the latter here
     // because even if we don't have composition, we call ResetInputState() on
     // Linux.  Currently, nsGtkIMModule can know the timing of the cursor move,
     // so, the latter meaning should be gone.
     // XXX This may commit a composition in another editor.
@@ -2324,17 +2323,17 @@ nsEditor::InsertTextImpl(const nsAString
                          nsIDOMDocument* aDoc)
 {
   // NOTE: caller *must* have already used nsAutoTxnsConserveSelection
   // stack-based class to turn off txn selection updating.  Caller also turned
   // on rules sniffing if desired.
 
   NS_ENSURE_TRUE(aInOutNode && *aInOutNode && aInOutOffset && aDoc,
                  NS_ERROR_NULL_POINTER);
-  if (!mInIMEMode && aStringToInsert.IsEmpty()) {
+  if (!mComposition && aStringToInsert.IsEmpty()) {
     return NS_OK;
   }
 
   nsCOMPtr<nsINode> node = do_QueryInterface(*aInOutNode);
   NS_ENSURE_STATE(node);
   uint32_t offset = static_cast<uint32_t>(*aInOutOffset);
 
   if (!node->IsNodeOfType(nsINode::eTEXT) && IsPlaintextEditor()) {
@@ -2364,17 +2363,17 @@ nsEditor::InsertTextImpl(const nsAString
         offset = node->Length();
       } else if (node->GetParentNode() && node->GetParentNode() == root) {
         node = node->GetParentNode();
       }
     }
   }
 
   nsresult res;
-  if (mInIMEMode) {
+  if (mComposition) {
     if (!node->IsNodeOfType(nsINode::eTEXT)) {
       // create a text node
       nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
       NS_ENSURE_STATE(doc);
       nsRefPtr<nsTextNode> newNode = doc->CreateTextNode(EmptyString());
       // then we insert it into the dom tree
       res = InsertNode(newNode->AsDOMNode(), node->AsDOMNode(), offset);
       NS_ENSURE_SUCCESS(res, res);
@@ -2419,17 +2418,17 @@ nsresult nsEditor::InsertTextIntoTextNod
                                               int32_t aOffset,
                                               bool aSuppressIME)
 {
   nsRefPtr<EditTxn> txn;
   nsresult result = NS_OK;
   bool isIMETransaction = false;
   // aSuppressIME is used when editor must insert text, yet this text is not
   // part of current ime operation.  example: adjusting whitespace around an ime insertion.
-  if (mIMETextRangeList && mInIMEMode && !aSuppressIME)
+  if (mIMETextRangeList && mComposition && !aSuppressIME)
   {
     if (!mIMETextNode)
     {
       mIMETextNode = aTextNode;
       mIMETextOffset = aOffset;
     }
     uint16_t len ;
     len = mIMETextRangeList->GetLength();
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -859,19 +859,17 @@ protected:
 
   uint32_t          mIMETextOffset;    // offset in text node where IME comp string begins
   uint32_t          mIMEBufferLength;  // current length of IME comp string
 
   EDirection        mDirection;          // the current direction of editor action
   int8_t            mDocDirtyState;      // -1 = not initialized
   uint8_t           mSpellcheckCheckboxState; // a Tristate value
 
-  bool mInIMEMode;        // are we inside an IME composition?
   bool mIsIMEComposing;   // is IME in composition state?
-                                                       // This is different from mInIMEMode. see Bug 98434.
 
   bool mShouldTxnSetSelection;  // turn off for conservative selection adjustment by txns
   bool mDidPreDestroy;    // whether PreDestroy has been called
   bool mDidPostCreate;    // whether PostCreate has been called
   bool mDispatchInputEvent;
 
   friend bool NSCanUnload(nsISupports* serviceMgr);
   friend class nsAutoTxnsConserveSelection;
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -691,18 +691,17 @@ nsPlaintextEditor::DeleteSelection(EDire
 NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   EditAction opID = EditAction::insertText;
-  if (mInIMEMode) 
-  {
+  if (mComposition) {
     opID = EditAction::insertIMEText;
   }
   nsAutoPlaceHolderBatch batch(this, nullptr); 
   nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
 
   // pre-process
   nsRefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -809,17 +808,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertL
   }
 
   return res;
 }
 
 nsresult
 nsPlaintextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent)
 {
-  NS_ENSURE_TRUE(!mInIMEMode, NS_OK);
+  NS_ENSURE_TRUE(!mComposition, NS_OK);
 
   if (IsPasswordEditor()) {
     NS_ENSURE_TRUE(mRules, NS_ERROR_NULL_POINTER);
     // Protect the edit rules object from dying
     nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
     nsTextEditRules *textEditRules =
       static_cast<nsTextEditRules*>(mRules.get());
@@ -834,17 +833,16 @@ nsPlaintextEditor::UpdateIMEComposition(
 {
   NS_ABORT_IF_FALSE(aDOMTextEvent, "aDOMTextEvent must not be nullptr");
 
   WidgetTextEvent* widgetTextEvent =
     aDOMTextEvent->GetInternalNSEvent()->AsTextEvent();
   NS_ENSURE_TRUE(widgetTextEvent, NS_ERROR_INVALID_ARG);
 
   EnsureComposition(widgetTextEvent);
-  mInIMEMode = true;
 
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
   nsCOMPtr<nsISelection> selection;
   nsresult rv = GetSelection(getter_AddRefs(selection));
   NS_ENSURE_SUCCESS(rv, rv);