Bug 1224994 part.12 Rename the variable names for the result of TSFTextStore::SelectionForTSF() to selectionForTSF r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 01 Jul 2016 14:13:46 +0900
changeset 383078 8eddb0e42693be86aba7c0699ee3682cea5c522b
parent 383077 5813a18b999a4a3606e79167e816e7bdefddd778
child 524375 8a6fcebd7299a0f4776297282a596bdde3d5a5b7
push id21915
push usermasayuki@d-toybox.com
push dateFri, 01 Jul 2016 05:16:51 +0000
reviewersm_kato
bugs1224994
milestone50.0a1
Bug 1224994 part.12 Rename the variable names for the result of TSFTextStore::SelectionForTSF() to selectionForTSF r?m_kato MozReview-Commit-ID: 9gYiIKVohQl
widget/windows/TSFTextStore.cpp
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1975,24 +1975,24 @@ TSFTextStore::GetSelection(ULONG ulIndex
   if (ulIndex != static_cast<ULONG>(TS_DEFAULT_SELECTION) &&
       ulIndex != 0) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::GetSelection() FAILED due to "
             "unsupported selection", this));
     return TS_E_NOSELECTION;
   }
 
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::GetSelection() FAILED due to "
             "SelectionForTSFRef() failure", this));
     return E_FAIL;
   }
-  *pSelection = currentSel.ACP();
+  *pSelection = selectionForTSF.ACP();
   *pcFetched = 1;
   MOZ_LOG(sTextStoreLog, LogLevel::Info,
          ("TSF: 0x%p   TSFTextStore::GetSelection() succeeded", this));
   return S_OK;
 }
 
 bool
 TSFTextStore::IsComposingInContent() const
@@ -2017,18 +2017,18 @@ TSFTextStore::ContentForTSFRef()
             "called wrong timing, IsReadLocked()=%s, "
             "mContentForTSF.IsInitialized()=%s",
             this, GetBoolName(IsReadLocked()),
             GetBoolName(mContentForTSF.IsInitialized())));
     mContentForTSF.Clear();
     return mContentForTSF;
   }
 
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::ContentForTSFRef(), FAILED, due to "
             "SelectionForTSFRef() failure", this));
     mContentForTSF.Clear();
     return mContentForTSF;
   }
 
   if (!mContentForTSF.IsInitialized()) {
@@ -2292,33 +2292,33 @@ TSFTextStore::RestartCompositionIfNecess
           this));
   return S_OK;
 }
 
 HRESULT
 TSFTextStore::RestartComposition(ITfCompositionView* aCompositionView,
                                  ITfRange* aNewRange)
 {
-  Selection& currentSelection = SelectionForTSFRef();
+  Selection& selectionForTSF = SelectionForTSFRef();
 
   LONG newStart, newLength;
   HRESULT hr = GetRangeExtent(aNewRange, &newStart, &newLength);
   LONG newEnd = newStart + newLength;
 
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   TSFTextStore::RestartComposition(aCompositionView=0x%p, "
           "aNewRange=0x%p { newStart=%d, newLength=%d }), "
           "mComposition={ mStart=%d, mCompositionString.Length()=%d }, "
-          "currentSelection={ IsDirty()=%s, StartOffset()=%d, Length()=%d }",
+          "selectionForTSF={ IsDirty()=%s, StartOffset()=%d, Length()=%d }",
           this, aCompositionView, aNewRange, newStart, newLength,
           mComposition.mStart, mComposition.mString.Length(),
-          GetBoolName(currentSelection.IsDirty()),
-          currentSelection.StartOffset(), currentSelection.Length()));
-
-  if (currentSelection.IsDirty()) {
+          GetBoolName(selectionForTSF.IsDirty()),
+          selectionForTSF.StartOffset(), selectionForTSF.Length()));
+
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::RestartComposition() FAILED "
             "due to SelectionForTSFRef() failure", this));
     return E_FAIL;
   }
 
   if (FAILED(hr)) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
@@ -2338,17 +2338,17 @@ TSFTextStore::RestartComposition(ITfComp
 
   // If the new range has an overlap with the current one, we should not commit
   // the whole current range to avoid creating an odd undo transaction.
   // I.e., the overlapped range which is being composed should not appear in
   // undo transaction.
 
   // Backup current composition data and selection data.
   Composition oldComposition = mComposition;
-  Selection oldSelection = currentSelection;
+  Selection oldSelection = selectionForTSF;
 
   // Commit only the part of composition.
   LONG keepComposingStartOffset = std::max(mComposition.mStart, newStart);
   LONG keepComposingEndOffset = std::min(mComposition.EndOffset(), newEnd);
   MOZ_ASSERT(keepComposingStartOffset <= keepComposingEndOffset,
     "Why keepComposingEndOffset is smaller than keepComposingStartOffset?");
   LONG keepComposingLength = keepComposingEndOffset - keepComposingStartOffset;
   // Remove the overlapped part from the commit string.
@@ -2384,25 +2384,25 @@ TSFTextStore::RestartComposition(ITfComp
   // hasn't restored composing string yet.
   RecordCompositionStartAction(aCompositionView, newStart, 0, false);
 
   // Restore the latest text content and selection.
   contentForTSF.ReplaceSelectedTextWith(
     nsDependentSubstring(oldComposition.mString,
                          keepComposingStartOffset - oldComposition.mStart,
                          keepComposingLength));
-  currentSelection = oldSelection;
+  selectionForTSF = oldSelection;
 
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   TSFTextStore::RestartComposition() succeeded, "
           "mComposition={ mStart=%d, mCompositionString.Length()=%d }, "
-          "currentSelection={ IsDirty()=%s, StartOffset()=%d, Length()=%d }",
+          "selectionForTSF={ IsDirty()=%s, StartOffset()=%d, Length()=%d }",
           this, mComposition.mStart, mComposition.mString.Length(),
-          GetBoolName(currentSelection.IsDirty()),
-          currentSelection.StartOffset(), currentSelection.Length()));
+          GetBoolName(selectionForTSF.IsDirty()),
+          selectionForTSF.StartOffset(), selectionForTSF.Length()));
 
   return S_OK;
 }
 
 static bool
 GetColor(const TF_DA_COLOR& aTSFColor, nscolor& aResult)
 {
   switch (aTSFColor.type) {
@@ -2497,18 +2497,18 @@ TSFTextStore::RecordCompositionUpdateAct
   if (FAILED(hr) || !enumRanges) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::RecordCompositionUpdateAction() FAILED "
             "due to attrPropetry->EnumRanges() failure", this));
     return FAILED(hr) ? hr : E_FAIL;
   }
 
   // First, put the log of content and selection here.
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::RecordCompositionUpdateAction() FAILED "
             "due to SelectionForTSFRef() failure", this));
     return E_FAIL;
   }
 
   PendingAction* action = LastOrNewPendingCompositionUpdate();
   action->mData = mComposition.mString;
@@ -2603,32 +2603,32 @@ TSFTextStore::RecordCompositionUpdateAct
   // We need to hack for Korean Input System which is Korean standard TIP.
   // It sets no change style to IME selection (the selection is always only
   // one).  So, the composition string looks like normal (or committed) string.
   // At this time, current selection range is same as the composition string
   // range.  Other applications set a wide caret which covers the composition
   // string,  however, Gecko doesn't support the wide caret drawing now (Gecko
   // doesn't support XOR drawing), unfortunately.  For now, we should change
   // the range style to undefined.
-  if (!currentSel.IsCollapsed() && action->mRanges->Length() == 1) {
+  if (!selectionForTSF.IsCollapsed() && action->mRanges->Length() == 1) {
     TextRange& range = action->mRanges->ElementAt(0);
-    LONG start = currentSel.MinOffset();
-    LONG end = currentSel.MaxOffset();
+    LONG start = selectionForTSF.MinOffset();
+    LONG end = selectionForTSF.MaxOffset();
     if ((LONG)range.mStartOffset == start - mComposition.mStart &&
         (LONG)range.mEndOffset == end - mComposition.mStart &&
         range.mRangeStyle.IsNoChangeStyle()) {
       range.mRangeStyle.Clear();
       // The looks of selected type is better than others.
       range.mRangeType = TextRangeType::eSelectedRawClause;
     }
   }
 
   // The caret position has to be collapsed.
   uint32_t caretPosition =
-    static_cast<uint32_t>(currentSel.MaxOffset() - mComposition.mStart);
+    static_cast<uint32_t>(selectionForTSF.MaxOffset() - mComposition.mStart);
 
   // If caret is in the target clause and it doesn't have specific style,
   // the target clause will be painted as normal selection range.  Since caret
   // shouldn't be in selection range on Windows, we shouldn't append caret
   // range in such case.
   const TextRange* targetClause = action->mRanges->GetTargetClause();
   if (!targetClause || targetClause->mRangeStyle.IsDefined() ||
       caretPosition < targetClause->mStartOffset ||
@@ -2659,32 +2659,32 @@ TSFTextStore::SetSelectionInternal(const
           this, pSelection->acpStart, pSelection->acpEnd,
           GetActiveSelEndName(pSelection->style.ase),
           GetBoolName(pSelection->style.fInterimChar),
           GetBoolName(aDispatchCompositionChangeEvent),
           GetBoolName(mComposition.IsComposing())));
 
   MOZ_ASSERT(IsReadWriteLocked());
 
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
        ("TSF: 0x%p   TSFTextStore::SetSelectionInternal() FAILED due to "
         "SelectionForTSFRef() failure", this));
     return E_FAIL;
   }
 
   // If actually the range is not changing, we should do nothing.
   // Perhaps, we can ignore the difference change because it must not be
   // important for following edit.
-  if (currentSel.EqualsExceptDirection(*pSelection)) {
+  if (selectionForTSF.EqualsExceptDirection(*pSelection)) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
        ("TSF: 0x%p   TSFTextStore::SetSelectionInternal() Succeeded but "
         "did nothing because the selection range isn't changing", this));
-    currentSel.SetSelection(*pSelection);
+    selectionForTSF.SetSelection(*pSelection);
     return S_OK;
   }
 
   if (mComposition.IsComposing()) {
     if (aDispatchCompositionChangeEvent) {
       HRESULT hr = RestartCompositionIfNecessary();
       if (FAILED(hr)) {
         MOZ_LOG(sTextStoreLog, LogLevel::Error,
@@ -2696,17 +2696,17 @@ TSFTextStore::SetSelectionInternal(const
     if (pSelection->acpStart < mComposition.mStart ||
         pSelection->acpEnd > mComposition.EndOffset()) {
       MOZ_LOG(sTextStoreLog, LogLevel::Error,
          ("TSF: 0x%p   TSFTextStore::SetSelectionInternal() FAILED due to "
           "the selection being out of the composition string", this));
       return TS_E_INVALIDPOS;
     }
     // Emulate selection during compositions
-    currentSel.SetSelection(*pSelection);
+    selectionForTSF.SetSelection(*pSelection);
     if (aDispatchCompositionChangeEvent) {
       HRESULT hr = RecordCompositionUpdateAction();
       if (FAILED(hr)) {
         MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::SetSelectionInternal() FAILED due to "
             "RecordCompositionUpdateAction() failure", this));
         return hr;
       }
@@ -2753,17 +2753,17 @@ TSFTextStore::SetSelectionInternal(const
   PendingAction* action = mPendingActions.AppendElement();
   action->mType = PendingAction::SET_SELECTION;
   action->mSelectionStart = selectionInContent.acpStart;
   action->mSelectionLength =
     selectionInContent.acpEnd - selectionInContent.acpStart;
   action->mSelectionReversed = (selectionInContent.style.ase == TS_AE_START);
 
   // Use TSF specified selection for updating mSelectionForTSF.
-  currentSel.SetSelection(*pSelection);
+  selectionForTSF.SetSelection(*pSelection);
 
   return S_OK;
 }
 
 STDMETHODIMP
 TSFTextStore::SetSelection(ULONG ulCount,
                            const TS_SELECTION_ACP* pSelection)
 {
@@ -3264,28 +3264,28 @@ TSFTextStore::RetrieveRequestedAttrs(ULO
       switch (i) {
         case eInputScope: {
           paAttrVals[count].varValue.vt = VT_UNKNOWN;
           RefPtr<IUnknown> inputScope = new InputScopeImpl(mInputScopes);
           paAttrVals[count].varValue.punkVal = inputScope.forget().take();
           break;
         }
         case eTextVerticalWriting: {
-          Selection& currentSelection = SelectionForTSFRef();
+          Selection& selectionForTSF = SelectionForTSFRef();
           paAttrVals[count].varValue.vt = VT_BOOL;
           paAttrVals[count].varValue.boolVal =
-            currentSelection.GetWritingMode().IsVertical()
-            ? VARIANT_TRUE : VARIANT_FALSE;
+            selectionForTSF.GetWritingMode().IsVertical() ? VARIANT_TRUE :
+                                                            VARIANT_FALSE;
           break;
         }
         case eTextOrientation: {
-          Selection& currentSelection = SelectionForTSFRef();
+          Selection& selectionForTSF = SelectionForTSFRef();
           paAttrVals[count].varValue.vt = VT_I4;
           paAttrVals[count].varValue.lVal =
-            currentSelection.GetWritingMode().IsVertical() ? 2700 : 0;
+            selectionForTSF.GetWritingMode().IsVertical() ? 2700 : 0;
           break;
         }
         default:
           MOZ_CRASH("Invalid index? Or not implemented yet?");
           break;
       }
     }
     count++;
@@ -3561,17 +3561,17 @@ TSFTextStore::GetTextExt(TsViewCookie vc
 
   // NOTE: TSF (at least on Win 8.1) doesn't return TS_E_NOLAYOUT to the
   // caller even if we return it.  It's converted to just E_FAIL.
   // However, this is fixed on Win 10.
 
   const TSFStaticSink* kSink = TSFStaticSink::GetInstance();
   if (mComposition.IsComposing() && mComposition.mStart < acpEnd &&
       mContentForTSF.IsLayoutChangedAfter(acpEnd)) {
-    const Selection& currentSel = SelectionForTSFRef();
+    const Selection& selectionForTSF = SelectionForTSFRef();
     // The bug of Microsoft Office IME 2010 for Japanese is similar to
     // MS-IME for Win 8.1 and Win 10.  Newer version of MS Office IME is not
     // released yet.  So, we can hack it without prefs  because there must be
     // no developers who want to disable this hack for tests.
     const bool kIsMSOfficeJapaneseIME2010 =
       kSink->IsMSOfficeJapaneseIME2010Active();
     // MS IME for Japanese doesn't support asynchronous handling at deciding
     // its suggest list window position.  The feature was implemented
@@ -3600,17 +3600,18 @@ TSFTextStore::GetTextExt(TsViewCookie vc
       }
       // Although, the condition is not clear, MS-IME sometimes retrieves the
       // caret rect immediately after modifying the composition string but
       // before unlocking the document.  In such case, we should return the
       // nearest character rect.
       else if ((kIsMSOfficeJapaneseIME2010 ||
                 sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret) &&
                acpStart == acpEnd &&
-               currentSel.IsCollapsed() && currentSel.EndOffset() == acpEnd) {
+               selectionForTSF.IsCollapsed() &&
+               selectionForTSF.EndOffset() == acpEnd) {
         acpEnd = acpStart = mContentForTSF.MinOffsetOfLayoutChanged();
         MOZ_LOG(sTextStoreLog, LogLevel::Debug,
                ("TSF: 0x%p   TSFTextStore::GetTextExt() hacked the offsets "
                 "of the caret of the composition string for TIP acpStart=%d, "
                 "acpEnd=%d", this, acpStart, acpEnd));
       }
     }
     // Free ChangJie 2010 and Easy Changjei 1.0.12.0 doesn't handle
@@ -3914,31 +3915,32 @@ TSFTextStore::InsertTextAtSelection(DWOR
     if (!pacpStart || !pacpEnd) {
       MOZ_LOG(sTextStoreLog, LogLevel::Error,
              ("TSF: 0x%p   TSFTextStore::InsertTextAtSelection() FAILED due to "
               "null argument", this));
       return E_INVALIDARG;
     }
 
     // Get selection first
-    Selection& currentSel = SelectionForTSFRef();
-    if (currentSel.IsDirty()) {
+    Selection& selectionForTSF = SelectionForTSFRef();
+    if (selectionForTSF.IsDirty()) {
       MOZ_LOG(sTextStoreLog, LogLevel::Error,
              ("TSF: 0x%p   TSFTextStore::InsertTextAtSelection() FAILED due to "
               "SelectionForTSFRef() failure", this));
       return E_FAIL;
     }
 
     // Simulate text insertion
-    *pacpStart = currentSel.StartOffset();
-    *pacpEnd = currentSel.EndOffset();
+    *pacpStart = selectionForTSF.StartOffset();
+    *pacpEnd = selectionForTSF.EndOffset();
     if (pChange) {
-      pChange->acpStart = currentSel.StartOffset();
-      pChange->acpOldEnd = currentSel.EndOffset();
-      pChange->acpNewEnd = currentSel.StartOffset() + static_cast<LONG>(cch);
+      pChange->acpStart = selectionForTSF.StartOffset();
+      pChange->acpOldEnd = selectionForTSF.EndOffset();
+      pChange->acpNewEnd =
+        selectionForTSF.StartOffset() + static_cast<LONG>(cch);
     }
   } else {
     if (!IsReadWriteLocked()) {
       MOZ_LOG(sTextStoreLog, LogLevel::Error,
              ("TSF: 0x%p   TSFTextStore::InsertTextAtSelection() FAILED due to "
               "not locked (read-write)", this));
       return TS_E_NOLOCK;
     }
@@ -4134,24 +4136,24 @@ TSFTextStore::RecordCompositionStartActi
     return S_OK;
   }
 
   PendingAction* action = mPendingActions.AppendElement();
   action->mType = PendingAction::COMPOSITION_START;
   action->mSelectionStart = aStart;
   action->mSelectionLength = aLength;
 
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::RecordCompositionStartAction() FAILED "
             "due to SelectionForTSFRef() failure", this));
     action->mAdjustSelection = true;
-  } else if (currentSel.MinOffset() != aStart ||
-             currentSel.MaxOffset() != aStart + aLength) {
+  } else if (selectionForTSF.MinOffset() != aStart ||
+             selectionForTSF.MaxOffset() != aStart + aLength) {
     // If new composition range is different from current selection range,
     // we need to set selection before dispatching compositionstart event.
     action->mAdjustSelection = true;
   } else {
     // We shouldn't dispatch selection set event before dispatching
     // compositionstart event because it may cause put caret different
     // position in HTML editor since generated flat text content and offset in
     // it are lossy data of HTML contents.
@@ -4326,31 +4328,31 @@ TSFTextStore::OnUpdateComposition(ITfCom
   if (FAILED(hr)) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::OnUpdateComposition() FAILED due to "
             "RecordCompositionUpdateAction() failure", this));
     return hr;
   }
 
   if (MOZ_LOG_TEST(sTextStoreLog, LogLevel::Info)) {
-    Selection& currentSel = SelectionForTSFRef();
-    if (currentSel.IsDirty()) {
+    Selection& selectionForTSF = SelectionForTSFRef();
+    if (selectionForTSF.IsDirty()) {
       MOZ_LOG(sTextStoreLog, LogLevel::Error,
              ("TSF: 0x%p   TSFTextStore::OnUpdateComposition() FAILED due to "
               "SelectionForTSFRef() failure", this));
       return E_FAIL;
     }
     MOZ_LOG(sTextStoreLog, LogLevel::Info,
            ("TSF: 0x%p   TSFTextStore::OnUpdateComposition() succeeded: "
             "mComposition={ mStart=%ld, mString=\"%s\" }, "
             "SelectionForTSFRef()={ acpStart=%ld, acpEnd=%ld, style.ase=%s }",
             this, mComposition.mStart,
             NS_ConvertUTF16toUTF8(mComposition.mString).get(),
-            currentSel.StartOffset(), currentSel.EndOffset(),
-            GetActiveSelEndName(currentSel.ActiveSelEnd())));
+            selectionForTSF.StartOffset(), selectionForTSF.EndOffset(),
+            GetActiveSelEndName(selectionForTSF.ActiveSelEnd())));
   }
   return S_OK;
 }
 
 STDMETHODIMP
 TSFTextStore::OnEndComposition(ITfCompositionView* pComposition)
 {
   MOZ_LOG(sTextStoreLog, LogLevel::Info,
@@ -5112,31 +5114,31 @@ TSFTextStore::CreateNativeCaret()
     return;
   }
 
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   TSFTextStore::CreateNativeCaret(), "
           "mComposition.IsComposing()=%s",
           this, GetBoolName(mComposition.IsComposing())));
 
-  Selection& currentSel = SelectionForTSFRef();
-  if (currentSel.IsDirty()) {
+  Selection& selectionForTSF = SelectionForTSFRef();
+  if (selectionForTSF.IsDirty()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::CreateNativeCaret() FAILED due to "
             "SelectionForTSFRef() failure", this));
     return;
   }
 
   WidgetQueryContentEvent queryCaretRect(true, eQueryCaretRect, mWidget);
   mWidget->InitEvent(queryCaretRect);
 
   WidgetQueryContentEvent::Options options;
   // XXX If this is called without composition and the selection isn't
   //     collapsed, is it OK?
-  int64_t caretOffset = currentSel.MaxOffset();
+  int64_t caretOffset = selectionForTSF.MaxOffset();
   if (mComposition.IsComposing()) {
     // If there is a composition, use insertion point relative query for
     // deciding caret position because composition might be at different
     // position where TSFTextStore believes it at.
     options.mRelativeToInsertionPoint = true;
     caretOffset -= mComposition.mStart;
   }
   queryCaretRect.InitForQueryCaretRect(caretOffset, options);