Bug 1922437 - Rename nsIAndroid* classes to nsIGeckoView*. r=geckoview-reviewers,nika,frontend-codestyle-reviewers,owlish
Differential Revision: https://phabricator.services.mozilla.com/D224429
This commit is contained in:
@@ -98,7 +98,7 @@ function createChromeScript() {
|
||||
function requestDocument() {
|
||||
// GeckoView shows an error page for CSP errors, which breaks this test, so just skip in that case.
|
||||
try {
|
||||
if (!SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIAndroidBridge).isFennec) {
|
||||
if (!SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIGeckoViewBridge).isFennec) {
|
||||
return false;
|
||||
}
|
||||
} catch (e){}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
const isLinux = AppConstants.platform == "linux";
|
||||
const isInsecureContext = !window.isSecureContext;
|
||||
// Currently, MOZ_APP_NAME is always "fennec" for all mobile builds, so we can't use AppConstants for this
|
||||
const isFennec = isAndroid && SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIAndroidBridge).isFennec;
|
||||
const isFennec = isAndroid && SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIGeckoViewBridge).isFennec;
|
||||
|
||||
const result = {
|
||||
isNightly, isEarlyBetaOrEarlier, isRelease, isDesktop, isMac,
|
||||
|
||||
@@ -49,7 +49,7 @@ const isInsecureContext = !window.isSecureContext;
|
||||
const isFennec =
|
||||
isAndroid &&
|
||||
SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(
|
||||
SpecialPowers.Ci.nsIAndroidBridge
|
||||
SpecialPowers.Ci.nsIGeckoViewBridge
|
||||
).isFennec;
|
||||
const isCrossOriginIsolated = window.crossOriginIsolated;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ function workerTestExec(script) {
|
||||
const isFennec =
|
||||
isAndroid &&
|
||||
SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(
|
||||
SpecialPowers.Ci.nsIAndroidBridge
|
||||
SpecialPowers.Ci.nsIGeckoViewBridge
|
||||
).isFennec;
|
||||
const isCrossOriginIsolated = window.crossOriginIsolated;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ XPCOMUtils.defineLazyScriptGetter(
|
||||
*/
|
||||
var ModuleManager = {
|
||||
get _initData() {
|
||||
return window.arguments[0].QueryInterface(Ci.nsIAndroidView).initData;
|
||||
return window.arguments[0].QueryInterface(Ci.nsIGeckoViewView).initData;
|
||||
},
|
||||
|
||||
init(aBrowser, aModules) {
|
||||
|
||||
@@ -195,7 +195,7 @@ void GeckoViewHistory::StartPendingVisitedQueries(
|
||||
* Called from the session handler for the history delegate, after the new
|
||||
* visit is recorded.
|
||||
*/
|
||||
class OnVisitedCallback final : public nsIAndroidEventCallback {
|
||||
class OnVisitedCallback final : public nsIGeckoViewEventCallback {
|
||||
public:
|
||||
explicit OnVisitedCallback(GeckoViewHistory* aHistory, nsIURI* aURI)
|
||||
: mHistory(aHistory), mURI(aURI) {}
|
||||
@@ -233,7 +233,7 @@ class OnVisitedCallback final : public nsIAndroidEventCallback {
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(OnVisitedCallback, nsIAndroidEventCallback)
|
||||
NS_IMPL_ISUPPORTS(OnVisitedCallback, nsIGeckoViewEventCallback)
|
||||
|
||||
NS_IMETHODIMP
|
||||
GeckoViewHistory::VisitURI(nsIWidget* aWidget, nsIURI* aURI,
|
||||
@@ -331,7 +331,7 @@ GeckoViewHistory::VisitURI(nsIWidget* aWidget, nsIURI* aURI,
|
||||
}
|
||||
auto bundle = java::GeckoBundle::New(bundleKeys, bundleValues);
|
||||
|
||||
nsCOMPtr<nsIAndroidEventCallback> callback =
|
||||
nsCOMPtr<nsIGeckoViewEventCallback> callback =
|
||||
new OnVisitedCallback(this, aURI);
|
||||
|
||||
Unused << NS_WARN_IF(
|
||||
@@ -349,7 +349,7 @@ GeckoViewHistory::SetURITitle(nsIURI* aURI, const nsAString& aTitle) {
|
||||
* Called from the session handler for the history delegate, with visited
|
||||
* statuses for all requested URIs.
|
||||
*/
|
||||
class GetVisitedCallback final : public nsIAndroidEventCallback {
|
||||
class GetVisitedCallback final : public nsIGeckoViewEventCallback {
|
||||
public:
|
||||
explicit GetVisitedCallback(GeckoViewHistory* aHistory,
|
||||
ContentParent* aInterestedProcess,
|
||||
@@ -437,7 +437,7 @@ class GetVisitedCallback final : public nsIAndroidEventCallback {
|
||||
nsTArray<RefPtr<nsIURI>> mURIs;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(GetVisitedCallback, nsIAndroidEventCallback)
|
||||
NS_IMPL_ISUPPORTS(GetVisitedCallback, nsIGeckoViewEventCallback)
|
||||
|
||||
/**
|
||||
* Queries the history delegate to find which URIs have been visited. This
|
||||
@@ -483,7 +483,7 @@ void GeckoViewHistory::QueryVisitedState(nsIWidget* aWidget,
|
||||
|
||||
auto bundle = java::GeckoBundle::New(bundleKeys, bundleValues);
|
||||
|
||||
nsCOMPtr<nsIAndroidEventCallback> callback =
|
||||
nsCOMPtr<nsIGeckoViewEventCallback> callback =
|
||||
new GetVisitedCallback(this, aInterestedProcess, std::move(aURIs));
|
||||
|
||||
Unused << NS_WARN_IF(
|
||||
|
||||
@@ -58,7 +58,7 @@ DispatcherDelegate.prototype = {
|
||||
/**
|
||||
* Register a listener to be notified of event(s).
|
||||
*
|
||||
* @param aListener Target listener implementing nsIAndroidEventListener.
|
||||
* @param aListener Target listener implementing nsIGeckoViewEventListener.
|
||||
* @param aEvents String or array of strings of events to listen to.
|
||||
*/
|
||||
registerListener(aListener, aEvents) {
|
||||
@@ -71,7 +71,7 @@ DispatcherDelegate.prototype = {
|
||||
/**
|
||||
* Unregister a previously-registered listener.
|
||||
*
|
||||
* @param aListener Registered listener implementing nsIAndroidEventListener.
|
||||
* @param aListener Registered listener implementing nsIGeckoViewEventListener.
|
||||
* @param aEvents String or array of strings of events to stop listening to.
|
||||
*/
|
||||
unregisterListener(aListener, aEvents) {
|
||||
@@ -88,8 +88,8 @@ DispatcherDelegate.prototype = {
|
||||
*
|
||||
* @param aEvent Name of event to dispatch.
|
||||
* @param aData Optional object containing data for the event.
|
||||
* @param aCallback Optional callback implementing nsIAndroidEventCallback.
|
||||
* @param aFinalizer Optional finalizer implementing nsIAndroidEventFinalizer.
|
||||
* @param aCallback Optional callback implementing nsIGeckoViewEventCallback.
|
||||
* @param aFinalizer Optional finalizer implementing nsIGeckoViewEventFinalizer.
|
||||
*/
|
||||
dispatch(aEvent, aData, aCallback, aFinalizer) {
|
||||
if (this._dispatcher) {
|
||||
@@ -120,7 +120,7 @@ DispatcherDelegate.prototype = {
|
||||
* Sends a request to Java.
|
||||
*
|
||||
* @param aMsg Message to send; must be an object with a "type" property
|
||||
* @param aCallback Optional callback implementing nsIAndroidEventCallback.
|
||||
* @param aCallback Optional callback implementing nsIGeckoViewEventCallback.
|
||||
*/
|
||||
sendRequest(aMsg, aCallback) {
|
||||
const type = aMsg.type;
|
||||
@@ -215,7 +215,7 @@ export var EventDispatcher = {
|
||||
aWindow &&
|
||||
aWindow.arguments &&
|
||||
aWindow.arguments[0] &&
|
||||
aWindow.arguments[0].QueryInterface(Ci.nsIAndroidView);
|
||||
aWindow.arguments[0].QueryInterface(Ci.nsIGeckoViewView);
|
||||
|
||||
if (!view) {
|
||||
const mm = !IS_PARENT_PROCESS && aWindow && aWindow.messageManager;
|
||||
|
||||
@@ -56,8 +56,8 @@ function run_test() {
|
||||
if ("nsISearchService" in Ci) {
|
||||
checkService("search", Ci.nsISearchService);
|
||||
}
|
||||
if ("nsIAndroidBridge" in Ci) {
|
||||
checkService("androidBridge", Ci.nsIAndroidBridge);
|
||||
if ("nsIGeckoViewBridge" in Ci) {
|
||||
checkService("androidBridge", Ci.nsIGeckoViewBridge);
|
||||
}
|
||||
if ("@mozilla.org/enterprisepolicies;1" in Cc) {
|
||||
checkService("policies", Ci.nsIEnterprisePolicies);
|
||||
|
||||
@@ -54,8 +54,8 @@ const platformSpecificInterfaces = new Map([
|
||||
["amIFoo", "any"],
|
||||
["nsIMeh", "any"],
|
||||
// Can't easily detect android builds from ESLint at the moment.
|
||||
["nsIAndroidBridge", "any"],
|
||||
["nsIAndroidView", "any"],
|
||||
["nsIGeckoViewBridge", "any"],
|
||||
["nsIGeckoViewView", "any"],
|
||||
// Code coverage is enabled only for certain builds (MOZ_CODE_COVERAGE).
|
||||
["nsICodeCoverage", "any"],
|
||||
// Layout debugging is enabled only for certain builds (MOZ_LAYOUT_DEBUGGER).
|
||||
|
||||
@@ -284,7 +284,8 @@ jobject AndroidBridge::GetGlobalContextRef() {
|
||||
}
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS(nsAndroidBridge, nsIAndroidEventDispatcher, nsIAndroidBridge)
|
||||
NS_IMPL_ISUPPORTS(nsAndroidBridge, nsIGeckoViewEventDispatcher,
|
||||
nsIGeckoViewBridge)
|
||||
|
||||
nsAndroidBridge::nsAndroidBridge() {
|
||||
if (jni::IsAvailable()) {
|
||||
@@ -297,7 +298,7 @@ nsAndroidBridge::nsAndroidBridge() {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidBridge::GetDispatcherByName(const char* aName,
|
||||
nsIAndroidEventDispatcher** aResult) {
|
||||
nsIGeckoViewEventDispatcher** aResult) {
|
||||
if (!jni::IsAvailable()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -255,19 +255,19 @@ class AutoLocalJNIFrame {
|
||||
} \
|
||||
}
|
||||
|
||||
class nsAndroidBridge final : public nsIAndroidBridge {
|
||||
class nsAndroidBridge final : public nsIGeckoViewBridge {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIANDROIDBRIDGE
|
||||
NS_DECL_NSIGECKOVIEWBRIDGE
|
||||
|
||||
NS_FORWARD_SAFE_NSIANDROIDEVENTDISPATCHER(mEventDispatcher)
|
||||
NS_FORWARD_SAFE_NSIGECKOVIEWEVENTDISPATCHER(mEventDispatcher)
|
||||
|
||||
nsAndroidBridge();
|
||||
|
||||
private:
|
||||
~nsAndroidBridge();
|
||||
|
||||
nsCOMPtr<nsIAndroidEventDispatcher> mEventDispatcher;
|
||||
nsCOMPtr<nsIGeckoViewEventDispatcher> mEventDispatcher;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
class AndroidView final : public nsIAndroidView {
|
||||
class AndroidView final : public nsIGeckoViewView {
|
||||
virtual ~AndroidView() {}
|
||||
|
||||
public:
|
||||
@@ -22,9 +22,9 @@ class AndroidView final : public nsIAndroidView {
|
||||
AndroidView() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIANDROIDVIEW
|
||||
NS_DECL_NSIGECKOVIEWVIEW
|
||||
|
||||
NS_FORWARD_NSIANDROIDEVENTDISPATCHER(mEventDispatcher->)
|
||||
NS_FORWARD_NSIGECKOVIEWEVENTDISPATCHER(mEventDispatcher->)
|
||||
|
||||
mozilla::java::GeckoBundle::GlobalRef mInitData;
|
||||
};
|
||||
|
||||
@@ -292,7 +292,7 @@ nsresult UnboxData(jni::String::Param aEvent, JSContext* aCx,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
class JavaCallbackDelegate final : public nsIAndroidEventCallback {
|
||||
class JavaCallbackDelegate final : public nsIGeckoViewEventCallback {
|
||||
const java::EventCallback::GlobalRef mCallback;
|
||||
|
||||
virtual ~JavaCallbackDelegate() {}
|
||||
@@ -328,7 +328,7 @@ class JavaCallbackDelegate final : public nsIAndroidEventCallback {
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(JavaCallbackDelegate, nsIAndroidEventCallback)
|
||||
NS_IMPL_ISUPPORTS(JavaCallbackDelegate, nsIGeckoViewEventCallback)
|
||||
|
||||
class NativeCallbackDelegateSupport final
|
||||
: public java::EventDispatcher::NativeCallbackDelegate ::Natives<
|
||||
@@ -336,13 +336,13 @@ class NativeCallbackDelegateSupport final
|
||||
using CallbackDelegate = java::EventDispatcher::NativeCallbackDelegate;
|
||||
using Base = CallbackDelegate::Natives<NativeCallbackDelegateSupport>;
|
||||
|
||||
const nsCOMPtr<nsIAndroidEventCallback> mCallback;
|
||||
const nsCOMPtr<nsIAndroidEventFinalizer> mFinalizer;
|
||||
const nsCOMPtr<nsIGeckoViewEventCallback> mCallback;
|
||||
const nsCOMPtr<nsIGeckoViewEventFinalizer> mFinalizer;
|
||||
const nsCOMPtr<nsIGlobalObject> mGlobalObject;
|
||||
|
||||
void Call(jni::Object::Param aData,
|
||||
nsresult (nsIAndroidEventCallback::*aCall)(JS::Handle<JS::Value>,
|
||||
JSContext*)) {
|
||||
nsresult (nsIGeckoViewEventCallback::*aCall)(JS::Handle<JS::Value>,
|
||||
JSContext*)) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Use either the attached window's realm or a default realm.
|
||||
@@ -376,8 +376,8 @@ class NativeCallbackDelegateSupport final
|
||||
DisposeNative(aInstance);
|
||||
}
|
||||
|
||||
NativeCallbackDelegateSupport(nsIAndroidEventCallback* callback,
|
||||
nsIAndroidEventFinalizer* finalizer,
|
||||
NativeCallbackDelegateSupport(nsIGeckoViewEventCallback* callback,
|
||||
nsIGeckoViewEventFinalizer* finalizer,
|
||||
nsIGlobalObject* globalObject)
|
||||
: mCallback(callback),
|
||||
mFinalizer(finalizer),
|
||||
@@ -390,17 +390,17 @@ class NativeCallbackDelegateSupport final
|
||||
}
|
||||
|
||||
void SendSuccess(jni::Object::Param aData) {
|
||||
Call(aData, &nsIAndroidEventCallback::OnSuccess);
|
||||
Call(aData, &nsIGeckoViewEventCallback::OnSuccess);
|
||||
}
|
||||
|
||||
void SendError(jni::Object::Param aData) {
|
||||
Call(aData, &nsIAndroidEventCallback::OnError);
|
||||
Call(aData, &nsIGeckoViewEventCallback::OnError);
|
||||
}
|
||||
};
|
||||
|
||||
class FinalizingCallbackDelegate final : public nsIAndroidEventCallback {
|
||||
const nsCOMPtr<nsIAndroidEventCallback> mCallback;
|
||||
const nsCOMPtr<nsIAndroidEventFinalizer> mFinalizer;
|
||||
class FinalizingCallbackDelegate final : public nsIGeckoViewEventCallback {
|
||||
const nsCOMPtr<nsIGeckoViewEventCallback> mCallback;
|
||||
const nsCOMPtr<nsIGeckoViewEventFinalizer> mFinalizer;
|
||||
|
||||
virtual ~FinalizingCallbackDelegate() {
|
||||
if (mFinalizer) {
|
||||
@@ -409,21 +409,21 @@ class FinalizingCallbackDelegate final : public nsIAndroidEventCallback {
|
||||
}
|
||||
|
||||
public:
|
||||
FinalizingCallbackDelegate(nsIAndroidEventCallback* aCallback,
|
||||
nsIAndroidEventFinalizer* aFinalizer)
|
||||
FinalizingCallbackDelegate(nsIGeckoViewEventCallback* aCallback,
|
||||
nsIGeckoViewEventFinalizer* aFinalizer)
|
||||
: mCallback(aCallback), mFinalizer(aFinalizer) {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_NSIANDROIDEVENTCALLBACK(mCallback->);
|
||||
NS_FORWARD_NSIGECKOVIEWEVENTCALLBACK(mCallback->);
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(FinalizingCallbackDelegate, nsIAndroidEventCallback)
|
||||
NS_IMPL_ISUPPORTS(FinalizingCallbackDelegate, nsIGeckoViewEventCallback)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using namespace detail;
|
||||
|
||||
NS_IMPL_ISUPPORTS(EventDispatcher, nsIAndroidEventDispatcher)
|
||||
NS_IMPL_ISUPPORTS(EventDispatcher, nsIGeckoViewEventDispatcher)
|
||||
|
||||
nsIGlobalObject* EventDispatcher::GetGlobalObject() {
|
||||
if (mDOMWindow) {
|
||||
@@ -432,10 +432,9 @@ nsIGlobalObject* EventDispatcher::GetGlobalObject() {
|
||||
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
nsresult EventDispatcher::DispatchOnGecko(ListenersList* list,
|
||||
const nsAString& aEvent,
|
||||
JS::Handle<JS::Value> aData,
|
||||
nsIAndroidEventCallback* aCallback) {
|
||||
nsresult EventDispatcher::DispatchOnGecko(
|
||||
ListenersList* list, const nsAString& aEvent, JS::Handle<JS::Value> aData,
|
||||
nsIGeckoViewEventCallback* aCallback) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
dom::AutoNoJSAPI nojsapi;
|
||||
|
||||
@@ -469,8 +468,8 @@ nsresult EventDispatcher::DispatchOnGecko(ListenersList* list,
|
||||
}
|
||||
|
||||
java::EventDispatcher::NativeCallbackDelegate::LocalRef
|
||||
EventDispatcher::WrapCallback(nsIAndroidEventCallback* aCallback,
|
||||
nsIAndroidEventFinalizer* aFinalizer) {
|
||||
EventDispatcher::WrapCallback(nsIGeckoViewEventCallback* aCallback,
|
||||
nsIGeckoViewEventFinalizer* aFinalizer) {
|
||||
if (!aCallback) {
|
||||
return java::EventDispatcher::NativeCallbackDelegate::LocalRef(
|
||||
jni::GetGeckoThreadEnv());
|
||||
@@ -497,8 +496,8 @@ bool EventDispatcher::HasListener(const char16_t* aEvent) {
|
||||
NS_IMETHODIMP
|
||||
EventDispatcher::Dispatch(JS::Handle<JS::Value> aEvent,
|
||||
JS::Handle<JS::Value> aData,
|
||||
nsIAndroidEventCallback* aCallback,
|
||||
nsIAndroidEventFinalizer* aFinalizer,
|
||||
nsIGeckoViewEventCallback* aCallback,
|
||||
nsIGeckoViewEventFinalizer* aFinalizer,
|
||||
JSContext* aCx) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@@ -519,7 +518,7 @@ EventDispatcher::Dispatch(JS::Handle<JS::Value> aEvent,
|
||||
if (!aCallback || !aFinalizer) {
|
||||
return DispatchOnGecko(list, event, aData, aCallback);
|
||||
}
|
||||
nsCOMPtr<nsIAndroidEventCallback> callback(
|
||||
nsCOMPtr<nsIGeckoViewEventCallback> callback(
|
||||
new FinalizingCallbackDelegate(aCallback, aFinalizer));
|
||||
return DispatchOnGecko(list, event, aData, callback);
|
||||
}
|
||||
@@ -545,7 +544,7 @@ EventDispatcher::Dispatch(JS::Handle<JS::Value> aEvent,
|
||||
|
||||
nsresult EventDispatcher::Dispatch(const char16_t* aEvent,
|
||||
java::GeckoBundle::Param aData,
|
||||
nsIAndroidEventCallback* aCallback) {
|
||||
nsIGeckoViewEventCallback* aCallback) {
|
||||
nsDependentString event(aEvent);
|
||||
|
||||
ListenersList* list = mListenersMap.Get(event);
|
||||
@@ -571,7 +570,7 @@ nsresult EventDispatcher::Dispatch(const char16_t* aEvent,
|
||||
nsresult EventDispatcher::IterateEvents(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aEvents,
|
||||
IterateEventsCallback aCallback,
|
||||
nsIAndroidEventListener* aListener) {
|
||||
nsIGeckoViewEventListener* aListener) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
@@ -613,7 +612,7 @@ nsresult EventDispatcher::IterateEvents(JSContext* aCx,
|
||||
}
|
||||
|
||||
nsresult EventDispatcher::RegisterEventLocked(
|
||||
const nsAString& aEvent, nsIAndroidEventListener* aListener) {
|
||||
const nsAString& aEvent, nsIGeckoViewEventListener* aListener) {
|
||||
ListenersList* list = mListenersMap.GetOrInsertNew(aEvent);
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -628,7 +627,7 @@ nsresult EventDispatcher::RegisterEventLocked(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EventDispatcher::RegisterListener(nsIAndroidEventListener* aListener,
|
||||
EventDispatcher::RegisterListener(nsIGeckoViewEventListener* aListener,
|
||||
JS::Handle<JS::Value> aEvents,
|
||||
JSContext* aCx) {
|
||||
return IterateEvents(aCx, aEvents, &EventDispatcher::RegisterEventLocked,
|
||||
@@ -636,7 +635,7 @@ EventDispatcher::RegisterListener(nsIAndroidEventListener* aListener,
|
||||
}
|
||||
|
||||
nsresult EventDispatcher::UnregisterEventLocked(
|
||||
const nsAString& aEvent, nsIAndroidEventListener* aListener) {
|
||||
const nsAString& aEvent, nsIGeckoViewEventListener* aListener) {
|
||||
ListenersList* list = mListenersMap.Get(aEvent);
|
||||
#ifdef DEBUG
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -666,7 +665,7 @@ nsresult EventDispatcher::UnregisterEventLocked(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EventDispatcher::UnregisterListener(nsIAndroidEventListener* aListener,
|
||||
EventDispatcher::UnregisterListener(nsIGeckoViewEventListener* aListener,
|
||||
JS::Handle<JS::Value> aEvents,
|
||||
JSContext* aCx) {
|
||||
return IterateEvents(aCx, aEvents, &EventDispatcher::UnregisterEventLocked,
|
||||
@@ -747,7 +746,7 @@ void EventDispatcher::DispatchToGecko(jni::String::Param aEvent,
|
||||
/* BundleOnly */ true);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsCOMPtr<nsIAndroidEventCallback> callback;
|
||||
nsCOMPtr<nsIGeckoViewEventCallback> callback;
|
||||
if (aCallback) {
|
||||
callback =
|
||||
new JavaCallbackDelegate(java::EventCallback::Ref::From(aCallback));
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace widget {
|
||||
* side may notify event listeners on the Gecko side, and vice versa.
|
||||
*/
|
||||
class EventDispatcher final
|
||||
: public nsIAndroidEventDispatcher,
|
||||
: public nsIGeckoViewEventDispatcher,
|
||||
public java::EventDispatcher::Natives<EventDispatcher> {
|
||||
using NativesBase = java::EventDispatcher::Natives<EventDispatcher>;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIANDROIDEVENTDISPATCHER
|
||||
NS_DECL_NSIGECKOVIEWEVENTDISPATCHER
|
||||
|
||||
EventDispatcher() {}
|
||||
|
||||
@@ -43,7 +43,7 @@ class EventDispatcher final
|
||||
|
||||
nsresult Dispatch(const char16_t* aEvent,
|
||||
java::GeckoBundle::Param aData = nullptr,
|
||||
nsIAndroidEventCallback* aCallback = nullptr);
|
||||
nsIGeckoViewEventCallback* aCallback = nullptr);
|
||||
|
||||
bool HasListener(const char16_t* aEvent);
|
||||
bool HasGeckoListener(jni::String::Param aEvent);
|
||||
@@ -68,7 +68,7 @@ class EventDispatcher final
|
||||
void Shutdown();
|
||||
|
||||
struct ListenersList {
|
||||
nsCOMArray<nsIAndroidEventListener> listeners{/* count */ 1};
|
||||
nsCOMArray<nsIGeckoViewEventListener> listeners{/* count */ 1};
|
||||
// 0 if the list can be modified
|
||||
uint32_t lockCount{0};
|
||||
// true if this list has a listener that is being unregistered
|
||||
@@ -80,22 +80,22 @@ class EventDispatcher final
|
||||
Mutex mLock MOZ_UNANNOTATED{"mozilla::widget::EventDispatcher"};
|
||||
ListenersMap mListenersMap;
|
||||
|
||||
using IterateEventsCallback =
|
||||
nsresult (EventDispatcher::*)(const nsAString&, nsIAndroidEventListener*);
|
||||
using IterateEventsCallback = nsresult (EventDispatcher::*)(
|
||||
const nsAString&, nsIGeckoViewEventListener*);
|
||||
|
||||
nsresult IterateEvents(JSContext* aCx, JS::Handle<JS::Value> aEvents,
|
||||
IterateEventsCallback aCallback,
|
||||
nsIAndroidEventListener* aListener);
|
||||
nsresult RegisterEventLocked(const nsAString&, nsIAndroidEventListener*);
|
||||
nsresult UnregisterEventLocked(const nsAString&, nsIAndroidEventListener*);
|
||||
nsIGeckoViewEventListener* aListener);
|
||||
nsresult RegisterEventLocked(const nsAString&, nsIGeckoViewEventListener*);
|
||||
nsresult UnregisterEventLocked(const nsAString&, nsIGeckoViewEventListener*);
|
||||
|
||||
nsresult DispatchOnGecko(ListenersList* list, const nsAString& aEvent,
|
||||
JS::Handle<JS::Value> aData,
|
||||
nsIAndroidEventCallback* aCallback);
|
||||
nsIGeckoViewEventCallback* aCallback);
|
||||
|
||||
java::EventDispatcher::NativeCallbackDelegate::LocalRef WrapCallback(
|
||||
nsIAndroidEventCallback* aCallback,
|
||||
nsIAndroidEventFinalizer* aFinalizer = nullptr);
|
||||
nsIGeckoViewEventCallback* aCallback,
|
||||
nsIGeckoViewEventFinalizer* aFinalizer = nullptr);
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
||||
@@ -87,7 +87,7 @@ Classes = [
|
||||
'js_name': 'androidBridge',
|
||||
'cid': '{0fe2321d-ebd9-467d-a743-03a68d40599e}',
|
||||
'contract_ids': ['@mozilla.org/android/bridge;1'],
|
||||
'interfaces': ['nsIAndroidBridge'],
|
||||
'interfaces': ['nsIGeckoViewBridge'],
|
||||
'type': 'nsAndroidBridge',
|
||||
'headers': ['/widget/android/AndroidBridge.h'],
|
||||
},
|
||||
|
||||
@@ -1037,7 +1037,7 @@ class NPZCSupport final
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(AndroidView, nsIAndroidEventDispatcher, nsIAndroidView)
|
||||
NS_IMPL_ISUPPORTS(AndroidView, nsIGeckoViewEventDispatcher, nsIGeckoViewView)
|
||||
|
||||
nsresult AndroidView::GetInitData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aOut) {
|
||||
@@ -1787,7 +1787,7 @@ void GeckoViewSupport::Open(
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare an nsIAndroidView to pass as argument to the window.
|
||||
// Prepare an nsIGeckoViewView to pass as argument to the window.
|
||||
RefPtr<AndroidView> androidView = new AndroidView();
|
||||
androidView->mEventDispatcher->Attach(
|
||||
java::EventDispatcher::Ref::From(aDispatcher), nullptr);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
interface mozIDOMWindowProxy;
|
||||
|
||||
[scriptable, uuid(e64c39b8-b8ec-477d-aef5-89d517ff9219)]
|
||||
interface nsIAndroidEventCallback : nsISupports
|
||||
interface nsIGeckoViewEventCallback : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
void onSuccess([optional] in jsval data);
|
||||
@@ -16,43 +16,43 @@ interface nsIAndroidEventCallback : nsISupports
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(819ee2db-d3b8-46dd-a476-40f89c49133c)]
|
||||
interface nsIAndroidEventFinalizer : nsISupports
|
||||
interface nsIGeckoViewEventFinalizer : nsISupports
|
||||
{
|
||||
void onFinalize();
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(73569a75-78eb-4c7f-82b9-2d4f5ccf44c3)]
|
||||
interface nsIAndroidEventListener : nsISupports
|
||||
interface nsIGeckoViewEventListener : nsISupports
|
||||
{
|
||||
void onEvent(in AString event,
|
||||
[optional] in jsval data,
|
||||
[optional] in nsIAndroidEventCallback callback);
|
||||
[optional] in nsIGeckoViewEventCallback callback);
|
||||
};
|
||||
|
||||
[scriptable, uuid(e98bf792-4145-411e-b298-8219d9b03817)]
|
||||
interface nsIAndroidEventDispatcher : nsISupports
|
||||
interface nsIGeckoViewEventDispatcher : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
void dispatch(in jsval event,
|
||||
[optional] in jsval data,
|
||||
[optional] in nsIAndroidEventCallback callback,
|
||||
[optional] in nsIAndroidEventFinalizer finalizer);
|
||||
[optional] in nsIGeckoViewEventCallback callback,
|
||||
[optional] in nsIGeckoViewEventFinalizer finalizer);
|
||||
[implicit_jscontext]
|
||||
void registerListener(in nsIAndroidEventListener listener,
|
||||
void registerListener(in nsIGeckoViewEventListener listener,
|
||||
in jsval events);
|
||||
[implicit_jscontext]
|
||||
void unregisterListener(in nsIAndroidEventListener listener,
|
||||
void unregisterListener(in nsIGeckoViewEventListener listener,
|
||||
in jsval events);
|
||||
};
|
||||
|
||||
[scriptable, uuid(60a78a94-6117-432f-9d49-304913a931c5)]
|
||||
interface nsIAndroidView : nsIAndroidEventDispatcher
|
||||
interface nsIGeckoViewView : nsIGeckoViewEventDispatcher
|
||||
{
|
||||
[implicit_jscontext] readonly attribute jsval initData;
|
||||
};
|
||||
|
||||
[scriptable, uuid(1beb70d3-70f3-4742-98cc-a3d301b26c0c)]
|
||||
interface nsIAndroidBridge : nsIAndroidEventDispatcher
|
||||
interface nsIGeckoViewBridge : nsIGeckoViewEventDispatcher
|
||||
{
|
||||
nsIAndroidEventDispatcher getDispatcherByName(in string name);
|
||||
nsIGeckoViewEventDispatcher getDispatcherByName(in string name);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user