forked from mirrors/gecko-dev
Bug 1449631 part 3. Remove nsIDOMEventTarget::RemoveSystemEventListener. r=smaug
MozReview-Commit-ID: F67Od8surQ8
This commit is contained in:
parent
1dce94cf16
commit
7c94e8697f
10 changed files with 37 additions and 65 deletions
|
|
@ -1133,22 +1133,16 @@ NS_IMETHODIMP
|
||||||
ChromeTooltipListener::RemoveTooltipListener()
|
ChromeTooltipListener::RemoveTooltipListener()
|
||||||
{
|
{
|
||||||
if (mEventTarget) {
|
if (mEventTarget) {
|
||||||
nsresult rv = NS_OK;
|
|
||||||
#ifndef XP_WIN
|
#ifndef XP_WIN
|
||||||
rv = mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keydown"),
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keydown"),
|
||||||
this, false);
|
this, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
#endif
|
#endif
|
||||||
rv = mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
||||||
this, false);
|
this, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mouseout"),
|
||||||
rv = mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mouseout"),
|
|
||||||
this, false);
|
this, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousemove"),
|
||||||
rv = mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousemove"),
|
|
||||||
this, false);
|
this, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
mTooltipListenerInstalled = false;
|
mTooltipListenerInstalled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -404,11 +404,9 @@ ScreenOrientation::UnlockDeviceOrientation()
|
||||||
// Remove event listener in case of fullscreen lock.
|
// Remove event listener in case of fullscreen lock.
|
||||||
nsCOMPtr<EventTarget> target = do_QueryInterface(GetOwner()->GetDoc());
|
nsCOMPtr<EventTarget> target = do_QueryInterface(GetOwner()->GetDoc());
|
||||||
if (target) {
|
if (target) {
|
||||||
DebugOnly<nsresult> rv =
|
|
||||||
target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
|
target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
|
||||||
mFullScreenListener,
|
mFullScreenListener,
|
||||||
/* useCapture */ true);
|
/* useCapture */ true);
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RemoveSystemEventListener failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mFullScreenListener = nullptr;
|
mFullScreenListener = nullptr;
|
||||||
|
|
@ -628,11 +626,8 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||||
ScreenOrientation* orientation = screen->Orientation();
|
ScreenOrientation* orientation = screen->Orientation();
|
||||||
MOZ_ASSERT(orientation);
|
MOZ_ASSERT(orientation);
|
||||||
|
|
||||||
rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
|
target->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
|
||||||
this, true);
|
this, true);
|
||||||
if (NS_WARN_IF(rv.Failed())) {
|
|
||||||
return rv.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc->CurrentOrientationType() != orientation->DeviceType(CallerType::System)) {
|
if (doc->CurrentOrientationType() != orientation->DeviceType(CallerType::System)) {
|
||||||
doc->SetCurrentOrientation(orientation->DeviceType(CallerType::System),
|
doc->SetCurrentOrientation(orientation->DeviceType(CallerType::System),
|
||||||
|
|
@ -684,9 +679,7 @@ ScreenOrientation::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||||
|
|
||||||
hal::UnlockScreenOrientation();
|
hal::UnlockScreenOrientation();
|
||||||
|
|
||||||
nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
|
target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
|
||||||
this, true);
|
this, true);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4481,8 +4481,6 @@ nsGlobalWindowInner::GetOwnerGlobalForBindings()
|
||||||
return nsPIDOMWindowOuter::GetFromCurrentInner(this);
|
return nsPIDOMWindowOuter::GetFromCurrentInner(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindowInner)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGlobalWindowInner::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
|
nsGlobalWindowInner::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6475,8 +6475,6 @@ nsGlobalWindowOuter::GetOwnerGlobalForBindings()
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindowOuter)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGlobalWindowOuter::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
|
nsGlobalWindowOuter::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1089,8 +1089,6 @@ nsINode::AddSystemEventListener(const nsAString& aType,
|
||||||
aWantsUntrusted);
|
aWantsUntrusted);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsINode)
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsINode::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
nsINode::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowRoot)
|
||||||
|
|
||||||
NS_IMPL_DOMTARGET_DEFAULTS(nsWindowRoot)
|
NS_IMPL_DOMTARGET_DEFAULTS(nsWindowRoot)
|
||||||
|
|
||||||
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsWindowRoot)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, bool *aRetVal)
|
nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, bool *aRetVal)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,6 @@ DOMEventTargetHelper::GetDocumentIfCurrent() const
|
||||||
return win->GetDoc();
|
return win->GetDoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(DOMEventTargetHelper)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DOMEventTargetHelper::AddEventListener(const nsAString& aType,
|
DOMEventTargetHelper::AddEventListener(const nsAString& aType,
|
||||||
nsIDOMEventListener* aListener,
|
nsIDOMEventListener* aListener,
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,20 @@ EventTarget::RemoveEventListener(const nsAString& aType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EventTarget::RemoveSystemEventListener(const nsAString& aType,
|
||||||
|
nsIDOMEventListener *aListener,
|
||||||
|
bool aUseCapture)
|
||||||
|
{
|
||||||
|
EventListenerManager* elm = GetExistingListenerManager();
|
||||||
|
if (elm) {
|
||||||
|
EventListenerFlags flags;
|
||||||
|
flags.mInSystemGroup = true;
|
||||||
|
flags.mCapture = aUseCapture;
|
||||||
|
elm->RemoveEventListenerByType(aListener, aType, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EventHandlerNonNull*
|
EventHandlerNonNull*
|
||||||
EventTarget::GetEventHandler(nsAtom* aType, const nsAString& aTypeString)
|
EventTarget::GetEventHandler(nsAtom* aType, const nsAString& aTypeString)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,14 @@ public:
|
||||||
void RemoveEventListener(const nsAString& aType,
|
void RemoveEventListener(const nsAString& aType,
|
||||||
nsIDOMEventListener* aListener,
|
nsIDOMEventListener* aListener,
|
||||||
bool aUseCapture);
|
bool aUseCapture);
|
||||||
|
/**
|
||||||
|
* RemoveSystemEventListener() should be used if you have used
|
||||||
|
* AddSystemEventListener().
|
||||||
|
*/
|
||||||
|
void RemoveSystemEventListener(const nsAString& aType,
|
||||||
|
nsIDOMEventListener* aListener,
|
||||||
|
bool aUseCapture);
|
||||||
|
|
||||||
bool DispatchEvent(Event& aEvent, CallerType aCallerType, ErrorResult& aRv);
|
bool DispatchEvent(Event& aEvent, CallerType aCallerType, ErrorResult& aRv);
|
||||||
|
|
||||||
nsIGlobalObject* GetParentObject() const
|
nsIGlobalObject* GetParentObject() const
|
||||||
|
|
|
||||||
|
|
@ -139,15 +139,6 @@ interface nsIDOMEventTarget : nsISupports
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/**
|
|
||||||
* removeSystemEventListener() should be used if you have used
|
|
||||||
* addSystemEventListener().
|
|
||||||
*/
|
|
||||||
[noscript] void removeSystemEventListener(
|
|
||||||
in DOMString type,
|
|
||||||
in nsIDOMEventListener listener,
|
|
||||||
[optional] in boolean aUseCapture);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method allows the dispatch of events into the implementations
|
* This method allows the dispatch of events into the implementations
|
||||||
* event model. Events dispatched in this manner will have the same
|
* event model. Events dispatched in this manner will have the same
|
||||||
|
|
@ -249,22 +240,4 @@ mozilla::dom::EventTarget* _class::GetTargetForDOMEvent() { return this; } \
|
||||||
mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; } \
|
mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; } \
|
||||||
nsresult _class::WillHandleEvent(mozilla::EventChainPostVisitor& aVisitor) { return NS_OK; }
|
nsresult _class::WillHandleEvent(mozilla::EventChainPostVisitor& aVisitor) { return NS_OK; }
|
||||||
|
|
||||||
#define NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(aClass) \
|
|
||||||
NS_IMETHODIMP \
|
|
||||||
aClass::RemoveSystemEventListener(const nsAString& aType, \
|
|
||||||
nsIDOMEventListener *aListener, \
|
|
||||||
bool aUseCapture) \
|
|
||||||
{ \
|
|
||||||
mozilla::EventListenerManager* listenerManager = \
|
|
||||||
GetExistingListenerManager(); \
|
|
||||||
if (!listenerManager) { \
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
|
||||||
mozilla::EventListenerFlags flags; \
|
|
||||||
flags.mInSystemGroup = true; \
|
|
||||||
flags.mCapture = aUseCapture; \
|
|
||||||
listenerManager->RemoveEventListenerByType(aListener, aType, flags); \
|
|
||||||
return NS_OK; \
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue