From 695383a67dd67f6e06a3a4aeb2fb65a4766af443 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 6 Mar 2015 01:08:06 -0500 Subject: [PATCH] Bug 1139964 part 2. Add classinfo helpers for the various message manager stuff to install WebIDL Exposed=System things on those globals. r=smaug --- dom/base/nsDOMClassInfo.cpp | 47 +++++++++++++++++++++++++++++++++++-- dom/base/nsDOMClassInfo.h | 25 ++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index cdb2c072ab6b..c7606ad2dc75 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -257,11 +257,15 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH, + NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, + nsMessageManagerSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | + nsIXPCScriptable::WANT_ENUMERATE | nsIXPCScriptable::IS_GLOBAL_OBJECT) - NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentProcessMessageManager, nsDOMGenericSH, + NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentProcessMessageManager, + nsMessageManagerSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | + nsIXPCScriptable::WANT_ENUMERATE | nsIXPCScriptable::IS_GLOBAL_OBJECT) NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageBroadcaster, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -2587,3 +2591,42 @@ nsNonDOMObjectSH::GetFlags(uint32_t *aFlags) *aFlags = nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::SINGLETON_CLASSINFO; return NS_OK; } + +// nsContentFrameMessageManagerSH + +template +NS_IMETHODIMP +nsMessageManagerSH::Resolve(nsIXPConnectWrappedNative* wrapper, + JSContext* cx, JSObject* obj_, + jsid id_, bool* resolvedp, + bool* _retval) +{ + JS::Rooted obj(cx, obj_); + JS::Rooted id(cx, id_); + + *_retval = SystemGlobalResolve(cx, obj, id, resolvedp); + NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE); + + if (*resolvedp) { + return NS_OK; + } + + return Super::Resolve(wrapper, cx, obj, id, resolvedp, _retval); +} + +template +NS_IMETHODIMP +nsMessageManagerSH::Enumerate(nsIXPConnectWrappedNative* wrapper, + JSContext* cx, JSObject* obj_, + bool* _retval) +{ + JS::Rooted obj(cx, obj_); + + *_retval = SystemGlobalEnumerate(cx, obj); + NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE); + + // Don't call up to our superclass, since neither nsDOMGenericSH nor + // nsEventTargetSH have WANT_ENUMERATE. + MOZ_ASSERT(!(this->GetScriptableFlags() & nsIXPCScriptable::WANT_ENUMERATE)); + return NS_OK; +} diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 6badc33ca0d7..11fd7ce001e2 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -313,4 +313,29 @@ public: } }; +template +class nsMessageManagerSH : public Super +{ +protected: + explicit nsMessageManagerSH(nsDOMClassInfoData* aData) + : Super(aData) + { + } + + virtual ~nsMessageManagerSH() + { + } +public: + NS_IMETHOD Resolve(nsIXPConnectWrappedNative* wrapper, JSContext* cx, + JSObject* obj_, jsid id_, bool* resolvedp, + bool* _retval) MOZ_OVERRIDE; + NS_IMETHOD Enumerate(nsIXPConnectWrappedNative* wrapper, JSContext* cx, + JSObject* obj_, bool* _retval) MOZ_OVERRIDE; + + static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) + { + return new nsMessageManagerSH(aData); + } +}; + #endif /* nsDOMClassInfo_h___ */