Bug 863140 - Remove GetInnerWindowInternal. r=bz

This commit is contained in:
Gabor Krizsanits 2013-04-29 17:34:16 +02:00
parent 064413bc86
commit ae998df2a8
9 changed files with 22 additions and 39 deletions

View File

@ -113,8 +113,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x8f33bc23, 0x5625, 0x448a, \
{ 0xb3, 0x38, 0xfe, 0x88, 0x16, 0xe, 0xb3, 0xdb } }
{ 0x4be4a58d, 0x7fce, 0x4315, \
{ 0x9d, 0x6c, 0x8e, 0x9f, 0xc7, 0x2e, 0x51, 0xb } };
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -826,7 +826,7 @@ public:
*/
nsPIDOMWindow* GetInnerWindow()
{
return mRemovedFromDocShell ? GetInnerWindowInternal() : mWindow;
return mRemovedFromDocShell ? nullptr : mWindow;
}
/**
@ -2109,9 +2109,6 @@ protected:
// Never ever call this. Only call GetWindow!
virtual nsPIDOMWindow *GetWindowInternal() const = 0;
// Never ever call this. Only call GetInnerWindow!
virtual nsPIDOMWindow *GetInnerWindowInternal() = 0;
// Never ever call this. Only call GetScriptHandlingObject!
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const = 0;

View File

@ -4239,17 +4239,6 @@ nsDocument::GetWindowInternal() const
return win->GetOuterWindow();
}
nsPIDOMWindow *
nsDocument::GetInnerWindowInternal()
{
MOZ_ASSERT(mRemovedFromDocShell,
"This document should have been removed from docshell!");
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(GetScriptGlobalObject()));
return win;
}
nsScriptLoader*
nsDocument::ScriptLoader()
{

View File

@ -1160,7 +1160,6 @@ protected:
bool aPersisted);
virtual nsPIDOMWindow *GetWindowInternal() const;
virtual nsPIDOMWindow *GetInnerWindowInternal();
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const;
virtual bool InternalAllowXULXBL();

View File

@ -805,7 +805,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
}
nsPIDOMWindow *pwin = mDocument->GetInnerWindow();
if (!pwin || !pwin->IsInnerWindow()) {
if (!pwin) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIScriptGlobalObject> globalObject = do_QueryInterface(pwin);

View File

@ -527,7 +527,7 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
HTMLBodyElement::GetOn##name_() \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
if (win) { \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->GetOn##name_(); \
@ -538,7 +538,7 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
HTMLBodyElement::SetOn##name_(type_* handler, ErrorResult& error) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win || !win->IsInnerWindow()) { \
if (!win) { \
return; \
} \
\

View File

@ -392,7 +392,7 @@ HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
HTMLFrameSetElement::GetOn##name_() \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
if (win) { \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->GetOn##name_(); \
@ -403,7 +403,7 @@ HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
HTMLFrameSetElement::SetOn##name_(type_* handler, ErrorResult& error) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win || !win->IsInnerWindow()) { \
if (!win) { \
return; \
} \
\

View File

@ -848,13 +848,8 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName,
// override BindToTree for those classes and munge event listeners there?
nsIDocument *document = OwnerDoc();
// FIXME (https://bugzilla.mozilla.org/show_bug.cgi?id=431767)
// nsDocument::GetInnerWindow can return an outer window in some cases,
// we don't want to stick an event listener on an outer window, so
// bail if it does. See similar code in HTMLBodyElement and
// HTMLFramesetElement
*aDefer = false;
if ((win = document->GetInnerWindow()) && win->IsInnerWindow()) {
if ((win = document->GetInnerWindow())) {
nsCOMPtr<EventTarget> piTarget(do_QueryInterface(win));
return piTarget->GetListenerManager(true);
@ -867,11 +862,6 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName,
aDefer);
}
// FIXME (https://bugzilla.mozilla.org/show_bug.cgi?id=431767)
// nsDocument::GetInnerWindow can return an outer window in some
// cases. We don't want to stick an event listener on an outer
// window, so bail if it does. See also similar code in
// nsGenericHTMLElement::GetEventListenerManagerForAttr.
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by nsINode */
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
EventHandlerNonNull* \
@ -880,7 +870,7 @@ nsGenericHTMLElement::GetOn##name_() \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
/* XXXbz note to self: add tests for this! */ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
if (win) { \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->GetOn##name_(); \
@ -896,7 +886,7 @@ nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
{ \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win || !win->IsInnerWindow()) { \
if (!win) { \
return; \
} \
\
@ -914,7 +904,7 @@ nsGenericHTMLElement::GetOn##name_() \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
/* XXXbz note to self: add tests for this! */ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
if (win) { \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
OnErrorEventHandlerNonNull* errorHandler = globalWin->GetOn##name_(); \
@ -936,7 +926,7 @@ nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
{ \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win || !win->IsInnerWindow()) { \
if (!win) { \
return; \
} \
\

View File

@ -498,7 +498,7 @@ nsXULElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer)
nsPIDOMWindow *window;
Element *root = doc->GetRootElement();
if ((!root || root == this) && !mNodeInfo->Equals(nsGkAtoms::overlay) &&
(window = doc->GetInnerWindow()) && window->IsInnerWindow()) {
(window = doc->GetInnerWindow())) {
nsCOMPtr<EventTarget> piTarget = do_QueryInterface(window);

View File

@ -1158,6 +1158,14 @@ TabParent::RecvPIndexedDBConstructor(PIndexedDBParent* aActor,
nsCOMPtr<nsPIDOMWindow> window = doc->GetInnerWindow();
NS_ENSURE_TRUE(window, false);
// Let's do a current inner check to see if the inner is active or is in
// bf cache, and bail out if it's not active.
nsCOMPtr<nsPIDOMWindow> outer = doc->GetWindow();
if (!outer || outer->GetCurrentInnerWindow() != window) {
*aAllowed = false;
return true;
}
ContentParent* contentParent = static_cast<ContentParent*>(Manager());
NS_ASSERTION(contentParent, "Null manager?!");