mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 964239 - Docshell and session history changes to add baseURI information to srcdoc loads. r=bz
This commit is contained in:
parent
3e8a969a0d
commit
1165641363
@ -1337,6 +1337,7 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
||||
nsXPIDLString target;
|
||||
nsAutoString srcdoc;
|
||||
nsCOMPtr<nsIDocShell> sourceDocShell;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
uint32_t loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
|
||||
|
||||
@ -1367,6 +1368,7 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
||||
aLoadInfo->GetIsSrcdocLoad(&isSrcdoc);
|
||||
aLoadInfo->GetSrcdocData(srcdoc);
|
||||
aLoadInfo->GetSourceDocShell(getter_AddRefs(sourceDocShell));
|
||||
aLoadInfo->GetBaseURI(getter_AddRefs(baseURI));
|
||||
}
|
||||
|
||||
#if defined(PR_LOGGING) && defined(DEBUG)
|
||||
@ -1613,6 +1615,7 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
||||
aFirstParty,
|
||||
srcdoc,
|
||||
sourceDocShell,
|
||||
baseURI,
|
||||
nullptr, // No nsIDocShell
|
||||
nullptr); // No nsIRequest
|
||||
}
|
||||
@ -4809,7 +4812,8 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const char16_t *aURL,
|
||||
return InternalLoad(errorPageURI, nullptr, nullptr,
|
||||
INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr, nullptr,
|
||||
NullString(), nullptr, nullptr, LOAD_ERROR_PAGE,
|
||||
nullptr, true, NullString(), this, nullptr, nullptr);
|
||||
nullptr, true, NullString(), this, nullptr, nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -4855,6 +4859,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
||||
nsAutoString srcdoc;
|
||||
nsIPrincipal* principal = nullptr;
|
||||
nsAutoString contentTypeHint;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
if (doc) {
|
||||
principal = doc->NodePrincipal();
|
||||
doc->GetContentType(contentTypeHint);
|
||||
@ -4862,6 +4867,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
||||
if (doc->IsSrcdocDocument()) {
|
||||
doc->GetSrcdocData(srcdoc);
|
||||
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
baseURI = doc->GetBaseURI();
|
||||
}
|
||||
}
|
||||
rv = InternalLoad(mCurrentURI,
|
||||
@ -4878,6 +4884,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
||||
true,
|
||||
srcdoc, // srcdoc argument for iframe
|
||||
this, // For reloads we are the source
|
||||
baseURI,
|
||||
nullptr, // No nsIDocShell
|
||||
nullptr); // No nsIRequest
|
||||
}
|
||||
@ -8683,7 +8690,8 @@ public:
|
||||
const char* aTypeHint, nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData, uint32_t aLoadType,
|
||||
nsISHEntry * aSHEntry, bool aFirstParty,
|
||||
const nsAString &aSrcdoc, nsIDocShell* aSourceDocShell) :
|
||||
const nsAString &aSrcdoc, nsIDocShell* aSourceDocShell,
|
||||
nsIURI * aBaseURI) :
|
||||
mSrcdoc(aSrcdoc),
|
||||
mDocShell(aDocShell),
|
||||
mURI(aURI),
|
||||
@ -8695,7 +8703,8 @@ public:
|
||||
mFlags(aFlags),
|
||||
mLoadType(aLoadType),
|
||||
mFirstParty(aFirstParty),
|
||||
mSourceDocShell(aSourceDocShell)
|
||||
mSourceDocShell(aSourceDocShell),
|
||||
mBaseURI(aBaseURI)
|
||||
{
|
||||
// Make sure to keep null things null as needed
|
||||
if (aTypeHint) {
|
||||
@ -8708,7 +8717,8 @@ public:
|
||||
nullptr, mTypeHint.get(),
|
||||
NullString(), mPostData, mHeadersData,
|
||||
mLoadType, mSHEntry, mFirstParty,
|
||||
mSrcdoc, mSourceDocShell, nullptr, nullptr);
|
||||
mSrcdoc, mSourceDocShell, mBaseURI,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -8729,6 +8739,7 @@ private:
|
||||
uint32_t mLoadType;
|
||||
bool mFirstParty;
|
||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -8763,6 +8774,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
bool aFirstParty,
|
||||
const nsAString &aSrcdoc,
|
||||
nsIDocShell* aSourceDocShell,
|
||||
nsIURI* aBaseURI,
|
||||
nsIDocShell** aDocShell,
|
||||
nsIRequest** aRequest)
|
||||
{
|
||||
@ -9018,6 +9030,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
aFirstParty,
|
||||
aSrcdoc,
|
||||
aSourceDocShell,
|
||||
aBaseURI,
|
||||
aDocShell,
|
||||
aRequest);
|
||||
if (rv == NS_ERROR_NO_CONTENT) {
|
||||
@ -9089,7 +9102,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
new InternalLoadEvent(this, aURI, aReferrer, aOwner, aFlags,
|
||||
aTypeHint, aPostData, aHeadersData,
|
||||
aLoadType, aSHEntry, aFirstParty, aSrcdoc,
|
||||
aSourceDocShell);
|
||||
aSourceDocShell, aBaseURI);
|
||||
return NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
|
||||
@ -9538,7 +9551,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
(aFlags & INTERNAL_LOAD_FLAGS_FIRST_LOAD) != 0,
|
||||
(aFlags & INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER) != 0,
|
||||
(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES) != 0,
|
||||
srcdoc);
|
||||
srcdoc, aBaseURI);
|
||||
if (req && aRequest)
|
||||
NS_ADDREF(*aRequest = req);
|
||||
|
||||
@ -9617,7 +9630,8 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
bool aIsNewWindowTarget,
|
||||
bool aBypassClassifier,
|
||||
bool aForceAllowCookies,
|
||||
const nsAString &aSrcdoc)
|
||||
const nsAString &aSrcdoc,
|
||||
nsIURI * aBaseURI)
|
||||
{
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
nsAutoCString urlSpec;
|
||||
@ -9702,7 +9716,8 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
nsViewSourceHandler *vsh = nsViewSourceHandler::GetInstance();
|
||||
NS_ENSURE_TRUE(vsh,NS_ERROR_FAILURE);
|
||||
|
||||
rv = vsh->NewSrcdocChannel(aURI, aSrcdoc,getter_AddRefs(channel));
|
||||
rv = vsh->NewSrcdocChannel(aURI, aSrcdoc, aBaseURI,
|
||||
getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
@ -9711,6 +9726,9 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
NS_LITERAL_CSTRING("text/html"),
|
||||
true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(channel);
|
||||
MOZ_ASSERT(isc);
|
||||
isc->SetBaseURI(aBaseURI);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10969,6 +10987,9 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
|
||||
nsAutoString srcdoc;
|
||||
inStrmChan->GetSrcdocData(srcdoc);
|
||||
entry->SetSrcdocData(srcdoc);
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
inStrmChan->GetBaseURI(getter_AddRefs(baseURI));
|
||||
entry->SetBaseURI(baseURI);
|
||||
}
|
||||
}
|
||||
/* If cache got a 'no-store', ask SH not to store
|
||||
@ -11122,9 +11143,11 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, uint32_t aLoadType)
|
||||
|
||||
nsAutoString srcdoc;
|
||||
bool isSrcdoc;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
aEntry->GetIsSrcdocEntry(&isSrcdoc);
|
||||
if (isSrcdoc) {
|
||||
aEntry->GetSrcdocData(srcdoc);
|
||||
aEntry->GetBaseURI(getter_AddRefs(baseURI));
|
||||
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
}
|
||||
else {
|
||||
@ -11149,6 +11172,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, uint32_t aLoadType)
|
||||
true,
|
||||
srcdoc,
|
||||
nullptr, // Source docshell, see comment above
|
||||
baseURI,
|
||||
nullptr, // No nsIDocShell
|
||||
nullptr); // No nsIRequest
|
||||
return rv;
|
||||
@ -12564,6 +12588,7 @@ nsDocShell::OnLinkClickSync(nsIContent *aContent,
|
||||
true, // first party site
|
||||
NullString(), // No srcdoc
|
||||
this, // We are the source
|
||||
nullptr, // baseURI not needed
|
||||
aDocShell, // DocShell out-param
|
||||
aRequest); // Request out-param
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -287,7 +287,8 @@ protected:
|
||||
bool aIsNewWindowTarget,
|
||||
bool aBypassClassifier,
|
||||
bool aForceAllowCookies,
|
||||
const nsAString &aSrcdoc);
|
||||
const nsAString &aSrcdoc,
|
||||
nsIURI * baseURI);
|
||||
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
|
||||
nsIChannel * aChannel);
|
||||
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
|
||||
|
@ -225,6 +225,21 @@ NS_IMETHODIMP nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo: Helpers
|
||||
//*****************************************************************************
|
||||
|
@ -45,6 +45,7 @@ protected:
|
||||
bool mIsSrcdocLoad;
|
||||
nsString mSrcdocData;
|
||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
};
|
||||
|
||||
#endif /* nsDocShellLoadInfo_h__ */
|
||||
|
@ -44,7 +44,7 @@ interface nsIReflowObserver;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(af035c67-1690-431b-9c4d-d38e3cc3137a)]
|
||||
[scriptable, builtinclass, uuid(d0eaef67-4234-47de-b05a-9c7b324eb4f4)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
@ -139,6 +139,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
* contents of this parameter will be loaded instead
|
||||
* of aURI.
|
||||
* @param aSourceDocShell - The source browsing context for the navigation.
|
||||
* @param aBaseURI - The base URI to be used for the load. Set in
|
||||
* srcdoc loads as it cannot otherwise be inferred
|
||||
* in certain situations such as view-source.
|
||||
*/
|
||||
[noscript]void internalLoad(in nsIURI aURI,
|
||||
in nsIURI aReferrer,
|
||||
@ -154,6 +157,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
in boolean firstParty,
|
||||
in AString aSrcdoc,
|
||||
in nsIDocShell aSourceDocShell,
|
||||
in nsIURI aBaseURI,
|
||||
out nsIDocShell aDocShell,
|
||||
out nsIRequest aRequest);
|
||||
|
||||
|
@ -18,7 +18,7 @@ interface nsIDocShell;
|
||||
|
||||
typedef long nsDocShellInfoLoadType;
|
||||
|
||||
[scriptable, uuid(c6b15de3-2f4f-4e80-bb20-95f43b5598c7)]
|
||||
[scriptable, uuid(c8d3b1e1-565a-427e-9d68-b109910ce9b7)]
|
||||
interface nsIDocShellLoadInfo : nsISupports
|
||||
{
|
||||
/** This is the referrer for the load. */
|
||||
@ -98,4 +98,10 @@ interface nsIDocShellLoadInfo : nsISupports
|
||||
|
||||
/** When set, this is the Source Browsing Context for the navigation. */
|
||||
attribute nsIDocShell sourceDocShell;
|
||||
|
||||
/**
|
||||
* Used for srcdoc loads to give view-source knowledge of the load's base
|
||||
* URI as this information isn't embedded in the load's URI.
|
||||
*/
|
||||
attribute nsIURI baseURI;
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ class nsSHEntryShared;
|
||||
[ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
|
||||
[ptr] native nsSHEntryShared(nsSHEntryShared);
|
||||
|
||||
[scriptable, uuid(c2a5827e-0fc0-11e3-bb95-59e799890b3c)]
|
||||
[scriptable, uuid(9eed7e92-1121-46f2-95e5-2f5c0dca46f0)]
|
||||
interface nsISHEntry : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -277,6 +277,13 @@ interface nsISHEntry : nsISupports
|
||||
* Setting this sets isSrcdocEntry to true
|
||||
*/
|
||||
attribute AString srcdocData;
|
||||
|
||||
/**
|
||||
* When isSrcdocEntry is true, this contains the baseURI of the srcdoc
|
||||
* document for use in situations where it cannot otherwise be determined,
|
||||
* for example with view-source.
|
||||
*/
|
||||
attribute nsIURI baseURI;
|
||||
};
|
||||
|
||||
[scriptable, uuid(bb66ac35-253b-471f-a317-3ece940f04c5)]
|
||||
|
@ -53,6 +53,7 @@ nsSHEntry::nsSHEntry(const nsSHEntry &other)
|
||||
, mStateData(other.mStateData)
|
||||
, mIsSrcdocEntry(other.mIsSrcdocEntry)
|
||||
, mSrcdocData(other.mSrcdocData)
|
||||
, mBaseURI(other.mBaseURI)
|
||||
{
|
||||
}
|
||||
|
||||
@ -516,7 +517,20 @@ nsSHEntry::SetSrcdocData(const nsAString &aSrcdocData)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetBaseURI(nsIURI **aBaseURI)
|
||||
{
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::SetBaseURI(nsIURI *aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHEntry: nsISHContainer
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
nsCOMPtr<nsIStructuredCloneContainer> mStateData;
|
||||
bool mIsSrcdocEntry;
|
||||
nsString mSrcdocData;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
};
|
||||
|
||||
#endif /* nsSHEntry_h */
|
||||
|
Loading…
Reference in New Issue
Block a user