Bug 1498812 - Part 5: Allow registering System event listeners through nsSessionStoreUtils. r=nika

Our internal Visual Viewport scroll events are dispatched system group-only, so
this is the only way to catch them.

Differential Revision: https://phabricator.services.mozilla.com/D15686

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2019-01-11 19:49:28 +00:00
Родитель 81a88a63e8
Коммит ea0543a948
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -51,7 +51,8 @@ interface nsISessionStoreUtils : nsISupports
nsISupports addDynamicFrameFilteredListener(in EventTarget target,
in AString type,
in jsval listener,
in boolean useCapture);
in boolean useCapture,
[optional] in boolean mozSystemGroup);
/**
* Remove the passed-in filtered listener from the given event target, if it's
@ -66,7 +67,8 @@ interface nsISessionStoreUtils : nsISupports
void removeDynamicFrameFilteredListener(in EventTarget target,
in AString type,
in nsISupports listener,
in boolean useCapture);
in boolean useCapture,
[optional] in boolean mozSystemGroup);
/*
* Save the docShell.allow* properties

Просмотреть файл

@ -116,8 +116,8 @@ nsSessionStoreUtils::ForEachNonDynamicChildFrame(
NS_IMETHODIMP
nsSessionStoreUtils::AddDynamicFrameFilteredListener(
EventTarget* aTarget, const nsAString& aType,
JS::Handle<JS::Value> aListener, bool aUseCapture, JSContext* aCx,
nsISupports** aResult) {
JS::Handle<JS::Value> aListener, bool aUseCapture, bool aMozSystemGroup,
JSContext* aCx, nsISupports** aResult) {
if (NS_WARN_IF(!aListener.isObject())) {
return NS_ERROR_INVALID_ARG;
}
@ -131,7 +131,12 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(
nsCOMPtr<nsIDOMEventListener> filter(new DynamicFrameEventFilter(listener));
nsresult rv = aTarget->AddEventListener(aType, filter, aUseCapture);
nsresult rv;
if (aMozSystemGroup) {
rv = aTarget->AddSystemEventListener(aType, filter, aUseCapture);
} else {
rv = aTarget->AddEventListener(aType, filter, aUseCapture);
}
NS_ENSURE_SUCCESS(rv, rv);
filter.forget(aResult);
@ -142,13 +147,18 @@ NS_IMETHODIMP
nsSessionStoreUtils::RemoveDynamicFrameFilteredListener(EventTarget* aTarget,
const nsAString& aType,
nsISupports* aListener,
bool aUseCapture) {
bool aUseCapture,
bool aMozSystemGroup) {
NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE);
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(aListener);
NS_ENSURE_TRUE(listener, NS_ERROR_NO_INTERFACE);
aTarget->RemoveEventListener(aType, listener, aUseCapture);
if (aMozSystemGroup) {
aTarget->RemoveSystemEventListener(aType, listener, aUseCapture);
} else {
aTarget->RemoveEventListener(aType, listener, aUseCapture);
}
return NS_OK;
}