зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1729477) for causing devtools failures in browser_webconsole_sidebar_object_expand_when_message_pruned. CLOSED TREE
Backed out changeset 8cbf3101ed8a (bug 1729477) Backed out changeset 7457834fb7d0 (bug 1729477) Backed out changeset 1259d2d1f247 (bug 1729477)
This commit is contained in:
Родитель
7ce670b735
Коммит
870ff4f480
|
@ -10494,8 +10494,7 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
|
|||
|
||||
/* static */
|
||||
nsContentUtils::SubresourceCacheValidationInfo
|
||||
nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest,
|
||||
nsIURI* aURI) {
|
||||
nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest) {
|
||||
SubresourceCacheValidationInfo info;
|
||||
if (nsCOMPtr<nsICacheInfoChannel> cache = do_QueryInterface(aRequest)) {
|
||||
uint32_t value = 0;
|
||||
|
@ -10514,18 +10513,6 @@ nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest,
|
|||
}
|
||||
}
|
||||
|
||||
// data: URIs are safe to cache across documents under any circumstance, so we
|
||||
// special-case them here even though the channel itself doesn't have any
|
||||
// caching policy. Same for chrome:// uris.
|
||||
//
|
||||
// TODO(emilio): Figure out which other schemes that don't have caching
|
||||
// policies are safe to cache. Blobs should be...
|
||||
if (aURI && (aURI->SchemeIs("data") || dom::IsChromeURI(aURI))) {
|
||||
MOZ_ASSERT(!info.mExpirationTime);
|
||||
MOZ_ASSERT(!info.mMustRevalidate);
|
||||
info.mExpirationTime = Some(0); // 0 means "doesn't expire".
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
@ -3271,7 +3271,7 @@ class nsContentUtils {
|
|||
* stylesheets.
|
||||
*/
|
||||
static SubresourceCacheValidationInfo GetSubresourceCacheValidationInfo(
|
||||
nsIRequest*, nsIURI*);
|
||||
nsIRequest*);
|
||||
|
||||
static uint32_t SecondsFromPRTime(PRTime aTime) {
|
||||
return uint32_t(int64_t(aTime) / int64_t(PR_USEC_PER_SEC));
|
||||
|
|
|
@ -165,6 +165,16 @@ nsresult nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mozilla::StyleSheet* nsXULPrototypeCache::GetStyleSheet(nsIURI* aURI) {
|
||||
return mStyleSheetTable.GetWeak(aURI);
|
||||
}
|
||||
|
||||
nsresult nsXULPrototypeCache::PutStyleSheet(RefPtr<StyleSheet>&& aStyleSheet) {
|
||||
nsIURI* uri = aStyleSheet->GetSheetURI();
|
||||
mStyleSheetTable.InsertOrUpdate(uri, std::move(aStyleSheet));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSScript* nsXULPrototypeCache::GetScript(nsIURI* aURI) {
|
||||
if (auto* entry = mScriptTable.GetEntry(aURI)) {
|
||||
return entry->mScript.get();
|
||||
|
@ -197,6 +207,7 @@ void nsXULPrototypeCache::FlushScripts() { mScriptTable.Clear(); }
|
|||
void nsXULPrototypeCache::Flush() {
|
||||
mPrototypeTable.Clear();
|
||||
mScriptTable.Clear();
|
||||
mStyleSheetTable.Clear();
|
||||
}
|
||||
|
||||
bool nsXULPrototypeCache::IsEnabled() { return !gDisableXULCache; }
|
||||
|
@ -496,6 +507,14 @@ void nsXULPrototypeCache::CollectMemoryReports(
|
|||
other += sInstance->mPrototypeTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||
// TODO Report content in mPrototypeTable?
|
||||
|
||||
other += sInstance->mStyleSheetTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||
for (const auto& stylesheet : sInstance->mStyleSheetTable.Values()) {
|
||||
// NOTE: If Loader::DoSheetComplete() is ever modified to stop clongin
|
||||
// sheets before inserting into this cache, we will need to stop using
|
||||
// SizeOfIncludingThis()
|
||||
other += stylesheet->SizeOfIncludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
other += sInstance->mScriptTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||
// TODO Report content inside mScriptTable?
|
||||
|
||||
|
|
|
@ -59,6 +59,18 @@ class nsXULPrototypeCache : public nsIObserver {
|
|||
JSScript* GetScript(nsIURI* aURI);
|
||||
nsresult PutScript(nsIURI* aURI, JS::Handle<JSScript*> aScriptObject);
|
||||
|
||||
/**
|
||||
* Get a style sheet by URI. If the style sheet is not in the cache,
|
||||
* returns nullptr.
|
||||
*/
|
||||
mozilla::StyleSheet* GetStyleSheet(nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Store a style sheet in the cache. The key, style sheet's URI is obtained
|
||||
* from the style sheet itself.
|
||||
*/
|
||||
nsresult PutStyleSheet(RefPtr<mozilla::StyleSheet>&& aStyleSheet);
|
||||
|
||||
/**
|
||||
* Write the XUL prototype document to a cache file. The proto must be
|
||||
* fully loaded.
|
||||
|
@ -96,8 +108,11 @@ class nsXULPrototypeCache : public nsIObserver {
|
|||
|
||||
static nsXULPrototypeCache* sInstance;
|
||||
|
||||
using StyleSheetTable = nsRefPtrHashtable<nsURIHashKey, mozilla::StyleSheet>;
|
||||
|
||||
nsRefPtrHashtable<nsURIHashKey, nsXULPrototypeDocument>
|
||||
mPrototypeTable; // owns the prototypes
|
||||
StyleSheetTable mStyleSheetTable;
|
||||
|
||||
class ScriptHashKey : public nsURIHashKey {
|
||||
public:
|
||||
|
|
|
@ -1880,10 +1880,10 @@ bool imgLoader::ValidateEntry(
|
|||
LOG_SCOPE(gImgLog, "imgLoader::ValidateEntry");
|
||||
|
||||
// If the expiration time is zero, then the request has not gotten far enough
|
||||
// to know when it will expire, or we know it will never expire (see
|
||||
// nsContentUtils::GetSubresourceCacheValidationInfo).
|
||||
// to know when it will expire.
|
||||
uint32_t expiryTime = aEntry->GetExpiryTime();
|
||||
bool hasExpired = expiryTime && expiryTime <= SecondsFromPRTime(PR_Now());
|
||||
bool hasExpired =
|
||||
expiryTime != 0 && expiryTime <= SecondsFromPRTime(PR_Now());
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ class imgCacheEntry {
|
|||
|
||||
void UpdateLoadTime();
|
||||
|
||||
uint32_t GetExpiryTime() const { return mExpiryTime; }
|
||||
void SetExpiryTime(uint32_t aExpiryTime) {
|
||||
int32_t GetExpiryTime() const { return mExpiryTime; }
|
||||
void SetExpiryTime(int32_t aExpiryTime) {
|
||||
mExpiryTime = aExpiryTime;
|
||||
Touch();
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class imgCacheEntry {
|
|||
uint32_t mDataSize;
|
||||
int32_t mTouchedTime;
|
||||
uint32_t mLoadTime;
|
||||
uint32_t mExpiryTime;
|
||||
int32_t mExpiryTime;
|
||||
nsExpirationState mExpirationState;
|
||||
bool mMustValidate : 1;
|
||||
bool mEvicted : 1;
|
||||
|
|
|
@ -544,17 +544,7 @@ void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry,
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<imgRequest> req = aCacheEntry->GetRequest();
|
||||
MOZ_ASSERT(req);
|
||||
RefPtr<nsIURI> uri;
|
||||
req->GetURI(getter_AddRefs(uri));
|
||||
// TODO(emilio): Seems we should be able to assert `uri` is not null, but we
|
||||
// get here in such cases sometimes (like for some redirects, see
|
||||
// docshell/test/chrome/test_bug89419.xhtml).
|
||||
//
|
||||
// We have the original URI in the cache key though, probably we should be
|
||||
// using that instead of relying on Init() getting called.
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(aRequest, uri);
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(aRequest);
|
||||
|
||||
// Expiration time defaults to 0. We set the expiration time on our entry if
|
||||
// it hasn't been set yet.
|
||||
|
|
|
@ -164,16 +164,6 @@ bool SheetLoadDataHashKey::KeyEquals(const SheetLoadDataHashKey& aKey) const {
|
|||
|
||||
LOG_URI("KeyEquals(%s)\n", mURI);
|
||||
|
||||
if (mParsingMode != aKey.mParsingMode) {
|
||||
LOG((" > Parsing mode mismatch\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Chrome URIs ignore everything else.
|
||||
if (dom::IsChromeURI(mURI)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mPrincipal->Equals(aKey.mPrincipal)) {
|
||||
LOG((" > Principal mismatch\n"));
|
||||
return false;
|
||||
|
@ -195,6 +185,11 @@ bool SheetLoadDataHashKey::KeyEquals(const SheetLoadDataHashKey& aKey) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mParsingMode != aKey.mParsingMode) {
|
||||
LOG((" > Parsing mode mismatch\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mCompatMode != aKey.mCompatMode) {
|
||||
LOG((" > Quirks mismatch\n"));
|
||||
return false;
|
||||
|
|
|
@ -128,8 +128,7 @@ static void AssertComplete(const StyleSheet& aSheet) {
|
|||
|
||||
static void AssertIncompleteSheetMatches(const SheetLoadData& aData,
|
||||
const SheetLoadDataHashKey& aKey) {
|
||||
MOZ_ASSERT(aKey.Principal()->Equals(aData.mTriggeringPrincipal) ||
|
||||
dom::IsChromeURI(aKey.URI()),
|
||||
MOZ_ASSERT(aKey.Principal()->Equals(aData.mTriggeringPrincipal),
|
||||
"Principals should be the same");
|
||||
MOZ_ASSERT(!aData.mSheet->HasForcedUniqueInner(),
|
||||
"CSSOM shouldn't allow access to incomplete sheets");
|
||||
|
@ -145,6 +144,30 @@ SharedStyleSheetCache::CacheResult SharedStyleSheetCache::Lookup(
|
|||
nsIURI* uri = aKey.URI();
|
||||
LOG(("SharedStyleSheetCache::Lookup(%s)", uri->GetSpecOrDefault().get()));
|
||||
|
||||
// Try to find first in the XUL prototype cache.
|
||||
if (dom::IsChromeURI(uri)) {
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (cache && cache->IsEnabled()) {
|
||||
if (StyleSheet* sheet = cache->GetStyleSheet(uri)) {
|
||||
LOG((" From XUL cache: %p", sheet));
|
||||
AssertComplete(*sheet);
|
||||
|
||||
// See below, we always clone on insertion so we can guarantee the
|
||||
// stylesheet is not modified.
|
||||
MOZ_ASSERT(!sheet->HasForcedUniqueInner());
|
||||
|
||||
// We need to check the parsing mode manually because the XUL cache only
|
||||
// keys off the URI. But we should fix that!
|
||||
if (sheet->ParsingMode() == aKey.ParsingMode()) {
|
||||
aLoader.DidHitCompleteSheetCache(aKey, nullptr);
|
||||
return {CloneSheet(*sheet), SheetState::Complete};
|
||||
}
|
||||
|
||||
LOG((" Not cloning due to mismatched parsing mode"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now complete sheets.
|
||||
if (auto lookup = mCompleteSheets.Lookup(aKey)) {
|
||||
const CompleteSheet& completeSheet = lookup.Data();
|
||||
|
@ -445,34 +468,50 @@ void SharedStyleSheetCache::InsertIntoCompleteCacheIfNeeded(
|
|||
// both SizeOfIncludingThis and nsXULPrototypeCache::CollectMemoryReports.
|
||||
RefPtr<StyleSheet> sheet = CloneSheet(*aData.mSheet);
|
||||
|
||||
LOG((" Putting style sheet in shared cache: %s",
|
||||
aData.mURI->GetSpecOrDefault().get()));
|
||||
SheetLoadDataHashKey key(aData);
|
||||
MOZ_ASSERT(sheet->IsComplete(), "Should only be caching complete sheets");
|
||||
if (dom::IsChromeURI(aData.mURI)) {
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (cache && cache->IsEnabled()) {
|
||||
if (!cache->GetStyleSheet(aData.mURI)) {
|
||||
LOG((" Putting sheet in XUL prototype cache"));
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
|
||||
// NOTE: If we stop cloning sheets before insertion, we need to change
|
||||
// nsXULPrototypeCache::CollectMemoryReports() to stop using
|
||||
// SizeOfIncludingThis() because it will no longer own the sheets.
|
||||
cache->PutStyleSheet(std::move(sheet));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG((" Putting style sheet in shared cache: %s",
|
||||
aData.mURI->GetSpecOrDefault().get()));
|
||||
SheetLoadDataHashKey key(aData);
|
||||
MOZ_ASSERT(sheet->IsComplete(), "Should only be caching complete sheets");
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
for (const auto& entry : mCompleteSheets) {
|
||||
if (!key.KeyEquals(entry.GetKey())) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(entry.GetData().mSheet != sheet,
|
||||
"Same sheet, different keys?");
|
||||
} else {
|
||||
MOZ_ASSERT(
|
||||
entry.GetData().Expired() || aData.mLoader->ShouldBypassCache(),
|
||||
"Overriding existing complete entry?");
|
||||
for (const auto& entry : mCompleteSheets) {
|
||||
if (!key.KeyEquals(entry.GetKey())) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(entry.GetData().mSheet != sheet,
|
||||
"Same sheet, different keys?");
|
||||
} else {
|
||||
MOZ_ASSERT(
|
||||
entry.GetData().Expired() || aData.mLoader->ShouldBypassCache(),
|
||||
"Overriding existing complete entry?");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UniquePtr<StyleUseCounters> counters;
|
||||
if (aData.mUseCounters) {
|
||||
// TODO(emilio): Servo_UseCounters_Clone() or something?
|
||||
counters = Servo_UseCounters_Create().Consume();
|
||||
Servo_UseCounters_Merge(counters.get(), aData.mUseCounters.get());
|
||||
}
|
||||
UniquePtr<StyleUseCounters> counters;
|
||||
if (aData.mUseCounters) {
|
||||
// TODO(emilio): Servo_UseCounters_Clone() or something?
|
||||
counters = Servo_UseCounters_Create().Consume();
|
||||
Servo_UseCounters_Merge(counters.get(), aData.mUseCounters.get());
|
||||
}
|
||||
|
||||
mCompleteSheets.InsertOrUpdate(
|
||||
key, CompleteSheet{aData.mExpirationTime, std::move(counters),
|
||||
std::move(sheet)});
|
||||
mCompleteSheets.InsertOrUpdate(
|
||||
key, CompleteSheet{aData.mExpirationTime, std::move(counters),
|
||||
std::move(sheet)});
|
||||
}
|
||||
}
|
||||
|
||||
void SharedStyleSheetCache::StartDeferredLoadsForLoader(
|
||||
|
|
|
@ -115,8 +115,19 @@ StreamLoader::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
|
|||
}
|
||||
} // run destructor for `bytes`
|
||||
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(
|
||||
aRequest, mSheetLoadData->mURI);
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(aRequest);
|
||||
|
||||
// data: URIs are safe to cache across documents under any circumstance, so we
|
||||
// special-case them here even though the channel itself doesn't have any
|
||||
// caching policy.
|
||||
//
|
||||
// TODO(emilio): Figure out which other schemes that don't have caching
|
||||
// policies are safe to cache. Blobs should be...
|
||||
if (mSheetLoadData->mURI->SchemeIs("data")) {
|
||||
MOZ_ASSERT(!info.mExpirationTime);
|
||||
MOZ_ASSERT(!info.mMustRevalidate);
|
||||
info.mExpirationTime = Some(0); // 0 means "doesn't expire".
|
||||
}
|
||||
|
||||
// For now, we never cache entries that we have to revalidate, or whose
|
||||
// channel don't support caching.
|
||||
|
|
|
@ -1036,8 +1036,7 @@ var BrowserTestUtils = {
|
|||
* @returns {Promise} Resolves with the new window once it is loaded.
|
||||
*/
|
||||
async openNewWindowWithFlushedXULCacheForMozSupports(options) {
|
||||
ChromeUtils.clearStyleSheetCache();
|
||||
|
||||
//
|
||||
Services.obs.notifyObservers(null, "chrome-flush-caches");
|
||||
await TestUtils.waitForTick();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче