зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1447828 part 2 - Remove StyleBackendType uses from nsXULPrototypeCache. r=emilio
MozReview-Commit-ID: 1tYFBTk9BqF --HG-- extra : rebase_source : 72c783c84ff36fddd6d49e79e7912f42bb0c11a8 extra : source : 4972e279ef76127e4898874478fcbd75c9631d76
This commit is contained in:
Родитель
0401ef821e
Коммит
d9cb92544e
|
@ -1036,13 +1036,11 @@ nsBindingManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||||
n += mDocumentTable->ShallowSizeOfIncludingThis(aMallocSizeOf);
|
n += mDocumentTable->ShallowSizeOfIncludingThis(aMallocSizeOf);
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||||
StyleBackendType backendType = mDocument->GetStyleBackendType();
|
|
||||||
#endif
|
#endif
|
||||||
for (auto iter = mDocumentTable->Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDocumentTable->Iter(); !iter.Done(); iter.Next()) {
|
||||||
nsXBLDocumentInfo* docInfo = iter.UserData();
|
nsXBLDocumentInfo* docInfo = iter.UserData();
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
nsXBLDocumentInfo* cachedInfo =
|
nsXBLDocumentInfo* cachedInfo = cache->GetXBLDocumentInfo(iter.Key());
|
||||||
cache->GetXBLDocumentInfo(iter.Key(), backendType);
|
|
||||||
if (cachedInfo == docInfo) {
|
if (cachedInfo == docInfo) {
|
||||||
// If this binding has been cached, skip it since it can be
|
// If this binding has been cached, skip it since it can be
|
||||||
// reused by other documents.
|
// reused by other documents.
|
||||||
|
|
|
@ -969,16 +969,9 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||||
bool useXULCache = cache && cache->IsEnabled();
|
bool useXULCache = cache && cache->IsEnabled();
|
||||||
|
|
||||||
if (!info && useXULCache) {
|
if (!info && useXULCache) {
|
||||||
// Assume Gecko style backend for the XBL document without a bound
|
|
||||||
// document. The only case is loading platformHTMLBindings.xml which
|
|
||||||
// doesn't have any style sheets or style attributes.
|
|
||||||
StyleBackendType styleBackend
|
|
||||||
= aBoundDocument ? aBoundDocument->GetStyleBackendType()
|
|
||||||
: StyleBackendType::Gecko;
|
|
||||||
|
|
||||||
// This cache crosses the entire product, so that any XBL bindings that are
|
// This cache crosses the entire product, so that any XBL bindings that are
|
||||||
// part of chrome will be reused across all XUL documents.
|
// part of chrome will be reused across all XUL documents.
|
||||||
info = cache->GetXBLDocumentInfo(documentURI, styleBackend);
|
info = cache->GetXBLDocumentInfo(documentURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useStartupCache = useXULCache && IsChromeOrResourceURI(documentURI);
|
bool useStartupCache = useXULCache && IsChromeOrResourceURI(documentURI);
|
||||||
|
@ -1042,12 +1035,6 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||||
bindingManager->PutXBLDocumentInfo(info);
|
bindingManager->PutXBLDocumentInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!aBoundDocument || !info ||
|
|
||||||
aBoundDocument->GetStyleBackendType() ==
|
|
||||||
info->GetDocument()->GetStyleBackendType(),
|
|
||||||
"Style backend type mismatched between the bound document and "
|
|
||||||
"the XBL document loaded.");
|
|
||||||
|
|
||||||
info.forget(aResult);
|
info.forget(aResult);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -192,22 +192,16 @@ nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument)
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::StyleSheet*
|
mozilla::StyleSheet*
|
||||||
nsXULPrototypeCache::GetStyleSheet(nsIURI* aURI,
|
nsXULPrototypeCache::GetStyleSheet(nsIURI* aURI)
|
||||||
StyleBackendType aType)
|
|
||||||
{
|
{
|
||||||
StyleSheetTable& table = StyleSheetTableFor(aType);
|
return mStyleSheetTable.GetWeak(aURI);
|
||||||
return table.GetWeak(aURI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULPrototypeCache::PutStyleSheet(StyleSheet* aStyleSheet,
|
nsXULPrototypeCache::PutStyleSheet(StyleSheet* aStyleSheet)
|
||||||
StyleBackendType aType)
|
|
||||||
{
|
{
|
||||||
nsIURI* uri = aStyleSheet->GetSheetURI();
|
nsIURI* uri = aStyleSheet->GetSheetURI();
|
||||||
|
mStyleSheetTable.Put(uri, aStyleSheet);
|
||||||
StyleSheetTable& table = StyleSheetTableFor(aType);
|
|
||||||
table.Put(uri, aStyleSheet);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,24 +234,18 @@ nsXULPrototypeCache::PutScript(nsIURI* aURI,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXBLDocumentInfo*
|
nsXBLDocumentInfo*
|
||||||
nsXULPrototypeCache::GetXBLDocumentInfo(nsIURI* aURL,
|
nsXULPrototypeCache::GetXBLDocumentInfo(nsIURI* aURL)
|
||||||
StyleBackendType aType)
|
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aType != StyleBackendType::None,
|
return mXBLDocTable.GetWeak(aURL);
|
||||||
"Please use either gecko or servo when looking up for the cache!");
|
|
||||||
return XBLDocTableFor(aType).GetWeak(aURL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
|
nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
|
||||||
{
|
{
|
||||||
nsIURI* uri = aDocumentInfo->DocumentURI();
|
nsIURI* uri = aDocumentInfo->DocumentURI();
|
||||||
XBLDocTable& table =
|
nsXBLDocumentInfo* info = mXBLDocTable.GetWeak(uri);
|
||||||
XBLDocTableFor(aDocumentInfo->GetDocument()->GetStyleBackendType());
|
|
||||||
|
|
||||||
nsXBLDocumentInfo* info = table.GetWeak(uri);
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
table.Put(uri, aDocumentInfo);
|
mXBLDocTable.Put(uri, aDocumentInfo);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -265,36 +253,29 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
|
||||||
void
|
void
|
||||||
nsXULPrototypeCache::FlushSkinFiles()
|
nsXULPrototypeCache::FlushSkinFiles()
|
||||||
{
|
{
|
||||||
StyleBackendType tableTypes[] = { StyleBackendType::Gecko,
|
// Flush out skin XBL files from the cache.
|
||||||
StyleBackendType::Servo };
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
nsAutoCString str;
|
||||||
for (auto tableType : tableTypes) {
|
iter.Key()->GetPathQueryRef(str);
|
||||||
// Flush out skin XBL files from the cache.
|
if (strncmp(str.get(), "/skin", 5) == 0) {
|
||||||
XBLDocTable& xblDocTable = XBLDocTableFor(tableType);
|
iter.Remove();
|
||||||
for (auto iter = xblDocTable.Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
nsAutoCString str;
|
|
||||||
iter.Key()->GetPathQueryRef(str);
|
|
||||||
if (strncmp(str.get(), "/skin", 5) == 0) {
|
|
||||||
iter.Remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now flush out our skin stylesheets from the cache.
|
// Now flush out our skin stylesheets from the cache.
|
||||||
StyleSheetTable& table = StyleSheetTableFor(tableType);
|
for (auto iter = mStyleSheetTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
for (auto iter = table.Iter(); !iter.Done(); iter.Next()) {
|
nsAutoCString str;
|
||||||
nsAutoCString str;
|
iter.Data()->GetSheetURI()->GetPathQueryRef(str);
|
||||||
iter.Data()->GetSheetURI()->GetPathQueryRef(str);
|
if (strncmp(str.get(), "/skin", 5) == 0) {
|
||||||
if (strncmp(str.get(), "/skin", 5) == 0) {
|
iter.Remove();
|
||||||
iter.Remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate over all the remaining XBL and make sure cached
|
// Iterate over all the remaining XBL and make sure cached
|
||||||
// scoped skin stylesheets are flushed and refetched by the
|
// scoped skin stylesheets are flushed and refetched by the
|
||||||
// prototype bindings.
|
// prototype bindings.
|
||||||
for (auto iter = xblDocTable.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
iter.Data()->FlushSkinStylesheets();
|
iter.Data()->FlushSkinStylesheets();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,10 +290,8 @@ nsXULPrototypeCache::Flush()
|
||||||
{
|
{
|
||||||
mPrototypeTable.Clear();
|
mPrototypeTable.Clear();
|
||||||
mScriptTable.Clear();
|
mScriptTable.Clear();
|
||||||
mGeckoStyleSheetTable.Clear();
|
mStyleSheetTable.Clear();
|
||||||
mServoStyleSheetTable.Clear();
|
mXBLDocTable.Clear();
|
||||||
mGeckoXBLDocTable.Clear();
|
|
||||||
mServoXBLDocTable.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -611,14 +590,8 @@ nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
|
||||||
void
|
void
|
||||||
nsXULPrototypeCache::MarkInCCGeneration(uint32_t aGeneration)
|
nsXULPrototypeCache::MarkInCCGeneration(uint32_t aGeneration)
|
||||||
{
|
{
|
||||||
StyleBackendType tableTypes[] = { StyleBackendType::Gecko,
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
StyleBackendType::Servo };
|
iter.Data()->MarkInCCGeneration(aGeneration);
|
||||||
|
|
||||||
for (auto tableType : tableTypes) {
|
|
||||||
XBLDocTable& xblDocTable = XBLDocTableFor(tableType);
|
|
||||||
for (auto iter = xblDocTable.Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
iter.Data()->MarkInCCGeneration(aGeneration);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (auto iter = mPrototypeTable.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mPrototypeTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
iter.Data()->MarkInCCGeneration(aGeneration);
|
iter.Data()->MarkInCCGeneration(aGeneration);
|
||||||
|
@ -679,30 +652,23 @@ nsXULPrototypeCache::CollectMemoryReports(
|
||||||
// TODO Report content in mPrototypeTable?
|
// TODO Report content in mPrototypeTable?
|
||||||
|
|
||||||
other += sInstance->
|
other += sInstance->
|
||||||
mGeckoStyleSheetTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
mStyleSheetTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||||
// TODO Report content inside mGeckoStyleSheetTable?
|
// TODO Report content inside mStyleSheetTable?
|
||||||
other += sInstance->
|
|
||||||
mServoStyleSheetTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
|
||||||
// TODO Report content inside mServoStyleSheetTable?
|
|
||||||
|
|
||||||
other += sInstance->
|
other += sInstance->
|
||||||
mScriptTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
mScriptTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||||
// TODO Report content inside mScriptTable?
|
// TODO Report content inside mScriptTable?
|
||||||
|
|
||||||
auto reportXBLDocTable =
|
other += sInstance->mXBLDocTable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||||
[&](const nsACString& prefix, const XBLDocTable& table) {
|
for (auto iter = sInstance->mXBLDocTable.ConstIter();
|
||||||
other += table.ShallowSizeOfExcludingThis(mallocSizeOf);
|
!iter.Done(); iter.Next()) {
|
||||||
for (auto iter = table.ConstIter(); !iter.Done(); iter.Next()) {
|
nsAutoCString path;
|
||||||
nsAutoCString path(prefix);
|
path += "xbl-docs/(";
|
||||||
path += "-xbl-docs/(";
|
AppendURIForMemoryReport(iter.Key(), path);
|
||||||
AppendURIForMemoryReport(iter.Key(), path);
|
path += ")";
|
||||||
path += ")";
|
size_t size = iter.UserData()->SizeOfIncludingThis(mallocSizeOf);
|
||||||
size_t size = iter.UserData()->SizeOfIncludingThis(mallocSizeOf);
|
REPORT_SIZE(path, size, "Memory used by this XBL document.");
|
||||||
REPORT_SIZE(path, size, "Memory used by this XBL document.");
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
reportXBLDocTable(NS_LITERAL_CSTRING("gecko"), sInstance->mGeckoXBLDocTable);
|
|
||||||
reportXBLDocTable(NS_LITERAL_CSTRING("servo"), sInstance->mServoXBLDocTable);
|
|
||||||
|
|
||||||
other += sInstance->
|
other += sInstance->
|
||||||
mStartupCacheURITable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
mStartupCacheURITable.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||||
|
|
|
@ -66,8 +66,7 @@ public:
|
||||||
JSScript* GetScript(nsIURI* aURI);
|
JSScript* GetScript(nsIURI* aURI);
|
||||||
nsresult PutScript(nsIURI* aURI, JS::Handle<JSScript*> aScriptObject);
|
nsresult PutScript(nsIURI* aURI, JS::Handle<JSScript*> aScriptObject);
|
||||||
|
|
||||||
nsXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURL,
|
nsXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURL);
|
||||||
mozilla::StyleBackendType aType);
|
|
||||||
|
|
||||||
nsresult PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo);
|
nsresult PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo);
|
||||||
|
|
||||||
|
@ -75,15 +74,13 @@ public:
|
||||||
* Get a style sheet by URI. If the style sheet is not in the cache,
|
* Get a style sheet by URI. If the style sheet is not in the cache,
|
||||||
* returns nullptr.
|
* returns nullptr.
|
||||||
*/
|
*/
|
||||||
mozilla::StyleSheet* GetStyleSheet(nsIURI* aURI,
|
mozilla::StyleSheet* GetStyleSheet(nsIURI* aURI);
|
||||||
mozilla::StyleBackendType aType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a style sheet in the cache. The key, style sheet's URI is obtained
|
* Store a style sheet in the cache. The key, style sheet's URI is obtained
|
||||||
* from the style sheet itself.
|
* from the style sheet itself.
|
||||||
*/
|
*/
|
||||||
nsresult PutStyleSheet(mozilla::StyleSheet* aStyleSheet,
|
nsresult PutStyleSheet(mozilla::StyleSheet* aStyleSheet);
|
||||||
mozilla::StyleBackendType aType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the XUL prototype document to a cache file. The proto must be
|
* Write the XUL prototype document to a cache file. The proto must be
|
||||||
|
@ -130,22 +127,10 @@ protected:
|
||||||
using StyleSheetTable = nsRefPtrHashtable<nsURIHashKey, mozilla::StyleSheet>;
|
using StyleSheetTable = nsRefPtrHashtable<nsURIHashKey, mozilla::StyleSheet>;
|
||||||
using XBLDocTable = nsRefPtrHashtable<nsURIHashKey, nsXBLDocumentInfo>;
|
using XBLDocTable = nsRefPtrHashtable<nsURIHashKey, nsXBLDocumentInfo>;
|
||||||
|
|
||||||
StyleSheetTable& StyleSheetTableFor(mozilla::StyleBackendType aType) {
|
|
||||||
return aType == mozilla::StyleBackendType::Gecko ? mGeckoStyleSheetTable
|
|
||||||
: mServoStyleSheetTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
XBLDocTable& XBLDocTableFor(mozilla::StyleBackendType aType) {
|
|
||||||
return aType == mozilla::StyleBackendType::Gecko ? mGeckoXBLDocTable
|
|
||||||
: mServoXBLDocTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtrHashtable<nsURIHashKey,nsXULPrototypeDocument> mPrototypeTable; // owns the prototypes
|
nsRefPtrHashtable<nsURIHashKey,nsXULPrototypeDocument> mPrototypeTable; // owns the prototypes
|
||||||
StyleSheetTable mGeckoStyleSheetTable;
|
StyleSheetTable mStyleSheetTable;
|
||||||
StyleSheetTable mServoStyleSheetTable;
|
|
||||||
nsJSThingHashtable<nsURIHashKey, JSScript*> mScriptTable;
|
nsJSThingHashtable<nsURIHashKey, JSScript*> mScriptTable;
|
||||||
XBLDocTable mGeckoXBLDocTable;
|
XBLDocTable mXBLDocTable;
|
||||||
XBLDocTable mServoXBLDocTable;
|
|
||||||
|
|
||||||
// URIs already written to the startup cache, to prevent double-caching.
|
// URIs already written to the startup cache, to prevent double-caching.
|
||||||
nsTHashtable<nsURIHashKey> mStartupCacheURITable;
|
nsTHashtable<nsURIHashKey> mStartupCacheURITable;
|
||||||
|
|
|
@ -922,7 +922,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||||
if (IsChromeURI(aURI)) {
|
if (IsChromeURI(aURI)) {
|
||||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||||
if (cache && cache->IsEnabled()) {
|
if (cache && cache->IsEnabled()) {
|
||||||
sheet = cache->GetStyleSheet(aURI, GetStyleBackendType());
|
sheet = cache->GetStyleSheet(aURI);
|
||||||
LOG((" From XUL cache: %p", sheet.get()));
|
LOG((" From XUL cache: %p", sheet.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1802,11 +1802,11 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, LoadDataArray& aDatasToNotify)
|
||||||
if (IsChromeURI(aLoadData->mURI)) {
|
if (IsChromeURI(aLoadData->mURI)) {
|
||||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||||
if (cache && cache->IsEnabled()) {
|
if (cache && cache->IsEnabled()) {
|
||||||
if (!cache->GetStyleSheet(aLoadData->mURI, GetStyleBackendType())) {
|
if (!cache->GetStyleSheet(aLoadData->mURI)) {
|
||||||
LOG((" Putting sheet in XUL prototype cache"));
|
LOG((" Putting sheet in XUL prototype cache"));
|
||||||
NS_ASSERTION(sheet->IsComplete(),
|
NS_ASSERTION(sheet->IsComplete(),
|
||||||
"Should only be caching complete sheets");
|
"Should only be caching complete sheets");
|
||||||
cache->PutStyleSheet(sheet, GetStyleBackendType());
|
cache->PutStyleSheet(sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче