Bug 960871 part.5 Copy mRanges and related methods from WidgetTextEvent to WidgetCompositionEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 07 Oct 2014 19:01:47 +0900
changeset 232355 97aa7fef7adc1c2f009df86a526aff937aa52ad9
parent 232354 279373ac52ffac806b4bf3f4856e43888daf9b4d
child 232356 5216b7b1e4e3115a11c126d4b52ecffff710f64c
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs960871
milestone35.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 960871 part.5 Copy mRanges and related methods from WidgetTextEvent to WidgetCompositionEvent r=smaug
widget/TextEvents.h
widget/nsGUIEventIPC.h
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -315,22 +315,42 @@ public:
     return result;
   }
 
   // The composition string or the commit string.  If the instance is a
   // compositionstart event, this is initialized with selected text by
   // TextComposition automatically.
   nsString mData;
 
+  nsRefPtr<TextRangeArray> mRanges;
+
   void AssignCompositionEventData(const WidgetCompositionEvent& aEvent,
                                   bool aCopyTargets)
   {
     AssignGUIEventData(aEvent, aCopyTargets);
 
     mData = aEvent.mData;
+
+    // Currently, we don't need to copy the other members because they are
+    // for internal use only (not available from JS).
+  }
+
+  bool IsComposing() const
+  {
+    return mRanges && mRanges->IsComposing();
+  }
+
+  uint32_t TargetClauseOffset() const
+  {
+    return mRanges ? mRanges->TargetClauseOffset() : 0;
+  }
+
+  uint32_t RangeCount() const
+  {
+    return mRanges ? mRanges->Length() : 0;
   }
 };
 
 /******************************************************************************
  * mozilla::WidgetQueryContentEvent
  ******************************************************************************/
 
 class WidgetQueryContentEvent : public WidgetGUIEvent
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -489,24 +489,43 @@ struct ParamTraits<mozilla::WidgetCompos
 {
   typedef mozilla::WidgetCompositionEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam));
     WriteParam(aMsg, aParam.mSeqno);
     WriteParam(aMsg, aParam.mData);
+    bool hasRanges = !!aParam.mRanges;
+    WriteParam(aMsg, hasRanges);
+    if (hasRanges) {
+      WriteParam(aMsg, *aParam.mRanges.get());
+    }
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
-    return ReadParam(aMsg, aIter,
-                     static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->mSeqno) &&
-           ReadParam(aMsg, aIter, &aResult->mData);
+    bool hasRanges;
+    if (!ReadParam(aMsg, aIter,
+                   static_cast<mozilla::WidgetGUIEvent*>(aResult)) ||
+        !ReadParam(aMsg, aIter, &aResult->mSeqno) ||
+        !ReadParam(aMsg, aIter, &aResult->mData) ||
+        !ReadParam(aMsg, aIter, &hasRanges)) {
+      return false;
+    }
+
+    if (!hasRanges) {
+      aResult->mRanges = nullptr;
+    } else {
+      aResult->mRanges = new mozilla::TextRangeArray();
+      if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) {
+        return false;
+      }
+    }
+    return true;
   }
 };
 
 template<>
 struct ParamTraits<mozilla::WidgetQueryContentEvent>
 {
   typedef mozilla::WidgetQueryContentEvent paramType;