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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "core/page/Page.h" | 47 #include "core/page/Page.h" |
48 #include "core/frame/Settings.h" | 48 #include "core/frame/Settings.h" |
49 #include "core/svg/SVGStyleElement.h" | 49 #include "core/svg/SVGStyleElement.h" |
50 #include "platform/URLPatternMatcher.h" | 50 #include "platform/URLPatternMatcher.h" |
51 | 51 |
52 namespace WebCore { | 52 namespace WebCore { |
53 | 53 |
54 using namespace HTMLNames; | 54 using namespace HTMLNames; |
55 | 55 |
56 StyleEngine::StyleEngine(Document& document) | 56 StyleEngine::StyleEngine(Document& document) |
57 : m_document(document) | 57 : m_document(&document) |
haraken
2014/05/06 15:59:42
Probably we should announce to blink-dev@ that Oil
Mads Ager (chromium)
2014/05/07 12:13:16
Yes, we should write a message explaining the fact
| |
58 , m_isMaster(!document.importsController() || document.importsController()-> isMaster(document) ) | 58 , m_isMaster(!document.importsController() || document.importsController()-> isMaster(document) ) |
59 , m_pendingStylesheets(0) | 59 , m_pendingStylesheets(0) |
60 , m_injectedStyleSheetCacheValid(false) | 60 , m_injectedStyleSheetCacheValid(false) |
61 , m_documentStyleSheetCollection(document) | 61 , m_documentStyleSheetCollection(document) |
62 , m_documentScopeDirty(true) | 62 , m_documentScopeDirty(true) |
63 , m_usesSiblingRules(false) | 63 , m_usesSiblingRules(false) |
64 , m_usesSiblingRulesOverride(false) | 64 , m_usesSiblingRulesOverride(false) |
65 , m_usesFirstLineRules(false) | 65 , m_usesFirstLineRules(false) |
66 , m_usesFirstLetterRules(false) | 66 , m_usesFirstLetterRules(false) |
67 , m_usesRemUnits(false) | 67 , m_usesRemUnits(false) |
68 , m_maxDirectAdjacentSelectors(0) | 68 , m_maxDirectAdjacentSelectors(0) |
69 , m_ignorePendingStylesheets(false) | 69 , m_ignorePendingStylesheets(false) |
70 , m_didCalculateResolver(false) | 70 , m_didCalculateResolver(false) |
71 // We don't need to create CSSFontSelector for imported document or | 71 // We don't need to create CSSFontSelector for imported document or |
72 // HTMLTemplateElement's document, because those documents have no frame. | 72 // HTMLTemplateElement's document, because those documents have no frame. |
73 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) | 73 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) |
74 { | 74 { |
75 } | 75 } |
76 | 76 |
77 StyleEngine::~StyleEngine() | 77 StyleEngine::~StyleEngine() |
78 { | 78 { |
79 } | 79 } |
80 | 80 |
81 #if !ENABLE(OILPAN) | |
81 void StyleEngine::detachFromDocument() | 82 void StyleEngine::detachFromDocument() |
82 { | 83 { |
83 // Cleanup is performed eagerly when the StyleEngine is removed from the | 84 // Cleanup is performed eagerly when the StyleEngine is removed from the |
84 // document. The StyleEngine is unreachable after this, since only the | 85 // document. The StyleEngine is unreachable after this, since only the |
85 // document has a reference to it. | 86 // document has a reference to it. |
86 #if !ENABLE(OILPAN) | |
87 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) | 87 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
88 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); | 88 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
89 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) | 89 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) |
90 m_authorStyleSheets[i]->clearOwnerNode(); | 90 m_authorStyleSheets[i]->clearOwnerNode(); |
91 #endif | |
92 | 91 |
93 if (m_fontSelector) { | 92 if (m_fontSelector) { |
94 m_fontSelector->clearDocument(); | 93 m_fontSelector->clearDocument(); |
haraken
2014/05/06 15:59:42
This is problematic but will be fixed in Gustav's
Mads Ager (chromium)
2014/05/07 12:13:16
Yes, I should have done that. Gustav's change is i
| |
95 #if !ENABLE(OILPAN) | |
96 if (m_resolver) | 94 if (m_resolver) |
97 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()) ; | 95 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()) ; |
98 #endif | |
99 } | 96 } |
100 | 97 |
101 // Decrement reference counts for things we could be keeping alive. | 98 // Decrement reference counts for things we could be keeping alive. |
102 m_fontSelector.clear(); | 99 m_fontSelector.clear(); |
103 m_resolver.clear(); | 100 m_resolver.clear(); |
104 m_styleSheetCollectionMap.clear(); | 101 m_styleSheetCollectionMap.clear(); |
105 } | 102 } |
103 #endif | |
106 | 104 |
107 inline Document* StyleEngine::master() | 105 inline Document* StyleEngine::master() |
108 { | 106 { |
109 if (isMaster()) | 107 if (isMaster()) |
110 return &m_document; | 108 return m_document; |
111 HTMLImportsController* import = m_document.importsController(); | 109 HTMLImportsController* import = m_document->importsController(); |
tkent
2014/05/07 00:41:19
We should have |Document& StyleEngine::document()|
Mads Ager (chromium)
2014/05/07 12:13:16
That is a good idea. That will be less intrusive i
| |
112 if (!import) // Document::import() can return null while executing its destr uctor. | 110 if (!import) // Document::import() can return null while executing its destr uctor. |
113 return 0; | 111 return 0; |
114 return import->master(); | 112 return import->master(); |
115 } | 113 } |
116 | 114 |
117 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope) | 115 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope) |
118 { | 116 { |
119 if (treeScopes.isEmpty()) { | 117 if (treeScopes.isEmpty()) { |
120 treeScopes.add(treeScope); | 118 treeScopes.add(treeScope); |
121 return; | 119 return; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 return m_injectedAuthorStyleSheets; | 195 return m_injectedAuthorStyleSheets; |
198 } | 196 } |
199 | 197 |
200 void StyleEngine::updateInjectedStyleSheetCache() const | 198 void StyleEngine::updateInjectedStyleSheetCache() const |
201 { | 199 { |
202 if (m_injectedStyleSheetCacheValid) | 200 if (m_injectedStyleSheetCacheValid) |
203 return; | 201 return; |
204 m_injectedStyleSheetCacheValid = true; | 202 m_injectedStyleSheetCacheValid = true; |
205 m_injectedAuthorStyleSheets.clear(); | 203 m_injectedAuthorStyleSheets.clear(); |
206 | 204 |
207 Page* owningPage = m_document.page(); | 205 Page* owningPage = m_document->page(); |
208 if (!owningPage) | 206 if (!owningPage) |
209 return; | 207 return; |
210 | 208 |
211 const InjectedStyleSheetEntryVector& entries = InjectedStyleSheets::instance ().entries(); | 209 const InjectedStyleSheetEntryVector& entries = InjectedStyleSheets::instance ().entries(); |
212 for (unsigned i = 0; i < entries.size(); ++i) { | 210 for (unsigned i = 0; i < entries.size(); ++i) { |
213 const InjectedStyleSheetEntry* entry = entries[i].get(); | 211 const InjectedStyleSheetEntry* entry = entries[i].get(); |
214 if (entry->injectedFrames() == InjectStyleInTopFrameOnly && m_document.o wnerElement()) | 212 if (entry->injectedFrames() == InjectStyleInTopFrameOnly && m_document-> ownerElement()) |
215 continue; | 213 continue; |
216 if (!URLPatternMatcher::matchesPatterns(m_document.url(), entry->whiteli st())) | 214 if (!URLPatternMatcher::matchesPatterns(m_document->url(), entry->whitel ist())) |
217 continue; | 215 continue; |
218 RefPtrWillBeRawPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInli ne(const_cast<Document*>(&m_document), KURL()); | 216 RefPtrWillBeRawPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInli ne(m_document, KURL()); |
219 m_injectedAuthorStyleSheets.append(groupSheet); | 217 m_injectedAuthorStyleSheets.append(groupSheet); |
220 groupSheet->contents()->parseString(entry->source()); | 218 groupSheet->contents()->parseString(entry->source()); |
221 } | 219 } |
222 } | 220 } |
223 | 221 |
224 void StyleEngine::invalidateInjectedStyleSheetCache() | 222 void StyleEngine::invalidateInjectedStyleSheetCache() |
225 { | 223 { |
226 m_injectedStyleSheetCacheValid = false; | 224 m_injectedStyleSheetCacheValid = false; |
227 markDocumentDirty(); | 225 markDocumentDirty(); |
228 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio n::updateActiveStyleSheets | 226 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio n::updateActiveStyleSheets |
229 // and batch updates lots of sheets so we can't call addedStyleSheet() or re movedStyleSheet(). | 227 // and batch updates lots of sheets so we can't call addedStyleSheet() or re movedStyleSheet(). |
230 m_document.styleResolverChanged(RecalcStyleDeferred); | 228 m_document->styleResolverChanged(RecalcStyleDeferred); |
231 } | 229 } |
232 | 230 |
233 void StyleEngine::addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> auth orSheet) | 231 void StyleEngine::addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> auth orSheet) |
234 { | 232 { |
235 m_authorStyleSheets.append(CSSStyleSheet::create(authorSheet, &m_document)); | 233 m_authorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_document)); |
236 m_document.addedStyleSheet(m_authorStyleSheets.last().get(), RecalcStyleImme diately); | 234 m_document->addedStyleSheet(m_authorStyleSheets.last().get(), RecalcStyleImm ediately); |
237 markDocumentDirty(); | 235 markDocumentDirty(); |
238 } | 236 } |
239 | 237 |
240 void StyleEngine::addPendingSheet() | 238 void StyleEngine::addPendingSheet() |
241 { | 239 { |
242 m_pendingStylesheets++; | 240 m_pendingStylesheets++; |
243 } | 241 } |
244 | 242 |
245 // This method is called whenever a top-level stylesheet has finished loading. | 243 // This method is called whenever a top-level stylesheet has finished loading. |
246 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode, RemovePendin gSheetNotificationType notification) | 244 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode, RemovePendin gSheetNotificationType notification) |
247 { | 245 { |
248 ASSERT(styleSheetCandidateNode); | 246 ASSERT(styleSheetCandidateNode); |
249 TreeScope* treeScope = isHTMLStyleElement(*styleSheetCandidateNode) ? &style SheetCandidateNode->treeScope() : &m_document; | 247 TreeScope* treeScope = isHTMLStyleElement(*styleSheetCandidateNode) ? &style SheetCandidateNode->treeScope() : m_document.get(); |
250 markTreeScopeDirty(*treeScope); | 248 markTreeScopeDirty(*treeScope); |
251 | 249 |
252 // Make sure we knew this sheet was pending, and that our count isn't out of sync. | 250 // Make sure we knew this sheet was pending, and that our count isn't out of sync. |
253 ASSERT(m_pendingStylesheets > 0); | 251 ASSERT(m_pendingStylesheets > 0); |
254 | 252 |
255 m_pendingStylesheets--; | 253 m_pendingStylesheets--; |
256 if (m_pendingStylesheets) | 254 if (m_pendingStylesheets) |
257 return; | 255 return; |
258 | 256 |
259 if (notification == RemovePendingSheetNotifyLater) { | 257 if (notification == RemovePendingSheetNotifyLater) { |
260 m_document.setNeedsNotifyRemoveAllPendingStylesheet(); | 258 m_document->setNeedsNotifyRemoveAllPendingStylesheet(); |
261 return; | 259 return; |
262 } | 260 } |
263 | 261 |
264 // FIXME: We can't call addedStyleSheet or removedStyleSheet here because we don't know | 262 // FIXME: We can't call addedStyleSheet or removedStyleSheet here because we don't know |
265 // what's new. We should track that to tell the style system what changed. | 263 // what's new. We should track that to tell the style system what changed. |
266 m_document.didRemoveAllPendingStylesheet(); | 264 m_document->didRemoveAllPendingStylesheet(); |
267 } | 265 } |
268 | 266 |
269 void StyleEngine::modifiedStyleSheet(StyleSheet* sheet) | 267 void StyleEngine::modifiedStyleSheet(StyleSheet* sheet) |
270 { | 268 { |
271 if (!sheet) | 269 if (!sheet) |
272 return; | 270 return; |
273 | 271 |
274 Node* node = sheet->ownerNode(); | 272 Node* node = sheet->ownerNode(); |
275 if (!node || !node->inDocument()) | 273 if (!node || !node->inDocument()) |
276 return; | 274 return; |
277 | 275 |
278 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_doc ument; | 276 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; |
279 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 277 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
280 | 278 |
281 markTreeScopeDirty(treeScope); | 279 markTreeScopeDirty(treeScope); |
282 } | 280 } |
283 | 281 |
284 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) | 282 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) |
285 { | 283 { |
286 if (!node->inDocument()) | 284 if (!node->inDocument()) |
287 return; | 285 return; |
288 | 286 |
289 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_doc ument; | 287 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; |
290 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 288 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
291 | 289 |
292 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope); | 290 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope); |
293 ASSERT(collection); | 291 ASSERT(collection); |
294 collection->addStyleSheetCandidateNode(node, createdByParser); | 292 collection->addStyleSheetCandidateNode(node, createdByParser); |
295 | 293 |
296 markTreeScopeDirty(treeScope); | 294 markTreeScopeDirty(treeScope); |
297 if (treeScope != m_document) | 295 if (treeScope != m_document) |
298 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); | 296 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); |
299 } | 297 } |
300 | 298 |
301 void StyleEngine::removeStyleSheetCandidateNode(Node* node) | 299 void StyleEngine::removeStyleSheetCandidateNode(Node* node) |
302 { | 300 { |
303 removeStyleSheetCandidateNode(node, 0, m_document); | 301 removeStyleSheetCandidateNode(node, 0, *m_document); |
304 } | 302 } |
305 | 303 |
306 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope) | 304 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope) |
307 { | 305 { |
308 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 306 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
309 | 307 |
310 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e); | 308 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e); |
311 ASSERT(collection); | 309 ASSERT(collection); |
312 collection->removeStyleSheetCandidateNode(node, scopingNode); | 310 collection->removeStyleSheetCandidateNode(node, scopingNode); |
313 | 311 |
314 markTreeScopeDirty(treeScope); | 312 markTreeScopeDirty(treeScope); |
315 m_activeTreeScopes.remove(&treeScope); | 313 m_activeTreeScopes.remove(&treeScope); |
316 } | 314 } |
317 | 315 |
318 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) | 316 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
319 { | 317 { |
320 if (!node->inDocument()) | 318 if (!node->inDocument()) |
321 return; | 319 return; |
322 | 320 |
323 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_doc ument; | 321 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; |
324 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 322 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
325 markTreeScopeDirty(treeScope); | 323 markTreeScopeDirty(treeScope); |
326 } | 324 } |
327 | 325 |
328 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) | 326 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) |
329 { | 327 { |
330 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; | 328 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; |
331 } | 329 } |
332 | 330 |
333 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes) | 331 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes) |
(...skipping 19 matching lines...) Expand all Loading... | |
353 ASSERT(!isMaster()); | 351 ASSERT(!isMaster()); |
354 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; | 352 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; |
355 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist); | 353 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist); |
356 m_documentStyleSheetCollection.collectStyleSheets(this, subcollector); | 354 m_documentStyleSheetCollection.collectStyleSheets(this, subcollector); |
357 m_documentStyleSheetCollection.swapSheetsForSheetList(sheetsForList); | 355 m_documentStyleSheetCollection.swapSheetsForSheetList(sheetsForList); |
358 } | 356 } |
359 | 357 |
360 bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) | 358 bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) |
361 { | 359 { |
362 ASSERT(isMaster()); | 360 ASSERT(isMaster()); |
363 ASSERT(!m_document.inStyleRecalc()); | 361 ASSERT(!m_document->inStyleRecalc()); |
364 | 362 |
365 if (!m_document.isActive()) | 363 if (!m_document->isActive()) |
366 return false; | 364 return false; |
367 | 365 |
368 bool requiresFullStyleRecalc = false; | 366 bool requiresFullStyleRecalc = false; |
369 if (m_documentScopeDirty || updateMode == FullStyleUpdate) | 367 if (m_documentScopeDirty || updateMode == FullStyleUpdate) |
370 requiresFullStyleRecalc = m_documentStyleSheetCollection.updateActiveSty leSheets(this, updateMode); | 368 requiresFullStyleRecalc = m_documentStyleSheetCollection.updateActiveSty leSheets(this, updateMode); |
371 | 369 |
372 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { | 370 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { |
373 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc opes : m_dirtyTreeScopes; | 371 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc opes : m_dirtyTreeScopes; |
374 HashSet<TreeScope*> treeScopesRemoved; | 372 HashSet<TreeScope*> treeScopesRemoved; |
375 | 373 |
376 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en d(); ++it) { | 374 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en d(); ++it) { |
377 TreeScope* treeScope = *it; | 375 TreeScope* treeScope = *it; |
378 ASSERT(treeScope != m_document); | 376 ASSERT(treeScope != m_document); |
379 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); | 377 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); |
380 ASSERT(collection); | 378 ASSERT(collection); |
381 collection->updateActiveStyleSheets(this, updateMode); | 379 collection->updateActiveStyleSheets(this, updateMode); |
382 if (!collection->hasStyleSheetCandidateNodes()) | 380 if (!collection->hasStyleSheetCandidateNodes()) |
383 treeScopesRemoved.add(treeScope); | 381 treeScopesRemoved.add(treeScope); |
384 } | 382 } |
385 m_activeTreeScopes.removeAll(treeScopesRemoved); | 383 m_activeTreeScopes.removeAll(treeScopesRemoved); |
386 } | 384 } |
387 | 385 |
388 InspectorInstrumentation::activeStyleSheetsUpdated(&m_document); | 386 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); |
389 m_usesRemUnits = m_documentStyleSheetCollection.usesRemUnits(); | 387 m_usesRemUnits = m_documentStyleSheetCollection.usesRemUnits(); |
390 | 388 |
391 m_dirtyTreeScopes.clear(); | 389 m_dirtyTreeScopes.clear(); |
392 m_documentScopeDirty = false; | 390 m_documentScopeDirty = false; |
393 | 391 |
394 return requiresFullStyleRecalc; | 392 return requiresFullStyleRecalc; |
395 } | 393 } |
396 | 394 |
397 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > StyleEngine::activeStyle SheetsForInspector() const | 395 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > StyleEngine::activeStyle SheetsForInspector() const |
398 { | 396 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 m_resolver->finishAppendAuthorStyleSheets(); | 437 m_resolver->finishAppendAuthorStyleSheets(); |
440 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false); | 438 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false); |
441 } | 439 } |
442 | 440 |
443 void StyleEngine::createResolver() | 441 void StyleEngine::createResolver() |
444 { | 442 { |
445 // It is a programming error to attempt to resolve style on a Document | 443 // It is a programming error to attempt to resolve style on a Document |
446 // which is not in a frame. Code which hits this should have checked | 444 // which is not in a frame. Code which hits this should have checked |
447 // Document::isActive() before calling into code which could get here. | 445 // Document::isActive() before calling into code which could get here. |
448 | 446 |
449 ASSERT(m_document.frame()); | 447 ASSERT(m_document->frame()); |
450 ASSERT(m_fontSelector); | 448 ASSERT(m_fontSelector); |
451 | 449 |
452 m_resolver = adoptPtrWillBeNoop(new StyleResolver(m_document)); | 450 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); |
453 appendActiveAuthorStyleSheets(); | 451 appendActiveAuthorStyleSheets(); |
454 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | 452 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); |
455 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); | 453 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); |
456 } | 454 } |
457 | 455 |
458 void StyleEngine::clearResolver() | 456 void StyleEngine::clearResolver() |
459 { | 457 { |
460 ASSERT(!m_document.inStyleRecalc()); | 458 ASSERT(!m_document->inStyleRecalc()); |
461 ASSERT(isMaster() || !m_resolver); | 459 ASSERT(isMaster() || !m_resolver); |
462 ASSERT(m_fontSelector || !m_resolver); | 460 ASSERT(m_fontSelector || !m_resolver); |
463 if (m_resolver) { | 461 if (m_resolver) { |
464 m_document.updateStyleInvalidationIfNeeded(); | 462 m_document->updateStyleInvalidationIfNeeded(); |
465 #if !ENABLE(OILPAN) | 463 #if !ENABLE(OILPAN) |
466 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | 464 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); |
467 #endif | 465 #endif |
468 } | 466 } |
469 m_resolver.clear(); | 467 m_resolver.clear(); |
470 } | 468 } |
471 | 469 |
472 void StyleEngine::clearMasterResolver() | 470 void StyleEngine::clearMasterResolver() |
473 { | 471 { |
474 if (Document* master = this->master()) | 472 if (Document* master = this->master()) |
(...skipping 20 matching lines...) Expand all Loading... | |
495 StyleResolverChange change; | 493 StyleResolverChange change; |
496 | 494 |
497 if (!isMaster()) { | 495 if (!isMaster()) { |
498 if (Document* master = this->master()) | 496 if (Document* master = this->master()) |
499 master->styleResolverChanged(time, mode); | 497 master->styleResolverChanged(time, mode); |
500 return change; | 498 return change; |
501 } | 499 } |
502 | 500 |
503 // Don't bother updating, since we haven't loaded all our style info yet | 501 // Don't bother updating, since we haven't loaded all our style info yet |
504 // and haven't calculated the style selector for the first time. | 502 // and haven't calculated the style selector for the first time. |
505 if (!m_document.isActive() || shouldClearResolver()) { | 503 if (!m_document->isActive() || shouldClearResolver()) { |
506 clearResolver(); | 504 clearResolver(); |
507 return change; | 505 return change; |
508 } | 506 } |
509 | 507 |
510 m_didCalculateResolver = true; | 508 m_didCalculateResolver = true; |
511 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 509 if (m_document->didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
512 change.setNeedsRepaint(); | 510 change.setNeedsRepaint(); |
513 | 511 |
514 if (updateActiveStyleSheets(mode)) | 512 if (updateActiveStyleSheets(mode)) |
515 change.setNeedsStyleRecalc(); | 513 change.setNeedsStyleRecalc(); |
516 | 514 |
517 return change; | 515 return change; |
518 } | 516 } |
519 | 517 |
520 void StyleEngine::clearFontCache() | 518 void StyleEngine::clearFontCache() |
521 { | 519 { |
522 // We should not recreate FontSelector. Instead, clear fontFaceCache. | 520 // We should not recreate FontSelector. Instead, clear fontFaceCache. |
523 if (m_fontSelector) | 521 if (m_fontSelector) |
524 m_fontSelector->fontFaceCache()->clear(); | 522 m_fontSelector->fontFaceCache()->clear(); |
525 if (m_resolver) | 523 if (m_resolver) |
526 m_resolver->invalidateMatchedPropertiesCache(); | 524 m_resolver->invalidateMatchedPropertiesCache(); |
527 } | 525 } |
528 | 526 |
529 void StyleEngine::updateGenericFontFamilySettings() | 527 void StyleEngine::updateGenericFontFamilySettings() |
530 { | 528 { |
531 if (!m_fontSelector) | 529 if (!m_fontSelector) |
532 return; | 530 return; |
533 | 531 |
534 m_fontSelector->updateGenericFontFamilySettings(m_document); | 532 m_fontSelector->updateGenericFontFamilySettings(*m_document); |
535 if (m_resolver) | 533 if (m_resolver) |
536 m_resolver->invalidateMatchedPropertiesCache(); | 534 m_resolver->invalidateMatchedPropertiesCache(); |
537 } | 535 } |
538 | 536 |
539 void StyleEngine::removeFontFaceRules(const WillBeHeapVector<RawPtrWillBeMember< const StyleRuleFontFace> >& fontFaceRules) | 537 void StyleEngine::removeFontFaceRules(const WillBeHeapVector<RawPtrWillBeMember< const StyleRuleFontFace> >& fontFaceRules) |
540 { | 538 { |
541 if (!m_fontSelector) | 539 if (!m_fontSelector) |
542 return; | 540 return; |
543 | 541 |
544 FontFaceCache* cache = m_fontSelector->fontFaceCache(); | 542 FontFaceCache* cache = m_fontSelector->fontFaceCache(); |
545 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | 543 for (unsigned i = 0; i < fontFaceRules.size(); ++i) |
546 cache->remove(fontFaceRules[i]); | 544 cache->remove(fontFaceRules[i]); |
547 if (m_resolver) | 545 if (m_resolver) |
548 m_resolver->invalidateMatchedPropertiesCache(); | 546 m_resolver->invalidateMatchedPropertiesCache(); |
549 } | 547 } |
550 | 548 |
551 void StyleEngine::markTreeScopeDirty(TreeScope& scope) | 549 void StyleEngine::markTreeScopeDirty(TreeScope& scope) |
552 { | 550 { |
553 if (scope == m_document) { | 551 if (scope == m_document) { |
554 markDocumentDirty(); | 552 markDocumentDirty(); |
555 return; | 553 return; |
556 } | 554 } |
557 | 555 |
558 m_dirtyTreeScopes.add(&scope); | 556 m_dirtyTreeScopes.add(&scope); |
559 } | 557 } |
560 | 558 |
561 void StyleEngine::markDocumentDirty() | 559 void StyleEngine::markDocumentDirty() |
562 { | 560 { |
563 m_documentScopeDirty = true; | 561 m_documentScopeDirty = true; |
564 if (m_document.importLoader()) | 562 if (m_document->importLoader()) |
565 m_document.importsController()->master()->styleEngine()->markDocumentDir ty(); | 563 m_document->importsController()->master()->styleEngine()->markDocumentDi rty(); |
566 } | 564 } |
567 | 565 |
568 static bool isCacheableForStyleElement(const StyleSheetContents& contents) | 566 static bool isCacheableForStyleElement(const StyleSheetContents& contents) |
569 { | 567 { |
570 // FIXME: Support copying import rules. | 568 // FIXME: Support copying import rules. |
571 if (!contents.importRules().isEmpty()) | 569 if (!contents.importRules().isEmpty()) |
572 return false; | 570 return false; |
573 // Until import rules are supported in cached sheets it's not possible for l oading to fail. | 571 // Until import rules are supported in cached sheets it's not possible for l oading to fail. |
574 ASSERT(!contents.didLoadErrorOccur()); | 572 ASSERT(!contents.didLoadErrorOccur()); |
575 // It is not the original sheet anymore. | 573 // It is not the original sheet anymore. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); | 624 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); |
627 if (it == m_sheetToTextCache.end()) | 625 if (it == m_sheetToTextCache.end()) |
628 return; | 626 return; |
629 | 627 |
630 m_textToSheetCache.remove(it->value); | 628 m_textToSheetCache.remove(it->value); |
631 m_sheetToTextCache.remove(contents); | 629 m_sheetToTextCache.remove(contents); |
632 } | 630 } |
633 | 631 |
634 void StyleEngine::trace(Visitor* visitor) | 632 void StyleEngine::trace(Visitor* visitor) |
635 { | 633 { |
634 visitor->trace(m_document); | |
636 visitor->trace(m_injectedAuthorStyleSheets); | 635 visitor->trace(m_injectedAuthorStyleSheets); |
637 visitor->trace(m_authorStyleSheets); | 636 visitor->trace(m_authorStyleSheets); |
638 visitor->trace(m_documentStyleSheetCollection); | 637 visitor->trace(m_documentStyleSheetCollection); |
639 visitor->trace(m_styleSheetCollectionMap); | 638 visitor->trace(m_styleSheetCollectionMap); |
640 visitor->trace(m_resolver); | 639 visitor->trace(m_resolver); |
641 visitor->trace(m_fontSelector); | 640 visitor->trace(m_fontSelector); |
642 visitor->trace(m_textToSheetCache); | 641 visitor->trace(m_textToSheetCache); |
643 visitor->trace(m_sheetToTextCache); | 642 visitor->trace(m_sheetToTextCache); |
644 } | 643 } |
645 | 644 |
646 } | 645 } |
OLD | NEW |