| OLD | NEW |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 { | 155 { |
| 156 if (treeScope == m_document) | 156 if (treeScope == m_document) |
| 157 return &m_documentStyleSheetCollection; | 157 return &m_documentStyleSheetCollection; |
| 158 | 158 |
| 159 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> >::iterator it = m
_styleSheetCollectionMap.find(&treeScope); | 159 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> >::iterator it = m
_styleSheetCollectionMap.find(&treeScope); |
| 160 if (it == m_styleSheetCollectionMap.end()) | 160 if (it == m_styleSheetCollectionMap.end()) |
| 161 return 0; | 161 return 0; |
| 162 return it->value.get(); | 162 return it->value.get(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 const Vector<RefPtr<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(Tre
eScope& treeScope) | 165 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleEngine::styleSheet
sForStyleSheetList(TreeScope& treeScope) |
| 166 { | 166 { |
| 167 if (treeScope == m_document) | 167 if (treeScope == m_document) |
| 168 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList(); | 168 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList(); |
| 169 | 169 |
| 170 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis
t(); | 170 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis
t(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::activeAuthorStyleSheets() con
st | 173 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& StyleEngine::activeA
uthorStyleSheets() const |
| 174 { | 174 { |
| 175 return m_documentStyleSheetCollection.activeAuthorStyleSheets(); | 175 return m_documentStyleSheetCollection.activeAuthorStyleSheets(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void StyleEngine::combineCSSFeatureFlags(const RuleFeatureSet& features) | 178 void StyleEngine::combineCSSFeatureFlags(const RuleFeatureSet& features) |
| 179 { | 179 { |
| 180 // 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). | 180 // 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). |
| 181 m_usesSiblingRules = m_usesSiblingRules || features.usesSiblingRules(); | 181 m_usesSiblingRules = m_usesSiblingRules || features.usesSiblingRules(); |
| 182 m_usesFirstLineRules = m_usesFirstLineRules || features.usesFirstLineRules()
; | 182 m_usesFirstLineRules = m_usesFirstLineRules || features.usesFirstLineRules()
; |
| 183 m_maxDirectAdjacentSelectors = max(m_maxDirectAdjacentSelectors, features.ma
xDirectAdjacentSelectors()); | 183 m_maxDirectAdjacentSelectors = max(m_maxDirectAdjacentSelectors, features.ma
xDirectAdjacentSelectors()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features) | 186 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features) |
| 187 { | 187 { |
| 188 m_usesSiblingRules = features.usesSiblingRules(); | 188 m_usesSiblingRules = features.usesSiblingRules(); |
| 189 m_usesFirstLineRules = features.usesFirstLineRules(); | 189 m_usesFirstLineRules = features.usesFirstLineRules(); |
| 190 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); | 190 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::injectedAuthorStyleSheets() c
onst | 193 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& StyleEngine::injecte
dAuthorStyleSheets() const |
| 194 { | 194 { |
| 195 updateInjectedStyleSheetCache(); | 195 updateInjectedStyleSheetCache(); |
| 196 return m_injectedAuthorStyleSheets; | 196 return m_injectedAuthorStyleSheets; |
| 197 } | 197 } |
| 198 | 198 |
| 199 void StyleEngine::updateInjectedStyleSheetCache() const | 199 void StyleEngine::updateInjectedStyleSheetCache() const |
| 200 { | 200 { |
| 201 if (m_injectedStyleSheetCacheValid) | 201 if (m_injectedStyleSheetCacheValid) |
| 202 return; | 202 return; |
| 203 m_injectedStyleSheetCacheValid = true; | 203 m_injectedStyleSheetCacheValid = true; |
| 204 m_injectedAuthorStyleSheets.clear(); | 204 m_injectedAuthorStyleSheets.clear(); |
| 205 | 205 |
| 206 Page* owningPage = m_document.page(); | 206 Page* owningPage = m_document.page(); |
| 207 if (!owningPage) | 207 if (!owningPage) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 const InjectedStyleSheetEntryVector& entries = InjectedStyleSheets::instance
().entries(); | 210 const InjectedStyleSheetEntryVector& entries = InjectedStyleSheets::instance
().entries(); |
| 211 for (unsigned i = 0; i < entries.size(); ++i) { | 211 for (unsigned i = 0; i < entries.size(); ++i) { |
| 212 const InjectedStyleSheetEntry* entry = entries[i].get(); | 212 const InjectedStyleSheetEntry* entry = entries[i].get(); |
| 213 if (entry->injectedFrames() == InjectStyleInTopFrameOnly && m_document.o
wnerElement()) | 213 if (entry->injectedFrames() == InjectStyleInTopFrameOnly && m_document.o
wnerElement()) |
| 214 continue; | 214 continue; |
| 215 if (!URLPatternMatcher::matchesPatterns(m_document.url(), entry->whiteli
st())) | 215 if (!URLPatternMatcher::matchesPatterns(m_document.url(), entry->whiteli
st())) |
| 216 continue; | 216 continue; |
| 217 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cas
t<Document*>(&m_document), KURL()); | 217 RefPtrWillBeRawPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInli
ne(const_cast<Document*>(&m_document), KURL()); |
| 218 m_injectedAuthorStyleSheets.append(groupSheet); | 218 m_injectedAuthorStyleSheets.append(groupSheet); |
| 219 groupSheet->contents()->parseString(entry->source()); | 219 groupSheet->contents()->parseString(entry->source()); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 void StyleEngine::invalidateInjectedStyleSheetCache() | 223 void StyleEngine::invalidateInjectedStyleSheetCache() |
| 224 { | 224 { |
| 225 m_injectedStyleSheetCacheValid = false; | 225 m_injectedStyleSheetCacheValid = false; |
| 226 markDocumentDirty(); | 226 markDocumentDirty(); |
| 227 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio
n::updateActiveStyleSheets | 227 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio
n::updateActiveStyleSheets |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 void StyleEngine::clearMediaQueryRuleSetStyleSheets() | 349 void StyleEngine::clearMediaQueryRuleSetStyleSheets() |
| 350 { | 350 { |
| 351 m_documentStyleSheetCollection.clearMediaQueryRuleSetStyleSheets(); | 351 m_documentStyleSheetCollection.clearMediaQueryRuleSetStyleSheets(); |
| 352 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); | 352 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); |
| 353 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes); | 353 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC
ollector) | 356 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC
ollector) |
| 357 { | 357 { |
| 358 ASSERT(!isMaster()); | 358 ASSERT(!isMaster()); |
| 359 Vector<RefPtr<StyleSheet> > sheetsForList; | 359 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; |
| 360 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL
ist); | 360 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL
ist); |
| 361 m_documentStyleSheetCollection.collectStyleSheets(this, subcollector); | 361 m_documentStyleSheetCollection.collectStyleSheets(this, subcollector); |
| 362 m_documentStyleSheetCollection.swapSheetsForSheetList(sheetsForList); | 362 m_documentStyleSheetCollection.swapSheetsForSheetList(sheetsForList); |
| 363 } | 363 } |
| 364 | 364 |
| 365 bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) | 365 bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) |
| 366 { | 366 { |
| 367 ASSERT(isMaster()); | 367 ASSERT(isMaster()); |
| 368 ASSERT(!m_document.inStyleRecalc()); | 368 ASSERT(!m_document.inStyleRecalc()); |
| 369 | 369 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 394 | 394 |
| 395 InspectorInstrumentation::activeStyleSheetsUpdated(&m_document); | 395 InspectorInstrumentation::activeStyleSheetsUpdated(&m_document); |
| 396 m_usesRemUnits = m_documentStyleSheetCollection.usesRemUnits(); | 396 m_usesRemUnits = m_documentStyleSheetCollection.usesRemUnits(); |
| 397 | 397 |
| 398 m_dirtyTreeScopes.clear(); | 398 m_dirtyTreeScopes.clear(); |
| 399 m_documentScopeDirty = false; | 399 m_documentScopeDirty = false; |
| 400 | 400 |
| 401 return requiresFullStyleRecalc; | 401 return requiresFullStyleRecalc; |
| 402 } | 402 } |
| 403 | 403 |
| 404 const Vector<RefPtr<StyleSheet> > StyleEngine::activeStyleSheetsForInspector() c
onst | 404 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > StyleEngine::activeStyle
SheetsForInspector() const |
| 405 { | 405 { |
| 406 if (m_activeTreeScopes.isEmpty()) | 406 if (m_activeTreeScopes.isEmpty()) |
| 407 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList(); | 407 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList(); |
| 408 | 408 |
| 409 Vector<RefPtr<StyleSheet> > activeStyleSheets; | 409 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets; |
| 410 | 410 |
| 411 activeStyleSheets.appendVector(m_documentStyleSheetCollection.styleSheetsFor
StyleSheetList()); | 411 activeStyleSheets.appendVector(m_documentStyleSheetCollection.styleSheetsFor
StyleSheetList()); |
| 412 | 412 |
| 413 TreeScopeSet::const_iterator begin = m_activeTreeScopes.begin(); | 413 TreeScopeSet::const_iterator begin = m_activeTreeScopes.begin(); |
| 414 TreeScopeSet::const_iterator end = m_activeTreeScopes.end(); | 414 TreeScopeSet::const_iterator end = m_activeTreeScopes.end(); |
| 415 for (TreeScopeSet::const_iterator it = begin; it != end; ++it) { | 415 for (TreeScopeSet::const_iterator it = begin; it != end; ++it) { |
| 416 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa
p.get(*it)) | 416 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa
p.get(*it)) |
| 417 activeStyleSheets.appendVector(collection->styleSheetsForStyleSheetL
ist()); | 417 activeStyleSheets.appendVector(collection->styleSheetsForStyleSheetL
ist()); |
| 418 } | 418 } |
| 419 | 419 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 void StyleEngine::removeSheet(StyleSheetContents* contents) | 611 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 612 { | 612 { |
| 613 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache()
.find(contents); | 613 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache()
.find(contents); |
| 614 if (it == sheetToTextCache().end()) | 614 if (it == sheetToTextCache().end()) |
| 615 return; | 615 return; |
| 616 | 616 |
| 617 textToSheetCache().remove(it->value); | 617 textToSheetCache().remove(it->value); |
| 618 sheetToTextCache().remove(contents); | 618 sheetToTextCache().remove(contents); |
| 619 } | 619 } |
| 620 | 620 |
| 621 void StyleEngine::trace(Visitor* visitor) |
| 622 { |
| 623 m_authorStyleSheets.trace(visitor); |
| 621 } | 624 } |
| 625 |
| 626 } |
| OLD | NEW |