Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: Source/WebCore/css/StyleResolver.cpp

Issue 11412176: Merge 135082 - REGRESSION(r129644): User StyleSheet not applying (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/css/StyleResolver.h ('k') | Source/WebCore/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/css/StyleResolver.cpp
===================================================================
--- Source/WebCore/css/StyleResolver.cpp (revision 135771)
+++ Source/WebCore/css/StyleResolver.cpp (working copy)
@@ -312,12 +312,11 @@
resetAuthorStyle();
DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection();
- // FIXME: This sucks! The user sheet is reparsed every time!
OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, this);
- addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->pageGroupUserSheets(), *tempUserStyle);
- addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->documentUserSheets(), *tempUserStyle);
+ collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheets(), *tempUserStyle);
+ collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheets(), *tempUserStyle);
if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
m_userStyle = tempUserStyle.release();
@@ -333,18 +332,11 @@
appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets());
}
-void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle)
+void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets, RuleSet& userStyle)
{
- if (!userSheets)
- return;
-
- unsigned length = userSheets->size();
- for (unsigned i = 0; i < length; i++) {
- StyleSheetContents* sheet = userSheets->at(i)->contents();
- if (sheet->isUserStyleSheet())
- userStyle.addRulesFromSheet(sheet, *m_medium, this);
- else
- m_authorStyle->addRulesFromSheet(sheet, *m_medium, this);
+ for (unsigned i = 0; i < userSheets.size(); ++i) {
+ ASSERT(userSheets[i]->contents()->isUserStyleSheet());
+ userStyle.addRulesFromSheet(userSheets[i]->contents(), *m_medium, this);
}
}
@@ -2577,27 +2569,18 @@
collectCSSOMWrappers(wrapperMap, styleSheetWrapper.get());
}
-static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, DocumentStyleSheetCollection* styleSheetCollection)
+static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, const Vector<RefPtr<CSSStyleSheet> >& sheets)
{
- const Vector<RefPtr<CSSStyleSheet> >& styleSheets = styleSheetCollection->activeAuthorStyleSheets();
- for (unsigned i = 0; i < styleSheets.size(); ++i)
- collectCSSOMWrappers(wrapperMap, styleSheets[i].get());
+ for (unsigned i = 0; i < sheets.size(); ++i)
+ collectCSSOMWrappers(wrapperMap, sheets[i].get());
+}
+static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, DocumentStyleSheetCollection* styleSheetCollection)
+{
+ collectCSSOMWrappers(wrapperMap, styleSheetCollection->activeAuthorStyleSheets());
collectCSSOMWrappers(wrapperMap, styleSheetCollection->pageUserSheet());
- {
- const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets = styleSheetCollection->pageGroupUserSheets();
- if (pageGroupUserSheets) {
- for (size_t i = 0, size = pageGroupUserSheets->size(); i < size; ++i)
- collectCSSOMWrappers(wrapperMap, pageGroupUserSheets->at(i).get());
- }
- }
- {
- const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets = styleSheetCollection->documentUserSheets();
- if (documentUserSheets) {
- for (size_t i = 0, size = documentUserSheets->size(); i < size; ++i)
- collectCSSOMWrappers(wrapperMap, documentUserSheets->at(i).get());
- }
- }
+ collectCSSOMWrappers(wrapperMap, styleSheetCollection->injectedUserStyleSheets());
+ collectCSSOMWrappers(wrapperMap, styleSheetCollection->documentUserStyleSheets());
}
CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule)
« no previous file with comments | « Source/WebCore/css/StyleResolver.h ('k') | Source/WebCore/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698