mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 899388 - Part 2: Implement allowXBL option for xpc bindings. r=bz
This commit is contained in:
parent
23171bc314
commit
3f765f0afe
@ -331,44 +331,31 @@ DOMCI_DATA_NO_CLASS(XULButtonElement)
|
||||
DOMCI_DATA_NO_CLASS(XULCheckboxElement)
|
||||
DOMCI_DATA_NO_CLASS(XULPopupElement)
|
||||
|
||||
#define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper, \
|
||||
_flags) \
|
||||
{ #_name, \
|
||||
nullptr, \
|
||||
#define NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, \
|
||||
_chromeOnly, _allowXBL) \
|
||||
{ #_class, \
|
||||
nullptr, \
|
||||
{ _helper::doCreate }, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
_flags, \
|
||||
true, \
|
||||
true, \
|
||||
0, \
|
||||
false, \
|
||||
false, \
|
||||
NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
||||
},
|
||||
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _name, \
|
||||
_helper, _flags) \
|
||||
{ #_name, \
|
||||
nullptr, \
|
||||
{ _helper::doCreate }, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
_flags, \
|
||||
true, \
|
||||
0, \
|
||||
true, \
|
||||
false, \
|
||||
_chromeOnly, \
|
||||
_allowXBL, \
|
||||
false, \
|
||||
NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
||||
},
|
||||
|
||||
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, false, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
|
||||
_flags)
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true)
|
||||
|
||||
namespace {
|
||||
|
||||
@ -1654,7 +1641,8 @@ nsDOMClassInfo::Init()
|
||||
for (i = 0; i < eDOMClassInfoIDCount; ++i) {
|
||||
nsDOMClassInfoData& data = sClassInfoData[i];
|
||||
nameSpaceManager->RegisterClassName(data.mName, i, data.mChromeOnly,
|
||||
data.mDisabled, &data.mNameUTF16);
|
||||
data.mAllowXBL, data.mDisabled,
|
||||
&data.mNameUTF16);
|
||||
}
|
||||
|
||||
for (i = 0; i < eDOMClassInfoIDCount; ++i) {
|
||||
@ -3463,14 +3451,15 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||
|
||||
static bool
|
||||
OldBindingConstructorEnabled(const nsGlobalNameStruct *aStruct,
|
||||
nsGlobalWindow *aWin)
|
||||
nsGlobalWindow *aWin, JSContext *cx)
|
||||
{
|
||||
MOZ_ASSERT(aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
aStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo);
|
||||
|
||||
// Don't expose chrome only constructors to content windows.
|
||||
if (aStruct->mChromeOnly &&
|
||||
!nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal())) {
|
||||
(aStruct->mAllowXBL ? !IsChromeOrXBL(cx, nullptr) :
|
||||
!nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3532,7 +3521,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
name_struct->mDefineDOMInterface;
|
||||
if (define) {
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
!OldBindingConstructorEnabled(name_struct, aWin)) {
|
||||
!OldBindingConstructorEnabled(name_struct, aWin, cx)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3627,7 +3616,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
if (!OldBindingConstructorEnabled(name_struct, aWin)) {
|
||||
if (!OldBindingConstructorEnabled(name_struct, aWin, cx)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3720,7 +3709,9 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) {
|
||||
if (name_struct->mChromeOnly && !nsContentUtils::IsCallerChrome())
|
||||
if (name_struct->mChromeOnly &&
|
||||
(name_struct->mAllowXBL ? !IsChromeOrXBL(cx, nullptr) :
|
||||
!nsContentUtils::IsCallerChrome()))
|
||||
return NS_OK;
|
||||
|
||||
// Before defining a global property, check for a named subframe of the
|
||||
|
@ -59,8 +59,9 @@ struct nsDOMClassInfoData
|
||||
uint32_t mScriptableFlags : 31; // flags must not use more than 31 bits!
|
||||
uint32_t mHasClassInterface : 1;
|
||||
uint32_t mInterfacesBitmap;
|
||||
bool mChromeOnly;
|
||||
bool mDisabled;
|
||||
bool mChromeOnly : 1;
|
||||
bool mAllowXBL : 1;
|
||||
bool mDisabled : 1;
|
||||
#ifdef DEBUG
|
||||
uint32_t mDebugID;
|
||||
#endif
|
||||
|
@ -479,6 +479,7 @@ nsresult
|
||||
nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||
int32_t aDOMClassInfoID,
|
||||
bool aPrivileged,
|
||||
bool aXBLAllowed,
|
||||
bool aDisabled,
|
||||
const PRUnichar **aResult)
|
||||
{
|
||||
@ -508,6 +509,7 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
||||
s->mDOMClassInfoID = aDOMClassInfoID;
|
||||
s->mChromeOnly = aPrivileged;
|
||||
s->mAllowXBL = aXBLAllowed;
|
||||
s->mDisabled = aDisabled;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -59,8 +59,9 @@ struct nsGlobalNameStruct
|
||||
// mChromeOnly is only used for structs that define non-WebIDL things
|
||||
// (possibly in addition to WebIDL ones). In particular, it's not even
|
||||
// initialized for eTypeNewDOMBinding structs.
|
||||
bool mChromeOnly;
|
||||
bool mDisabled;
|
||||
bool mChromeOnly : 1;
|
||||
bool mAllowXBL : 1;
|
||||
bool mDisabled : 1;
|
||||
|
||||
union {
|
||||
int32_t mDOMClassInfoID; // eTypeClassConstructor
|
||||
@ -119,6 +120,7 @@ public:
|
||||
nsresult RegisterClassName(const char *aClassName,
|
||||
int32_t aDOMClassInfoID,
|
||||
bool aPrivileged,
|
||||
bool aXBLAllowed,
|
||||
bool aDisabled,
|
||||
const PRUnichar **aResult);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user