Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Andreea Pavel 2018-07-13 00:51:26 +03:00
Родитель 0b74f5f689 754824a1ae
Коммит b0e30af17e
206 изменённых файлов: 4593 добавлений и 4374 удалений

Просмотреть файл

@ -11,9 +11,19 @@
#include "mozilla/Types.h"
#include "mozilla/WindowsDllBlocklist.h"
#define MOZ_LITERAL_UNICODE_STRING(s) \
{ \
/* Length of the string in bytes, less the null terminator */ \
sizeof(s) - sizeof(wchar_t), \
/* Length of the string in bytes, including the null terminator */ \
sizeof(s), \
/* Pointer to the buffer */ \
const_cast<wchar_t*>(s) \
}
#define DLL_BLOCKLIST_ENTRY(name, ...) \
{ L##name, __VA_ARGS__ },
#define DLL_BLOCKLIST_CHAR_TYPE wchar_t
{ MOZ_LITERAL_UNICODE_STRING(L##name), __VA_ARGS__ },
#define DLL_BLOCKLIST_STRING_TYPE UNICODE_STRING
// Restrict the blocklist definitions to Nightly-only for now
#if defined(NIGHTLY_BUILD)
@ -34,13 +44,13 @@ class MOZ_STATIC_CLASS MOZ_TRIVIAL_CTOR_DTOR NativeNtBlockSet final
{
NativeNtBlockSetEntry() = default;
~NativeNtBlockSetEntry() = default;
NativeNtBlockSetEntry(const wchar_t* aName, uint64_t aVersion,
NativeNtBlockSetEntry(const UNICODE_STRING& aName, uint64_t aVersion,
NativeNtBlockSetEntry* aNext)
: mName(aName)
, mVersion(aVersion)
, mNext(aNext)
{}
const wchar_t* mName;
UNICODE_STRING mName;
uint64_t mVersion;
NativeNtBlockSetEntry* mNext;
};
@ -50,11 +60,12 @@ public:
NativeNtBlockSet() = default;
~NativeNtBlockSet() = default;
void Add(const wchar_t* aName, uint64_t aVersion);
void Add(const UNICODE_STRING& aName, uint64_t aVersion);
void Write(HANDLE aFile);
private:
static NativeNtBlockSetEntry* NewEntry(const wchar_t* aName, uint64_t aVersion,
static NativeNtBlockSetEntry* NewEntry(const UNICODE_STRING& aName,
uint64_t aVersion,
NativeNtBlockSetEntry* aNextEntry);
private:
@ -65,7 +76,7 @@ private:
};
NativeNtBlockSet::NativeNtBlockSetEntry*
NativeNtBlockSet::NewEntry(const wchar_t* aName, uint64_t aVersion,
NativeNtBlockSet::NewEntry(const UNICODE_STRING& aName, uint64_t aVersion,
NativeNtBlockSet::NativeNtBlockSetEntry* aNextEntry)
{
HANDLE processHeap = mozilla::nt::RtlGetProcessHeap();
@ -82,14 +93,13 @@ NativeNtBlockSet::NewEntry(const wchar_t* aName, uint64_t aVersion,
}
void
NativeNtBlockSet::Add(const wchar_t* aName, uint64_t aVersion)
NativeNtBlockSet::Add(const UNICODE_STRING& aName, uint64_t aVersion)
{
::RtlAcquireSRWLockExclusive(&mLock);
for (NativeNtBlockSetEntry* entry = mFirstEntry; entry; entry = entry->mNext) {
// We just need to compare the string pointers, not the strings themselves,
// as we always pass in the strings statically defined in the blocklist.
if (aName == entry->mName && aVersion == entry->mVersion) {
if (::RtlEqualUnicodeString(&entry->mName, &aName, TRUE) &&
aVersion == entry->mVersion) {
::RtlReleaseSRWLockExclusive(&mLock);
return;
}
@ -118,8 +128,9 @@ NativeNtBlockSet::Write(HANDLE aFile)
MOZ_SEH_TRY {
for (auto entry = mFirstEntry; entry; entry = entry->mNext) {
int convOk = ::WideCharToMultiByte(CP_UTF8, 0, entry->mName, -1, buf,
sizeof(buf), nullptr, nullptr);
int convOk = ::WideCharToMultiByte(CP_UTF8, 0, entry->mName.Buffer,
entry->mName.Length / sizeof(wchar_t),
buf, sizeof(buf), nullptr, nullptr);
if (!convOk) {
continue;
}
@ -225,11 +236,11 @@ IsDllAllowed(const UNICODE_STRING& aLeafName, void* aBaseAddress)
return false;
}
UNICODE_STRING testStr;
DECLARE_POINTER_TO_FIRST_DLL_BLOCKLIST_ENTRY(info);
while (info->name) {
::RtlInitUnicodeString(&testStr, info->name);
if (::RtlEqualUnicodeString(&aLeafName, &testStr, TRUE)) {
DECLARE_POINTER_TO_LAST_DLL_BLOCKLIST_ENTRY(end);
while (info < end) {
if (::RtlEqualUnicodeString(&aLeafName, &info->name, TRUE)) {
break;
}
@ -237,7 +248,7 @@ IsDllAllowed(const UNICODE_STRING& aLeafName, void* aBaseAddress)
}
uint64_t version;
if (info->name && !CheckBlockInfo(info, aBaseAddress, version)) {
if (info->name.Length && !CheckBlockInfo(info, aBaseAddress, version)) {
gBlockSet.Add(info->name, version);
return false;
}

Просмотреть файл

@ -148,6 +148,13 @@ MatchUnicodeString(const UNICODE_STRING& aStr, bool (*aPredicate)(WCHAR))
inline bool
Contains12DigitHexString(const UNICODE_STRING& aLeafName)
{
// Quick check: If the string is too short, don't bother
// (We need at least 12 hex digits, one char for '.', and 3 for extension)
const USHORT kMinLen = (12 + 1 + 3) * sizeof(wchar_t);
if (aLeafName.Length < kMinLen) {
return false;
}
uint16_t start, end;
if (!FindCharInUnicodeString(aLeafName, L'.', start)) {
return false;
@ -173,6 +180,13 @@ Contains12DigitHexString(const UNICODE_STRING& aLeafName)
inline bool
IsFileNameAtLeast16HexDigits(const UNICODE_STRING& aLeafName)
{
// Quick check: If the string is too short, don't bother
// (We need 16 hex digits, one char for '.', and 3 for extension)
const USHORT kMinLen = (16 + 1 + 3) * sizeof(wchar_t);
if (aLeafName.Length < kMinLen) {
return false;
}
uint16_t dotIndex;
if (!FindCharInUnicodeString(aLeafName, L'.', dotIndex)) {
return false;

Просмотреть файл

@ -7273,58 +7273,6 @@ exports.CSS_PROPERTIES = {
"unset"
]
},
"offset-block-end": {
"isInherited": false,
"subproperties": [
"inset-block-end"
],
"supports": [],
"values": [
"auto",
"inherit",
"initial",
"unset"
]
},
"offset-block-start": {
"isInherited": false,
"subproperties": [
"inset-block-start"
],
"supports": [],
"values": [
"auto",
"inherit",
"initial",
"unset"
]
},
"offset-inline-end": {
"isInherited": false,
"subproperties": [
"inset-inline-end"
],
"supports": [],
"values": [
"auto",
"inherit",
"initial",
"unset"
]
},
"offset-inline-start": {
"isInherited": false,
"subproperties": [
"inset-inline-start"
],
"supports": [],
"values": [
"auto",
"inherit",
"initial",
"unset"
]
},
"opacity": {
"isInherited": false,
"subproperties": [

Просмотреть файл

@ -41,7 +41,6 @@ XPIDL_SOURCES += [
'nsIContentViewer.idl',
'nsIContentViewerEdit.idl',
'nsIDocShell.idl',
'nsIDocShellLoadInfo.idl',
'nsIDocShellTreeItem.idl',
'nsIDocShellTreeOwner.idl',
'nsIDocumentLoaderFactory.idl',
@ -64,6 +63,7 @@ XPIDL_MODULE = 'docshell'
EXPORTS += [
'nsCTooltipTextProvider.h',
'nsDocShellLoadInfo.h',
'nsDocShellLoadTypes.h',
'nsDocShellTreeOwner.h',
'nsILinkHandler.h',

Просмотреть файл

@ -656,7 +656,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
NS_IMETHODIMP
nsDocShell::LoadURI(nsIURI* aURI,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
uint32_t aLoadFlags,
bool aFirstParty)
{
@ -705,30 +705,28 @@ nsDocShell::LoadURI(nsIURI* aURI,
// Extract the info from the DocShellLoadInfo struct...
if (aLoadInfo) {
aLoadInfo->GetReferrer(getter_AddRefs(referrer));
aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI));
GetMaybeResultPrincipalURI(aLoadInfo, resultPrincipalURI);
aLoadInfo->GetLoadReplace(&loadReplace);
nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
aLoadInfo->GetLoadType(&lt);
referrer = aLoadInfo->Referrer();
originalURI = aLoadInfo->OriginalURI();
aLoadInfo->GetMaybeResultPrincipalURI(resultPrincipalURI);
loadReplace = aLoadInfo->LoadReplace();
// Get the appropriate loadType from nsIDocShellLoadInfo type
loadType = ConvertDocShellInfoLoadTypeToLoadType(lt);
loadType = aLoadInfo->LoadType();
aLoadInfo->GetTriggeringPrincipal(getter_AddRefs(triggeringPrincipal));
aLoadInfo->GetInheritPrincipal(&inheritPrincipal);
aLoadInfo->GetPrincipalIsExplicit(&principalIsExplicit);
aLoadInfo->GetSHEntry(getter_AddRefs(shEntry));
aLoadInfo->GetTarget(getter_Copies(target));
aLoadInfo->GetPostDataStream(getter_AddRefs(postStream));
aLoadInfo->GetHeadersStream(getter_AddRefs(headersStream));
aLoadInfo->GetSendReferrer(&sendReferrer);
aLoadInfo->GetReferrerPolicy(&referrerPolicy);
aLoadInfo->GetIsSrcdocLoad(&isSrcdoc);
triggeringPrincipal = aLoadInfo->TriggeringPrincipal();
inheritPrincipal = aLoadInfo->InheritPrincipal();
principalIsExplicit = aLoadInfo->PrincipalIsExplicit();
shEntry = aLoadInfo->SHEntry();
aLoadInfo->GetTarget(target);
postStream = aLoadInfo->PostDataStream();
headersStream = aLoadInfo->HeadersStream();
sendReferrer = aLoadInfo->SendReferrer();
referrerPolicy = aLoadInfo->ReferrerPolicy();
isSrcdoc = aLoadInfo->IsSrcdocLoad();
aLoadInfo->GetSrcdocData(srcdoc);
aLoadInfo->GetSourceDocShell(getter_AddRefs(sourceDocShell));
aLoadInfo->GetBaseURI(getter_AddRefs(baseURI));
aLoadInfo->GetForceAllowDataURI(&forceAllowDataURI);
aLoadInfo->GetOriginalFrameSrc(&originalFrameSrc);
sourceDocShell = aLoadInfo->SourceDocShell();
baseURI = aLoadInfo->BaseURI();
forceAllowDataURI = aLoadInfo->ForceAllowDataURI();
originalFrameSrc = aLoadInfo->OriginalFrameSrc();
}
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
@ -1024,16 +1022,6 @@ nsDocShell::LoadURI(nsIURI* aURI,
nullptr); // No nsIRequest
}
NS_IMETHODIMP
nsDocShell::CreateLoadInfo(nsIDocShellLoadInfo** aLoadInfo)
{
nsDocShellLoadInfo* loadInfo = new nsDocShellLoadInfo();
nsCOMPtr<nsIDocShellLoadInfo> localRef(loadInfo);
localRef.forget(aLoadInfo);
return NS_OK;
}
/*
* Reset state to a new content model within the current document and the
* document viewer. Called by the document before initiating an out of band
@ -3726,21 +3714,19 @@ nsDocShell::GetChildSHEntry(int32_t aChildOffset, nsISHEntry** aResult)
/* Get the parent's Load Type so that it can be set on the child too.
* By default give a loadHistory value
*/
uint32_t loadType = nsIDocShellLoadInfo::loadHistory;
uint32_t loadType = LOAD_HISTORY;
mLSHE->GetLoadType(&loadType);
// If the user did a shift-reload on this frameset page,
// we don't want to load the subframes from history.
if (loadType == nsIDocShellLoadInfo::loadReloadBypassCache ||
loadType == nsIDocShellLoadInfo::loadReloadBypassProxy ||
loadType == nsIDocShellLoadInfo::loadReloadBypassProxyAndCache ||
loadType == nsIDocShellLoadInfo::loadRefresh) {
if (IsForceReloadType(loadType) ||
loadType == LOAD_REFRESH) {
return rv;
}
/* If the user pressed reload and the parent frame has expired
* from cache, we do not want to load the child frame from history.
*/
if (parentExpired && (loadType == nsIDocShellLoadInfo::loadReloadNormal)) {
if (parentExpired && (loadType == LOAD_RELOAD_NORMAL)) {
// The parent has expired. Return null.
*aResult = nullptr;
return rv;
@ -4228,11 +4214,7 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
uint32_t extraFlags = (aLoadFlags & EXTRA_LOAD_FLAGS);
aLoadFlags &= ~EXTRA_LOAD_FLAGS;
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
rv = CreateLoadInfo(getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) {
return rv;
}
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
/*
* If the user "Disables Protection on This Page", we have to make sure to
@ -4245,10 +4227,10 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
}
loadInfo->SetLoadType(ConvertLoadTypeToDocShellInfoLoadType(loadType));
loadInfo->SetLoadType(loadType);
loadInfo->SetPostDataStream(postStream);
loadInfo->SetReferrer(aReferringURI);
loadInfo->SetReferrerPolicy(aReferrerPolicy);
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
loadInfo->SetHeadersStream(aHeaderStream);
loadInfo->SetBaseURI(aBaseURI);
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
@ -6190,9 +6172,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
{
NS_ENSURE_ARG(aURI);
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_OUT_OF_MEMORY);
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
/* We do need to pass in a referrer, but we don't want it to
* be sent to the server.
@ -6228,7 +6208,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
* we have in mind (15000 ms as defined by REFRESH_REDIRECT_TIMER).
* Pass a REPLACE flag to LoadURI().
*/
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadNormalReplace);
loadInfo->SetLoadType(LOAD_NORMAL_REPLACE);
/* for redirects we mimic HTTP, which passes the
* original referrer
@ -6239,7 +6219,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
loadInfo->SetReferrer(internalReferrer);
}
} else {
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
loadInfo->SetLoadType(LOAD_REFRESH);
}
/*
@ -7091,7 +7071,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
// onLoadHandler tries to load something different in
// itself or one of its children, we can deal with it appropriately.
if (mLSHE) {
mLSHE->SetLoadType(nsIDocShellLoadInfo::loadHistory);
mLSHE->SetLoadType(LOAD_HISTORY);
// Clear the mLSHE reference to indicate document loading is done one
// way or another.
@ -9425,20 +9405,16 @@ nsDocShell::InternalLoad(nsIURI* aURI,
MOZ_ASSERT(!aSHEntry);
MOZ_ASSERT(aFirstParty); // Windowwatcher will assume this.
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
rv = CreateLoadInfo(getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) {
return rv;
}
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
// Set up our loadinfo so it will do the load as much like we would have
// as possible.
loadInfo->SetReferrer(aReferrer);
loadInfo->SetReferrerPolicy(aReferrerPolicy);
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
loadInfo->SetSendReferrer(!(aFlags &
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
loadInfo->SetOriginalURI(aOriginalURI);
SetMaybeResultPrincipalURI(loadInfo, aResultPrincipalURI);
loadInfo->SetMaybeResultPrincipalURI(aResultPrincipalURI);
loadInfo->SetLoadReplace(aLoadReplace);
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
loadInfo->SetInheritPrincipal(
@ -9446,7 +9422,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Explicit principal because we do not want any guesses as to what the
// principal to inherit is: it should be aTriggeringPrincipal.
loadInfo->SetPrincipalIsExplicit(true);
loadInfo->SetLoadType(ConvertLoadTypeToDocShellInfoLoadType(LOAD_LINK));
loadInfo->SetLoadType(LOAD_LINK);
loadInfo->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
rv = win->Open(NS_ConvertUTF8toUTF16(spec),
@ -10961,7 +10937,7 @@ nsDocShell::DoChannelLoad(nsIChannel* aChannel,
// If the user pressed shift-reload, then do not allow ServiceWorker
// interception to occur. See step 12.1 of the SW HandleFetch algorithm.
if (IsForceReloadType(mLoadType)) {
if (IsForceReloading()) {
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
}
@ -14217,3 +14193,9 @@ nsDocShell::GetColorMatrix(uint32_t* aMatrixLen, float** aMatrix)
return NS_OK;
}
bool
nsDocShell::IsForceReloading()
{
return IsForceReloadType(mLoadType);
}

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsIClipboardCommands.h"
#include "nsIDeprecationWarner.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMStorageManager.h"
#include "nsIInterfaceRequestor.h"
@ -376,6 +375,10 @@ public:
return static_cast<nsDocShell*>(aDocShell);
}
// Returns true if the current load is a force reload (started by holding
// shift while triggering reload)
bool IsForceReloading();
private: // member functions
friend class nsDSURIContentListener;
friend class FramingChecker;

Просмотреть файл

@ -11,54 +11,10 @@
#include "nsIDocShell.h"
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/Unused.h"
#include "mozilla/Maybe.h"
namespace mozilla {
void
GetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>>& aRPURI)
{
if (!aLoadInfo) {
return;
}
nsresult rv;
bool isSome;
rv = aLoadInfo->GetResultPrincipalURIIsSome(&isSome);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
aRPURI.reset();
if (!isSome) {
return;
}
nsCOMPtr<nsIURI> uri;
rv = aLoadInfo->GetResultPrincipalURI(getter_AddRefs(uri));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
aRPURI.emplace(std::move(uri));
}
void
SetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
{
if (!aLoadInfo) {
return;
}
nsresult rv;
rv = aLoadInfo->SetResultPrincipalURI(aRPURI.refOr(nullptr));
Unused << NS_WARN_IF(NS_FAILED(rv));
rv = aLoadInfo->SetResultPrincipalURIIsSome(aRPURI.isSome());
Unused << NS_WARN_IF(NS_FAILED(rv));
}
} // mozilla
@ -71,7 +27,7 @@ nsDocShellLoadInfo::nsDocShellLoadInfo()
, mOriginalFrameSrc(false)
, mSendReferrer(true)
, mReferrerPolicy(mozilla::net::RP_Unset)
, mLoadType(nsIDocShellLoadInfo::loadNormal)
, mLoadType(LOAD_NORMAL)
, mIsSrcdocLoad(false)
{
}
@ -80,331 +36,270 @@ nsDocShellLoadInfo::~nsDocShellLoadInfo()
{
}
NS_IMPL_ADDREF(nsDocShellLoadInfo)
NS_IMPL_RELEASE(nsDocShellLoadInfo)
NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
nsIURI*
nsDocShellLoadInfo::Referrer() const
{
NS_ENSURE_ARG_POINTER(aReferrer);
*aReferrer = mReferrer;
NS_IF_ADDREF(*aReferrer);
return NS_OK;
return mReferrer;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
{
mReferrer = aReferrer;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetOriginalURI(nsIURI** aOriginalURI)
nsIURI*
nsDocShellLoadInfo::OriginalURI() const
{
NS_ENSURE_ARG_POINTER(aOriginalURI);
*aOriginalURI = mOriginalURI;
NS_IF_ADDREF(*aOriginalURI);
return NS_OK;
return mOriginalURI;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetOriginalURI(nsIURI* aOriginalURI)
{
mOriginalURI = aOriginalURI;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetResultPrincipalURI(nsIURI** aResultPrincipalURI)
nsIURI*
nsDocShellLoadInfo::ResultPrincipalURI() const
{
NS_ENSURE_ARG_POINTER(aResultPrincipalURI);
*aResultPrincipalURI = mResultPrincipalURI;
NS_IF_ADDREF(*aResultPrincipalURI);
return NS_OK;
return mResultPrincipalURI;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetResultPrincipalURI(nsIURI* aResultPrincipalURI)
{
mResultPrincipalURI = aResultPrincipalURI;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetResultPrincipalURIIsSome(bool* aIsSome)
bool
nsDocShellLoadInfo::ResultPrincipalURIIsSome() const
{
*aIsSome = mResultPrincipalURIIsSome;
return NS_OK;
return mResultPrincipalURIIsSome;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetResultPrincipalURIIsSome(bool aIsSome)
{
mResultPrincipalURIIsSome = aIsSome;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetLoadReplace(bool* aLoadReplace)
bool
nsDocShellLoadInfo::LoadReplace() const
{
*aLoadReplace = mLoadReplace;
return NS_OK;
return mLoadReplace;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetLoadReplace(bool aLoadReplace)
{
mLoadReplace = aLoadReplace;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal)
nsIPrincipal*
nsDocShellLoadInfo::TriggeringPrincipal() const
{
NS_ENSURE_ARG_POINTER(aTriggeringPrincipal);
NS_IF_ADDREF(*aTriggeringPrincipal = mTriggeringPrincipal);
return NS_OK;
return mTriggeringPrincipal;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
{
mTriggeringPrincipal = aTriggeringPrincipal;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetInheritPrincipal(bool* aInheritPrincipal)
bool
nsDocShellLoadInfo::InheritPrincipal() const
{
NS_ENSURE_ARG_POINTER(aInheritPrincipal);
*aInheritPrincipal = mInheritPrincipal;
return NS_OK;
return mInheritPrincipal;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetInheritPrincipal(bool aInheritPrincipal)
{
mInheritPrincipal = aInheritPrincipal;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetPrincipalIsExplicit(bool* aPrincipalIsExplicit)
bool
nsDocShellLoadInfo::PrincipalIsExplicit() const
{
*aPrincipalIsExplicit = mPrincipalIsExplicit;
return NS_OK;
return mPrincipalIsExplicit;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetPrincipalIsExplicit(bool aPrincipalIsExplicit)
{
mPrincipalIsExplicit = aPrincipalIsExplicit;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetForceAllowDataURI(bool* aForceAllowDataURI)
bool
nsDocShellLoadInfo::ForceAllowDataURI() const
{
*aForceAllowDataURI = mForceAllowDataURI;
return NS_OK;
return mForceAllowDataURI;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetForceAllowDataURI(bool aForceAllowDataURI)
{
mForceAllowDataURI = aForceAllowDataURI;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetOriginalFrameSrc(bool* aOriginalFrameSrc)
bool
nsDocShellLoadInfo::OriginalFrameSrc() const
{
*aOriginalFrameSrc = mOriginalFrameSrc;
return NS_OK;
return mOriginalFrameSrc;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetOriginalFrameSrc(bool aOriginalFrameSrc)
{
mOriginalFrameSrc = aOriginalFrameSrc;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
uint32_t
nsDocShellLoadInfo::LoadType() const
{
NS_ENSURE_ARG_POINTER(aLoadType);
*aLoadType = mLoadType;
return NS_OK;
return mLoadType;
}
NS_IMETHODIMP
nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
void
nsDocShellLoadInfo::SetLoadType(uint32_t aLoadType)
{
mLoadType = aLoadType;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
nsISHEntry*
nsDocShellLoadInfo::SHEntry() const
{
NS_ENSURE_ARG_POINTER(aSHEntry);
*aSHEntry = mSHEntry;
NS_IF_ADDREF(*aSHEntry);
return NS_OK;
return mSHEntry;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
{
mSHEntry = aSHEntry;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
void
nsDocShellLoadInfo::GetTarget(nsAString& aTarget) const
{
NS_ENSURE_ARG_POINTER(aTarget);
*aTarget = ToNewUnicode(mTarget);
return NS_OK;
aTarget = mTarget;
}
NS_IMETHODIMP
nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
void
nsDocShellLoadInfo::SetTarget(const nsAString& aTarget)
{
mTarget.Assign(aTarget);
return NS_OK;
mTarget = aTarget;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult)
nsIInputStream*
nsDocShellLoadInfo::PostDataStream() const
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mPostDataStream;
NS_IF_ADDREF(*aResult);
return NS_OK;
return mPostDataStream;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
{
mPostDataStream = aStream;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
nsIInputStream*
nsDocShellLoadInfo::HeadersStream() const
{
NS_ENSURE_ARG_POINTER(aHeadersStream);
*aHeadersStream = mHeadersStream;
NS_IF_ADDREF(*aHeadersStream);
return NS_OK;
return mHeadersStream;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
{
mHeadersStream = aHeadersStream;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
bool
nsDocShellLoadInfo::SendReferrer() const
{
NS_ENSURE_ARG_POINTER(aSendReferrer);
*aSendReferrer = mSendReferrer;
return NS_OK;
return mSendReferrer;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
{
mSendReferrer = aSendReferrer;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrerPolicy(
nsDocShellInfoReferrerPolicy* aReferrerPolicy)
uint32_t
nsDocShellLoadInfo::ReferrerPolicy() const
{
*aReferrerPolicy = mReferrerPolicy;
return NS_OK;
return mReferrerPolicy;
}
NS_IMETHODIMP
nsDocShellLoadInfo::SetReferrerPolicy(
nsDocShellInfoReferrerPolicy aReferrerPolicy)
void
nsDocShellLoadInfo::SetReferrerPolicy(mozilla::net::ReferrerPolicy aReferrerPolicy)
{
mReferrerPolicy = aReferrerPolicy;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
bool
nsDocShellLoadInfo::IsSrcdocLoad() const
{
*aIsSrcdocLoad = mIsSrcdocLoad;
return NS_OK;
return mIsSrcdocLoad;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData)
void
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData) const
{
aSrcdocData = mSrcdocData;
return NS_OK;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
{
mSrcdocData = aSrcdocData;
mIsSrcdocLoad = true;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
nsIDocShell*
nsDocShellLoadInfo::SourceDocShell() const
{
MOZ_ASSERT(aSourceDocShell);
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
result.forget(aSourceDocShell);
return NS_OK;
return mSourceDocShell;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
{
mSourceDocShell = aSourceDocShell;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
nsIURI*
nsDocShellLoadInfo::BaseURI() const
{
NS_ENSURE_ARG_POINTER(aBaseURI);
*aBaseURI = mBaseURI;
NS_IF_ADDREF(*aBaseURI);
return NS_OK;
return mBaseURI;
}
NS_IMETHODIMP
void
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
{
mBaseURI = aBaseURI;
return NS_OK;
}
void
nsDocShellLoadInfo::GetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const
{
bool isSome = ResultPrincipalURIIsSome();
aRPURI.reset();
if (!isSome) {
return;
}
nsCOMPtr<nsIURI> uri = ResultPrincipalURI();
aRPURI.emplace(std::move(uri));
}
void
nsDocShellLoadInfo::SetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
{
SetResultPrincipalURI(aRPURI.refOr(nullptr));
SetResultPrincipalURIIsSome(aRPURI.isSome());
}

Просмотреть файл

@ -10,47 +10,195 @@
// Helper Classes
#include "nsCOMPtr.h"
#include "nsString.h"
// Interfaces Needed
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadTypes.h"
class nsIInputStream;
class nsISHEntry;
class nsIURI;
class nsIDocShell;
class nsDocShellLoadInfo : public nsIDocShellLoadInfo
/**
* nsDocShellLoadInfo contains setup information used in a nsIDocShell::loadURI
* call.
*/
class nsDocShellLoadInfo
{
public:
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadInfo);
nsDocShellLoadInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCSHELLLOADINFO
nsIURI* Referrer() const;
void SetReferrer(nsIURI* aReferrer);
nsIURI* OriginalURI() const;
void SetOriginalURI(nsIURI* aOriginalURI);
nsIURI* ResultPrincipalURI() const;
void SetResultPrincipalURI(nsIURI* aResultPrincipalURI);
bool ResultPrincipalURIIsSome() const;
void SetResultPrincipalURIIsSome(bool aIsSome);
bool LoadReplace() const;
void SetLoadReplace(bool aLoadReplace);
nsIPrincipal* TriggeringPrincipal() const;
void SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
bool InheritPrincipal() const;
void SetInheritPrincipal(bool aInheritPrincipal);
bool PrincipalIsExplicit() const;
void SetPrincipalIsExplicit(bool aPrincipalIsExplicit);
bool ForceAllowDataURI() const;
void SetForceAllowDataURI(bool aForceAllowDataURI);
bool OriginalFrameSrc() const;
void SetOriginalFrameSrc(bool aOriginalFrameSrc);
uint32_t LoadType() const;
void SetLoadType(uint32_t aLoadType);
nsISHEntry* SHEntry() const;
void SetSHEntry(nsISHEntry* aSHEntry);
void GetTarget(nsAString& aTarget) const;
void SetTarget(const nsAString& aTarget);
nsIInputStream* PostDataStream() const;
void SetPostDataStream(nsIInputStream* aStream);
nsIInputStream* HeadersStream() const;
void SetHeadersStream(nsIInputStream* aHeadersStream);
bool SendReferrer() const;
void SetSendReferrer(bool aSendReferrer);
uint32_t ReferrerPolicy() const;
void SetReferrerPolicy(mozilla::net::ReferrerPolicy aReferrerPolicy);
bool IsSrcdocLoad() const;
void GetSrcdocData(nsAString& aSrcdocData) const;
void SetSrcdocData(const nsAString& aSrcdocData);
nsIDocShell* SourceDocShell() const;
void SetSourceDocShell(nsIDocShell* aSourceDocShell);
nsIURI* BaseURI() const;
void SetBaseURI(nsIURI* aBaseURI);
// Helper function allowing convenient work with mozilla::Maybe in C++, hiding
// resultPrincipalURI and resultPrincipalURIIsSome attributes from the consumer.
void
GetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const;
void
SetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI);
protected:
virtual ~nsDocShellLoadInfo();
protected:
// This is the referrer for the load.
nsCOMPtr<nsIURI> mReferrer;
// The originalURI to be passed to nsIDocShell.internalLoad. May be null.
nsCOMPtr<nsIURI> mOriginalURI;
// Result principal URL from nsILoadInfo, may be null. Valid only if
// mResultPrincipalURIIsSome is true (has the same meaning as isSome() on
// mozilla::Maybe.)
nsCOMPtr<nsIURI> mResultPrincipalURI;
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
bool mResultPrincipalURIIsSome;
// The principal of the load, that is, the entity responsible for causing the
// load to occur. In most cases the referrer and the triggeringPrincipal's URI
// will be identical.
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
// loadReplace flag to be passed to nsIDocShell.internalLoad.
bool mLoadReplace;
// If this attribute is true and no triggeringPrincipal is specified,
// copy the principal from the referring document.
bool mInheritPrincipal;
// If this attribute is true only ever use the principal specified
// by the triggeringPrincipal and inheritPrincipal attributes.
// If there are security reasons for why this is unsafe, such
// as trying to use a systemprincipal as the triggeringPrincipal
// for a content docshell the load fails.
bool mPrincipalIsExplicit;
// If this attribute is true, then a top-level navigation
// to a data URI will be allowed.
bool mForceAllowDataURI;
// If this attribute is true, this load corresponds to a frame
// element loading its original src (or srcdoc) attribute.
bool mOriginalFrameSrc;
// True if the referrer should be sent, false if it shouldn't be sent, even if
// it's available. This attribute defaults to true.
bool mSendReferrer;
nsDocShellInfoReferrerPolicy mReferrerPolicy;
nsDocShellInfoLoadType mLoadType;
// Referrer policy for the load. This attribute holds one of the values
// (REFERRER_POLICY_*) defined in nsIHttpChannel.
mozilla::net::ReferrerPolicy mReferrerPolicy;
// Contains a load type as specified by the nsDocShellLoadTypes::load*
// constants
uint32_t mLoadType;
// SHEntry for this page
nsCOMPtr<nsISHEntry> mSHEntry;
// Target for load, like _content, _blank etc.
nsString mTarget;
// Post data
nsCOMPtr<nsIInputStream> mPostDataStream;
// Additional Headers
nsCOMPtr<nsIInputStream> mHeadersStream;
// True if the docshell has been created to load an iframe where the srcdoc
// attribute has been set. Set when srcdocData is specified.
bool mIsSrcdocLoad;
// When set, the load will be interpreted as a srcdoc load, where contents of
// this string will be loaded instead of the URI. Setting srcdocData sets
// isSrcdocLoad to true
nsString mSrcdocData;
// When set, this is the Source Browsing Context for the navigation.
nsCOMPtr<nsIDocShell> mSourceDocShell;
// 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.
nsCOMPtr<nsIURI> mBaseURI;
};

Просмотреть файл

@ -11,7 +11,7 @@
#include "nsDOMNavigationTiming.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIWebNavigation.h"
/**
@ -39,7 +39,7 @@
* Remember to update the IsValidLoadType function below if you change this
* enum to ensure bad flag combinations will be rejected.
*/
enum LoadType
enum LoadType : uint32_t
{
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
@ -75,6 +75,18 @@ enum LoadType
// NOTE: Adding a new value? Remember to update IsValidLoadType!
};
static inline bool
IsForceReloadType(uint32_t aLoadType) {
switch (aLoadType) {
case LOAD_RELOAD_BYPASS_CACHE:
case LOAD_RELOAD_BYPASS_PROXY:
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
return true;
}
return false;
}
static inline bool
IsValidLoadType(uint32_t aLoadType)
{
@ -108,182 +120,6 @@ IsValidLoadType(uint32_t aLoadType)
return false;
}
static inline bool
IsForceReloadType(uint32_t aLoadType) {
switch (aLoadType) {
case LOAD_RELOAD_BYPASS_CACHE:
case LOAD_RELOAD_BYPASS_PROXY:
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
return true;
}
return false;
}
static inline nsDocShellInfoLoadType
ConvertLoadTypeToDocShellInfoLoadType(uint32_t aLoadType)
{
nsDocShellInfoLoadType docShellLoadType = nsIDocShellLoadInfo::loadNormal;
switch (aLoadType) {
case LOAD_NORMAL:
docShellLoadType = nsIDocShellLoadInfo::loadNormal;
break;
case LOAD_NORMAL_REPLACE:
docShellLoadType = nsIDocShellLoadInfo::loadNormalReplace;
break;
case LOAD_NORMAL_EXTERNAL:
docShellLoadType = nsIDocShellLoadInfo::loadNormalExternal;
break;
case LOAD_NORMAL_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassCache;
break;
case LOAD_NORMAL_BYPASS_PROXY:
docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassProxy;
break;
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassProxyAndCache;
break;
case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
docShellLoadType = nsIDocShellLoadInfo::loadNormalAllowMixedContent;
break;
case LOAD_HISTORY:
docShellLoadType = nsIDocShellLoadInfo::loadHistory;
break;
case LOAD_RELOAD_NORMAL:
docShellLoadType = nsIDocShellLoadInfo::loadReloadNormal;
break;
case LOAD_RELOAD_CHARSET_CHANGE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
break;
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache;
break;
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache;
break;
case LOAD_RELOAD_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassCache;
break;
case LOAD_RELOAD_BYPASS_PROXY:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
break;
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
break;
case LOAD_LINK:
docShellLoadType = nsIDocShellLoadInfo::loadLink;
break;
case LOAD_REFRESH:
docShellLoadType = nsIDocShellLoadInfo::loadRefresh;
break;
case LOAD_BYPASS_HISTORY:
case LOAD_ERROR_PAGE:
docShellLoadType = nsIDocShellLoadInfo::loadBypassHistory;
break;
case LOAD_STOP_CONTENT:
docShellLoadType = nsIDocShellLoadInfo::loadStopContent;
break;
case LOAD_STOP_CONTENT_AND_REPLACE:
docShellLoadType = nsIDocShellLoadInfo::loadStopContentAndReplace;
break;
case LOAD_PUSHSTATE:
docShellLoadType = nsIDocShellLoadInfo::loadPushState;
break;
case LOAD_REPLACE_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReplaceBypassCache;
break;
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
docShellLoadType = nsIDocShellLoadInfo::loadReloadMixedContent;
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected load type value");
}
return docShellLoadType;
}
static inline uint32_t
ConvertDocShellInfoLoadTypeToLoadType(nsDocShellInfoLoadType aDocShellLoadType)
{
uint32_t loadType = LOAD_NORMAL;
switch (aDocShellLoadType) {
case nsIDocShellLoadInfo::loadNormal:
loadType = LOAD_NORMAL;
break;
case nsIDocShellLoadInfo::loadNormalReplace:
loadType = LOAD_NORMAL_REPLACE;
break;
case nsIDocShellLoadInfo::loadNormalExternal:
loadType = LOAD_NORMAL_EXTERNAL;
break;
case nsIDocShellLoadInfo::loadHistory:
loadType = LOAD_HISTORY;
break;
case nsIDocShellLoadInfo::loadNormalBypassCache:
loadType = LOAD_NORMAL_BYPASS_CACHE;
break;
case nsIDocShellLoadInfo::loadNormalBypassProxy:
loadType = LOAD_NORMAL_BYPASS_PROXY;
break;
case nsIDocShellLoadInfo::loadNormalBypassProxyAndCache:
loadType = LOAD_NORMAL_BYPASS_PROXY_AND_CACHE;
break;
case nsIDocShellLoadInfo::loadNormalAllowMixedContent:
loadType = LOAD_NORMAL_ALLOW_MIXED_CONTENT;
break;
case nsIDocShellLoadInfo::loadReloadNormal:
loadType = LOAD_RELOAD_NORMAL;
break;
case nsIDocShellLoadInfo::loadReloadCharsetChange:
loadType = LOAD_RELOAD_CHARSET_CHANGE;
break;
case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache:
loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE;
break;
case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache:
loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE;
break;
case nsIDocShellLoadInfo::loadReloadBypassCache:
loadType = LOAD_RELOAD_BYPASS_CACHE;
break;
case nsIDocShellLoadInfo::loadReloadBypassProxy:
loadType = LOAD_RELOAD_BYPASS_PROXY;
break;
case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
break;
case nsIDocShellLoadInfo::loadLink:
loadType = LOAD_LINK;
break;
case nsIDocShellLoadInfo::loadRefresh:
loadType = LOAD_REFRESH;
break;
case nsIDocShellLoadInfo::loadBypassHistory:
loadType = LOAD_BYPASS_HISTORY;
break;
case nsIDocShellLoadInfo::loadStopContent:
loadType = LOAD_STOP_CONTENT;
break;
case nsIDocShellLoadInfo::loadStopContentAndReplace:
loadType = LOAD_STOP_CONTENT_AND_REPLACE;
break;
case nsIDocShellLoadInfo::loadPushState:
loadType = LOAD_PUSHSTATE;
break;
case nsIDocShellLoadInfo::loadReplaceBypassCache:
loadType = LOAD_REPLACE_BYPASS_CACHE;
break;
case nsIDocShellLoadInfo::loadReloadMixedContent:
loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected nsDocShellInfoLoadType value");
}
return loadType;
}
static inline nsDOMNavigationTiming::Type
ConvertLoadTypeToNavigationType(uint32_t aLoadType)
{

Просмотреть файл

@ -17,6 +17,7 @@
#include "nsIURI.h"
class nsPresContext;
class nsIPresShell;
class nsDocShellLoadInfo;
namespace mozilla {
class Encoding;
class HTMLEditor;
@ -61,6 +62,7 @@ interface nsICommandManager;
interface nsICommandParams;
interface nsILoadURIDelegate;
native TabChildRef(already_AddRefed<nsITabChild>);
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
webidl EventTarget;
@ -87,7 +89,7 @@ interface nsIDocShell : nsIDocShellTreeItem
* be allowed. Use at your own risk.
*/
[noscript]void loadURI(in nsIURI uri,
in nsIDocShellLoadInfo loadInfo,
in nsDocShellLoadInfoPtr loadInfo,
in unsigned long aLoadFlags,
in boolean firstParty);
@ -206,12 +208,6 @@ interface nsIDocShell : nsIDocShellTreeItem
void addState(in jsval aData, in DOMString aTitle,
in DOMString aURL, in boolean aReplace);
/**
* Creates a DocShellLoadInfo object that you can manipulate and then pass
* to loadURI.
*/
void createLoadInfo(out nsIDocShellLoadInfo loadInfo);
/**
* Reset state to a new content model within the current document and the document
* viewer. Called by the document before initiating an out of band document.write().

Просмотреть файл

@ -1,168 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/**
* The nsIDocShellLoadInfo interface defines an interface for specifying
* setup information used in a nsIDocShell::loadURI call.
*/
interface nsIURI;
interface nsIInputStream;
interface nsISHEntry;
interface nsIDocShell;
interface nsIPrincipal;
typedef long nsDocShellInfoLoadType;
typedef unsigned long nsDocShellInfoReferrerPolicy;
[scriptable, uuid(e7570e5a-f1d6-452d-b4f8-b35fdc63aa03)]
interface nsIDocShellLoadInfo : nsISupports
{
/** This is the referrer for the load. */
attribute nsIURI referrer;
/**
* The originalURI to be passed to nsIDocShell.internalLoad. May be null.
*/
attribute nsIURI originalURI;
/**
* Result principal URL from nsILoadInfo, may be null. Valid only if
* the "IsSome" part is true (has the same meaning as isSome()
* on mozilla::Maybe.)
*
* In C++ please use Get/SetMaybeResultPrincipalURI helper functions.
*/
attribute nsIURI resultPrincipalURI;
attribute boolean resultPrincipalURIIsSome;
/**
* loadReplace flag to be passed to nsIDocShell.internalLoad.
*/
attribute boolean loadReplace;
/** The principal of the load, that is, the entity responsible for
* causing the load to occur. In most cases the referrer and
* the triggeringPrincipal's URI will be identical.
*/
attribute nsIPrincipal triggeringPrincipal;
/** If this attribute is true and no triggeringPrincipal is specified,
* copy the principal from the referring document.
*/
attribute boolean inheritPrincipal;
/** If this attribute is true only ever use the principal specified
* by the triggeringPrincipal and inheritPrincipal attributes.
* If there are security reasons for why this is unsafe, such
* as trying to use a systemprincipal as the triggeringPrincipal
* for a content docshell the load fails.
*/
attribute boolean principalIsExplicit;
/**
* If this attribute is true, then a top-level navigation
* to a data URI will be allowed.
*/
attribute boolean forceAllowDataURI;
/**
* If this attribute is true, this load corresponds to a frame
* element loading its original src (or srcdoc) attribute.
*/
attribute boolean originalFrameSrc;
/* these are load type enums... */
const long loadNormal = 0; // Normal Load
const long loadNormalReplace = 1; // Normal Load but replaces current history slot
const long loadHistory = 2; // Load from history
const long loadReloadNormal = 3; // Reload
const long loadReloadBypassCache = 4;
const long loadReloadBypassProxy = 5;
const long loadReloadBypassProxyAndCache = 6;
const long loadLink = 7;
const long loadRefresh = 8;
const long loadReloadCharsetChange = 9;
const long loadBypassHistory = 10;
const long loadStopContent = 11;
const long loadStopContentAndReplace = 12;
const long loadNormalExternal = 13;
const long loadNormalBypassCache = 14;
const long loadNormalBypassProxy = 15;
const long loadNormalBypassProxyAndCache = 16;
const long loadPushState = 17; // history.pushState or replaceState
const long loadReplaceBypassCache = 18;
const long loadReloadMixedContent = 19;
const long loadNormalAllowMixedContent = 20;
const long loadReloadCharsetChangeBypassCache = 21;
const long loadReloadCharsetChangeBypassProxyAndCache = 22;
/** Contains a load type as specified by the load* constants */
attribute nsDocShellInfoLoadType loadType;
/** SHEntry for this page */
attribute nsISHEntry SHEntry;
/** Target for load, like _content, _blank etc. */
attribute wstring target;
/** Post data */
attribute nsIInputStream postDataStream;
/** Additional headers */
attribute nsIInputStream headersStream;
/** True if the referrer should be sent, false if it shouldn't be
* sent, even if it's available. This attribute defaults to true.
*/
attribute boolean sendReferrer;
/** Referrer policy for the load. This attribute holds one of
* the values (REFERRER_POLICY_*) defined in nsIHttpChannel.
*/
attribute nsDocShellInfoReferrerPolicy referrerPolicy;
/** True if the docshell has been created to load an iframe where the
* srcdoc attribute has been set. Set when srcdocData is specified.
*/
readonly attribute boolean isSrcdocLoad;
/** When set, the load will be interpreted as a srcdoc load, where contents
* of this string will be loaded instead of the URI. Setting srcdocData
* sets isSrcdocLoad to true
*/
attribute AString srcdocData;
/** 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;
};
%{C++
#include "mozilla/Maybe.h"
namespace mozilla {
/**
* Helper function allowing convenient work with mozilla::Maybe in C++, hiding
* resultPrincipalURI and resultPrincipalURIIsSome attributes from the consumer.
*/
void
GetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>>& aRPURI);
void
SetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>> const& aRPURI);
} // mozilla
%}

Просмотреть файл

@ -346,6 +346,17 @@ interface nsISHEntry : nsISupports
* changed once set to a non-null value.
*/
[noscript] attribute nsISHistory SHistory;
/**
* Sets an SHEntry to reflect that it is a history type load. as
* nsIDocShellLoadInfo and its LoadType enum were removed, this is the
* equivalent to doing
*
* shEntry.loadType = 4;
*
* in js, but easier to maintain and less opaque.
*/
void setAsHistoryLoad();
};
[scriptable, uuid(bb66ac35-253b-471f-a317-3ece940f04c5)]

Просмотреть файл

@ -10,7 +10,7 @@
#include "nsDocShellEditorData.h"
#include "nsIContentViewer.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIDocShellTreeItem.h"
#include "nsIInputStream.h"
#include "nsILayoutHistoryState.h"
@ -453,7 +453,7 @@ nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
mPostData = aInputStream;
// Set the LoadType by default to loadHistory during creation
mLoadType = (uint32_t)nsIDocShellLoadInfo::loadHistory;
mLoadType = LOAD_HISTORY;
mShared->mCacheKey = aCacheKey;
mShared->mContentType = aContentType;
@ -1011,3 +1011,11 @@ nsSHEntry::SetSHistory(nsISHistory* aSHistory)
mShared->mSHistory = shistory;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetAsHistoryLoad()
{
// Set the LoadType by default to loadHistory during creation
mLoadType = LOAD_HISTORY;
return NS_OK;
}

Просмотреть файл

@ -13,7 +13,7 @@
#include "nsDocShell.h"
#include "nsIContentViewer.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIDocShellTreeItem.h"
#include "nsILayoutHistoryState.h"
#include "nsIObserverService.h"
@ -1114,7 +1114,7 @@ nsSHistory::GoBack()
if (!canGoBack) {
return NS_ERROR_UNEXPECTED;
}
return LoadEntry(mIndex - 1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
return LoadEntry(mIndex - 1, LOAD_HISTORY, HIST_CMD_BACK);
}
NS_IMETHODIMP
@ -1126,27 +1126,27 @@ nsSHistory::GoForward()
if (!canGoForward) {
return NS_ERROR_UNEXPECTED;
}
return LoadEntry(mIndex + 1, nsIDocShellLoadInfo::loadHistory,
return LoadEntry(mIndex + 1, LOAD_HISTORY,
HIST_CMD_FORWARD);
}
NS_IMETHODIMP
nsSHistory::Reload(uint32_t aReloadFlags)
{
nsDocShellInfoLoadType loadType;
uint32_t loadType;
if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
loadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
} else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) {
loadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
loadType = LOAD_RELOAD_BYPASS_PROXY;
} else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
loadType = nsIDocShellLoadInfo::loadReloadBypassCache;
loadType = LOAD_RELOAD_BYPASS_CACHE;
} else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE) {
loadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
loadType = LOAD_RELOAD_CHARSET_CHANGE;
} else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
loadType = nsIDocShellLoadInfo::loadReloadMixedContent;
loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
} else {
loadType = nsIDocShellLoadInfo::loadReloadNormal;
loadType = LOAD_RELOAD_NORMAL;
}
// We are reloading. Send Reload notifications.
@ -1178,7 +1178,7 @@ nsSHistory::ReloadCurrentEntry()
return NS_OK;
}
return LoadEntry(mIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
return LoadEntry(mIndex, LOAD_HISTORY, HIST_CMD_RELOAD);
}
NS_IMETHODIMP
@ -1194,7 +1194,7 @@ nsSHistory::RestoreToEntryAtIndex(int32_t aIndex)
}
// XXX We may want to ensure docshell is currently holding about:blank
return InitiateLoad(nextEntry, mRootDocShell, nsIDocShellLoadInfo::loadHistory);
return InitiateLoad(nextEntry, mRootDocShell, LOAD_HISTORY);
}
void
@ -1840,7 +1840,7 @@ nsSHistory::LoadURI(const char16_t* aURI,
NS_IMETHODIMP
nsSHistory::GotoIndex(int32_t aIndex)
{
return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX);
}
nsresult
@ -2039,14 +2039,13 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
{
NS_ENSURE_STATE(aFrameDS && aFrameEntry);
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
/* Set the loadType in the SHEntry too to what was passed on.
* This will be passed on to child subframes later in nsDocShell,
* so that proper loadType is maintained through out a frameset
*/
aFrameEntry->SetLoadType(aLoadType);
aFrameDS->CreateLoadInfo(getter_AddRefs(loadInfo));
loadInfo->SetLoadType(aLoadType);
loadInfo->SetSHEntry(aFrameEntry);

Просмотреть файл

@ -446,6 +446,7 @@ public:
mOpenMode(aOpenMode),
mWriteParams(aWriteParams),
mOperationMayProceed(true),
mModuleIndex(0),
mState(eInitial),
mResult(JS::AsmJSCache_InternalError),
mActorDestroyed(false),

Просмотреть файл

@ -135,7 +135,6 @@ protected:
nsCString mName;
nsCOMPtr<nsIStackFrame> mLocation;
nsCOMPtr<nsISupports> mData;
bool mInitialized;
bool mHoldingJSVal;
JS::Heap<JS::Value> mThrownJSVal;

Просмотреть файл

@ -196,7 +196,7 @@ DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
// Just use the global of the Promise itself as the callee global.
JS::Rooted<JSObject*> global(aCx, mPromise->PromiseObj());
global = js::GetGlobalForObjectCrossCompartment(global);
global = JS::GetNonCCWObjectGlobal(global);
mPromise->Then(aCx, global, aResolveCallback, aRejectCallback, aRetval, aRv);
}

Просмотреть файл

@ -1881,6 +1881,19 @@ RemoveFromBindingManagerRunnable::Run()
return NS_OK;
}
static bool
ShouldRemoveFromIdTableOnUnbind(const Element& aElement, bool aNullParent)
{
if (aElement.IsInUncomposedDoc()) {
return true;
}
if (!aElement.IsInShadowTree()) {
return false;
}
return aNullParent || !aElement.GetParent()->IsInShadowTree();
}
void
Element::UnbindFromTree(bool aDeep, bool aNullParent)
@ -1889,7 +1902,11 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
"Shallow unbind won't clear document and binding parent on "
"kids!");
RemoveFromIdTable();
// Make sure to only remove from the ID table if our subtree root is actually
// changing.
if (ShouldRemoveFromIdTableOnUnbind(*this, aNullParent)) {
RemoveFromIdTable();
}
// Make sure to unbind this node before doing the kids
nsIDocument* document = GetComposedDoc();
@ -1931,7 +1948,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
}
}
if (this->IsRootOfNativeAnonymousSubtree()) {
if (IsRootOfNativeAnonymousSubtree()) {
nsNodeUtils::NativeAnonymousChildListChange(this, true);
}

Просмотреть файл

@ -455,6 +455,7 @@ public:
NS_LITERAL_CSTRING("EventSource :: Init"))
, mImpl(aEventSourceImpl)
, mURL(aURL)
, mRv(NS_ERROR_NOT_INITIALIZED)
{
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();

Просмотреть файл

@ -763,10 +763,12 @@ FragmentOrElement::nsExtendedDOMSlots::UnlinkExtendedSlots()
// Don't clear mXBLBinding, it'll be done in
// BindingManager::RemovedFromDocument from FragmentOrElement::Unlink.
//
// mShadowRoot will similarly be cleared explicitly from
// FragmentOrElement::Unlink.
mSMILOverrideStyle = nullptr;
mControllers = nullptr;
mLabelsList = nullptr;
mShadowRoot = nullptr;
if (mCustomElementData) {
mCustomElementData->Unlink();
mCustomElementData = nullptr;
@ -1500,6 +1502,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FragmentOrElement)
// containing shadow root pointer.
tmp->UnsetFlags(NODE_IS_IN_SHADOW_TREE);
if (ShadowRoot* shadowRoot = tmp->GetShadowRoot()) {
for (nsIContent* child = shadowRoot->GetFirstChild();
child;
child = child->GetNextSibling()) {
child->UnbindFromTree(true, false);
}
shadowRoot->SetIsComposedDocParticipant(false);
tmp->ExtendedDOMSlots()->mShadowRoot = nullptr;
}
nsIDocument* doc = tmp->OwnerDoc();
doc->BindingManager()->RemovedFromDocument(tmp, doc,
nsBindingManager::eDoNotRunDtor);

Просмотреть файл

@ -9,7 +9,7 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptContext.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIWebNavigation.h"
#include "nsCDefaultURIFixup.h"
#include "nsIURIFixup.h"
@ -62,7 +62,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(Location)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Location)
nsresult
Location::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
Location::CheckURL(nsIURI* aURI, nsDocShellLoadInfo** aLoadInfo)
{
*aLoadInfo = nullptr;
@ -150,9 +150,7 @@ Location::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
}
// Create load info
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
loadInfo->SetTriggeringPrincipal(triggeringPrincipal);
@ -233,15 +231,15 @@ Location::SetURI(nsIURI* aURI, bool aReplace)
{
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
if (docShell) {
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
RefPtr<nsDocShellLoadInfo> loadInfo;
if(NS_FAILED(CheckURL(aURI, getter_AddRefs(loadInfo))))
return NS_ERROR_FAILURE;
if (aReplace) {
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContentAndReplace);
loadInfo->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
} else {
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContent);
loadInfo->SetLoadType(LOAD_STOP_CONTENT);
}
// Get the incumbent script's browsing context to set as source.

Просмотреть файл

@ -16,7 +16,6 @@
#include "nsWrapperCache.h"
class nsIDocShell;
class nsIDocShellLoadInfo;
class nsIURI;
namespace mozilla {
@ -179,7 +178,7 @@ protected:
bool aReplace);
nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL);
nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
nsresult CheckURL(nsIURI *url, nsDocShellLoadInfo** aLoadInfo);
bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal);
nsString mCachedHash;

Просмотреть файл

@ -71,7 +71,11 @@ private:
virtual ~NodeIterator();
struct NodePointer {
NodePointer() : mNode(nullptr) {}
NodePointer()
: mNode(nullptr)
, mBeforeNode(false)
{
}
NodePointer(nsINode *aNode, bool aBeforeNode);
typedef bool (NodePointer::*MoveToMethodType)(nsINode*);

Просмотреть файл

@ -39,6 +39,7 @@ class TextInputProcessorNotification final :
public:
explicit TextInputProcessorNotification(const char* aType)
: mType(aType)
, mTextChangeData()
{
}
@ -279,7 +280,10 @@ private:
SelectionChangeDataBase mSelectionChangeData;
};
TextInputProcessorNotification() { }
TextInputProcessorNotification()
: mTextChangeData()
{
}
};
NS_IMPL_ISUPPORTS(TextInputProcessorNotification,

Просмотреть файл

@ -575,11 +575,11 @@ public:
mString == aKey->mString;
}
#ifdef DEBUG
enum ContentListType {
eNodeList,
eHTMLCollection
};
#ifdef DEBUG
ContentListType mType;
#endif
@ -588,8 +588,12 @@ protected:
nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString) :
const nsAString& aString,
mozilla::DebugOnly<ContentListType> aType) :
nsContentList(aRootNode, aFunc, aDestroyFunc, nullptr),
#ifdef DEBUG
mType(aType),
#endif
mString(aString)
{
mData = (*aDataAllocator)(aRootNode, &mString);
@ -614,11 +618,8 @@ public:
nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString)
: nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc,
aDataAllocator, aString)
aDataAllocator, aString, eNodeList)
{
#ifdef DEBUG
mType = eNodeList;
#endif
}
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
@ -640,11 +641,8 @@ public:
nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString)
: nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc,
aDataAllocator, aString)
aDataAllocator, aString, eHTMLCollection)
{
#ifdef DEBUG
mType = eHTMLCollection;
#endif
}
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;

Просмотреть файл

@ -167,8 +167,8 @@ ContentPermissionRequestParent::~ContentPermissionRequestParent()
mozilla::ipc::IPCResult
ContentPermissionRequestParent::Recvprompt()
{
mProxy = new nsContentPermissionRequestProxy();
if (NS_FAILED(mProxy->Init(mRequests, this))) {
mProxy = new nsContentPermissionRequestProxy(this);
if (NS_FAILED(mProxy->Init(mRequests))) {
mProxy->Cancel();
}
return IPC_OK();
@ -578,8 +578,10 @@ nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy
}
}
nsContentPermissionRequestProxy::nsContentPermissionRequestProxy()
nsContentPermissionRequestProxy::nsContentPermissionRequestProxy(ContentPermissionRequestParent* parent)
: mParent(parent)
{
NS_ASSERTION(mParent, "null parent");
}
nsContentPermissionRequestProxy::~nsContentPermissionRequestProxy()
@ -587,11 +589,8 @@ nsContentPermissionRequestProxy::~nsContentPermissionRequestProxy()
}
nsresult
nsContentPermissionRequestProxy::Init(const nsTArray<PermissionRequest>& requests,
ContentPermissionRequestParent* parent)
nsContentPermissionRequestProxy::Init(const nsTArray<PermissionRequest>& requests)
{
NS_ASSERTION(parent, "null parent");
mParent = parent;
mPermissionRequests = requests;
mRequester = new nsContentPermissionRequesterProxy(mParent);

Просмотреть файл

@ -126,10 +126,9 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTPERMISSIONREQUEST
nsContentPermissionRequestProxy();
explicit nsContentPermissionRequestProxy(ContentPermissionRequestParent* parent);
nsresult Init(const nsTArray<mozilla::dom::PermissionRequest>& requests,
ContentPermissionRequestParent* parent);
nsresult Init(const nsTArray<mozilla::dom::PermissionRequest>& requests);
void OnParentDestroyed();

Просмотреть файл

@ -8838,6 +8838,26 @@ nsContentUtils::IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow,
return thirdParty;
}
// static public
bool
nsContentUtils::IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(aWindow);
nsIDocument* document = aWindow->GetExtantDoc();
if (!document) {
return false;
}
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(document->GetChannel());
if (!httpChannel) {
return false;
}
return httpChannel->GetIsTrackingResource();
}
// static public
bool
nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
@ -9635,7 +9655,8 @@ nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri)
MOZ_ASSERT(strncmp(aUri, "about:", 6) == 0);
// Make sure the global is a window
nsGlobalWindowInner* win = xpc::WindowGlobalOrNull(aGlobal);
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
nsGlobalWindowInner* win = xpc::WindowOrNull(aGlobal);
if (!win) {
return false;
}

Просмотреть файл

@ -2964,6 +2964,12 @@ public:
nsIChannel* aChannel,
nsIURI* aURI);
/*
* Returns true if this window's channel has been marked as a tracking
* resource.
*/
static bool IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow);
/*
* Serializes a HTML nsINode into its markup representation.
*/

Просмотреть файл

@ -2043,8 +2043,8 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
nsresult rv = targetWidget->DispatchEvent(&queryEvent, status);
NS_ENSURE_SUCCESS(rv, rv);
auto* result = new nsQueryContentEventResult();
result->SetEventResult(widget, queryEvent);
auto* result = new nsQueryContentEventResult(queryEvent);
result->SetEventResult(widget);
NS_ADDREF(*aResult = result);
return NS_OK;
}

Просмотреть файл

@ -2599,9 +2599,10 @@ nsIDocument::IsSynthesized() {
}
bool
nsDocument::IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject)
nsDocument::IsShadowDOMEnabled(JSContext* aCx, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindowInner> window = xpc::WindowGlobalOrNull(aObject);
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
nsCOMPtr<nsPIDOMWindowInner> window = xpc::WindowOrNull(aGlobal);
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
if (!doc) {
@ -4631,7 +4632,7 @@ nsIDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
JSObject *obj = GetWrapperPreserveColor();
if (obj) {
JSObject *newScope = aScriptGlobalObject->GetGlobalJSObject();
NS_ASSERTION(js::GetGlobalForObjectCrossCompartment(obj) == newScope,
NS_ASSERTION(JS::GetNonCCWObjectGlobal(obj) == newScope,
"Wrong scope, this is really bad!");
}
}
@ -4713,12 +4714,9 @@ nsIDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
}
if (!mMaybeServiceWorkerControlled && mDocumentContainer && mScriptGlobalObject && GetChannel()) {
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
uint32_t loadType;
docShell->GetLoadType(&loadType);
// If we are shift-reloaded, don't associate with a ServiceWorker.
if (IsForceReloadType(loadType)) {
if (mDocumentContainer->IsForceReloading()) {
NS_WARNING("Page was shift reloaded, skipping ServiceWorker control");
return;
}
@ -12453,9 +12451,10 @@ nsIDocument::MaybeAllowStorageForOpener()
return;
}
// No 3rd party.
// No 3rd party or no tracking resource.
if (!nsContentUtils::IsThirdPartyWindowOrChannel(openerInner, nullptr,
nullptr)) {
nullptr) ||
!nsContentUtils::IsTrackingResourceWindow(openerInner)) {
return;
}
@ -12575,6 +12574,8 @@ namespace {
struct PrefStore
{
PrefStore()
: mFlashBlockEnabled(false)
, mPluginsHttpOnly(false)
{
Preferences::AddBoolVarCache(&mFlashBlockEnabled,
"plugins.flashBlock.enabled");

Просмотреть файл

@ -194,8 +194,8 @@ public:
nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
// Check whether shadow DOM is enabled for the global of aObject.
static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject);
// Check whether shadow DOM is enabled for aGlobal.
static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aGlobal);
// Check whether shadow DOM is enabled for the document this node belongs to.
static bool IsShadowDOMEnabled(const nsINode* aNode);

Просмотреть файл

@ -213,6 +213,7 @@ NS_IMPL_CYCLE_COLLECTION(nsDocumentEncoder,
nsDocumentEncoder::nsDocumentEncoder()
: mEncoding(nullptr)
, mIsCopying(false)
, mCachedBuffer(nullptr)
{
Initialize();

Просмотреть файл

@ -25,7 +25,7 @@
#include "nsIWebProgress.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIBaseWindow.h"
#include "nsIBrowser.h"
#include "nsContentUtils.h"
@ -472,9 +472,7 @@ nsFrameLoader::ReallyStartLoadingInternal()
rv = CheckURILoad(mURIToLoad, mTriggeringPrincipal);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
loadInfo->SetOriginalFrameSrc(mLoadingOriginalSrc);
mLoadingOriginalSrc = false;

Просмотреть файл

@ -511,8 +511,6 @@ private:
bool mClipSubdocument : 1;
bool mClampScrollPosition : 1;
bool mObservingOwnerContent : 1;
bool mFreshProcess : 1;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsFrameLoader, NS_FRAMELOADER_IID)

Просмотреть файл

@ -8212,7 +8212,11 @@ nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
const nsCString& aGrantedOrigin)
{
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(aPrincipal);
if (NS_WARN_IF(!aPrincipal)) {
// The child process is sending something wrong. Let's ignore it.
return;
}
nsAutoCString origin;
nsresult rv = aPrincipal->GetOriginNoSuffix(origin);

Просмотреть файл

@ -59,6 +59,7 @@
#include "nsPrintfCString.h"
#include "mozilla/intl/LocaleService.h"
#include "WindowDestroyedEvent.h"
#include "nsDocShellLoadInfo.h"
// Helper Classes
#include "nsJSUtils.h"
@ -5467,7 +5468,7 @@ nsGlobalWindowOuter::OpenOuter(const nsAString& aUrl, const nsAString& aName,
nsresult
nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions, nsIDocShellLoadInfo* aLoadInfo,
const nsAString& aOptions, nsDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener, nsPIDOMWindowOuter **_retval)
{
return OpenInternal(aUrl, aName, aOptions,
@ -6852,7 +6853,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
bool aDoJSFixups, bool aNavigate,
nsIArray *argv,
nsISupports *aExtraArgument,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener,
nsPIDOMWindowOuter **aReturn)
{
@ -6897,12 +6898,14 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
}
}
bool windowExists = WindowExists(aName, forceNoOpener, !aCalledNoScript);
// XXXbz When this gets fixed to not use LegacyIsCallerNativeCode()
// (indirectly) maybe we can nix the AutoJSAPI usage OnLinkClickEvent::Run.
// But note that if you change this to GetEntryGlobal(), say, then
// OnLinkClickEvent::Run will need a full-blown AutoEntryScript.
const bool checkForPopup = !nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
!aDialog && !WindowExists(aName, forceNoOpener, !aCalledNoScript);
!aDialog && !windowExists;
// Note: the Void handling here is very important, because the window watcher
// expects a null URL string (not an empty string) if there is no URL to load.
@ -6910,6 +6913,8 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
url.SetIsVoid(true);
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uri;
// It's important to do this security check before determining whether this
// window opening should be blocked, to ensure that we don't FireAbuseEvents
// for a window opening that wouldn't have succeeded in the first place.
@ -6923,7 +6928,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
// If we're not navigating, we assume that whoever *does* navigate the
// window will do a security check of their own.
if (!url.IsVoid() && !aDialog && aNavigate)
rv = SecurityCheckURL(url.get());
rv = SecurityCheckURL(url.get(), getter_AddRefs(uri));
}
if (NS_FAILED(rv))
@ -7025,6 +7030,10 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
// success!
if (!aCalledNoScript && !windowExists && uri) {
MaybeAllowStorageForOpenedWindow(uri);
}
NS_ENSURE_TRUE(domReturn, NS_OK);
nsCOMPtr<nsPIDOMWindowOuter> outerReturn =
nsPIDOMWindowOuter::From(domReturn);
@ -7049,6 +7058,29 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
return rv;
}
void
nsGlobalWindowOuter::MaybeAllowStorageForOpenedWindow(nsIURI* aURI)
{
nsGlobalWindowInner *inner = GetCurrentInnerWindowInternal();
if (NS_WARN_IF(!inner)) {
return;
}
// No 3rd party or no tracking resource.
if (!nsContentUtils::IsThirdPartyWindowOrChannel(inner, nullptr, nullptr) ||
!nsContentUtils::IsTrackingResourceWindow(inner)) {
return;
}
nsAutoString origin;
nsresult rv = nsContentUtils::GetUTFOrigin(aURI, origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
inner->AddFirstPartyStorageAccessGrantedFor(origin, true);
}
//*****************************************************************************
// nsGlobalWindowOuter: Helper Functions
//*****************************************************************************
@ -7108,7 +7140,7 @@ nsGlobalWindowOuter::GetScrollFrame()
}
nsresult
nsGlobalWindowOuter::SecurityCheckURL(const char *aURL)
nsGlobalWindowOuter::SecurityCheckURL(const char *aURL, nsIURI** aURI)
{
nsCOMPtr<nsPIDOMWindowInner> sourceWindow = do_QueryInterface(GetEntryGlobal());
if (!sourceWindow) {
@ -7141,6 +7173,7 @@ nsGlobalWindowOuter::SecurityCheckURL(const char *aURL)
return NS_ERROR_FAILURE;
}
uri.forget(aURI);
return NS_OK;
}
@ -7575,6 +7608,7 @@ nsGlobalWindowOuter::AbstractMainThreadFor(TaskCategory aCategory)
nsGlobalWindowOuter::TemporarilyDisableDialogs::TemporarilyDisableDialogs(
nsGlobalWindowOuter* aWindow MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: mSavedDialogsEnabled(false)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;

Просмотреть файл

@ -72,6 +72,7 @@ class nsITimeoutHandler;
class nsIWebBrowserChrome;
class mozIDOMWindowProxy;
class nsDocShellLoadInfo;
class nsDOMWindowList;
class nsScreen;
class nsHistory;
@ -611,7 +612,7 @@ public:
mozilla::ErrorResult& aError);
nsresult Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener,
nsPIDOMWindowOuter **_retval) override;
mozilla::dom::Navigator* GetNavigator() override;
@ -897,7 +898,7 @@ private:
bool aNavigate,
nsIArray *argv,
nsISupports *aExtraArgument,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener,
nsPIDOMWindowOuter **aReturn);
@ -906,7 +907,7 @@ public:
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
nsresult SecurityCheckURL(const char *aURL);
nsresult SecurityCheckURL(const char *aURL, nsIURI** aURI);
bool IsPrivateBrowsing();
bool PopupWhitelisted();
@ -1053,6 +1054,8 @@ private:
nsresult GetInterfaceInternal(const nsIID& aIID, void** aSink);
void MaybeAllowStorageForOpenedWindow(nsIURI* aURI);
public:
// Dispatch a runnable related to the global.
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,

Просмотреть файл

@ -1295,7 +1295,7 @@ CheckForOutdatedParent(nsINode* aParent, nsINode* aNode, ErrorResult& aError)
nsIGlobalObject* global = aParent->OwnerDoc()->GetScopeObject();
MOZ_ASSERT(global);
if (js::GetGlobalForObjectCrossCompartment(existingObj) !=
if (JS::GetNonCCWObjectGlobal(existingObj) !=
global->GetGlobalJSObject()) {
JSAutoRealm ar(cx, existingObj);
ReparentWrapper(cx, existingObj, aError);

Просмотреть файл

@ -151,9 +151,6 @@ private:
bool mGCOnDestruction;
bool mProcessingScriptTag;
PRTime mModalStateTime;
uint32_t mModalStateDepth;
// mGlobalObjectRef ensures that the outer window stays alive as long as the
// context does. It is eventually collected by the cycle collector.
nsCOMPtr<nsIScriptGlobalObject> mGlobalObjectRef;

Просмотреть файл

@ -16,7 +16,6 @@
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIDocument.h"
#include "nsIExternalProtocolHandler.h"
#include "nsIInterfaceRequestorUtils.h"

Просмотреть файл

@ -29,7 +29,7 @@ class nsIArray;
class nsIContent;
class nsICSSDeclaration;
class nsIDocShell;
class nsIDocShellLoadInfo;
class nsDocShellLoadInfo;
class nsIDocument;
class nsIIdleObserver;
class nsIPrincipal;
@ -1125,7 +1125,7 @@ public:
// will not affect any other window features.
virtual nsresult Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener,
nsPIDOMWindowOuter **_retval) = 0;
virtual nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,

Просмотреть файл

@ -81,7 +81,10 @@ NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer)
}
nsPlainTextSerializer::nsPlainTextSerializer()
: kSpace(NS_LITERAL_STRING(" ")) // Init of "constant"
: mFlags(0)
, mFloatingLines(-1)
, mLineBreakDue(false)
, kSpace(NS_LITERAL_STRING(" ")) // Init of "constant"
{
mOutputString = nullptr;

Просмотреть файл

@ -51,10 +51,18 @@ NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsQueryContentEventResult)
NS_IMPL_RELEASE(nsQueryContentEventResult)
nsQueryContentEventResult::nsQueryContentEventResult()
: mEventMessage(eVoidEvent)
, mSucceeded(false)
nsQueryContentEventResult::nsQueryContentEventResult(mozilla::WidgetQueryContentEvent &aEvent)
: mEventMessage(aEvent.mMessage)
, mOffset(aEvent.mReply.mOffset)
, mTentativeCaretOffset(aEvent.mReply.mTentativeCaretOffset)
, mString(aEvent.mReply.mString)
, mRect(aEvent.mReply.mRect)
, mRectArray(std::move(aEvent.mReply.mRectArray))
, mSucceeded(aEvent.mSucceeded)
, mReversed(aEvent.mReply.mReversed)
{
// Mark as result that is longer used.
aEvent.mSucceeded = false;
}
nsQueryContentEventResult::~nsQueryContentEventResult()
@ -223,20 +231,8 @@ nsQueryContentEventResult::GetCharacterRect(int32_t aOffset,
}
void
nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
WidgetQueryContentEvent &aEvent)
nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget)
{
mEventMessage = aEvent.mMessage;
mSucceeded = aEvent.mSucceeded;
mReversed = aEvent.mReply.mReversed;
mRect = aEvent.mReply.mRect;
mOffset = aEvent.mReply.mOffset;
mTentativeCaretOffset = aEvent.mReply.mTentativeCaretOffset;
mString = aEvent.mReply.mString;
mRectArray = std::move(aEvent.mReply.mRectArray);
// Mark as result that is longer used.
aEvent.mSucceeded = false;
if (!IsRectRelatedPropertyAvailable(mEventMessage) ||
!aWidget || !mSucceeded) {
return;

Просмотреть файл

@ -19,12 +19,11 @@ class nsIWidget;
class nsQueryContentEventResult final : public nsIQueryContentEventResult
{
public:
nsQueryContentEventResult();
explicit nsQueryContentEventResult(mozilla::WidgetQueryContentEvent& aEvent);
NS_DECL_ISUPPORTS
NS_DECL_NSIQUERYCONTENTEVENTRESULT
void SetEventResult(nsIWidget* aWidget,
mozilla::WidgetQueryContentEvent& aEvent);
void SetEventResult(nsIWidget* aWidget);
protected:
~nsQueryContentEventResult();

Просмотреть файл

@ -39,7 +39,11 @@ class nsSyncLoader : public nsIStreamListener,
public nsSupportsWeakReference
{
public:
nsSyncLoader() : mLoading(false) {}
nsSyncLoader()
: mLoading(false)
, mAsyncLoadStatus(NS_ERROR_NOT_INITIALIZED)
{
}
NS_DECL_ISUPPORTS

Просмотреть файл

@ -48,6 +48,10 @@ NS_NewXHTMLContentSerializer(nsIContentSerializer** aSerializer)
nsXHTMLContentSerializer::nsXHTMLContentSerializer()
: mIsHTMLSerializer(false)
, mIsCopying(false)
, mDisableEntityEncoding(0)
, mRewriteEncodingDeclaration(false)
, mIsFirstChildOfOL(false)
{
}

Просмотреть файл

@ -109,7 +109,6 @@ protected:
*/
bool mIsHTMLSerializer;
bool mDoHeader;
bool mIsCopying; // Set to true only while copying
/*

Просмотреть файл

@ -482,7 +482,7 @@ public:
protected:
// ptr is left uninitialized for optimization purposes.
T* ptr;
MOZ_INIT_OUTSIDE_CTOR T* ptr;
#ifdef DEBUG
bool inited;
#endif

Просмотреть файл

@ -174,7 +174,11 @@ namespace binding_danger {
template<typename CleanupPolicy>
struct TErrorResult<CleanupPolicy>::Message {
Message() { MOZ_COUNT_CTOR(TErrorResult::Message); }
Message()
: mErrorNumber(dom::Err_Limit)
{
MOZ_COUNT_CTOR(TErrorResult::Message);
}
~Message() { MOZ_COUNT_DTOR(TErrorResult::Message); }
nsTArray<nsString> mArgs;
@ -1645,7 +1649,7 @@ ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::MutableHandle<JS::PropertyDescriptor> desc,
bool& cacheOnHolder)
{
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
JS::Rooted<JSObject*> global(cx, JS::GetNonCCWObjectGlobal(obj));
{
JSAutoRealm ar(cx, global);
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
@ -3052,7 +3056,7 @@ struct MaybeGlobalThisPolicy : public NormalThisPolicy
{
return aArgs.thisv().isObject() ?
&aArgs.thisv().toObject() :
js::GetGlobalForObjectCrossCompartment(&aArgs.callee());
JS::GetNonCCWObjectGlobal(&aArgs.callee());
}
// We want the MaybeUnwrapThisObject of NormalThisPolicy.

Просмотреть файл

@ -1664,7 +1664,9 @@ FindAssociatedGlobal(JSContext* cx, T* p, nsWrapperCache* cache,
}
MOZ_ASSERT(JS::ObjectIsNotGray(obj));
obj = js::GetGlobalForObjectCrossCompartment(obj);
// The object is never a CCW but it may not be in the current compartment of
// the JSContext.
obj = JS::GetNonCCWObjectGlobal(obj);
if (!useXBLScope) {
return obj;
@ -2412,7 +2414,7 @@ inline bool
XrayGetNativeProto(JSContext* cx, JS::Handle<JSObject*> obj,
JS::MutableHandle<JSObject*> protop)
{
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
JS::Rooted<JSObject*> global(cx, JS::GetNonCCWObjectGlobal(obj));
{
JSAutoRealm ar(cx, global);
const DOMJSClass* domClass = GetDOMClass(obj);

Просмотреть файл

@ -522,7 +522,10 @@ private:
// |mJSException| has a non-trivial constructor and therefore MUST be
// placement-new'd into existence.
MOZ_PUSH_DISABLE_NONTRIVIAL_UNION_WARNINGS
Extra() {}
Extra()
: mMessage(nullptr)
{
}
MOZ_POP_DISABLE_NONTRIVIAL_UNION_WARNINGS
} mExtra;

Просмотреть файл

@ -111,9 +111,9 @@ private:
}
// mData is left uninitialized for optimization purposes.
nsString::char_type* mData;
MOZ_INIT_OUTSIDE_CTOR nsString::char_type* mData;
// mLength is left uninitialized for optimization purposes.
nsString::size_type mLength;
MOZ_INIT_OUTSIDE_CTOR nsString::size_type mLength;
nsString::DataFlags mDataFlags;
nsString::ClassFlags mClassFlags;

Просмотреть файл

@ -221,6 +221,7 @@ private:
public:
ArrayBufferView_base()
: Base()
, mType(js::Scalar::MaxTypedArrayViewType)
{
}

22
dom/cache/SavedTypes.h поставляемый
Просмотреть файл

@ -22,7 +22,16 @@ namespace cache {
struct SavedRequest
{
SavedRequest() : mHasBodyId(false) { mValue.body() = void_t(); }
SavedRequest()
: mHasBodyId(false)
, mCacheId(0)
{
mBodyId.m0 = 0;
mBodyId.m1 = 0;
mBodyId.m2 = 0;
memset(mBodyId.m3, 0, sizeof(mBodyId.m3));
mValue.body() = void_t();
}
CacheRequest mValue;
bool mHasBodyId;
nsID mBodyId;
@ -31,7 +40,16 @@ struct SavedRequest
struct SavedResponse
{
SavedResponse() : mHasBodyId(false) { mValue.body() = void_t(); }
SavedResponse()
: mHasBodyId(false)
, mCacheId(0)
{
mBodyId.m0 = 0;
mBodyId.m1 = 0;
mBodyId.m2 = 0;
memset(mBodyId.m3, 0, sizeof(mBodyId.m3));
mValue.body() = void_t();
}
CacheResponse mValue;
bool mHasBodyId;
nsID mBodyId;

Просмотреть файл

@ -9,7 +9,7 @@
#include "ClientState.h"
#include "mozilla/Unused.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIWebNavigation.h"
#include "nsIWebProgress.h"
#include "nsIWebProgressListener.h"
@ -216,16 +216,11 @@ ClientNavigateOpChild::DoNavigate(const ClientNavigateOpConstructorArgs& aArgs)
return ref.forget();
}
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
rv = docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) {
ref = ClientOpPromise::CreateAndReject(rv, __func__);
return ref.forget();
}
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
loadInfo->SetTriggeringPrincipal(principal);
loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContent);
loadInfo->SetLoadType(LOAD_STOP_CONTENT);
loadInfo->SetSourceDocShell(docShell);
rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -42,6 +42,7 @@ protected:
HashEntry(uint8_t aType, const char* aEntryName)
: mEntryName(aEntryName)
, mEntryType(aType)
, mData()
{
Reset(mEntryType);
}

Просмотреть файл

@ -339,6 +339,7 @@ FetchDriver::FetchDriver(InternalRequest* aRequest,
, mPerformanceStorage(aPerformanceStorage)
, mNeedToObserveOnDataAvailable(false)
, mIsTrackingFetch(aIsTrackingFetch)
, mOnStopRequestCalled(false)
#ifdef DEBUG
, mResponseAvailableCalled(false)
, mFetchCalled(false)

Просмотреть файл

@ -124,6 +124,7 @@ InternalRequest::InternalRequest(const nsACString& aURL,
const nsAString& aIntegrity)
: mMethod(aMethod)
, mHeaders(aHeaders)
, mBodyLength(InternalResponse::UNKNOWN_BODY_SIZE)
, mContentPolicyType(aContentPolicyType)
, mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy)
@ -184,13 +185,16 @@ InternalRequest::InternalRequest(const IPCInternalRequest& aIPCRequest)
, mURLList(aIPCRequest.urls())
, mHeaders(new InternalHeaders(aIPCRequest.headers(),
aIPCRequest.headersGuard()))
, mBodyLength(InternalResponse::UNKNOWN_BODY_SIZE)
, mContentPolicyType(aIPCRequest.contentPolicyType())
, mReferrer(aIPCRequest.referrer())
, mReferrerPolicy(aIPCRequest.referrerPolicy())
, mEnvironmentReferrerPolicy(net::RP_Unset)
, mMode(aIPCRequest.mode())
, mCredentialsMode(aIPCRequest.credentials())
, mCacheMode(aIPCRequest.requestCache())
, mRedirectMode(aIPCRequest.requestRedirect())
, mMozErrors(false)
{
MOZ_ASSERT(!mURLList.IsEmpty());
}

Просмотреть файл

@ -22,10 +22,6 @@ class GamepadHapticActuator : public nsISupports,
public:
GamepadHapticActuator(nsISupports* aParent, uint32_t aGamepadId,
uint32_t aIndex);
explicit GamepadHapticActuator(nsISupports* aParent)
: mParent(aParent), mType(GamepadHapticActuatorType::Vibration)
{
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadHapticActuator)

Просмотреть файл

@ -26,6 +26,7 @@ GridLine::GridLine(GridLines *aParent)
, mBreadth(0.0)
, mType(GridDeclaration::Implicit)
, mNumber(0)
, mNegativeNumber(0)
{
MOZ_ASSERT(aParent, "Should never be instantiated with a null GridLines");
}

Просмотреть файл

@ -775,8 +775,8 @@ IndexedDatabaseManager::ExperimentalFeaturesEnabled(JSContext* aCx, JSObject* aG
// that preference. We can retrieve gExperimentalFeaturesEnabled without
// actually going through IndexedDatabaseManager.
// See Bug 1198093 comment 14 for detailed explanation.
if (IsNonExposedGlobal(aCx, js::GetGlobalForObjectCrossCompartment(aGlobal),
GlobalNames::BackstagePass)) {
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
if (IsNonExposedGlobal(aCx, aGlobal, GlobalNames::BackstagePass)) {
MOZ_ASSERT(NS_IsMainThread());
static bool featureRetrieved = false;
if (!featureRetrieved) {

Просмотреть файл

@ -23,7 +23,8 @@ NS_IMPL_ISUPPORTS(ContentBridgeParent,
nsIObserver)
ContentBridgeParent::ContentBridgeParent()
: mIsForJSPlugin(false)
: mIsForBrowser(false)
, mIsForJSPlugin(false)
{}
ContentBridgeParent::~ContentBridgeParent()

Просмотреть файл

@ -114,7 +114,7 @@
#include "mozInlineSpellChecker.h"
#include "nsDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#include "nsIConsoleListener.h"
#include "nsIContentViewer.h"
#include "nsICycleCollectorListener.h"
@ -546,6 +546,7 @@ ContentChild::ContentChild()
, mMainChromeTid(0)
, mMsaaID(0)
#endif
, mIsForBrowser(false)
, mIsAlive(true)
, mShuttingDown(false)
{
@ -756,7 +757,7 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
const nsAString& aName,
const nsACString& aFeatures,
bool aForceNoOpener,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn)
{
@ -768,7 +769,7 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
static nsresult
GetCreateWindowParams(mozIDOMWindowProxy* aParent,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
nsACString& aBaseURIString, float* aFullZoom,
uint32_t* aReferrerPolicy,
nsIPrincipal** aTriggeringPrincipal)
@ -796,13 +797,11 @@ GetCreateWindowParams(mozIDOMWindowProxy* aParent,
baseURI->GetSpec(aBaseURIString);
bool sendReferrer = true;
if (aLoadInfo) {
aLoadInfo->GetSendReferrer(&sendReferrer);
if (!sendReferrer) {
if (!aLoadInfo->SendReferrer()) {
*aReferrerPolicy = mozilla::net::RP_No_Referrer;
} else {
aLoadInfo->GetReferrerPolicy(aReferrerPolicy);
*aReferrerPolicy = aLoadInfo->ReferrerPolicy();
}
}
@ -833,7 +832,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
const nsAString& aName,
const nsACString& aFeatures,
bool aForceNoOpener,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn)
{

Просмотреть файл

@ -34,7 +34,7 @@ struct OverrideMapping;
class nsIDomainPolicy;
class nsIURIClassifierCallback;
struct LookAndFeelInt;
class nsIDocShellLoadInfo;
class nsDocShellLoadInfo;
namespace mozilla {
class RemoteSpellcheckEngineChild;
@ -115,7 +115,7 @@ public:
const nsAString& aName,
const nsACString& aFeatures,
bool aForceNoOpener,
nsIDocShellLoadInfo* aLoadInfo,
nsDocShellLoadInfo* aLoadInfo,
bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn);

Просмотреть файл

@ -26,6 +26,7 @@ class FilePickerParent : public PFilePickerParent
const int16_t& aMode)
: mTitle(aTitle)
, mMode(aMode)
, mResult(nsIFilePicker::returnOK)
{}
virtual ~FilePickerParent();

Просмотреть файл

@ -123,7 +123,7 @@
#include "nsString.h"
#include "nsISupportsPrimitives.h"
#include "mozilla/Telemetry.h"
#include "nsIDocShellLoadInfo.h"
#include "nsDocShellLoadInfo.h"
#ifdef XP_WIN
#include "mozilla/plugins/PluginWidgetChild.h"
@ -1000,7 +1000,7 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
bool aPositionSpecified, bool aSizeSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener,
nsIDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
nsDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn)
{
*aReturn = nullptr;

Просмотреть файл

@ -832,7 +832,6 @@ private:
layers::LayersId mLayersId;
int64_t mBeforeUnloadListeners;
CSSRect mUnscaledOuterRect;
nscolor mLastBackgroundColor;
Maybe<bool> mLayersConnected;
bool mDidFakeShow;
bool mNotified;

Просмотреть файл

@ -161,6 +161,8 @@ TabParent::TabParent(nsIContentParent* aManager,
, mTabId(aTabId)
, mCreatingWindow(false)
, mCursor(eCursorInvalid)
, mCustomCursorHotspotX(0)
, mCustomCursorHotspotY(0)
, mTabSetsCursor(false)
, mHasContentOpener(false)
#ifdef DEBUG

Просмотреть файл

@ -196,8 +196,9 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(MessagePort, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(MessagePort, DOMEventTargetHelper)
MessagePort::MessagePort(nsIGlobalObject* aGlobal)
MessagePort::MessagePort(nsIGlobalObject* aGlobal, State aState)
: DOMEventTargetHelper(aGlobal)
, mState(aState)
, mMessageQueueEnabled(false)
, mIsKeptAlive(false)
, mHasBeenTransferredOrClosed(false)
@ -221,9 +222,9 @@ MessagePort::Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
{
MOZ_ASSERT(aGlobal);
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
RefPtr<MessagePort> mp = new MessagePort(aGlobal, eStateUnshippedEntangled);
mp->Initialize(aUUID, aDestinationUUID, 1 /* 0 is an invalid sequence ID */,
false /* Neutered */, eStateUnshippedEntangled, aRv);
false /* Neutered */, aRv);
return mp.forget();
}
@ -234,10 +235,9 @@ MessagePort::Create(nsIGlobalObject* aGlobal,
{
MOZ_ASSERT(aGlobal);
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
RefPtr<MessagePort> mp = new MessagePort(aGlobal, eStateEntangling);
mp->Initialize(aIdentifier.uuid(), aIdentifier.destinationUuid(),
aIdentifier.sequenceId(), aIdentifier.neutered(),
eStateEntangling, aRv);
aIdentifier.sequenceId(), aIdentifier.neutered(), aRv);
return mp.forget();
}
@ -254,15 +254,13 @@ void
MessagePort::Initialize(const nsID& aUUID,
const nsID& aDestinationUUID,
uint32_t aSequenceID, bool mNeutered,
State aState, ErrorResult& aRv)
ErrorResult& aRv)
{
MOZ_ASSERT(mIdentifier);
mIdentifier->uuid() = aUUID;
mIdentifier->destinationUuid() = aDestinationUUID;
mIdentifier->sequenceId() = aSequenceID;
mState = aState;
if (mNeutered) {
// If this port is neutered we don't want to keep it alive artificially nor
// we want to add listeners or WorkerRefs.

Просмотреть файл

@ -89,11 +89,6 @@ public:
void Closed();
private:
explicit MessagePort(nsIGlobalObject* aGlobal);
~MessagePort();
void DisconnectFromOwner() override;
enum State {
// When a port is created by a MessageChannel it is entangled with the
// other. They both run on the same thread, same event loop and the
@ -139,9 +134,13 @@ private:
eStateDisentangledForClose
};
explicit MessagePort(nsIGlobalObject* aGlobal, State aState);
~MessagePort();
void DisconnectFromOwner() override;
void Initialize(const nsID& aUUID, const nsID& aDestinationUUID,
uint32_t aSequenceID, bool mNeutered, State aState,
ErrorResult& aRv);
uint32_t aSequenceID, bool mNeutered, ErrorResult& aRv);
bool ConnectToPBackground();

Просмотреть файл

@ -153,6 +153,7 @@ NS_IMPL_ISUPPORTS_INHERITED(PaymentCanMakeActionResponse,
nsIPaymentCanMakeActionResponse)
PaymentCanMakeActionResponse::PaymentCanMakeActionResponse()
: mResult(false)
{
mType = nsIPaymentActionResponse::CANMAKE_ACTION;
}
@ -180,6 +181,7 @@ NS_IMPL_ISUPPORTS_INHERITED(PaymentShowActionResponse,
nsIPaymentShowActionResponse)
PaymentShowActionResponse::PaymentShowActionResponse()
: mAcceptStatus(nsIPaymentActionResponse::PAYMENT_REJECTED)
{
mType = nsIPaymentActionResponse::SHOW_ACTION;
}
@ -291,6 +293,7 @@ NS_IMPL_ISUPPORTS_INHERITED(PaymentAbortActionResponse,
nsIPaymentAbortActionResponse)
PaymentAbortActionResponse::PaymentAbortActionResponse()
: mAbortStatus(nsIPaymentActionResponse::ABORT_FAILED)
{
mType = nsIPaymentActionResponse::ABORT_ACTION;
}
@ -327,6 +330,7 @@ NS_IMPL_ISUPPORTS_INHERITED(PaymentCompleteActionResponse,
nsIPaymentCompleteActionResponse)
PaymentCompleteActionResponse::PaymentCompleteActionResponse()
: mCompleteStatus(nsIPaymentActionResponse::COMPLETE_FAILED)
{
mType = nsIPaymentActionResponse::COMPLETE_ACTION;
}

Просмотреть файл

@ -56,8 +56,10 @@ Performance::CreateForMainThread(nsPIDOMWindowInner* aWindow,
MOZ_ASSERT(NS_IsMainThread());
RefPtr<Performance> performance =
new PerformanceMainThread(aWindow, aDOMTiming, aChannel);
performance->mSystemPrincipal = nsContentUtils::IsSystemPrincipal(aPrincipal);
new PerformanceMainThread(aWindow,
aDOMTiming,
aChannel,
nsContentUtils::IsSystemPrincipal(aPrincipal));
return performance.forget();
}
@ -68,21 +70,22 @@ Performance::CreateForWorker(WorkerPrivate* aWorkerPrivate)
aWorkerPrivate->AssertIsOnWorkerThread();
RefPtr<Performance> performance = new PerformanceWorker(aWorkerPrivate);
performance->mSystemPrincipal = aWorkerPrivate->UsesSystemPrincipal();
return performance.forget();
}
Performance::Performance()
Performance::Performance(bool aSystemPrincipal)
: mResourceTimingBufferSize(kDefaultResourceTimingBufferSize)
, mPendingNotificationObserversTask(false)
, mSystemPrincipal(aSystemPrincipal)
{
MOZ_ASSERT(!NS_IsMainThread());
}
Performance::Performance(nsPIDOMWindowInner* aWindow)
Performance::Performance(nsPIDOMWindowInner* aWindow, bool aSystemPrincipal)
: DOMEventTargetHelper(aWindow)
, mResourceTimingBufferSize(kDefaultResourceTimingBufferSize)
, mPendingNotificationObserversTask(false)
, mSystemPrincipal(aSystemPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
}

Просмотреть файл

@ -118,8 +118,8 @@ public:
void InsertResourceEntry(PerformanceEntry* aEntry);
protected:
Performance();
explicit Performance(nsPIDOMWindowInner* aWindow);
explicit Performance(bool aSystemPrincipal);
Performance(nsPIDOMWindowInner* aWindow, bool aSystemPrincipal);
virtual ~Performance();

Просмотреть файл

@ -75,8 +75,9 @@ NS_INTERFACE_MAP_END_INHERITING(Performance)
PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel)
: Performance(aWindow)
nsITimedChannel* aChannel,
bool aPrincipal)
: Performance(aWindow, aPrincipal)
, mDOMTiming(aDOMTiming)
, mChannel(aChannel)
{

Просмотреть файл

@ -19,7 +19,8 @@ class PerformanceMainThread final : public Performance
public:
PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel);
nsITimedChannel* aChannel,
bool aPrincipal);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,

Просмотреть файл

@ -12,7 +12,8 @@ namespace mozilla {
namespace dom {
PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
: mWorkerPrivate(aWorkerPrivate)
: Performance(aWorkerPrivate->UsesSystemPrincipal())
, mWorkerPrivate(aWorkerPrivate)
{
mWorkerPrivate->AssertIsOnWorkerThread();
}

Просмотреть файл

@ -568,6 +568,7 @@ AutoJSAPI::ReportException()
errorGlobal = GetCurrentThreadWorkerGlobal();
}
}
MOZ_ASSERT(JS_IsGlobalObject(errorGlobal));
JSAutoRealm ar(cx(), errorGlobal);
JS::Rooted<JS::Value> exn(cx());
js::ErrorReport jsReport(cx());
@ -576,7 +577,7 @@ AutoJSAPI::ReportException()
if (mIsMainThread) {
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
RefPtr<nsGlobalWindowInner> win = xpc::WindowGlobalOrNull(errorGlobal);
RefPtr<nsGlobalWindowInner> win = xpc::WindowOrNull(errorGlobal);
nsPIDOMWindowInner* inner = win ? win->AsInner() : nullptr;
bool isChrome = nsContentUtils::IsSystemPrincipal(
nsContentUtils::ObjectPrincipal(errorGlobal));

Просмотреть файл

@ -208,6 +208,7 @@ ServiceWorkerUpdateJob::ServiceWorkerUpdateJob(
: ServiceWorkerJob(aType, aPrincipal, aScope, aScriptSpec)
, mLoadGroup(aLoadGroup)
, mUpdateViaCache(aUpdateViaCache)
, mOnFailure(serviceWorkerScriptCache::OnFailure::DoNothing)
{
}

Просмотреть файл

@ -917,6 +917,7 @@ public:
, mOrigin(aOriginNoSuffix)
, mKey(aKey)
, mValue(aValue)
, mRv(NS_ERROR_NOT_INITIALIZED)
{ }
LoadRunnable(StorageDBParent* aParent,

Просмотреть файл

@ -98,6 +98,7 @@ public:
, mDisconnectingOrDisconnected(false)
, mCloseEventWasClean(false)
, mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL)
, mPort(0)
, mScriptLine(0)
, mScriptColumn(0)
, mInnerWindowID(0)

Просмотреть файл

@ -433,9 +433,19 @@ ExecutionRunnable::RunOnMainThread()
// ---------------------------------------------------------------------------
// WorkletLoadInfo
WorkletLoadInfo::WorkletLoadInfo()
WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
: mInnerWindowID(aWindow->WindowID())
, mDumpEnabled(DOMPrefs::DumpEnabled())
, mOriginAttributes(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef())
, mPrincipal(aPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
nsPIDOMWindowOuter* outerWindow = aWindow->GetOuterWindow();
if (outerWindow) {
mOuterWindowID = outerWindow->WindowID();
} else {
mOuterWindowID = 0;
}
}
WorkletLoadInfo::~WorkletLoadInfo()
@ -472,6 +482,7 @@ Worklet::Worklet(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
WorkletType aWorkletType)
: mWindow(aWindow)
, mWorkletType(aWorkletType)
, mWorkletLoadInfo(aWindow, aPrincipal)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aPrincipal);
@ -480,24 +491,6 @@ Worklet::Worklet(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
#ifdef RELEASE_OR_BETA
MOZ_CRASH("This code should not go to release/beta yet!");
#endif
// Reset mWorkletLoadInfo and populate it.
memset(&mWorkletLoadInfo, 0, sizeof(WorkletLoadInfo));
mWorkletLoadInfo.mInnerWindowID = aWindow->WindowID();
nsPIDOMWindowOuter* outerWindow = aWindow->GetOuterWindow();
if (outerWindow) {
mWorkletLoadInfo.mOuterWindowID = outerWindow->WindowID();
}
mWorkletLoadInfo.mOriginAttributes =
BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
mWorkletLoadInfo.mPrincipal = aPrincipal;
mWorkletLoadInfo.mDumpEnabled = DOMPrefs::DumpEnabled();
}
Worklet::~Worklet()

Просмотреть файл

@ -30,7 +30,7 @@ enum class CallerType : uint32_t;
class WorkletLoadInfo
{
public:
WorkletLoadInfo();
WorkletLoadInfo(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
~WorkletLoadInfo();
uint64_t OuterWindowID() const { return mOuterWindowID; }

Просмотреть файл

@ -210,6 +210,7 @@ XMLHttpRequestMainThread::XMLHttpRequestMainThread()
mIsHtml(false),
mWarnAboutSyncHtml(false),
mLoadTotal(-1),
mLoadTransferred(0),
mIsSystem(false),
mIsAnon(false),
mFirstStartRequestSeen(false),

Просмотреть файл

@ -599,16 +599,16 @@ public:
}
/**
* Indicates how many times the surface has been invalidated.
* Yields a dirty rect of what has changed since it was last called.
*/
virtual int32_t Invalidations() const {
return -1;
virtual Maybe<IntRect> TakeDirtyRect() {
return Nothing();
}
/**
* Increment the invalidation counter.
* Indicate a region which has changed in the surface.
*/
virtual void Invalidate() { }
virtual void Invalidate(const IntRect& aDirtyRect) { }
protected:
bool mIsMapped;

Просмотреть файл

@ -119,7 +119,6 @@ public:
, mStride(0)
, mMapCount(0)
, mHandleCount(0)
, mInvalidations(0)
, mFormat(SurfaceFormat::UNKNOWN)
, mClosed(false)
, mFinalized(false)
@ -249,22 +248,34 @@ public:
}
/**
* Indicates how many times the surface has been invalidated.
* Yields a dirty rect of what has changed since it was last called.
*/
int32_t Invalidations() const override
Maybe<IntRect> TakeDirtyRect() override
{
MutexAutoLock lock(mMutex);
return mInvalidations;
if (mDirtyRect) {
Maybe<IntRect> ret = std::move(mDirtyRect);
return ret;
}
return Nothing();
}
/**
* Increment the invalidation counter.
*/
void Invalidate() override
void Invalidate(const IntRect& aDirtyRect) override
{
MutexAutoLock lock(mMutex);
++mInvalidations;
MOZ_ASSERT(mInvalidations >= 0);
if (!aDirtyRect.IsEmpty()) {
if (mDirtyRect) {
mDirtyRect->UnionRect(mDirtyRect.ref(), aDirtyRect);
} else {
mDirtyRect = Some(aDirtyRect);
}
} else {
mDirtyRect = Some(IntRect(IntPoint(0, 0), mSize));
}
MOZ_ASSERT_IF(mDirtyRect, !mDirtyRect->IsEmpty());
}
/**
@ -333,7 +344,7 @@ private:
int32_t mStride;
int32_t mMapCount;
int32_t mHandleCount;
int32_t mInvalidations;
Maybe<IntRect> mDirtyRect;
IntSize mSize;
RefPtr<SharedMemoryBasic> mBuf;
RefPtr<SharedMemoryBasic> mOldBuf;

Просмотреть файл

@ -90,9 +90,12 @@ BasicPaintedLayer::PaintThebes(gfxContext* aContext,
context = aContext;
}
if (context) {
SetAntialiasingFlags(this, context->GetDrawTarget());
DrawTarget* target = context->GetDrawTarget();
bool oldAA = target->GetPermitSubpixelAA();
SetAntialiasingFlags(this, target);
aCallback(this, context, toDraw, toDraw, DrawRegionClip::NONE,
nsIntRegion(), aCallbackData);
target->SetPermitSubpixelAA(oldAA);
}
if (needsGroup && availableGroup) {
BasicManager()->PopGroupForLayer(group);

Просмотреть файл

@ -135,7 +135,7 @@ void
CompositorBridgeChild::Destroy()
{
// This must not be called from the destructor!
mTexturesWaitingRecycled.Clear();
mTexturesWaitingRecycled.clear();
// Destroying the layer manager may cause all sorts of things to happen, so
// let's make sure there is still a reference to keep this alive whatever
@ -898,25 +898,26 @@ CompositorBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient
}
aClient->SetLastFwdTransactionId(GetFwdTransactionId());
mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
mTexturesWaitingRecycled.emplace(aClient->GetSerial(), aClient);
}
void
CompositorBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
{
if (auto entry = mTexturesWaitingRecycled.Lookup(aTextureId)) {
if (aFwdTransactionId < entry.Data()->GetLastFwdTransactionId()) {
auto it = mTexturesWaitingRecycled.find(aTextureId);
if (it != mTexturesWaitingRecycled.end()) {
if (aFwdTransactionId < it->second->GetLastFwdTransactionId()) {
// Released on host side, but client already requested newer use texture.
return;
}
entry.Remove();
mTexturesWaitingRecycled.erase(it);
}
}
void
CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
{
mTexturesWaitingRecycled.Remove(aTextureId);
mTexturesWaitingRecycled.erase(aTextureId);
}
TextureClientPool*

Просмотреть файл

@ -17,13 +17,14 @@
#include "mozilla/layers/PaintThread.h" // for PaintThread
#include "mozilla/webrender/WebRenderTypes.h"
#include "nsClassHashtable.h" // for nsClassHashtable
#include "nsRefPtrHashtable.h"
#include "nsCOMPtr.h" // for nsCOMPtr
#include "nsHashKeys.h" // for nsUint64HashKey
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
#include "nsWeakReference.h"
#include <unordered_map>
namespace mozilla {
namespace dom {
@ -389,7 +390,7 @@ private:
* Hold TextureClients refs until end of their usages on host side.
* It defer calling of TextureClient recycle callback.
*/
nsRefPtrHashtable<nsUint64HashKey, TextureClient> mTexturesWaitingRecycled;
std::unordered_map<uint64_t, RefPtr<TextureClient>> mTexturesWaitingRecycled;
MessageLoop* mMessageLoop;

Просмотреть файл

@ -158,18 +158,19 @@ ImageBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aCl
return;
}
aClient->SetLastFwdTransactionId(GetFwdTransactionId());
mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
mTexturesWaitingRecycled.emplace(aClient->GetSerial(), aClient);
}
void
ImageBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
{
if (auto entry = mTexturesWaitingRecycled.Lookup(aTextureId)) {
if (aFwdTransactionId < entry.Data()->GetLastFwdTransactionId()) {
auto it = mTexturesWaitingRecycled.find(aTextureId);
if (it != mTexturesWaitingRecycled.end()) {
if (aFwdTransactionId < it->second->GetLastFwdTransactionId()) {
// Released on host side, but client already requested newer use texture.
return;
}
entry.Remove();
mTexturesWaitingRecycled.erase(it);
}
}
@ -177,7 +178,7 @@ void
ImageBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
{
MOZ_ASSERT(InImageBridgeChildThread());
mTexturesWaitingRecycled.Remove(aTextureId);
mTexturesWaitingRecycled.erase(aTextureId);
}
// Singleton
@ -235,7 +236,7 @@ ImageBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
mDestroyed = true;
{
MutexAutoLock lock(mContainerMapLock);
mImageContainerListeners.Clear();
mImageContainerListeners.clear();
}
}
@ -287,7 +288,7 @@ ImageBridgeChild::~ImageBridgeChild()
void
ImageBridgeChild::MarkShutDown()
{
mTexturesWaitingRecycled.Clear();
mTexturesWaitingRecycled.clear();
mCanSend = false;
}
@ -310,8 +311,8 @@ ImageBridgeChild::Connect(CompositableClient* aCompositable,
// But offscreen canvas does not provide it.
if (aImageContainer) {
MutexAutoLock lock(mContainerMapLock);
MOZ_ASSERT(!mImageContainerListeners.Contains(id));
mImageContainerListeners.Put(id, aImageContainer->GetImageContainerListener());
MOZ_ASSERT(mImageContainerListeners.find(id) == mImageContainerListeners.end());
mImageContainerListeners.emplace(id, aImageContainer->GetImageContainerListener());
}
CompositableHandle handle(id);
@ -323,7 +324,7 @@ void
ImageBridgeChild::ForgetImageContainer(const CompositableHandle& aHandle)
{
MutexAutoLock lock(mContainerMapLock);
mImageContainerListeners.Remove(aHandle.Value());
mImageContainerListeners.erase(aHandle.Value());
}
Thread* ImageBridgeChild::GetThread() const
@ -724,9 +725,8 @@ ImageBridgeChild::UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier&
nsTArray<RefPtr<ImageContainerListener> > listeners;
{
MutexAutoLock lock(mContainerMapLock);
for (auto iter = mImageContainerListeners.Iter(); !iter.Done(); iter.Next()) {
RefPtr<ImageContainerListener>& listener = iter.Data();
listeners.AppendElement(listener);
for (const auto& entry : mImageContainerListeners) {
listeners.AppendElement(entry.second);
}
}
// Drop ImageContainer's ImageClient whithout holding mContainerMapLock to avoid deadlock.
@ -1004,8 +1004,9 @@ ImageBridgeChild::RecvDidComposite(InfallibleTArray<ImageCompositeNotification>&
RefPtr<ImageContainerListener> listener;
{
MutexAutoLock lock(mContainerMapLock);
if (auto entry = mImageContainerListeners.Lookup(n.compositable().Value())) {
listener = entry.Data();
auto it = mImageContainerListeners.find(n.compositable().Value());
if (it != mImageContainerListeners.end()) {
listener = it->second;
}
}
if (listener) {
@ -1117,7 +1118,7 @@ ImageBridgeChild::ReleaseCompositable(const CompositableHandle& aHandle)
{
MutexAutoLock lock(mContainerMapLock);
mImageContainerListeners.Remove(aHandle.Value());
mImageContainerListeners.erase(aHandle.Value());
}
}

Просмотреть файл

@ -9,6 +9,8 @@
#include <stddef.h> // for size_t
#include <stdint.h> // for uint32_t, uint64_t
#include <unordered_map>
#include "mozilla/Attributes.h" // for override
#include "mozilla/Atomics.h"
#include "mozilla/RefPtr.h" // for already_AddRefed
@ -21,7 +23,6 @@
#include "mozilla/webrender/WebRenderTypes.h"
#include "nsIObserver.h"
#include "nsRegion.h" // for nsIntRegion
#include "nsRefPtrHashtable.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc
@ -395,13 +396,13 @@ private:
* Hold TextureClients refs until end of their usages on host side.
* It defer calling of TextureClient recycle callback.
*/
nsRefPtrHashtable<nsUint64HashKey, TextureClient> mTexturesWaitingRecycled;
std::unordered_map<uint64_t, RefPtr<TextureClient>> mTexturesWaitingRecycled;
/**
* Mapping from async compositable IDs to image containers.
*/
Mutex mContainerMapLock;
nsRefPtrHashtable<nsUint64HashKey, ImageContainerListener> mImageContainerListeners;
std::unordered_map<uint64_t, RefPtr<ImageContainerListener>> mImageContainerListeners;
#if defined(XP_WIN)
/**

Просмотреть файл

@ -23,24 +23,20 @@ class SharedSurfacesChild::ImageKeyData final
{
public:
ImageKeyData(WebRenderLayerManager* aManager,
const wr::ImageKey& aImageKey,
int32_t aInvalidations)
const wr::ImageKey& aImageKey)
: mManager(aManager)
, mImageKey(aImageKey)
, mInvalidations(aInvalidations)
{ }
ImageKeyData(ImageKeyData&& aOther)
: mManager(std::move(aOther.mManager))
, mImageKey(aOther.mImageKey)
, mInvalidations(aOther.mInvalidations)
{ }
ImageKeyData& operator=(ImageKeyData&& aOther)
{
mManager = std::move(aOther.mManager);
mImageKey = aOther.mImageKey;
mInvalidations = aOther.mInvalidations;
return *this;
}
@ -49,7 +45,6 @@ public:
RefPtr<WebRenderLayerManager> mManager;
wr::ImageKey mImageKey;
int32_t mInvalidations;
};
class SharedSurfacesChild::SharedUserData final
@ -119,7 +114,7 @@ public:
wr::ImageKey UpdateKey(WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
int32_t aInvalidations)
const Maybe<IntRect>& aDirtyRect)
{
MOZ_ASSERT(aManager);
MOZ_ASSERT(!aManager->IsDestroyed());
@ -146,13 +141,12 @@ public:
// can change state. If our namespace differs, then our old key has
// already been discarded.
bool ownsKey = wrBridge->GetNamespace() == entry.mImageKey.mNamespace;
if (!ownsKey || entry.mInvalidations != aInvalidations) {
if (ownsKey) {
aManager->AddImageKeyForDiscard(entry.mImageKey);
}
entry.mInvalidations = aInvalidations;
if (!ownsKey) {
entry.mImageKey = wrBridge->GetNextImageKey();
aResources.AddExternalImage(mId, entry.mImageKey);
} else if (aDirtyRect) {
aResources.UpdateExternalImage(mId, entry.mImageKey,
ViewAs<ImagePixel>(aDirtyRect.ref()));
}
key = entry.mImageKey;
@ -162,7 +156,7 @@ public:
if (!found) {
key = aManager->WrBridge()->GetNextImageKey();
ImageKeyData data(aManager, key, aInvalidations);
ImageKeyData data(aManager, key);
mKeys.AppendElement(std::move(data));
aResources.AddExternalImage(mId, key);
}
@ -323,12 +317,12 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
// surfaces promise to increment the invalidation counter each time the
// surface has changed. We can use this counter to determine whether or not
// we should upate our paired ImageKey.
int32_t invalidations = aSurface->Invalidations();
Maybe<IntRect> dirtyRect = aSurface->TakeDirtyRect();
SharedUserData* data = nullptr;
nsresult rv = SharedSurfacesChild::ShareInternal(aSurface, &data);
if (NS_SUCCEEDED(rv)) {
MOZ_ASSERT(data);
aKey = data->UpdateKey(aManager, aResources, invalidations);
aKey = data->UpdateKey(aManager, aResources, dirtyRect);
}
return rv;

Просмотреть файл

@ -132,6 +132,12 @@ struct OpUpdateBlobImage {
ImageIntRect dirtyRect;
};
struct OpUpdateExternalImage {
ExternalImageId externalImageId;
ImageKey key;
ImageIntRect dirtyRect;
};
struct OpDeleteImage {
ImageKey key;
};
@ -178,6 +184,7 @@ union OpUpdateResource {
OpDeleteFontInstance;
OpAddExternalImage;
OpPushExternalImageForTexture;
OpUpdateExternalImage;
};
} // namespace

Просмотреть файл

@ -319,6 +319,14 @@ IpcResourceUpdateQueue::UpdateBlobImage(ImageKey aKey,
return true;
}
void
IpcResourceUpdateQueue::UpdateExternalImage(wr::ExternalImageId aExtId,
wr::ImageKey aKey,
ImageIntRect aDirtyRect)
{
mUpdates.AppendElement(layers::OpUpdateExternalImage(aExtId, aKey, aDirtyRect));
}
void
IpcResourceUpdateQueue::DeleteImage(ImageKey aKey)
{

Просмотреть файл

@ -99,11 +99,9 @@ public:
Range<uint8_t> aBytes,
ImageIntRect aDirtyRect);
void UpdateExternalImage(ImageKey aKey,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::WrExternalImageBufferType aBufferType,
uint8_t aChannelIndex = 0);
void UpdateExternalImage(ExternalImageId aExtID,
ImageKey aKey,
ImageIntRect aDirtyRect);
void DeleteImage(wr::ImageKey aKey);

Просмотреть файл

@ -353,6 +353,13 @@ WebRenderBridgeParent::UpdateResources(const nsTArray<OpUpdateResource>& aResour
}
break;
}
case OpUpdateResource::TOpUpdateExternalImage: {
const auto& op = cmd.get_OpUpdateExternalImage();
if (!UpdateExternalImage(op.externalImageId(), op.key(), op.dirtyRect(), aUpdates)) {
return false;
}
break;
}
case OpUpdateResource::TOpAddRawFont: {
const auto& op = cmd.get_OpAddRawFont();
wr::Vec<uint8_t> bytes;
@ -518,6 +525,54 @@ WebRenderBridgeParent::PushExternalImageForTexture(wr::ExternalImageId aExtId,
return true;
}
bool
WebRenderBridgeParent::UpdateExternalImage(wr::ExternalImageId aExtId,
wr::ImageKey aKey,
const ImageIntRect& aDirtyRect,
wr::TransactionBuilder& aResources)
{
Range<wr::ImageKey> keys(&aKey, 1);
// Check if key is obsoleted.
if (keys[0].mNamespace != mIdNamespace) {
return true;
}
uint64_t imageId = wr::AsUint64(aExtId);
if (mSharedSurfaceIds.find(imageId) == mSharedSurfaceIds.end()) {
gfxCriticalNote << "Updating unknown shared surface: " << wr::AsUint64(aExtId);
return false;
}
RefPtr<DataSourceSurface> dSurf = SharedSurfacesParent::Get(aExtId);
if (!dSurf) {
gfxCriticalNote << "Shared surface does not exist for extId:" << wr::AsUint64(aExtId);
return false;
}
if (!gfxEnv::EnableWebRenderRecording()) {
wr::ImageDescriptor descriptor(dSurf->GetSize(), dSurf->Stride(),
dSurf->GetFormat());
aResources.UpdateExternalImageWithDirtyRect(aKey, descriptor, aExtId,
wr::WrExternalImageBufferType::ExternalBuffer,
wr::ToDeviceUintRect(aDirtyRect),
0);
return true;
}
DataSourceSurface::ScopedMap map(dSurf, DataSourceSurface::READ);
if (!map.IsMapped()) {
gfxCriticalNote << "DataSourceSurface failed to map for Image for extId:" << wr::AsUint64(aExtId);
return false;
}
IntSize size = dSurf->GetSize();
wr::ImageDescriptor descriptor(size, map.GetStride(), dSurf->GetFormat());
wr::Vec<uint8_t> data;
data.PushBytes(Range<uint8_t>(map.GetData(), size.height * map.GetStride()));
aResources.UpdateImageBuffer(keys[0], descriptor, data);
return true;
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvUpdateResources(nsTArray<OpUpdateResource>&& aResourceUpdates,
nsTArray<RefCountedShmem>&& aSmallShmems,

Просмотреть файл

@ -209,6 +209,9 @@ private:
wr::TransactionBuilder& aUpdates);
bool AddExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey,
wr::TransactionBuilder& aResources);
bool UpdateExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey,
const ImageIntRect& aDirtyRect,
wr::TransactionBuilder& aResources);
bool PushExternalImageForTexture(wr::ExternalImageId aExtId,
wr::ImageKey aKey,

Просмотреть файл

@ -12,7 +12,6 @@
#include "base/thread.h" // for Thread
#include "base/message_loop.h"
#include "nsISupportsImpl.h"
#include "nsRefPtrHashtable.h"
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
#include "mozilla/Mutex.h"
#include "mozilla/webrender/webrender_ffi.h"

Просмотреть файл

@ -638,6 +638,23 @@ TransactionBuilder::UpdateExternalImage(ImageKey aKey,
aChannelIndex);
}
void
TransactionBuilder::UpdateExternalImageWithDirtyRect(ImageKey aKey,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::WrExternalImageBufferType aBufferType,
const wr::DeviceUintRect& aDirtyRect,
uint8_t aChannelIndex)
{
wr_resource_updates_update_external_image_with_dirty_rect(mTxn,
aKey,
&aDescriptor,
aExtID,
aBufferType,
aChannelIndex,
aDirtyRect);
}
void
TransactionBuilder::DeleteImage(ImageKey aKey)
{

Просмотреть файл

@ -120,6 +120,13 @@ public:
wr::WrExternalImageBufferType aBufferType,
uint8_t aChannelIndex = 0);
void UpdateExternalImageWithDirtyRect(ImageKey aKey,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::WrExternalImageBufferType aBufferType,
const wr::DeviceUintRect& aDirtyRect,
uint8_t aChannelIndex = 0);
void DeleteImage(wr::ImageKey aKey);
void AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше