Bug 974318 part.10 Remove WidgetTextEvent::rangeCount and WidgetTextEvent::rangeArray r=smaug

This commit is contained in:
Masayuki Nakano 2014-03-04 22:48:28 +09:00
parent 988a8c3033
commit 3a137667e8
4 changed files with 0 additions and 57 deletions

View File

@ -60,9 +60,6 @@ TextComposition::DispatchEvent(WidgetGUIEvent* aEvent,
{ {
if (aEvent->message == NS_COMPOSITION_UPDATE) { if (aEvent->message == NS_COMPOSITION_UPDATE) {
mLastData = aEvent->AsCompositionEvent()->data; mLastData = aEvent->AsCompositionEvent()->data;
} else if (aEvent->message == NS_TEXT_TEXT) {
// XXX This will be removed by later patch.
aEvent->AsTextEvent()->EnsureRanges();
} }
nsEventDispatcher::Dispatch(mNode, mPresContext, nsEventDispatcher::Dispatch(mNode, mPresContext,

View File

@ -2039,7 +2039,6 @@ TabChild::RecvTextEvent(const WidgetTextEvent& event)
{ {
WidgetTextEvent localEvent(event); WidgetTextEvent localEvent(event);
DispatchWidgetEvent(localEvent); DispatchWidgetEvent(localEvent);
IPC::ParamTraits<WidgetTextEvent>::Free(event);
return true; return true;
} }

View File

@ -181,8 +181,6 @@ private:
WidgetTextEvent() WidgetTextEvent()
: mSeqno(kLatestSeqno) : mSeqno(kLatestSeqno)
, rangeCount(0)
, rangeArray(nullptr)
, isChar(false) , isChar(false)
{ {
} }
@ -196,8 +194,6 @@ public:
WidgetTextEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) WidgetTextEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_TEXT_EVENT) : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_TEXT_EVENT)
, mSeqno(kLatestSeqno) , mSeqno(kLatestSeqno)
, rangeCount(0)
, rangeArray(nullptr)
, isChar(false) , isChar(false)
{ {
} }
@ -215,13 +211,6 @@ public:
// The composition string or the commit string. // The composition string or the commit string.
nsString theText; nsString theText;
// Count of rangeArray.
uint32_t rangeCount;
// Pointer to the first item of the ranges (clauses).
// Note that the range array may not specify a caret position; in that
// case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
// array.
TextRange* rangeArray;
// Indicates whether the event signifies printable text. // Indicates whether the event signifies printable text.
// XXX This is not a standard, and most platforms don't set this properly. // XXX This is not a standard, and most platforms don't set this properly.
// So, perhaps, we can get rid of this. // So, perhaps, we can get rid of this.
@ -239,34 +228,18 @@ public:
// for internal use only (not available from JS). // for internal use only (not available from JS).
} }
// XXX This copies all ranges from legacy member to new member.
// This will be removed later.
void EnsureRanges()
{
if (mRanges || !rangeCount) {
return;
}
mRanges = new TextRangeArray();
for (uint32_t i = 0; i < rangeCount; i++) {
mRanges->AppendElement(rangeArray[i]);
}
}
bool IsComposing() const bool IsComposing() const
{ {
const_cast<WidgetTextEvent*>(this)->EnsureRanges();
return mRanges && mRanges->IsComposing(); return mRanges && mRanges->IsComposing();
} }
uint32_t TargetClauseOffset() const uint32_t TargetClauseOffset() const
{ {
const_cast<WidgetTextEvent*>(this)->EnsureRanges();
return mRanges ? mRanges->TargetClauseOffset() : 0; return mRanges ? mRanges->TargetClauseOffset() : 0;
} }
uint32_t RangeCount() const uint32_t RangeCount() const
{ {
const_cast<WidgetTextEvent*>(this)->EnsureRanges();
return mRanges ? mRanges->Length() : 0; return mRanges ? mRanges->Length() : 0;
} }
}; };

View File

@ -420,11 +420,8 @@ struct ParamTraits<mozilla::WidgetTextEvent>
WriteParam(aMsg, aParam.mSeqno); WriteParam(aMsg, aParam.mSeqno);
WriteParam(aMsg, aParam.theText); WriteParam(aMsg, aParam.theText);
WriteParam(aMsg, aParam.isChar); WriteParam(aMsg, aParam.isChar);
WriteParam(aMsg, aParam.rangeCount);
bool hasRanges = !!aParam.mRanges; bool hasRanges = !!aParam.mRanges;
WriteParam(aMsg, hasRanges); WriteParam(aMsg, hasRanges);
for (uint32_t index = 0; index < aParam.rangeCount; index++)
WriteParam(aMsg, aParam.rangeArray[index]);
if (hasRanges) { if (hasRanges) {
WriteParam(aMsg, *aParam.mRanges.get()); WriteParam(aMsg, *aParam.mRanges.get());
} }
@ -438,27 +435,10 @@ struct ParamTraits<mozilla::WidgetTextEvent>
!ReadParam(aMsg, aIter, &aResult->mSeqno) || !ReadParam(aMsg, aIter, &aResult->mSeqno) ||
!ReadParam(aMsg, aIter, &aResult->theText) || !ReadParam(aMsg, aIter, &aResult->theText) ||
!ReadParam(aMsg, aIter, &aResult->isChar) || !ReadParam(aMsg, aIter, &aResult->isChar) ||
!ReadParam(aMsg, aIter, &aResult->rangeCount) ||
!ReadParam(aMsg, aIter, &hasRanges)) { !ReadParam(aMsg, aIter, &hasRanges)) {
return false; return false;
} }
if (!aResult->rangeCount) {
aResult->rangeArray = nullptr;
} else {
aResult->rangeArray = new mozilla::TextRange[aResult->rangeCount];
if (!aResult->rangeArray) {
return false;
}
for (uint32_t index = 0; index < aResult->rangeCount; index++) {
if (!ReadParam(aMsg, aIter, &aResult->rangeArray[index])) {
Free(*aResult);
return false;
}
}
}
if (!hasRanges) { if (!hasRanges) {
aResult->mRanges = nullptr; aResult->mRanges = nullptr;
} else { } else {
@ -472,12 +452,6 @@ struct ParamTraits<mozilla::WidgetTextEvent>
} }
return true; return true;
} }
static void Free(const paramType& aResult)
{
if (aResult.rangeArray)
delete [] aResult.rangeArray;
}
}; };
template<> template<>