Skip to content

Commit

Permalink
Bug 1492648 - Move from nsDocShellLoadInfo to nsDocShellLoadState r=b…
Browse files Browse the repository at this point in the history
…zbarsky,nika

Creates the nsDocShellLoadState object, which is basically
nsDocShellLoadInfo plus a few extra fields to make it usable as a
single argument to nsDocShell::LoadURI (and eventually
nsDocShell::InternalLoad).

Subframe history handling is a huge logic block in
nsDocShell::LoadURI, which is only used on history loads. This patch
also extracts the logic out into its own function to make the body of
LoadURI clearer.

Differential Revision: https://phabricator.services.mozilla.com/D6944

--HG--
rename : docshell/base/nsDocShellLoadInfo.cpp => docshell/base/nsDocShellLoadState.cpp
rename : docshell/base/nsDocShellLoadInfo.h => docshell/base/nsDocShellLoadState.h
extra : moz-landing-system : lando
  • Loading branch information
qdot committed Oct 26, 2018
1 parent 96d721e commit ca0550b
Show file tree
Hide file tree
Showing 27 changed files with 1,022 additions and 823 deletions.
15 changes: 10 additions & 5 deletions caps/NullPrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,24 @@ NS_IMPL_CI_INTERFACE_GETTER(NullPrincipal,
/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
{
RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return nullPrin.forget();
MOZ_ASSERT(aInheritFrom);
return CreateWithInheritedAttributes(Cast(aInheritFrom)->OriginAttributesRef(), false);
}

/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty)
{
MOZ_ASSERT(aDocShell);

OriginAttributes attrs = nsDocShell::Cast(aDocShell)->GetOriginAttributes();
return CreateWithInheritedAttributes(attrs, aIsFirstParty);
}

/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::CreateWithInheritedAttributes(const OriginAttributes& aOriginAttributes, bool aIsFirstParty)
{
RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
nsresult rv = nullPrin->Init(attrs, aIsFirstParty);
nsresult rv = nullPrin->Init(aOriginAttributes, aIsFirstParty);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return nullPrin.forget();
}
Expand Down
12 changes: 9 additions & 3 deletions caps/NullPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ class NullPrincipal final : public BasePrincipal
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
NS_IMETHOD GetAddonId(nsAString& aAddonId) override;

static already_AddRefed<NullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
static already_AddRefed<NullPrincipal>
CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);

// Create NullPrincipal with origin attributes from docshell.
// If aIsFirstParty is true, and the pref 'privacy.firstparty.isolate' is also
// enabled, the mFirstPartyDomain value of the origin attributes will be set
// to an unique value.
static already_AddRefed<NullPrincipal>
CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty = false);
CreateWithInheritedAttributes(nsIDocShell* aDocShell,
bool aIsFirstParty = false);
static already_AddRefed<NullPrincipal>
CreateWithInheritedAttributes(const OriginAttributes& aOriginAttributes,
bool aIsFirstParty = false);

static already_AddRefed<NullPrincipal>
Create(const OriginAttributes& aOriginAttributes,
Expand All @@ -85,7 +90,8 @@ class NullPrincipal final : public BasePrincipal
protected:
virtual ~NullPrincipal() = default;

bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override
bool SubsumesInternal(nsIPrincipal* aOther,
DocumentDomainConsideration aConsideration) override
{
return aOther == this;
}
Expand Down
4 changes: 2 additions & 2 deletions docshell/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ XPIDL_MODULE = 'docshell'
EXPORTS += [
'nsCTooltipTextProvider.h',
'nsDocShell.h',
'nsDocShellLoadInfo.h',
'nsDocShellLoadState.h',
'nsDocShellLoadTypes.h',
'nsDocShellTreeOwner.h',
'nsILinkHandler.h',
Expand All @@ -88,7 +88,7 @@ UNIFIED_SOURCES += [
'nsDocShell.cpp',
'nsDocShellEditorData.cpp',
'nsDocShellEnumerator.cpp',
'nsDocShellLoadInfo.cpp',
'nsDocShellLoadState.cpp',
'nsDocShellTreeOwner.cpp',
'nsDSURIContentListener.cpp',
'nsPingListener.cpp',
Expand Down
Loading

0 comments on commit ca0550b

Please sign in to comment.