mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 19:10:36 +00:00
Bug 964718 Don't dispatch DOM event if internal event doesn't need that. Otherwise, implement Duplicate() method r=smaug
This commit is contained in:
parent
142d55ee85
commit
5c2e9920b9
@ -38,6 +38,8 @@ public:
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
// This event isn't an internal event of any DOM event.
|
||||
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
||||
"WidgetQueryContentEvent needs to support Duplicate()");
|
||||
MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
|
||||
return nullptr;
|
||||
}
|
||||
@ -149,14 +151,28 @@ public:
|
||||
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
// This event isn't an internal event of any DOM event.
|
||||
MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
|
||||
return nullptr;
|
||||
// NOTE: PluginEvent has to be dispatched to nsIFrame::HandleEvent().
|
||||
// So, this event needs to support Duplicate().
|
||||
MOZ_ASSERT(eventStructType == NS_PLUGIN_EVENT,
|
||||
"Duplicate() must be overridden by sub class");
|
||||
// Not copying widget, it is a weak reference.
|
||||
WidgetPluginEvent* result = new WidgetPluginEvent(false, message, nullptr);
|
||||
result->AssignPluginEventData(*this, true);
|
||||
result->mFlags = mFlags;
|
||||
return result;
|
||||
}
|
||||
|
||||
// If true, this event needs to be retargeted to focused document.
|
||||
// Otherwise, never retargeted. Defaults to false.
|
||||
bool retargetToFocusedDocument;
|
||||
|
||||
void AssignPluginEventData(const WidgetPluginEvent& aEvent,
|
||||
bool aCopyTargets)
|
||||
{
|
||||
AssignGUIEventData(aEvent, aCopyTargets);
|
||||
|
||||
retargetToFocusedDocument = aEvent.retargetToFocusedDocument;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -338,6 +338,8 @@ public:
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
// This event isn't an internal event of any DOM event.
|
||||
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
||||
"WidgetQueryContentEvent needs to support Duplicate()");
|
||||
MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
|
||||
return nullptr;
|
||||
}
|
||||
@ -469,6 +471,8 @@ public:
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
// This event isn't an internal event of any DOM event.
|
||||
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
||||
"WidgetSelectionEvent needs to support Duplicate()");
|
||||
MOZ_CRASH("WidgetSelectionEvent doesn't support Duplicate()");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -45,9 +45,19 @@ public:
|
||||
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
// This event isn't an internal event of any DOM event.
|
||||
MOZ_CRASH("WidgetGestureNotifyEvent doesn't support Duplicate()");
|
||||
return nullptr;
|
||||
// XXX Looks like this event is handled only in PostHandleEvent() of
|
||||
// EventStateManager. Therefore, it might be possible to handle this
|
||||
// in PreHandleEvent() and not to dispatch as a DOM event into the DOM
|
||||
// tree like ContentQueryEvent. Then, this event doesn't need to
|
||||
// support Duplicate().
|
||||
MOZ_ASSERT(eventStructType == NS_GESTURENOTIFY_EVENT,
|
||||
"Duplicate() must be overridden by sub class");
|
||||
// Not copying widget, it is a weak reference.
|
||||
WidgetGestureNotifyEvent* result =
|
||||
new WidgetGestureNotifyEvent(false, message, nullptr);
|
||||
result->AssignGestureNotifyEventData(*this, true);
|
||||
result->mFlags = mFlags;
|
||||
return result;
|
||||
}
|
||||
|
||||
enum ePanDirection
|
||||
@ -60,6 +70,15 @@ public:
|
||||
|
||||
ePanDirection panDirection;
|
||||
bool displayPanFeedback;
|
||||
|
||||
void AssignGestureNotifyEventData(const WidgetGestureNotifyEvent& aEvent,
|
||||
bool aCopyTargets)
|
||||
{
|
||||
AssignGUIEventData(aEvent, aCopyTargets);
|
||||
|
||||
panDirection = aEvent.panDirection;
|
||||
displayPanFeedback = aEvent.displayPanFeedback;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -232,6 +232,13 @@ WidgetEvent::IsAllowedToDispatchDOMEvent() const
|
||||
wheelEvent->deltaZ != 0.0;
|
||||
}
|
||||
|
||||
// Following events are handled in EventStateManager, so, we don't need to
|
||||
// dispatch DOM event for them into the DOM tree.
|
||||
case NS_QUERY_CONTENT_EVENT:
|
||||
case NS_SELECTION_EVENT:
|
||||
case NS_CONTENT_COMMAND_EVENT:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user