From d4a40b2bea5e77de9e897bfaa6abf3119a7939e9 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sat, 29 Mar 2014 01:45:10 -0400 Subject: [PATCH] Bug 987112. Remove the redundant and somewhat annoying parentObject argument to dictionary ToObject() methods. r=bholley --- dom/activities/src/Activity.cpp | 2 +- dom/base/Console.cpp | 14 +++++++------- dom/base/nsGlobalWindow.cpp | 2 +- dom/bindings/Codegen.py | 9 +++++---- dom/browser-element/BrowserElementParent.cpp | 6 ++---- dom/media/MediaManager.cpp | 2 +- dom/src/notification/DesktopNotification.cpp | 2 +- dom/src/notification/Notification.cpp | 2 +- dom/system/gonk/NetworkWorker.cpp | 2 +- dom/wifi/WifiProxyService.cpp | 2 +- layout/inspector/inDOMUtils.cpp | 2 +- netwerk/base/src/Dashboard.cpp | 12 ++++++------ 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/dom/activities/src/Activity.cpp b/dom/activities/src/Activity.cpp index 26344f91760..f428266a1bc 100644 --- a/dom/activities/src/Activity.cpp +++ b/dom/activities/src/Activity.cpp @@ -67,7 +67,7 @@ Activity::Initialize(nsPIDOMWindow* aWindow, NS_ENSURE_SUCCESS(rv, rv); JS::Rooted optionsValue(aCx); - if (!aOptions.ToObject(aCx, JS::NullPtr(), &optionsValue)) { + if (!aOptions.ToObject(aCx, &optionsValue)) { return NS_ERROR_FAILURE; } diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp index 3b5d738d13c..ad7852b5d82 100644 --- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -689,7 +689,7 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction, } JS::Rooted eventValue(aCx); - if (!event.ToObject(aCx, JS::NullPtr(), &eventValue)) { + if (!event.ToObject(aCx, &eventValue)) { aRv.Throw(NS_ERROR_FAILURE); return; } @@ -1001,7 +1001,7 @@ Console::ProcessCallData(ConsoleCallData* aData) } JS::Rooted eventValue(cx); - if (!event.ToObject(cx, JS::NullPtr(), &eventValue)) { + if (!event.ToObject(cx, &eventValue)) { Throw(cx, NS_ERROR_FAILURE); return; } @@ -1300,7 +1300,7 @@ Console::StartTimer(JSContext* aCx, const JS::Value& aName, RootedDictionary error(aCx); JS::Rooted value(aCx); - if (!error.ToObject(aCx, JS::NullPtr(), &value)) { + if (!error.ToObject(aCx, &value)) { return JS::UndefinedValue(); } @@ -1332,7 +1332,7 @@ Console::StartTimer(JSContext* aCx, const JS::Value& aName, timer.mStarted = aTimestamp; JS::Rooted value(aCx); - if (!timer.ToObject(aCx, JS::NullPtr(), &value)) { + if (!timer.ToObject(aCx, &value)) { return JS::UndefinedValue(); } @@ -1366,7 +1366,7 @@ Console::StopTimer(JSContext* aCx, const JS::Value& aName, timer.mDuration = aTimestamp - entry; JS::Rooted value(aCx); - if (!timer.ToObject(aCx, JS::NullPtr(), &value)) { + if (!timer.ToObject(aCx, &value)) { return JS::UndefinedValue(); } @@ -1414,7 +1414,7 @@ Console::IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame, RootedDictionary error(aCx); JS::Rooted value(aCx); - if (!error.ToObject(aCx, JS::NullPtr(), &value)) { + if (!error.ToObject(aCx, &value)) { return JS::UndefinedValue(); } @@ -1430,7 +1430,7 @@ Console::IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame, data.mCount = count; JS::Rooted value(aCx); - if (!data.ToObject(aCx, JS::NullPtr(), &value)) { + if (!data.ToObject(aCx, &value)) { return JS::UndefinedValue(); } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index cc078eb6473..84042b50da0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -5678,7 +5678,7 @@ nsGlobalWindow::DispatchResizeEvent(const nsIntSize& aSize) detail.mWidth = aSize.width; detail.mHeight = aSize.height; JS::Rooted detailValue(cx); - if (!detail.ToObject(cx, JS::NullPtr(), &detailValue)) { + if (!detail.ToObject(cx, &detailValue)) { return false; } diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 00c9ca3dd6f..71fb90f0ba2 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -4672,7 +4672,7 @@ if (!returnArray) { False) if type.isDictionary(): - return (wrapAndSetPtr("%s.ToObject(cx, ${obj}, ${jsvalHandle})" % result), + return (wrapAndSetPtr("%s.ToObject(cx, ${jsvalHandle})" % result), False) if type.isDate(): @@ -9319,7 +9319,7 @@ if (!*reinterpret_cast(atomsCache) && !InitIds(cx, atomsCache)) { if self.dictionary.parent: body += ( "// Per spec, we define the parent's members first\n" - "if (!%s::ToObject(cx, parentObject, rval)) {\n" + "if (!%s::ToObject(cx, rval)) {\n" " return false;\n" "}\n" "JS::Rooted obj(cx, &rval.toObject());\n" @@ -9339,7 +9339,6 @@ if (!*reinterpret_cast(atomsCache) && !InitIds(cx, atomsCache)) { return ClassMethod("ToObject", "bool", [ Argument('JSContext*', 'cx'), - Argument('JS::Handle', 'parentObject'), Argument('JS::MutableHandle', 'rval'), ], const=True, body=body) @@ -9598,7 +9597,9 @@ if (""", 'jsvalRef': "temp", 'jsvalHandle': "&temp", 'returnsNewObject': False, - 'obj': "parentObject", + # 'obj' can just be allowed to be the string "obj", since that + # will be our dictionary object, which is presumably itself in + # the right scope. 'typedArraysAreStructs': True }) conversion = CGGeneric(innerTemplate) diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp index 8e626c1110e..0b26a969162 100644 --- a/dom/browser-element/BrowserElementParent.cpp +++ b/dom/browser-element/BrowserElementParent.cpp @@ -160,7 +160,7 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement, JS::Rooted global(cx, sgo->GetGlobalJSObject()); JSAutoCompartment ac(cx, global); - if (!detail.ToObject(cx, global, &val)) { + if (!detail.ToObject(cx, &val)) { MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM."); return BrowserElementParent::OPEN_WINDOW_IGNORED; } @@ -332,9 +332,7 @@ NS_IMETHODIMP DispatchAsyncScrollEventRunnable::Run() JSAutoCompartment ac(cx, globalJSObject); JS::Rooted val(cx); - // We can get away with a null global here because - // AsyncScrollEventDetail only contains numeric values. - if (!detail.ToObject(cx, JS::NullPtr(), &val)) { + if (!detail.ToObject(cx, &val)) { MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM."); return NS_ERROR_FAILURE; } diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index cc3f1da7dd7..04fbf89cdda 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -90,7 +90,7 @@ static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA, JS::Rooted a(aCx, aA); JSAutoCompartment ac(aCx, aA); JS::Rooted bval(aCx); - aB.ToObject(aCx, JS::NullPtr(), &bval); + aB.ToObject(aCx, &bval); JS::Rooted b(aCx, &bval.toObject()); // Iterate over each property in A, and check if it is in B diff --git a/dom/src/notification/DesktopNotification.cpp b/dom/src/notification/DesktopNotification.cpp index 044ca299279..1a4d90ab46c 100644 --- a/dom/src/notification/DesktopNotification.cpp +++ b/dom/src/notification/DesktopNotification.cpp @@ -101,7 +101,7 @@ DesktopNotification::PostDesktopNotification() ops.mTextClickable = true; ops.mManifestURL = manifestUrl; - if (!ops.ToObject(cx, JS::NullPtr(), &val)) { + if (!ops.ToObject(cx, &val)) { return NS_ERROR_FAILURE; } diff --git a/dom/src/notification/Notification.cpp b/dom/src/notification/Notification.cpp index c9dbaa9b88b..619ce1853ef 100644 --- a/dom/src/notification/Notification.cpp +++ b/dom/src/notification/Notification.cpp @@ -583,7 +583,7 @@ Notification::ShowInternal() ops.mLang = mLang; ops.mTag = mTag; - if (!ops.ToObject(cx, JS::NullPtr(), &val)) { + if (!ops.ToObject(cx, &val)) { NS_WARNING("Converting dict to object failed!"); return; } diff --git a/dom/system/gonk/NetworkWorker.cpp b/dom/system/gonk/NetworkWorker.cpp index 7648fdd6d6b..ade352cc605 100644 --- a/dom/system/gonk/NetworkWorker.cpp +++ b/dom/system/gonk/NetworkWorker.cpp @@ -208,7 +208,7 @@ NetworkWorker::DispatchNetworkResult(const NetworkResultOptions& aOptions) mozilla::AutoSafeJSContext cx; JS::RootedValue val(cx); - if (!aOptions.ToObject(cx, JS::NullPtr(), &val)) { + if (!aOptions.ToObject(cx, &val)) { return; } diff --git a/dom/wifi/WifiProxyService.cpp b/dom/wifi/WifiProxyService.cpp index 27626e817f4..ba9aa907667 100644 --- a/dom/wifi/WifiProxyService.cpp +++ b/dom/wifi/WifiProxyService.cpp @@ -281,7 +281,7 @@ WifiProxyService::DispatchWifiResult(const WifiResultOptions& aOptions, const ns mozilla::AutoSafeJSContext cx; JS::Rooted val(cx); - if (!aOptions.ToObject(cx, JS::NullPtr(), &val)) { + if (!aOptions.ToObject(cx, &val)) { return; } diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index 3bf2cc61b46..b8d96c7173f 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -641,7 +641,7 @@ inDOMUtils::ColorNameToRGB(const nsAString& aColorName, JSContext* aCx, triple.mG = NS_GET_G(color); triple.mB = NS_GET_B(color); - if (!triple.ToObject(aCx, JS::NullPtr(), aValue)) { + if (!triple.ToObject(aCx, aValue)) { return NS_ERROR_FAILURE; } diff --git a/netwerk/base/src/Dashboard.cpp b/netwerk/base/src/Dashboard.cpp index 1beba010cec..bbd66568013 100644 --- a/netwerk/base/src/Dashboard.cpp +++ b/netwerk/base/src/Dashboard.cpp @@ -317,7 +317,7 @@ LookupHelper::ConstructAnswer(LookupArgument *aArgument) } JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) { + if (!dict.ToObject(cx, &val)) { return NS_ERROR_FAILURE; } @@ -400,7 +400,7 @@ Dashboard::GetSockets(SocketData *aSocketData) dict.mSent += socketData->mTotalSent; dict.mReceived += socketData->mTotalRecv; JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) + if (!dict.ToObject(cx, &val)) return NS_ERROR_FAILURE; socketData->mCallback->OnDashboardDataAvailable(val); @@ -503,7 +503,7 @@ Dashboard::GetHttpConnections(HttpData *aHttpData) } JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) { + if (!dict.ToObject(cx, &val)) { return NS_ERROR_FAILURE; } @@ -630,7 +630,7 @@ Dashboard::GetWebSocketConnections(WebSocketRequest *aWsRequest) } JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) { + if (!dict.ToObject(cx, &val)) { return NS_ERROR_FAILURE; } wsRequest->mCallback->OnDashboardDataAvailable(val); @@ -717,7 +717,7 @@ Dashboard::GetDNSCacheEntries(DnsData *dnsData) } JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) { + if (!dict.ToObject(cx, &val)) { return NS_ERROR_FAILURE; } dnsData->mCallback->OnDashboardDataAvailable(val); @@ -819,7 +819,7 @@ Dashboard::GetConnectionStatus(ConnectionData *aConnectionData) dict.mStatus = connectionData->mStatus; JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) + if (!dict.ToObject(cx, &val)) return NS_ERROR_FAILURE; connectionData->mCallback->OnDashboardDataAvailable(val);