diff --git a/dom/base/WindowNamedPropertiesHandler.h b/dom/base/WindowNamedPropertiesHandler.h index cd0df01c36dc..a9570d2999ab 100644 --- a/dom/base/WindowNamedPropertiesHandler.h +++ b/dom/base/WindowNamedPropertiesHandler.h @@ -15,9 +15,9 @@ namespace dom { class WindowNamedPropertiesHandler : public BaseDOMProxyHandler { public: - WindowNamedPropertiesHandler() - : BaseDOMProxyHandler(nullptr, /* hasPrototype = */ true) + WindowNamedPropertiesHandler() : BaseDOMProxyHandler(nullptr) { + setHasPrototype(true); } virtual bool preventExtensions(JSContext* aCx, JS::Handle aProxy) MOZ_OVERRIDE diff --git a/dom/bindings/DOMJSProxyHandler.h b/dom/bindings/DOMJSProxyHandler.h index d806b37ce347..d5a8bb4d2dc9 100644 --- a/dom/bindings/DOMJSProxyHandler.h +++ b/dom/bindings/DOMJSProxyHandler.h @@ -38,8 +38,8 @@ inline bool IsDOMProxy(JSObject *obj) class BaseDOMProxyHandler : public js::BaseProxyHandler { public: - BaseDOMProxyHandler(const void* aProxyFamily, bool aHasPrototype = false) - : js::BaseProxyHandler(aProxyFamily, aHasPrototype) + BaseDOMProxyHandler(const void* aProxyFamily) + : js::BaseProxyHandler(aProxyFamily) {} // Implementations of traps that can be implemented in terms of diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 102cb6490618..a4718fffcc6e 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -79,10 +79,10 @@ js::assertEnteredPolicy(JSContext *cx, JSObject *proxy, jsid id, } #endif -BaseProxyHandler::BaseProxyHandler(const void *family, bool hasPrototype, bool hasSecurityPolicy) +BaseProxyHandler::BaseProxyHandler(const void *family) : mFamily(family), - mHasPrototype(hasPrototype), - mHasSecurityPolicy(hasSecurityPolicy) + mHasPrototype(false), + mHasSecurityPolicy(false) { } @@ -538,9 +538,8 @@ DirectProxyHandler::weakmapKeyDelegate(JSObject *proxy) return UncheckedUnwrap(proxy); } -DirectProxyHandler::DirectProxyHandler(const void *family, bool hasPrototype, - bool hasSecurityPolicy) - : BaseProxyHandler(family, hasPrototype, hasSecurityPolicy) +DirectProxyHandler::DirectProxyHandler(const void *family) + : BaseProxyHandler(family) { } diff --git a/js/src/jsproxy.h b/js/src/jsproxy.h index eeaaf039e2db..aea22e60823f 100644 --- a/js/src/jsproxy.h +++ b/js/src/jsproxy.h @@ -116,9 +116,13 @@ class JS_FRIEND_API(BaseProxyHandler) */ bool mHasSecurityPolicy; + protected: + // Subclasses may set this in their constructor. + void setHasPrototype(bool aHasPrototype) { mHasPrototype = aHasPrototype; } + void setHasSecurityPolicy(bool aHasPolicy) { mHasSecurityPolicy = aHasPolicy; } + public: - explicit BaseProxyHandler(const void *family, bool hasPrototype = false, - bool hasSecurityPolicy = false); + explicit BaseProxyHandler(const void *family); virtual ~BaseProxyHandler(); bool hasPrototype() { @@ -237,8 +241,7 @@ class JS_FRIEND_API(BaseProxyHandler) class JS_PUBLIC_API(DirectProxyHandler) : public BaseProxyHandler { public: - explicit DirectProxyHandler(const void *family, bool hasPrototype = false, - bool hasSecurityPolicy = false); + explicit DirectProxyHandler(const void *family); /* ES5 Harmony fundamental proxy traps. */ virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE; diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index b57c74e63c8d..ff5f9b4e8d10 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -127,10 +127,10 @@ js::IsCrossCompartmentWrapper(JSObject *obj) !!(Wrapper::wrapperHandler(obj)->flags() & Wrapper::CROSS_COMPARTMENT); } -Wrapper::Wrapper(unsigned flags, bool hasPrototype, bool hasSecurityPolicy) - : DirectProxyHandler(&sWrapperFamily, hasPrototype, hasSecurityPolicy), - mFlags(flags) +Wrapper::Wrapper(unsigned flags, bool hasPrototype) : DirectProxyHandler(&sWrapperFamily) + , mFlags(flags) { + setHasPrototype(hasPrototype); } Wrapper::~Wrapper() @@ -170,9 +170,8 @@ ErrorCopier::~ErrorCopier() /* Cross compartment wrappers. */ -CrossCompartmentWrapper::CrossCompartmentWrapper(unsigned flags, bool hasPrototype, - bool hasSecurityPolicy) - : Wrapper(CROSS_COMPARTMENT | flags, hasPrototype, hasSecurityPolicy) +CrossCompartmentWrapper::CrossCompartmentWrapper(unsigned flags, bool hasPrototype) + : Wrapper(CROSS_COMPARTMENT | flags, hasPrototype) { } @@ -608,9 +607,10 @@ CrossCompartmentWrapper CrossCompartmentWrapper::singleton(0u); /* Security wrappers. */ template -SecurityWrapper::SecurityWrapper(unsigned flags, bool hasPrototype) - : Base(flags, hasPrototype, /* hasSecurityPolicy = */ true) +SecurityWrapper::SecurityWrapper(unsigned flags) + : Base(flags) { + BaseProxyHandler::setHasSecurityPolicy(true); } template diff --git a/js/src/jswrapper.h b/js/src/jswrapper.h index 8311d8031585..a7561958bf42 100644 --- a/js/src/jswrapper.h +++ b/js/src/jswrapper.h @@ -81,7 +81,7 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler return mFlags; } - explicit Wrapper(unsigned flags, bool hasPrototype = false, bool hasSecurityPolicy = false); + explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper(); @@ -103,8 +103,7 @@ WrapperOptions::proto() const class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper { public: - explicit CrossCompartmentWrapper(unsigned flags, bool hasPrototype = false, - bool hasSecurityPolicy = false); + explicit CrossCompartmentWrapper(unsigned flags, bool hasPrototype = false); virtual ~CrossCompartmentWrapper(); @@ -168,7 +167,7 @@ template class JS_FRIEND_API(SecurityWrapper) : public Base { public: - explicit SecurityWrapper(unsigned flags, bool hasPrototype = false); + explicit SecurityWrapper(unsigned flags); virtual bool isExtensible(JSContext *cx, HandleObject wrapper, bool *extensible) MOZ_OVERRIDE; virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE; diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 1e31fcfb58f2..ef11332ac68c 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -1986,8 +1986,9 @@ DOMXrayTraits::createHolder(JSContext *cx, JSObject *wrapper) template XrayWrapper::XrayWrapper(unsigned flags) - : Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG, /* hasPrototype = */ Traits::HasPrototype) + : Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG) { + Base::setHasPrototype(Traits::HasPrototype); } template