Bug 1333590 - 6. Remove GeckoEventListener and NativeEventListener; r=snorp r=sebastian

Remove GeckoEventListener and NativeEventListener now that we uniformly
use BundleEventListener. Also remove related classes NativeJSContainer,
NativeJSObject, and GeckoRequest, as well as related tests and C++
code.

The "Messaging" object in Messaging.jsm is replaced with a dummy object
that redirect calls to the global and/or window event dispatcher.
This commit is contained in:
Jim Chen
2017-02-01 17:35:45 -05:00
parent ec34fb0bdd
commit a47ea26590
31 changed files with 126 additions and 3674 deletions

View File

@@ -37,7 +37,6 @@
#include "nsIDOMClientRect.h"
#include "mozilla/ClearOnShutdown.h"
#include "nsPrintfCString.h"
#include "NativeJSContainer.h"
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsIHttpChannel.h"
@@ -664,15 +663,6 @@ AndroidBridge::GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInf
env->ReleaseDoubleArrayElements(arr.Get(), info, 0);
}
void
AndroidBridge::HandleGeckoMessage(JSContext* cx, JS::HandleObject object)
{
ALOG_BRIDGE("%s", __PRETTY_FUNCTION__);
auto message = widget::CreateNativeJSContainer(cx, object);
GeckoAppShell::HandleGeckoMessage(message);
}
void
AndroidBridge::GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
{
@@ -758,34 +748,43 @@ nsAndroidBridge::~nsAndroidBridge()
NS_IMETHODIMP nsAndroidBridge::HandleGeckoMessage(JS::HandleValue val,
JSContext *cx)
{
if (val.isObject()) {
JS::RootedObject object(cx, &val.toObject());
AndroidBridge::Bridge()->HandleGeckoMessage(cx, object);
return NS_OK;
}
// Now handle legacy JSON messages.
if (!val.isString()) {
return NS_ERROR_INVALID_ARG;
}
JS::RootedString jsonStr(cx, val.toString());
JS::RootedValue jsonVal(cx);
if (!JS_ParseJSON(cx, jsonStr, &jsonVal) || !jsonVal.isObject()) {
return NS_ERROR_INVALID_ARG;
}
// Spit out a warning before sending the message.
nsContentUtils::ReportToConsoleNonLocalized(
NS_LITERAL_STRING("Use of JSON is deprecated. "
"Please pass Javascript objects directly to handleGeckoMessage."),
NS_LITERAL_STRING("Use of handleGeckoMessage is deprecated. "
"Please use EventDispatcher from Messaging.jsm."),
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("nsIAndroidBridge"),
nullptr);
JS::RootedObject object(cx, &jsonVal.toObject());
AndroidBridge::Bridge()->HandleGeckoMessage(cx, object);
return NS_OK;
JS::RootedValue jsonVal(cx);
if (val.isObject()) {
jsonVal = val;
} else {
// Handle legacy JSON messages.
if (!val.isString()) {
return NS_ERROR_INVALID_ARG;
}
JS::RootedString jsonStr(cx, val.toString());
if (!JS_ParseJSON(cx, jsonStr, &jsonVal) || !jsonVal.isObject()) {
JS_ClearPendingException(cx);
return NS_ERROR_INVALID_ARG;
}
}
JS::RootedObject jsonObj(cx, &jsonVal.toObject());
JS::RootedValue typeVal(cx);
nsAutoJSString typeStr;
if (!JS_GetProperty(cx, jsonObj, "type", &typeVal) ||
!typeStr.init(cx, typeVal)) {
JS_ClearPendingException(cx);
return NS_ERROR_INVALID_ARG;
}
return Dispatch(typeStr, jsonVal, /* callback */ nullptr, cx);
}
NS_IMETHODIMP nsAndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow)