mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 960871 part.7 Get rid of WidgetTextEvent r=smaug
This commit is contained in:
parent
9011740f12
commit
d08404080c
@ -702,7 +702,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
|
||||
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
|
||||
aEvent->AsKeyboardEvent());
|
||||
case eCompositionEventClass:
|
||||
case eTextEventClass:
|
||||
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext,
|
||||
aEvent->AsCompositionEvent());
|
||||
case eMouseEventClass:
|
||||
|
@ -288,11 +288,6 @@ NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aResult,
|
||||
nsPresContext* aPresContext,
|
||||
mozilla::WidgetEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMTextEvent(nsIDOMEvent** aResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
mozilla::WidgetTextEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
|
@ -22,7 +22,6 @@ NS_EVENT_CLASS(Internal, UIEvent)
|
||||
|
||||
// TextEvents.h
|
||||
NS_EVENT_CLASS(Widget, KeyboardEvent)
|
||||
NS_EVENT_CLASS(Widget, TextEvent)
|
||||
NS_EVENT_CLASS(Widget, CompositionEvent)
|
||||
NS_EVENT_CLASS(Widget, QueryContentEvent)
|
||||
NS_EVENT_CLASS(Widget, SelectionEvent)
|
||||
|
@ -194,80 +194,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::WidgetTextEvent
|
||||
*
|
||||
* XXX WidgetTextEvent is fired with compositionupdate event almost every time.
|
||||
* This wastes performance and the cost of mantaining each platform's
|
||||
* implementation. Therefore, we should merge WidgetTextEvent and
|
||||
* WidgetCompositionEvent. Then, DOM compositionupdate should be fired
|
||||
* from TextComposition automatically.
|
||||
******************************************************************************/
|
||||
|
||||
class WidgetTextEvent : public WidgetGUIEvent
|
||||
{
|
||||
private:
|
||||
friend class dom::PBrowserParent;
|
||||
friend class dom::PBrowserChild;
|
||||
friend class plugins::PPluginInstanceChild;
|
||||
|
||||
WidgetTextEvent()
|
||||
: mSeqno(kLatestSeqno)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
uint32_t mSeqno;
|
||||
|
||||
public:
|
||||
virtual WidgetTextEvent* AsTextEvent() MOZ_OVERRIDE { return this; }
|
||||
|
||||
WidgetTextEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
||||
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eTextEventClass)
|
||||
, mSeqno(kLatestSeqno)
|
||||
{
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(mClass == eTextEventClass,
|
||||
"Duplicate() must be overridden by sub class");
|
||||
// Not copying widget, it is a weak reference.
|
||||
WidgetTextEvent* result = new WidgetTextEvent(false, message, nullptr);
|
||||
result->AssignTextEventData(*this, true);
|
||||
result->mFlags = mFlags;
|
||||
return result;
|
||||
}
|
||||
|
||||
// The composition string or the commit string.
|
||||
nsString mData;
|
||||
|
||||
nsRefPtr<TextRangeArray> mRanges;
|
||||
|
||||
void AssignTextEventData(const WidgetTextEvent& aEvent, bool aCopyTargets)
|
||||
{
|
||||
AssignGUIEventData(aEvent, aCopyTargets);
|
||||
|
||||
// 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::WidgetCompositionEvent
|
||||
******************************************************************************/
|
||||
|
@ -441,49 +441,6 @@ struct ParamTraits<mozilla::TextRangeArray>
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::WidgetTextEvent>
|
||||
{
|
||||
typedef mozilla::WidgetTextEvent 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)
|
||||
{
|
||||
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 (!aResult->mRanges) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::WidgetCompositionEvent>
|
||||
{
|
||||
|
@ -291,9 +291,6 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
|
||||
case eCompositionEventClass:
|
||||
seqno = event->AsCompositionEvent()->mSeqno;
|
||||
break;
|
||||
case eTextEventClass:
|
||||
seqno = event->AsTextEvent()->mSeqno;
|
||||
break;
|
||||
case eSelectionEventClass:
|
||||
seqno = event->AsSelectionEvent()->mSeqno;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user