From c57a4a55e3e39275b0e70e00e66f4290d238fc6e Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 9 Dec 2013 10:34:04 -0500 Subject: [PATCH] Bug 946564 part 1. Allow installing chromeonly webidl quickstubs too. r=peterv --- js/xpconnect/src/XPCQuickStubs.cpp | 9 ++++++++- js/xpconnect/src/XPCQuickStubs.h | 4 ++-- js/xpconnect/src/dom_quickstubs.qsconf | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/js/xpconnect/src/XPCQuickStubs.cpp b/js/xpconnect/src/XPCQuickStubs.cpp index 031fb155bb5c..67aa18a22b5f 100644 --- a/js/xpconnect/src/XPCQuickStubs.cpp +++ b/js/xpconnect/src/XPCQuickStubs.cpp @@ -7,6 +7,7 @@ #include "jsfriendapi.h" #include "jsprf.h" #include "nsCOMPtr.h" +#include "AccessCheck.h" #include "WrapperFactory.h" #include "xpcprivate.h" #include "XPCInlines.h" @@ -140,7 +141,13 @@ xpc_qsDefineQuickStubs(JSContext *cx, JSObject *protoArg, unsigned flags, } if (entry->newBindingProperties) { - mozilla::dom::DefineWebIDLBindingPropertiesOnXPCObject(cx, proto, entry->newBindingProperties, false); + if (entry->newBindingProperties->regular) { + mozilla::dom::DefineWebIDLBindingPropertiesOnXPCObject(cx, proto, entry->newBindingProperties->regular, false); + } + if (entry->newBindingProperties->chromeOnly && + xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) { + mozilla::dom::DefineWebIDLBindingPropertiesOnXPCObject(cx, proto, entry->newBindingProperties->chromeOnly, false); + } } // Next. size_t j = entry->parentInterface; diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index 92f0e07494ad..6c3de2d596ec 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -12,7 +12,7 @@ class qsObjectHelper; namespace mozilla { namespace dom { -class NativeProperties; +class NativePropertiesHolder; } } @@ -41,7 +41,7 @@ struct xpc_qsHashEntry { uint16_t n_props; uint16_t func_index; uint16_t n_funcs; - const mozilla::dom::NativeProperties* newBindingProperties; + const mozilla::dom::NativePropertiesHolder* newBindingProperties; // These last two fields index to other entries in the same table. // XPC_QS_NULL_ENTRY indicates there are no more entries in the chain. uint16_t parentInterface; diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 857aa03a6791..da0ec67d3192 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -111,6 +111,6 @@ customMethodCalls = { newBindingProperties = { # Once the last entry here goes away, we can make the sNativePropertyHooks # of bindings static. - 'nsIDOMEventTarget': 'mozilla::dom::EventTargetBinding::sNativePropertyHooks->mNativeProperties.regular', - 'nsIDOMWindow': 'mozilla::dom::WindowBinding::sNativePropertyHooks->mNativeProperties.regular', + 'nsIDOMEventTarget': '&mozilla::dom::EventTargetBinding::sNativePropertyHooks->mNativeProperties', + 'nsIDOMWindow': '&mozilla::dom::WindowBinding::sNativePropertyHooks->mNativeProperties', }