Bug 574517 - Separate the inner and outer windows' JS classes. r=jst

This commit is contained in:
Blake Kaplan 2010-06-28 16:39:00 -07:00
Родитель 0734877eda
Коммит f5e7b5fe84
3 изменённых файлов: 84 добавлений и 4 удалений

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

@ -637,6 +637,11 @@ static nsDOMClassInfoData sClassInfoData[] = {
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
// XXX Wrong helper!
NS_DEFINE_CLASSINFO_DATA(InnerWindow, nsWindowSH,
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
(DOM_DEFAULT_SCRIPTABLE_FLAGS &
~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
@ -931,6 +936,11 @@ static nsDOMClassInfoData sClassInfoData[] = {
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
// XXX Wrong helper!
NS_DEFINE_CLASSINFO_DATA(InnerChromeWindow, nsWindowSH,
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSRGBColor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -1312,6 +1322,11 @@ static nsDOMClassInfoData sClassInfoData[] = {
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
// XXX Wrong helper!
NS_DEFINE_CLASSINFO_DATA(InnerModalContentWindow, nsWindowSH,
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DataContainerEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -2146,6 +2161,17 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(InnerWindow, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
DOM_CLASSINFO_MAP_END
@ -2859,6 +2885,18 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(InnerChromeWindow, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(RangeException, nsIDOMRangeException)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMRangeException)
DOM_CLASSINFO_MAP_ENTRY(nsIException)
@ -3734,6 +3772,18 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(InnerModalContentWindow, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(DataContainerEvent, nsIDOMDataContainerEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataContainerEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
@ -4543,7 +4593,15 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
if (if_info) {
nsXPIDLCString name;
if_info->GetName(getter_Copies(name));
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
// Allow for inner/non-inner mismatch.
static const char inner[] = "Inner";
const char *dataname = mData->mName;
if (!strncmp(dataname, "Inner", sizeof(inner) - 1)) {
dataname += sizeof(inner) - 1;
}
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), dataname) == 0,
"Class name and proto chain interface name mismatch!");
}
}
@ -5136,6 +5194,10 @@ nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
if ((*name == 'W' && strcmp(name, "Window") == 0) ||
(*name == 'C' && strcmp(name, "ChromeWindow") == 0) ||
(*name == 'M' && strcmp(name, "ModalContentWindow") == 0) ||
(*name == 'I' &&
(strcmp(name, "InnerWindow") == 0 ||
strcmp(name, "InnerChromeWindow") == 0 ||
strcmp(name, "InnerModalContentWindow") == 0)) ||
(*name == 'X' && strcmp(name, "XPCCrossOriginWrapper") == 0)) {
nsCOMPtr<nsIDOMWindow> window = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));

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

@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
DOMCI_CLASS(Window)
DOMCI_CLASS(InnerWindow)
DOMCI_CLASS(Location)
DOMCI_CLASS(Navigator)
DOMCI_CLASS(Plugin)
@ -188,6 +189,7 @@ DOMCI_CLASS(CSSRect)
// DOM Chrome Window class, almost identical to Window
DOMCI_CLASS(ChromeWindow)
DOMCI_CLASS(InnerChromeWindow)
// RGBColor object used by getComputedStyle
DOMCI_CLASS(CSSRGBColor)
@ -406,6 +408,7 @@ DOMCI_CLASS(FileReader)
// DOM modal content window class, almost identical to Window
DOMCI_CLASS(ModalContentWindow)
DOMCI_CLASS(InnerModalContentWindow)
// Data Events
DOMCI_CLASS(DataContainerEvent)

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

@ -1134,9 +1134,22 @@ nsGlobalWindow::FreeInnerObjects(PRBool aClearScope)
// nsGlobalWindow::nsISupports
//*****************************************************************************
#define WINDOW_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class) \
if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
foundInterface = NS_GetDOMClassInfoInstance(IsInnerWindow() \
? eDOMClassInfo_Inner##_class##_id \
: eDOMClassInfo_##_class##_id);\
if (!foundInterface) { \
*aInstancePtr = nsnull; \
return NS_ERROR_OUT_OF_MEMORY; \
} \
} else
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalWindow)
DOMCI_DATA(Window, nsGlobalWindow)
DOMCI_DATA(InnerWindow, nsGlobalWindow)
// QueryInterface implementation for nsGlobalWindow
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
@ -1158,7 +1171,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageWindow)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
WINDOW_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
NS_INTERFACE_MAP_END
@ -9480,11 +9493,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalChromeWindow,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
DOMCI_DATA(ChromeWindow, nsGlobalChromeWindow)
DOMCI_DATA(InnerChromeWindow, nsGlobalChromeWindow)
// QueryInterface implementation for nsGlobalChromeWindow
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsGlobalChromeWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMChromeWindow)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ChromeWindow)
WINDOW_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ChromeWindow)
NS_INTERFACE_MAP_END_INHERITING(nsGlobalWindow)
NS_IMPL_ADDREF_INHERITED(nsGlobalChromeWindow, nsGlobalWindow)
@ -9744,10 +9758,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalModalWindow,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
DOMCI_DATA(ModalContentWindow, nsGlobalModalWindow)
DOMCI_DATA(InnerModalContentWindow, nsGlobalModalWindow)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsGlobalModalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMModalContentWindow)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ModalContentWindow)
WINDOW_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ModalContentWindow)
NS_INTERFACE_MAP_END_INHERITING(nsGlobalWindow)
NS_IMPL_ADDREF_INHERITED(nsGlobalModalWindow, nsGlobalWindow)