Bug 960871 part.5 Copy mRanges and related methods from WidgetTextEvent to WidgetCompositionEvent r=smaug

This commit is contained in:
Masayuki Nakano 2014-10-07 19:01:47 +09:00
parent 20ded1179a
commit 40622dd546
2 changed files with 43 additions and 4 deletions

View File

@ -320,12 +320,32 @@ public:
// 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;
}
};

View File

@ -494,14 +494,33 @@ struct ParamTraits<mozilla::WidgetCompositionEvent>
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;
}
};