Bug 1084439. Remove ResolveWorkerClasses in favor of [Exposed=System] annotations. r=bholley

This commit is contained in:
Boris Zbarsky 2014-10-19 22:25:49 -04:00
Родитель b2eb743d9b
Коммит 95886106af
13 изменённых файлов: 12 добавлений и 97 удалений

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

@ -11956,8 +11956,7 @@ class CGResolveSystemBinding(CGAbstractMethod):
defineCode = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
defineCode = CGIfWrapper(CGGeneric("return false;\n"), defineCode)
defineCode = CGList([defineCode,
CGGeneric("aObjp.set(aObj);\n"),
CGGeneric("return true;\n")])
CGGeneric("aObjp.set(aObj);\n")])
condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
if desc.isExposedConditionally():

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

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[NoInterfaceObject, Exposed=(Window,Worker)]
[NoInterfaceObject, Exposed=(Window,Worker,System)]
interface AbstractWorker {
attribute EventHandler onerror;
};

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

@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
[Constructor(DOMString type, optional ErrorEventInit eventInitDict)]
[Constructor(DOMString type, optional ErrorEventInit eventInitDict),
Exposed=(Window,System)]
interface ErrorEvent : Event
{
readonly attribute DOMString message;

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

@ -11,7 +11,7 @@
*/
[Constructor(DOMString type, optional EventInit eventInitDict),
Exposed=(Window,Worker)]
Exposed=(Window,Worker,System)]
interface Event {
[Pure]
readonly attribute DOMString type;

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

@ -10,7 +10,7 @@
* liability, trademark and document use rules apply.
*/
[Exposed=(Window,Worker)]
[Exposed=(Window,Worker,System)]
interface EventTarget {
/* Passing null for wantsUntrusted means "default behavior", which
differs in content and chrome. In content that default boolean

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

@ -10,7 +10,7 @@ interface IID;
[NoInterfaceObject,
// Need Exposed here, because this is a mixin onto things like Event
// that are exposed in workers.
Exposed=(Window,Worker)]
Exposed=(Window,Worker,System)]
interface LegacyQueryInterface {
// Legacy QueryInterface, only exposed to chrome or XBL code on the
// main thread.

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

@ -10,7 +10,7 @@
interface WindowProxy;
[Constructor(DOMString type, optional MessageEventInit eventInitDict),
Exposed=(Window,Worker)]
Exposed=(Window,Worker,System)]
interface MessageEvent : Event {
/**
* Custom data associated with this event.

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

@ -7,7 +7,7 @@
* http://www.whatwg.org/specs/web-apps/current-work/#channel-messaging
*/
[Exposed=(Window,Worker)]
[Exposed=(Window,Worker,System)]
interface MessagePort : EventTarget {
[Throws]
void postMessage(any message, optional sequence<Transferable> transferable);

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

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[NoInterfaceObject, ArrayClass, Exposed=(Window,Worker)]
[NoInterfaceObject, ArrayClass, Exposed=(Window,Worker,System)]
interface MessagePortList {
readonly attribute unsigned long length;
getter MessagePort? item(unsigned long index);

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

@ -14,7 +14,7 @@
[Constructor(DOMString scriptURL),
Func="mozilla::dom::workers::WorkerPrivate::WorkerAvailable",
Exposed=(Window,Worker)]
Exposed=(Window,Worker,System)]
interface Worker : EventTarget {
void terminate();
@ -28,6 +28,6 @@ Worker implements AbstractWorker;
[Constructor(DOMString scriptURL),
Func="mozilla::dom::workers::ChromeWorkerPrivate::WorkerAvailable",
Exposed=(Window,Worker)]
Exposed=(Window,Worker,System)]
interface ChromeWorker : Worker {
};

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

@ -188,23 +188,6 @@ enum {
ID_COUNT
};
// These are jsids for the main runtime. Only touched on the main thread.
jsid gStringIDs[ID_COUNT] = { JSID_VOID };
const char* gStringChars[] = {
"Worker",
"ChromeWorker",
"Event",
"MessageEvent",
"ErrorEvent"
// XXX Don't care about ProgressEvent since it should never leak to the main
// thread.
};
static_assert(MOZ_ARRAY_LENGTH(gStringChars) == ID_COUNT,
"gStringChars should have the right length.");
class LiteralRebindingCString : public nsDependentCString
{
public:
@ -1222,55 +1205,6 @@ NS_IMPL_ISUPPORTS(RuntimeService::WorkerThread::TestPBackgroundCreateCallback,
BEGIN_WORKERS_NAMESPACE
// Entry point for main thread non-window globals.
bool
ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
JS::MutableHandle<JSObject*> aObjp)
{
AssertIsOnMainThread();
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
// Make sure our strings are interned.
if (JSID_IS_VOID(gStringIDs[0])) {
for (uint32_t i = 0; i < ID_COUNT; i++) {
JSString* str = JS_InternString(aCx, gStringChars[i]);
if (!str) {
while (i) {
gStringIDs[--i] = JSID_VOID;
}
return false;
}
gStringIDs[i] = INTERNED_STRING_TO_JSID(aCx, str);
}
}
// Invoking this function with JSID_VOID means "always resolve".
bool shouldResolve = JSID_IS_VOID(aId);
if (!shouldResolve) {
for (uint32_t i = 0; i < ID_COUNT; i++) {
if (gStringIDs[i] == aId) {
shouldResolve = true;
break;
}
}
}
if (!shouldResolve) {
aObjp.set(nullptr);
return true;
}
if (!WorkerBinding::GetConstructorObject(aCx, aObj) ||
!ChromeWorkerBinding::GetConstructorObject(aCx, aObj) ||
!ErrorEventBinding::GetConstructorObject(aCx, aObj) ||
!MessageEventBinding::GetConstructorObject(aCx, aObj)) {
return false;
}
aObjp.set(aObj);
return true;
}
void
CancelWorkersForWindow(nsPIDOMWindow* aWindow)
{

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

@ -171,12 +171,6 @@ enum WorkerPreference
// All of these are implemented in RuntimeService.cpp
// Resolves all of the worker classes onto |aObjp| if one of them matches |aId|
// or if |aId| is JSID_VOID.
bool
ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
JS::MutableHandle<JSObject*> aObjp);
void
CancelWorkersForWindow(nsPIDOMWindow* aWindow);

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

@ -10,10 +10,8 @@
#include "nsDOMClassInfo.h"
#include "nsIPrincipal.h"
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/dom/ResolveSystemBinding.h"
using mozilla::dom::workers::ResolveWorkerClasses;
using mozilla::dom::ResolveSystemBinding;
NS_INTERFACE_MAP_BEGIN(BackstagePass)
@ -68,14 +66,6 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
JS::RootedObject objp(cx, *objpArg);
*_retval = ResolveWorkerClasses(cx, obj, id, &objp);
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
if (objp) {
*objpArg = objp;
return NS_OK;
}
*_retval = ResolveSystemBinding(cx, obj, id, &objp);
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
@ -97,9 +87,6 @@ BackstagePass::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
JS::RootedObject ignored(cx);
*_retval = ResolveWorkerClasses(cx, obj, JSID_VOIDHANDLE, &ignored);
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
*_retval = ResolveSystemBinding(cx, obj, JSID_VOIDHANDLE, &ignored);
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);