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