Index: Source/WebCore/dom/DocumentStyleSheetCollection.cpp |
=================================================================== |
--- Source/WebCore/dom/DocumentStyleSheetCollection.cpp (revision 135771) |
+++ Source/WebCore/dom/DocumentStyleSheetCollection.cpp (working copy) |
@@ -58,7 +58,7 @@ |
DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document* document) |
: m_document(document) |
, m_pendingStylesheets(0) |
- , m_pageGroupUserSheetCacheValid(false) |
+ , m_injectedStyleSheetCacheValid(false) |
, m_hadActiveLoadingStylesheet(false) |
, m_needsUpdateActiveStylesheetsOnStyleRecalc(false) |
, m_usesSiblingRules(false) |
@@ -75,14 +75,12 @@ |
{ |
if (m_pageUserSheet) |
m_pageUserSheet->clearOwnerNode(); |
- if (m_pageGroupUserSheets) { |
- for (size_t i = 0; i < m_pageGroupUserSheets->size(); ++i) |
- (*m_pageGroupUserSheets)[i]->clearOwnerNode(); |
- } |
- if (m_userSheets) { |
- for (size_t i = 0; i < m_userSheets->size(); ++i) |
- (*m_userSheets)[i]->clearOwnerNode(); |
- } |
+ for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i) |
+ m_injectedUserStyleSheets[i]->clearOwnerNode(); |
+ for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
+ m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
+ for (unsigned i = 0; i < m_userStyleSheets.size(); ++i) |
+ m_userStyleSheets[i]->clearOwnerNode(); |
} |
void DocumentStyleSheetCollection::combineCSSFeatureFlags() |
@@ -137,21 +135,34 @@ |
m_document->styleResolverChanged(RecalcStyleImmediately); |
} |
-const Vector<RefPtr<CSSStyleSheet> >* DocumentStyleSheetCollection::pageGroupUserSheets() const |
+const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedUserStyleSheets() const |
{ |
- if (m_pageGroupUserSheetCacheValid) |
- return m_pageGroupUserSheets.get(); |
- |
- m_pageGroupUserSheetCacheValid = true; |
- |
+ updateInjectedStyleSheetCache(); |
+ return m_injectedUserStyleSheets; |
+} |
+ |
+const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedAuthorStyleSheets() const |
+{ |
+ updateInjectedStyleSheetCache(); |
+ return m_injectedAuthorStyleSheets; |
+} |
+ |
+void DocumentStyleSheetCollection::updateInjectedStyleSheetCache() const |
+{ |
+ if (m_injectedStyleSheetCacheValid) |
+ return; |
+ m_injectedStyleSheetCacheValid = true; |
+ m_injectedUserStyleSheets.clear(); |
+ m_injectedAuthorStyleSheets.clear(); |
+ |
Page* owningPage = m_document->page(); |
if (!owningPage) |
- return 0; |
+ return; |
const PageGroup& pageGroup = owningPage->group(); |
const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets(); |
if (!sheetsMap) |
- return 0; |
+ return; |
UserStyleSheetMap::const_iterator end = sheetsMap->end(); |
for (UserStyleSheetMap::const_iterator it = sheetsMap->begin(); it != end; ++it) { |
@@ -163,38 +174,26 @@ |
if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet->whitelist(), sheet->blacklist())) |
continue; |
RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(m_document), sheet->url()); |
- if (!m_pageGroupUserSheets) |
- m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >); |
- m_pageGroupUserSheets->append(groupSheet); |
- groupSheet->contents()->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel); |
+ bool isUserStyleSheet = sheet->level() == UserStyleUserLevel; |
+ if (isUserStyleSheet) |
+ m_injectedUserStyleSheets.append(groupSheet); |
+ else |
+ m_injectedAuthorStyleSheets.append(groupSheet); |
+ groupSheet->contents()->setIsUserStyleSheet(isUserStyleSheet); |
groupSheet->contents()->parseString(sheet->source()); |
} |
} |
- |
- return m_pageGroupUserSheets.get(); |
} |
-void DocumentStyleSheetCollection::clearPageGroupUserSheets() |
+void DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache() |
{ |
- m_pageGroupUserSheetCacheValid = false; |
- if (m_pageGroupUserSheets && m_pageGroupUserSheets->size()) { |
- m_pageGroupUserSheets->clear(); |
- m_document->styleResolverChanged(DeferRecalcStyle); |
- } |
+ m_injectedStyleSheetCacheValid = false; |
+ m_document->styleResolverChanged(DeferRecalcStyle); |
} |
-void DocumentStyleSheetCollection::updatePageGroupUserSheets() |
-{ |
- clearPageGroupUserSheets(); |
- if (pageGroupUserSheets() && pageGroupUserSheets()->size()) |
- m_document->styleResolverChanged(RecalcStyleImmediately); |
-} |
- |
void DocumentStyleSheetCollection::addUserSheet(PassRefPtr<StyleSheetContents> userSheet) |
{ |
- if (!m_userSheets) |
- m_userSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >); |
- m_userSheets->append(CSSStyleSheet::create(userSheet, m_document)); |
+ m_userStyleSheets.append(CSSStyleSheet::create(userSheet, m_document)); |
m_document->styleResolverChanged(RecalcStyleImmediately); |
} |
@@ -455,6 +454,7 @@ |
collectActiveStyleSheets(activeStyleSheets); |
Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets; |
+ activeCSSStyleSheets.append(injectedAuthorStyleSheets()); |
collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document); |
filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); |
@@ -490,8 +490,9 @@ |
{ |
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); |
info.addMember(m_pageUserSheet); |
- info.addMember(m_pageGroupUserSheets); |
- info.addMember(m_userSheets); |
+ info.addMember(m_injectedUserStyleSheets); |
+ info.addMember(m_injectedAuthorStyleSheets); |
+ info.addMember(m_userStyleSheets); |
info.addMember(m_activeAuthorStyleSheets); |
info.addMember(m_styleSheetsForStyleSheetList); |
info.addMember(m_styleSheetCandidateNodes); |