Bug 1455052 part 1. Switch event dispatch to working with Event, not nsIDOMEvent. r=masayuki

MozReview-Commit-ID: 4vZgmBnTWKH
This commit is contained in:
Boris Zbarsky 2018-04-20 12:53:16 -04:00
parent 4b2b2d4c9f
commit f1e26dcba7
7 changed files with 26 additions and 30 deletions

View File

@ -660,7 +660,7 @@ MayRetargetToChromeIfCanNotHandleEvent(
EventDispatcher::Dispatch(nsISupports* aTarget,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
Event* aDOMEvent,
nsEventStatus* aEventStatus,
EventDispatchingCallback* aCallback,
nsTArray<EventTarget*>* aTargets)
@ -809,7 +809,7 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
return NS_ERROR_FAILURE;
}
// Make sure that nsIDOMEvent::target and nsIDOMEvent::originalTarget
// Make sure that Event::target and Event::originalTarget
// point to the last item in the chain.
if (!aEvent->mTarget) {
// Note, CurrentTarget() points always to the object returned by
@ -987,7 +987,7 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
/* static */ nsresult
EventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
Event* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
@ -1000,7 +1000,7 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
innerEvent->mTarget = nullptr;
innerEvent->mOriginalTarget = nullptr;
} else {
aDOMEvent->GetIsTrusted(&dontResetTrusted);
dontResetTrusted = aDOMEvent->IsTrusted();
}
if (!dontResetTrusted) {

View File

@ -17,7 +17,6 @@
#undef CreateEvent
class nsIContent;
class nsIDOMEvent;
class nsPresContext;
template<class E> class nsCOMArray;
@ -53,7 +52,7 @@ class EventChainVisitor
public:
EventChainVisitor(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
dom::Event* aDOMEvent,
nsEventStatus aEventStatus = nsEventStatus_eIgnore)
: mPresContext(aPresContext)
, mEvent(aEvent)
@ -77,7 +76,7 @@ public:
* The DOM Event assiciated with the mEvent. Possibly nullptr if a DOM Event
* is not (yet) created.
*/
nsIDOMEvent* mDOMEvent;
dom::Event* mDOMEvent;
/**
* The status of the event.
@ -113,7 +112,7 @@ class EventChainPreVisitor : public EventChainVisitor
public:
EventChainPreVisitor(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
dom::Event* aDOMEvent,
nsEventStatus aEventStatus,
bool aIsInAnon,
dom::EventTarget* aTargetInKnownToBeHandledScope)
@ -327,7 +326,7 @@ public:
static nsresult Dispatch(nsISupports* aTarget,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent = nullptr,
dom::Event* aDOMEvent = nullptr,
nsEventStatus* aEventStatus = nullptr,
EventDispatchingCallback* aCallback = nullptr,
nsTArray<dom::EventTarget*>* aTargets = nullptr);
@ -338,11 +337,11 @@ public:
* (aEvent can then be nullptr) and (if aDOMEvent is not |trusted| already),
* the |trusted| flag is set based on the UniversalXPConnect capability.
* Otherwise this works like EventDispatcher::Dispatch.
* @note Use this method when dispatching nsIDOMEvent.
* @note Use this method when dispatching a dom::Event.
*/
static nsresult DispatchDOMEvent(nsISupports* aTarget,
WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
dom::Event* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);

View File

@ -1093,7 +1093,7 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
nsresult
EventListenerManager::HandleEventSubType(Listener* aListener,
nsIDOMEvent* aDOMEvent,
Event* aDOMEvent,
EventTarget* aCurrentTarget)
{
nsresult result = NS_OK;
@ -1111,15 +1111,14 @@ EventListenerManager::HandleEventSubType(Listener* aListener,
if (NS_SUCCEEDED(result)) {
nsAutoMicroTask mt;
// nsIDOMEvent::currentTarget is set in EventDispatcher.
// Event::currentTarget is set in EventDispatcher.
if (listenerHolder.HasWebIDLCallback()) {
ErrorResult rv;
listenerHolder.GetWebIDLCallback()->
HandleEvent(aCurrentTarget, *(aDOMEvent->InternalDOMEvent()), rv);
HandleEvent(aCurrentTarget, *aDOMEvent, rv);
result = rv.StealNSResult();
} else {
result = listenerHolder.GetXPCOMCallback()->
HandleEvent(aDOMEvent->InternalDOMEvent());
result = listenerHolder.GetXPCOMCallback()-> HandleEvent(aDOMEvent);
}
}
@ -1167,7 +1166,7 @@ EventListenerManager::GetLegacyEventMessage(EventMessage aEventMessage) const
void
EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent** aDOMEvent,
Event** aDOMEvent,
EventTarget* aCurrentTarget,
nsEventStatus* aEventStatus)
{
@ -1242,8 +1241,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
needsEndEventMarker = true;
nsAutoString typeStr;
(*aDOMEvent)->GetType(typeStr);
uint16_t phase;
(*aDOMEvent)->GetEventPhase(&phase);
uint16_t phase = (*aDOMEvent)->EventPhase();
timelines->AddMarkerForDocShell(docShell, Move(
MakeUnique<EventTimelineMarker>(
typeStr, phase, MarkerTracingType::START)));
@ -1278,8 +1276,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
TimeStamp endTime = TimeStamp::Now();
uint16_t phase;
(*aDOMEvent)->GetEventPhase(&phase);
uint16_t phase = (*aDOMEvent)->EventPhase();
profiler_add_marker(
"DOMEvent",
MakeUnique<DOMEventMarkerPayload>(typeStr, phase,

View File

@ -18,7 +18,6 @@
#include "nsTObserverArray.h"
class nsIDocShell;
class nsIDOMEvent;
class nsIEventListenerInfo;
class nsPIDOMWindowInner;
class JSTracer;
@ -33,6 +32,7 @@ class ELMCreationDetector;
class EventListenerManager;
namespace dom {
class Event;
class EventTarget;
class Element;
} // namespace dom
@ -367,7 +367,7 @@ public:
void HandleEvent(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent** aDOMEvent,
dom::Event** aDOMEvent,
dom::EventTarget* aCurrentTarget,
nsEventStatus* aEventStatus)
{
@ -497,12 +497,12 @@ public:
protected:
void HandleEventInternal(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIDOMEvent** aDOMEvent,
dom::Event** aDOMEvent,
dom::EventTarget* aCurrentTarget,
nsEventStatus* aEventStatus);
nsresult HandleEventSubType(Listener* aListener,
nsIDOMEvent* aDOMEvent,
dom::Event* aDOMEvent,
dom::EventTarget* aCurrentTarget);
/**

View File

@ -8100,7 +8100,7 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent,
// See the method above.
nsresult
PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
Event* aEvent,
nsEventStatus* aStatus)
{
nsresult rv = NS_OK;

View File

@ -237,7 +237,7 @@ public:
WidgetEvent* aEvent,
nsEventStatus* aStatus) override;
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
dom::Event* aEvent,
nsEventStatus* aStatus) override;
bool ShouldIgnoreInvalidation() override;
void WillPaint() override;

View File

@ -70,7 +70,6 @@ template<class E> class nsCOMArray;
class AutoWeakFrame;
class WeakFrame;
class nsIScrollableFrame;
class nsIDOMEvent;
class nsDisplayList;
class nsDisplayListBuilder;
class nsPIDOMWindowOuter;
@ -96,6 +95,7 @@ class EventStates;
namespace dom {
class Element;
class Event;
class HTMLSlotElement;
class Touch;
class Selection;
@ -945,8 +945,8 @@ public:
* @note The caller must have a strong reference to the PresShell.
*/
virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
nsEventStatus* aStatus) = 0;
mozilla::dom::Event* aEvent,
nsEventStatus* aStatus) = 0;
/**
* Return whether or not the event is valid to be dispatched