mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 775464 - Part 1: Add nsILoadContext::GetTopFrameElement. r=smaug
--HG-- extra : rebase_source : 92b8b11f6111db27ff6563a295000675ec0ddae9
This commit is contained in:
parent
4d3c9f2aaf
commit
de66d7d2ca
@ -13,6 +13,17 @@ namespace mozilla {
|
||||
|
||||
NS_IMPL_ISUPPORTS1(LoadContext, nsILoadContext);
|
||||
|
||||
LoadContext::LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
nsIDOMElement* aTopFrameElemenet)
|
||||
: mIsNotNull(aToCopy.mIsNotNull)
|
||||
, mIsContent(aToCopy.mIsContent)
|
||||
, mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
|
||||
, mIsInBrowserElement(aToCopy.mIsInBrowserElement)
|
||||
, mAppId(aToCopy.mAppId)
|
||||
, mTopFrameElement(do_GetWeakReference(aTopFrameElemenet))
|
||||
{}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LoadContext::nsILoadContext
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -35,6 +46,14 @@ LoadContext::GetTopWindow(nsIDOMWindow**)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetTopFrameElement(nsIDOMElement** aElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryReferent(mTopFrameElement);
|
||||
element.forget(aElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::IsAppOfType(uint32_t, bool*)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -28,20 +29,24 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILOADCONTEXT
|
||||
|
||||
LoadContext(const IPC::SerializedLoadContext& toCopy)
|
||||
: mIsNotNull(toCopy.mIsNotNull)
|
||||
, mIsContent(toCopy.mIsContent)
|
||||
, mUsePrivateBrowsing(toCopy.mUsePrivateBrowsing)
|
||||
, mIsInBrowserElement(toCopy.mIsInBrowserElement)
|
||||
, mAppId(toCopy.mAppId)
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy)
|
||||
: mIsNotNull(aToCopy.mIsNotNull)
|
||||
, mIsContent(aToCopy.mIsContent)
|
||||
, mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
|
||||
, mIsInBrowserElement(aToCopy.mIsInBrowserElement)
|
||||
, mAppId(aToCopy.mAppId)
|
||||
{}
|
||||
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
nsIDOMElement* aTopFrameElemenet);
|
||||
|
||||
private:
|
||||
bool mIsNotNull;
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mIsInBrowserElement;
|
||||
uint32_t mAppId;
|
||||
nsWeakPtr mTopFrameElement;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -11515,6 +11515,24 @@ nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
|
||||
{
|
||||
*aElement = nullptr;
|
||||
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(GetAsSupports(this));
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> top;
|
||||
win->GetScriptableTop(getter_AddRefs(top));
|
||||
NS_ENSURE_TRUE(top, NS_ERROR_FAILURE);
|
||||
|
||||
// GetFrameElement, /not/ GetScriptableFrameElement -- if |top| is inside
|
||||
// <iframe mozbrowser>, we want to return the iframe, not null.
|
||||
return top->GetFrameElement(aElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::IsAppOfType(uint32_t aAppType, bool *aIsOfType)
|
||||
{
|
||||
|
@ -222,6 +222,7 @@ public:
|
||||
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
|
||||
NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**);
|
||||
NS_IMETHOD GetTopWindow(nsIDOMWindow**);
|
||||
NS_IMETHOD GetTopFrameElement(nsIDOMElement**);
|
||||
NS_IMETHOD IsAppOfType(uint32_t, bool*);
|
||||
NS_IMETHOD GetIsContent(bool*);
|
||||
NS_IMETHOD GetUsePrivateBrowsing(bool*);
|
||||
|
@ -7,13 +7,14 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDOMElement;
|
||||
|
||||
/**
|
||||
* An nsILoadContext represents the context of a load. This interface
|
||||
* can be queried for various information about where the load is
|
||||
* happening.
|
||||
*/
|
||||
[scriptable, uuid(48b5bf16-e0c7-11e1-b28e-91726188709b)]
|
||||
[scriptable, uuid(17f6a38a-3f4b-4c94-8252-9d9f7dbf4960)]
|
||||
interface nsILoadContext : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -33,6 +34,15 @@ interface nsILoadContext : nsISupports
|
||||
*/
|
||||
readonly attribute nsIDOMWindow topWindow;
|
||||
|
||||
/**
|
||||
* topFrameElement is the <iframe> or <frame> element which contains the
|
||||
* topWindow with which the load is associated.
|
||||
*
|
||||
* Note that we may have a topFrameElement even when we don't have an
|
||||
* associatedWindow, if the topFrameElement's content lives out of process.
|
||||
*/
|
||||
readonly attribute nsIDOMElement topFrameElement;
|
||||
|
||||
/**
|
||||
* Check whether the load is happening in a particular type of application.
|
||||
*
|
||||
|
@ -47,7 +47,7 @@ HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding)
|
||||
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &handler);
|
||||
NS_ASSERTION(handler, "no http handler");
|
||||
|
||||
mTabParent = do_QueryObject(static_cast<TabParent*>(iframeEmbedding));
|
||||
mTabParent = static_cast<mozilla::dom::TabParent*>(iframeEmbedding);
|
||||
}
|
||||
|
||||
HttpChannelParent::~HttpChannelParent()
|
||||
@ -147,8 +147,12 @@ HttpChannelParent::RecvAsyncOpen(const URIParams& aURI,
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
if (loadContext.IsNotNull())
|
||||
mLoadContext = new LoadContext(loadContext);
|
||||
if (loadContext.IsNotNull()) {
|
||||
if (mTabParent)
|
||||
mLoadContext = new LoadContext(loadContext, mTabParent->GetOwnerElement());
|
||||
else
|
||||
mLoadContext = new LoadContext(loadContext);
|
||||
}
|
||||
|
||||
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
||||
|
||||
|
@ -14,13 +14,17 @@
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
#include "nsIParentRedirectingChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsITabParent.h"
|
||||
#include "nsHttpChannel.h"
|
||||
|
||||
class nsICacheEntryDescriptor;
|
||||
class nsIAssociatedContentSecurity;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom{
|
||||
class TabParent;
|
||||
}
|
||||
|
||||
namespace net {
|
||||
|
||||
class HttpChannelParentListener;
|
||||
@ -83,7 +87,7 @@ protected:
|
||||
|
||||
protected:
|
||||
friend class mozilla::net::HttpChannelParentListener;
|
||||
nsCOMPtr<nsITabParent> mTabParent;
|
||||
nsRefPtr<mozilla::dom::TabParent> mTabParent;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
Loading…
Reference in New Issue
Block a user