зеркало из https://github.com/mozilla/gecko-dev.git
Bug 736688 - Part 5: Remove window.{top,parent,frameElement} mozbrowser changes in nsGlobalWindow (undoes changes from bug 725796). r=smaug
--HG-- extra : rebase_source : fdeccb7e995229cdbc6ebd945109fe8441f9f525
This commit is contained in:
Родитель
1c274793d6
Коммит
e71a362f01
|
@ -3088,47 +3088,14 @@ nsGlobalWindow::GetPerformance(nsIDOMPerformance** aPerformance)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetScriptableParent is called when script reads window.parent.
|
||||
*
|
||||
* In contrast to GetRealParent, GetScriptableParent respects <iframe
|
||||
* mozbrowser> boundaries, so if |this| is contained by an <iframe
|
||||
* mozbrowser>, we will return |this| as its own parent.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetScriptableParent(nsIDOMWindow** aParent)
|
||||
nsGlobalWindow::GetParent(nsIDOMWindow** aParent)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetScriptableParent, (aParent), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
*aParent = NULL;
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool isMozBrowser = false;
|
||||
mDocShell->GetIsBrowserFrame(&isMozBrowser);
|
||||
if (isMozBrowser) {
|
||||
nsCOMPtr<nsIDOMWindow> parent = static_cast<nsIDOMWindow*>(this);
|
||||
parent.swap(*aParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return GetRealParent(aParent);
|
||||
}
|
||||
|
||||
/**
|
||||
* nsIDOMWindow::GetParent (when called from C++) is just a wrapper around
|
||||
* GetRealParent.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetRealParent, (aParent), NS_ERROR_NOT_INITIALIZED);
|
||||
FORWARD_TO_OUTER(GetParent, (aParent), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
*aParent = nsnull;
|
||||
if (!mDocShell) {
|
||||
if (!mDocShell)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||
|
@ -3148,62 +3115,21 @@ nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetScriptableTop is called when script reads window.top.
|
||||
*
|
||||
* In contrast to GetRealTop, GetScriptableTop respects <iframe mozbrowser>
|
||||
* boundaries. If we encounter a window owned by an <iframe mozbrowser> while
|
||||
* walking up the window hierarchy, we'll stop and return that window.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetScriptableTop(nsIDOMWindow **aTop)
|
||||
nsGlobalWindow::GetTop(nsIDOMWindow** aTop)
|
||||
{
|
||||
return GetTopImpl(aTop, /* aScriptable = */ true);
|
||||
}
|
||||
FORWARD_TO_OUTER(GetTop, (aTop), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
/**
|
||||
* nsIDOMWindow::GetTop (when called from C++) is just a wrapper around
|
||||
* GetRealTop.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetRealTop(nsIDOMWindow** aTop)
|
||||
{
|
||||
return GetTopImpl(aTop, /* aScriptable = */ false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::GetTopImpl(nsIDOMWindow** aTop, bool aScriptable)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetTopImpl, (aTop, aScriptable), NS_ERROR_NOT_INITIALIZED);
|
||||
*aTop = nsnull;
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||
|
||||
// Walk up the parent chain.
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> prevParent = this;
|
||||
nsCOMPtr<nsIDOMWindow> parent = this;
|
||||
do {
|
||||
if (!parent) {
|
||||
break;
|
||||
if (root) {
|
||||
nsCOMPtr<nsIDOMWindow> top(do_GetInterface(root));
|
||||
top.swap(*aTop);
|
||||
}
|
||||
|
||||
prevParent = parent;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newParent;
|
||||
nsresult rv;
|
||||
if (aScriptable) {
|
||||
rv = parent->GetScriptableParent(getter_AddRefs(newParent));
|
||||
}
|
||||
else {
|
||||
rv = parent->GetParent(getter_AddRefs(newParent));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
parent = newParent;
|
||||
|
||||
} while (parent != prevParent);
|
||||
|
||||
if (parent) {
|
||||
parent.swap(*aTop);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -7070,43 +6996,12 @@ nsGlobalWindow::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
|
|||
mCachedXBLPrototypeHandlers.Put(aKey, aHandler.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* GetScriptableFrameElement is called when script reads
|
||||
* nsIGlobalWindow::frameElement.
|
||||
*
|
||||
* In contrast to GetRealFrameElement, GetScriptableFrameElement says that the
|
||||
* window contained by an <iframe mozbrowser> has no frame element
|
||||
* (effectively treating a mozbrowser the same as a content/chrome boundary).
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetScriptableFrameElement(nsIDOMElement** aFrameElement)
|
||||
nsGlobalWindow::GetFrameElement(nsIDOMElement** aFrameElement)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetScriptableFrameElement, (aFrameElement), NS_ERROR_NOT_INITIALIZED);
|
||||
*aFrameElement = NULL;
|
||||
FORWARD_TO_OUTER(GetFrameElement, (aFrameElement), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool isMozBrowser = false;
|
||||
mDocShell->GetIsBrowserFrame(&isMozBrowser);
|
||||
if (isMozBrowser) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return GetFrameElement(aFrameElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* nsIGlobalWindow::GetFrameElement (when called from C++) is just a wrapper
|
||||
* around GetRealFrameElement.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetRealFrameElement(nsIDOMElement** aFrameElement)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetRealFrameElement, (aFrameElement), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
*aFrameElement = NULL;
|
||||
*aFrameElement = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTI(do_QueryInterface(mDocShell));
|
||||
|
||||
|
|
|
@ -402,16 +402,6 @@ public:
|
|||
return FromSupports(wrapper->Native());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap nsIDOMWindow::GetTop so we can overload the inline GetTop()
|
||||
* implementation below. (nsIDOMWindow::GetTop simply calls
|
||||
* nsIDOMWindow::GetRealTop().)
|
||||
*/
|
||||
nsresult GetTop(nsIDOMWindow **aWindow)
|
||||
{
|
||||
return nsIDOMWindow::GetTop(aWindow);
|
||||
}
|
||||
|
||||
inline nsGlobalWindow *GetTop()
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> top;
|
||||
|
@ -573,9 +563,6 @@ public:
|
|||
|
||||
void AddEventTargetObject(nsDOMEventTargetHelper* aObject);
|
||||
void RemoveEventTargetObject(nsDOMEventTargetHelper* aObject);
|
||||
private:
|
||||
// Implements Get{Real,Scriptable}Top.
|
||||
nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
|
||||
|
||||
protected:
|
||||
friend class HashchangeCallback;
|
||||
|
|
|
@ -70,7 +70,7 @@ interface nsIDOMMozURLProperty : nsISupports
|
|||
* @see <http://www.whatwg.org/html/#window>
|
||||
*/
|
||||
|
||||
[scriptable, uuid(17400E2B-F78B-4E69-B500-C2A3135A40FD)]
|
||||
[scriptable, uuid(f6e3b10d-d5f4-4fcd-aa4c-5f98626d428a)]
|
||||
interface nsIDOMWindow : nsISupports
|
||||
{
|
||||
// the current browsing context
|
||||
|
@ -134,91 +134,25 @@ interface nsIDOMWindow : nsISupports
|
|||
readonly attribute unsigned long length;
|
||||
|
||||
/**
|
||||
* |top| gets the root of the window hierarchy.
|
||||
* Accessor for the root of this hierarchy of windows. This root may
|
||||
* be the window itself if there is no parent, or if the parent is
|
||||
* of different type (i.e. this does not cross chrome-content
|
||||
* boundaries).
|
||||
*
|
||||
* This function does not cross chrome-content boundaries, so if this
|
||||
* window's parent is of a different type, |top| will return this window.
|
||||
*
|
||||
* When script reads the top property, we run GetScriptableTop, which
|
||||
* will not cross an <iframe mozbrowser> boundary.
|
||||
*
|
||||
* In contrast, C++ calls to GetTop are forwarded to GetRealTop, which
|
||||
* ignores <iframe mozbrowser> boundaries.
|
||||
*
|
||||
* This property is "replaceable" in JavaScript.
|
||||
*/
|
||||
[binaryname(ScriptableTop)]
|
||||
* This property is "replaceable" in JavaScript */
|
||||
readonly attribute nsIDOMWindow top;
|
||||
|
||||
/**
|
||||
* You shouldn't need to call this function directly; call GetTop instead.
|
||||
*/
|
||||
[noscript]
|
||||
readonly attribute nsIDOMWindow realTop;
|
||||
|
||||
%{C++
|
||||
nsresult GetTop(nsIDOMWindow **aWindow)
|
||||
{
|
||||
return GetRealTop(aWindow);
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* |parent| gets this window's parent window. If this window has no parent,
|
||||
* we return the window itself.
|
||||
*
|
||||
* This property does not cross chrome-content boundaries, so if this
|
||||
* window's parent is of a different type, we return the window itself as its
|
||||
* parent.
|
||||
*
|
||||
* When script reads the property (or when C++ calls ScriptableTop), this
|
||||
* property does not cross <iframe mozbrowser> boundaries. In contrast, when
|
||||
* C++ calls GetParent, we ignore the mozbrowser attribute.
|
||||
*/
|
||||
[binaryname(ScriptableParent)]
|
||||
readonly attribute nsIDOMWindow parent;
|
||||
|
||||
/**
|
||||
* You shouldn't need to read this property directly; call GetParent instead.
|
||||
*/
|
||||
[noscript]
|
||||
readonly attribute nsIDOMWindow realParent;
|
||||
|
||||
%{C++
|
||||
inline nsresult GetParent(nsIDOMWindow **aWindow)
|
||||
{
|
||||
return GetRealParent(aWindow);
|
||||
}
|
||||
%}
|
||||
|
||||
attribute nsIDOMWindow opener;
|
||||
|
||||
/**
|
||||
* |frameElement| gets this window's <iframe> or <frame> element, if it has
|
||||
* one.
|
||||
*
|
||||
* When script reads this property (or when C++ calls
|
||||
* ScriptableFrameElement), we return |null| if the window is inside an
|
||||
* <iframe mozbrowser>. In contrast, when C++ calls GetFrameElement, we
|
||||
* ignore the mozbrowser attribute.
|
||||
* Accessor for this window's parent window, or the window itself if
|
||||
* there is no parent, or if the parent is of different type
|
||||
* (i.e. this does not cross chrome-content boundaries).
|
||||
*/
|
||||
[binaryname(ScriptableFrameElement)]
|
||||
readonly attribute nsIDOMWindow parent;
|
||||
|
||||
readonly attribute nsIDOMElement frameElement;
|
||||
|
||||
/**
|
||||
* You shouldn't need to read this property directly; call GetFrameElement
|
||||
* instead.
|
||||
*/
|
||||
[noscript]
|
||||
readonly attribute nsIDOMElement realFrameElement;
|
||||
|
||||
%{C++
|
||||
inline nsresult GetFrameElement(nsIDOMElement **aElement)
|
||||
{
|
||||
return GetRealFrameElement(aElement);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
// the user agent
|
||||
readonly attribute nsIDOMNavigator navigator;
|
||||
|
|
Загрузка…
Ссылка в новой задаче