зеркало из https://github.com/mozilla/gecko-dev.git
Bug 386743 - Set default event bubbling/cancelable flags in the WidgetEvent constructor. r=smaug
This commit is contained in:
Родитель
55614d4c60
Коммит
547b61eae3
|
@ -264,6 +264,59 @@ public:
|
|||
|
||||
class WidgetEvent : public WidgetEventTime
|
||||
{
|
||||
private:
|
||||
void SetDefaultCancelableAndBubbles()
|
||||
{
|
||||
switch (mClass) {
|
||||
case eEditorInputEventClass:
|
||||
mFlags.mCancelable = false;
|
||||
mFlags.mBubbles = mFlags.mIsTrusted;
|
||||
break;
|
||||
case eMouseEventClass:
|
||||
mFlags.mCancelable = (mMessage != eMouseEnter &&
|
||||
mMessage != eMouseLeave);
|
||||
mFlags.mBubbles = (mMessage != eMouseEnter &&
|
||||
mMessage != eMouseLeave);
|
||||
break;
|
||||
case ePointerEventClass:
|
||||
mFlags.mCancelable = (mMessage != ePointerEnter &&
|
||||
mMessage != ePointerLeave &&
|
||||
mMessage != ePointerCancel &&
|
||||
mMessage != ePointerGotCapture &&
|
||||
mMessage != ePointerLostCapture);
|
||||
mFlags.mBubbles = (mMessage != ePointerEnter &&
|
||||
mMessage != ePointerLeave);
|
||||
break;
|
||||
case eDragEventClass:
|
||||
mFlags.mCancelable = (mMessage != eDragExit &&
|
||||
mMessage != eDragLeave &&
|
||||
mMessage != eDragEnd);
|
||||
mFlags.mBubbles = true;
|
||||
break;
|
||||
case eSMILTimeEventClass:
|
||||
mFlags.mCancelable = false;
|
||||
mFlags.mBubbles = false;
|
||||
break;
|
||||
case eTransitionEventClass:
|
||||
case eAnimationEventClass:
|
||||
case eSVGZoomEventClass:
|
||||
mFlags.mCancelable = false;
|
||||
mFlags.mBubbles = true;
|
||||
break;
|
||||
case eCompositionEventClass:
|
||||
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
||||
// However, it doesn't make sense for us, we cannot cancel
|
||||
// composition when we send compositionstart event.
|
||||
mFlags.mCancelable = false;
|
||||
mFlags.mBubbles = true;
|
||||
break;
|
||||
default:
|
||||
mFlags.mCancelable = true;
|
||||
mFlags.mBubbles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
WidgetEvent(bool aIsTrusted,
|
||||
EventMessage aMessage,
|
||||
|
@ -278,8 +331,7 @@ protected:
|
|||
MOZ_COUNT_CTOR(WidgetEvent);
|
||||
mFlags.Clear();
|
||||
mFlags.mIsTrusted = aIsTrusted;
|
||||
mFlags.mCancelable = true;
|
||||
mFlags.mBubbles = true;
|
||||
SetDefaultCancelableAndBubbles();
|
||||
}
|
||||
|
||||
WidgetEvent()
|
||||
|
@ -290,18 +342,8 @@ protected:
|
|||
|
||||
public:
|
||||
WidgetEvent(bool aIsTrusted, EventMessage aMessage)
|
||||
: WidgetEventTime()
|
||||
, mClass(eBasicEventClass)
|
||||
, mMessage(aMessage)
|
||||
, mRefPoint(0, 0)
|
||||
, mLastRefPoint(0, 0)
|
||||
, mSpecifiedEventType(nullptr)
|
||||
: WidgetEvent(aIsTrusted, aMessage, eBasicEventClass)
|
||||
{
|
||||
MOZ_COUNT_CTOR(WidgetEvent);
|
||||
mFlags.Clear();
|
||||
mFlags.mIsTrusted = aIsTrusted;
|
||||
mFlags.mCancelable = true;
|
||||
mFlags.mBubbles = true;
|
||||
}
|
||||
|
||||
virtual ~WidgetEvent()
|
||||
|
|
|
@ -244,7 +244,6 @@ public:
|
|||
: WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
|
||||
, mElapsedTime(0.0)
|
||||
{
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
@ -289,7 +288,6 @@ public:
|
|||
: WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
|
||||
, mElapsedTime(0.0)
|
||||
{
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
@ -330,7 +328,6 @@ public:
|
|||
InternalSVGZoomEvent(bool aIsTrusted, EventMessage aMessage)
|
||||
: WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eSVGZoomEventClass)
|
||||
{
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
@ -366,8 +363,6 @@ public:
|
|||
InternalSMILTimeEvent(bool aIsTrusted, EventMessage aMessage)
|
||||
: InternalUIEvent(aIsTrusted, aMessage, eSMILTimeEventClass)
|
||||
{
|
||||
mFlags.mBubbles = false;
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
|
|
@ -217,15 +217,6 @@ protected:
|
|||
, exit(eChild)
|
||||
, clickCount(0)
|
||||
{
|
||||
switch (aMessage) {
|
||||
case eMouseEnter:
|
||||
case eMouseLeave:
|
||||
mFlags.mBubbles = false;
|
||||
mFlags.mCancelable = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -237,17 +228,8 @@ public:
|
|||
acceptActivation(false), ignoreRootScrollFrame(false),
|
||||
reason(aReason), context(aContext), exit(eChild), clickCount(0)
|
||||
{
|
||||
switch (aMessage) {
|
||||
case eMouseEnter:
|
||||
case eMouseLeave:
|
||||
mFlags.mBubbles = false;
|
||||
mFlags.mCancelable = false;
|
||||
break;
|
||||
case eContextMenu:
|
||||
button = (context == eNormal) ? eRightButton : eLeftButton;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (aMessage == eContextMenu) {
|
||||
button = (context == eNormal) ? eRightButton : eLeftButton;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,8 +319,6 @@ public:
|
|||
, mUserCancelled(false)
|
||||
, mDefaultPreventedOnContent(false)
|
||||
{
|
||||
mFlags.mCancelable =
|
||||
(aMessage != eDragExit && aMessage != eDragLeave && aMessage != eDragEnd);
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
@ -675,7 +655,6 @@ public:
|
|||
, height(0)
|
||||
, isPrimary(true)
|
||||
{
|
||||
UpdateFlags();
|
||||
}
|
||||
|
||||
explicit WidgetPointerEvent(const WidgetMouseEvent& aEvent)
|
||||
|
@ -685,25 +664,6 @@ public:
|
|||
, isPrimary(true)
|
||||
{
|
||||
mClass = ePointerEventClass;
|
||||
UpdateFlags();
|
||||
}
|
||||
|
||||
void UpdateFlags()
|
||||
{
|
||||
switch (mMessage) {
|
||||
case ePointerEnter:
|
||||
case ePointerLeave:
|
||||
mFlags.mBubbles = false;
|
||||
mFlags.mCancelable = false;
|
||||
break;
|
||||
case ePointerCancel:
|
||||
case ePointerGotCapture:
|
||||
case ePointerLostCapture:
|
||||
mFlags.mCancelable = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
|
|
@ -498,10 +498,6 @@ public:
|
|||
, mNativeIMEContext(aWidget)
|
||||
, mOriginalMessage(eVoidEvent)
|
||||
{
|
||||
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
||||
// However, it doesn't make sense for us, we cannot cancel composition
|
||||
// when we send compositionstart event.
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
@ -854,14 +850,6 @@ public:
|
|||
: InternalUIEvent(aIsTrusted, aMessage, aWidget, eEditorInputEventClass)
|
||||
, mIsComposing(false)
|
||||
{
|
||||
if (!aIsTrusted) {
|
||||
mFlags.mBubbles = false;
|
||||
mFlags.mCancelable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mFlags.mBubbles = true;
|
||||
mFlags.mCancelable = false;
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
|
|
Загрузка…
Ссылка в новой задаче