Bug 960871 part.5 Copy mRanges and related methods from WidgetTextEvent to WidgetCompositionEvent r=smaug
--- 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;