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

Side by Side Diff: Source/WebCore/dom/DocumentStyleSheetCollection.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 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 unified diff | Download patch
« no previous file with comments | « Source/WebCore/dom/DocumentStyleSheetCollection.h ('k') | Source/WebCore/page/PageGroup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include <wtf/MemoryInstrumentationListHashSet.h> 51 #include <wtf/MemoryInstrumentationListHashSet.h>
52 #include <wtf/MemoryInstrumentationVector.h> 52 #include <wtf/MemoryInstrumentationVector.h>
53 53
54 namespace WebCore { 54 namespace WebCore {
55 55
56 using namespace HTMLNames; 56 using namespace HTMLNames;
57 57
58 DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document* document) 58 DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document* document)
59 : m_document(document) 59 : m_document(document)
60 , m_pendingStylesheets(0) 60 , m_pendingStylesheets(0)
61 , m_pageGroupUserSheetCacheValid(false) 61 , m_injectedStyleSheetCacheValid(false)
62 , m_hadActiveLoadingStylesheet(false) 62 , m_hadActiveLoadingStylesheet(false)
63 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false) 63 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false)
64 , m_usesSiblingRules(false) 64 , m_usesSiblingRules(false)
65 , m_usesSiblingRulesOverride(false) 65 , m_usesSiblingRulesOverride(false)
66 , m_usesFirstLineRules(false) 66 , m_usesFirstLineRules(false)
67 , m_usesFirstLetterRules(false) 67 , m_usesFirstLetterRules(false)
68 , m_usesBeforeAfterRules(false) 68 , m_usesBeforeAfterRules(false)
69 , m_usesBeforeAfterRulesOverride(false) 69 , m_usesBeforeAfterRulesOverride(false)
70 , m_usesRemUnits(false) 70 , m_usesRemUnits(false)
71 { 71 {
72 } 72 }
73 73
74 DocumentStyleSheetCollection::~DocumentStyleSheetCollection() 74 DocumentStyleSheetCollection::~DocumentStyleSheetCollection()
75 { 75 {
76 if (m_pageUserSheet) 76 if (m_pageUserSheet)
77 m_pageUserSheet->clearOwnerNode(); 77 m_pageUserSheet->clearOwnerNode();
78 if (m_pageGroupUserSheets) { 78 for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i)
79 for (size_t i = 0; i < m_pageGroupUserSheets->size(); ++i) 79 m_injectedUserStyleSheets[i]->clearOwnerNode();
80 (*m_pageGroupUserSheets)[i]->clearOwnerNode(); 80 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i)
81 } 81 m_injectedAuthorStyleSheets[i]->clearOwnerNode();
82 if (m_userSheets) { 82 for (unsigned i = 0; i < m_userStyleSheets.size(); ++i)
83 for (size_t i = 0; i < m_userSheets->size(); ++i) 83 m_userStyleSheets[i]->clearOwnerNode();
84 (*m_userSheets)[i]->clearOwnerNode();
85 }
86 } 84 }
87 85
88 void DocumentStyleSheetCollection::combineCSSFeatureFlags() 86 void DocumentStyleSheetCollection::combineCSSFeatureFlags()
89 { 87 {
90 // Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/afte r). 88 // Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/afte r).
91 StyleResolver* styleResolver = m_document->styleResolver(); 89 StyleResolver* styleResolver = m_document->styleResolver();
92 m_usesSiblingRules = m_usesSiblingRules || styleResolver->usesSiblingRules() ; 90 m_usesSiblingRules = m_usesSiblingRules || styleResolver->usesSiblingRules() ;
93 m_usesFirstLineRules = m_usesFirstLineRules || styleResolver->usesFirstLineR ules(); 91 m_usesFirstLineRules = m_usesFirstLineRules || styleResolver->usesFirstLineR ules();
94 m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver->usesBefore AfterRules(); 92 m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver->usesBefore AfterRules();
95 } 93 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 128 }
131 } 129 }
132 130
133 void DocumentStyleSheetCollection::updatePageUserSheet() 131 void DocumentStyleSheetCollection::updatePageUserSheet()
134 { 132 {
135 clearPageUserSheet(); 133 clearPageUserSheet();
136 if (pageUserSheet()) 134 if (pageUserSheet())
137 m_document->styleResolverChanged(RecalcStyleImmediately); 135 m_document->styleResolverChanged(RecalcStyleImmediately);
138 } 136 }
139 137
140 const Vector<RefPtr<CSSStyleSheet> >* DocumentStyleSheetCollection::pageGroupUse rSheets() const 138 const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedUser StyleSheets() const
141 { 139 {
142 if (m_pageGroupUserSheetCacheValid) 140 updateInjectedStyleSheetCache();
143 return m_pageGroupUserSheets.get(); 141 return m_injectedUserStyleSheets;
144 142 }
145 m_pageGroupUserSheetCacheValid = true; 143
146 144 const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedAuth orStyleSheets() const
145 {
146 updateInjectedStyleSheetCache();
147 return m_injectedAuthorStyleSheets;
148 }
149
150 void DocumentStyleSheetCollection::updateInjectedStyleSheetCache() const
151 {
152 if (m_injectedStyleSheetCacheValid)
153 return;
154 m_injectedStyleSheetCacheValid = true;
155 m_injectedUserStyleSheets.clear();
156 m_injectedAuthorStyleSheets.clear();
157
147 Page* owningPage = m_document->page(); 158 Page* owningPage = m_document->page();
148 if (!owningPage) 159 if (!owningPage)
149 return 0; 160 return;
150 161
151 const PageGroup& pageGroup = owningPage->group(); 162 const PageGroup& pageGroup = owningPage->group();
152 const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets(); 163 const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets();
153 if (!sheetsMap) 164 if (!sheetsMap)
154 return 0; 165 return;
155 166
156 UserStyleSheetMap::const_iterator end = sheetsMap->end(); 167 UserStyleSheetMap::const_iterator end = sheetsMap->end();
157 for (UserStyleSheetMap::const_iterator it = sheetsMap->begin(); it != end; + +it) { 168 for (UserStyleSheetMap::const_iterator it = sheetsMap->begin(); it != end; + +it) {
158 const UserStyleSheetVector* sheets = it->value.get(); 169 const UserStyleSheetVector* sheets = it->value.get();
159 for (unsigned i = 0; i < sheets->size(); ++i) { 170 for (unsigned i = 0; i < sheets->size(); ++i) {
160 const UserStyleSheet* sheet = sheets->at(i).get(); 171 const UserStyleSheet* sheet = sheets->at(i).get();
161 if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document->o wnerElement()) 172 if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document->o wnerElement())
162 continue; 173 continue;
163 if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet ->whitelist(), sheet->blacklist())) 174 if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet ->whitelist(), sheet->blacklist()))
164 continue; 175 continue;
165 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const _cast<Document*>(m_document), sheet->url()); 176 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const _cast<Document*>(m_document), sheet->url());
166 if (!m_pageGroupUserSheets) 177 bool isUserStyleSheet = sheet->level() == UserStyleUserLevel;
167 m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet > >); 178 if (isUserStyleSheet)
168 m_pageGroupUserSheets->append(groupSheet); 179 m_injectedUserStyleSheets.append(groupSheet);
169 groupSheet->contents()->setIsUserStyleSheet(sheet->level() == UserSt yleUserLevel); 180 else
181 m_injectedAuthorStyleSheets.append(groupSheet);
182 groupSheet->contents()->setIsUserStyleSheet(isUserStyleSheet);
170 groupSheet->contents()->parseString(sheet->source()); 183 groupSheet->contents()->parseString(sheet->source());
171 } 184 }
172 } 185 }
173
174 return m_pageGroupUserSheets.get();
175 } 186 }
176 187
177 void DocumentStyleSheetCollection::clearPageGroupUserSheets() 188 void DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache()
178 { 189 {
179 m_pageGroupUserSheetCacheValid = false; 190 m_injectedStyleSheetCacheValid = false;
180 if (m_pageGroupUserSheets && m_pageGroupUserSheets->size()) { 191 m_document->styleResolverChanged(DeferRecalcStyle);
181 m_pageGroupUserSheets->clear();
182 m_document->styleResolverChanged(DeferRecalcStyle);
183 }
184 }
185
186 void DocumentStyleSheetCollection::updatePageGroupUserSheets()
187 {
188 clearPageGroupUserSheets();
189 if (pageGroupUserSheets() && pageGroupUserSheets()->size())
190 m_document->styleResolverChanged(RecalcStyleImmediately);
191 } 192 }
192 193
193 void DocumentStyleSheetCollection::addUserSheet(PassRefPtr<StyleSheetContents> u serSheet) 194 void DocumentStyleSheetCollection::addUserSheet(PassRefPtr<StyleSheetContents> u serSheet)
194 { 195 {
195 if (!m_userSheets) 196 m_userStyleSheets.append(CSSStyleSheet::create(userSheet, m_document));
196 m_userSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
197 m_userSheets->append(CSSStyleSheet::create(userSheet, m_document));
198 m_document->styleResolverChanged(RecalcStyleImmediately); 197 m_document->styleResolverChanged(RecalcStyleImmediately);
199 } 198 }
200 199
201 // This method is called whenever a top-level stylesheet has finished loading. 200 // This method is called whenever a top-level stylesheet has finished loading.
202 void DocumentStyleSheetCollection::removePendingSheet(RemovePendingSheetNotifica tionType notification) 201 void DocumentStyleSheetCollection::removePendingSheet(RemovePendingSheetNotifica tionType notification)
203 { 202 {
204 // Make sure we knew this sheet was pending, and that our count isn't out of sync. 203 // Make sure we knew this sheet was pending, and that our count isn't out of sync.
205 ASSERT(m_pendingStylesheets > 0); 204 ASSERT(m_pendingStylesheets > 0);
206 205
207 m_pendingStylesheets--; 206 m_pendingStylesheets--;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 return false; 447 return false;
449 448
450 } 449 }
451 if (!m_document->renderer() || !m_document->attached()) 450 if (!m_document->renderer() || !m_document->attached())
452 return false; 451 return false;
453 452
454 Vector<RefPtr<StyleSheet> > activeStyleSheets; 453 Vector<RefPtr<StyleSheet> > activeStyleSheets;
455 collectActiveStyleSheets(activeStyleSheets); 454 collectActiveStyleSheets(activeStyleSheets);
456 455
457 Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets; 456 Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets;
457 activeCSSStyleSheets.append(injectedAuthorStyleSheets());
458 collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_docum ent); 458 collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_docum ent);
459 filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); 459 filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
460 460
461 StyleResolverUpdateType styleResolverUpdateType; 461 StyleResolverUpdateType styleResolverUpdateType;
462 bool requiresFullStyleRecalc; 462 bool requiresFullStyleRecalc;
463 analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdat eType, requiresFullStyleRecalc); 463 analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdat eType, requiresFullStyleRecalc);
464 464
465 if (styleResolverUpdateType == Reconstruct) 465 if (styleResolverUpdateType == Reconstruct)
466 m_document->clearStyleResolver(); 466 m_document->clearStyleResolver();
467 else { 467 else {
(...skipping 15 matching lines...) Expand all
483 483
484 m_document->notifySeamlessChildDocumentsOfStylesheetUpdate(); 484 m_document->notifySeamlessChildDocumentsOfStylesheetUpdate();
485 485
486 return requiresFullStyleRecalc; 486 return requiresFullStyleRecalc;
487 } 487 }
488 488
489 void DocumentStyleSheetCollection::reportMemoryUsage(MemoryObjectInfo* memoryObj ectInfo) const 489 void DocumentStyleSheetCollection::reportMemoryUsage(MemoryObjectInfo* memoryObj ectInfo) const
490 { 490 {
491 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 491 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
492 info.addMember(m_pageUserSheet); 492 info.addMember(m_pageUserSheet);
493 info.addMember(m_pageGroupUserSheets); 493 info.addMember(m_injectedUserStyleSheets);
494 info.addMember(m_userSheets); 494 info.addMember(m_injectedAuthorStyleSheets);
495 info.addMember(m_userStyleSheets);
495 info.addMember(m_activeAuthorStyleSheets); 496 info.addMember(m_activeAuthorStyleSheets);
496 info.addMember(m_styleSheetsForStyleSheetList); 497 info.addMember(m_styleSheetsForStyleSheetList);
497 info.addMember(m_styleSheetCandidateNodes); 498 info.addMember(m_styleSheetCandidateNodes);
498 info.addMember(m_preferredStylesheetSetName); 499 info.addMember(m_preferredStylesheetSetName);
499 info.addMember(m_selectedStylesheetSetName); 500 info.addMember(m_selectedStylesheetSetName);
500 } 501 }
501 502
502 } 503 }
OLDNEW
« no previous file with comments | « Source/WebCore/dom/DocumentStyleSheetCollection.h ('k') | Source/WebCore/page/PageGroup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698