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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 if (m_document->getSecurityOrigin()->canRequest(sheet.baseURL())) | 419 if (m_document->getSecurityOrigin()->canRequest(sheet.baseURL())) |
420 addRuleFlags = RuleHasDocumentSecurityOrigin; | 420 addRuleFlags = RuleHasDocumentSecurityOrigin; |
421 return &sheet.contents()->ensureRuleSet(*m_mediaQueryEvaluator, addRuleFlags); | 421 return &sheet.contents()->ensureRuleSet(*m_mediaQueryEvaluator, addRuleFlags); |
422 } | 422 } |
423 | 423 |
424 void StyleEngine::createResolver() { | 424 void StyleEngine::createResolver() { |
425 m_resolver = StyleResolver::create(*m_document); | 425 m_resolver = StyleResolver::create(*m_document); |
426 m_resolver->setRuleUsageTracker(m_tracker); | 426 m_resolver->setRuleUsageTracker(m_tracker); |
427 } | 427 } |
428 | 428 |
429 void StyleEngine::clearResolver() { | 429 void StyleEngine::clearResolvers() { |
430 DCHECK(!document().inStyleRecalc()); | 430 DCHECK(!document().inStyleRecalc()); |
431 DCHECK(isMaster() || !m_resolver); | 431 DCHECK(isMaster() || !m_resolver); |
432 | 432 |
433 document().clearScopedStyleResolver(); | 433 document().clearScopedStyleResolver(); |
434 // TODO(rune@opera.com): The clearing of all shadow tree scoped style | |
435 // resolvers below should not be necessary. It was introduced to fix a crash | |
436 // bug (https://crbug.com/447976) when clearResolver is called from didDetach | |
437 // on document destruction. That was pre-oilpan, and removing the for-loop | |
438 // below does not re-introduce that crash. If m_activeTreeScopes keeps too | |
439 // much memory alive after detach, we should probably clear m_activeTreeScopes | |
440 // in didDetach instead. | |
441 // | |
442 // The current code will clear too much if clearResolver is called from | |
443 // clearMasterResolver as a result of a Reconstruct in | |
444 // DocumentStyleSheetCollection. Such a reconstruct should not necessarily | |
445 // affect scoped resolvers from shadow trees at all. | |
446 for (TreeScope* treeScope : m_activeTreeScopes) | 434 for (TreeScope* treeScope : m_activeTreeScopes) |
447 treeScope->clearScopedStyleResolver(); | 435 treeScope->clearScopedStyleResolver(); |
448 | 436 |
449 m_treeBoundaryCrossingScopes.clear(); | |
450 | |
451 if (m_resolver) { | 437 if (m_resolver) { |
452 TRACE_EVENT1("blink", "StyleEngine::clearResolver", "frame", | 438 TRACE_EVENT1("blink", "StyleEngine::clearResolver", "frame", |
453 document().frame()); | 439 document().frame()); |
454 m_resolver->dispose(); | 440 m_resolver->dispose(); |
455 m_resolver.clear(); | 441 m_resolver.clear(); |
456 } | 442 } |
457 } | 443 } |
458 | 444 |
459 void StyleEngine::didDetach() { | 445 void StyleEngine::didDetach() { |
| 446 clearResolvers(); |
460 m_globalRuleSet.dispose(); | 447 m_globalRuleSet.dispose(); |
461 clearResolver(); | 448 m_treeBoundaryCrossingScopes.clear(); |
| 449 m_dirtyTreeScopes.clear(); |
| 450 m_activeTreeScopes.clear(); |
462 m_viewportResolver = nullptr; | 451 m_viewportResolver = nullptr; |
463 m_mediaQueryEvaluator = nullptr; | 452 m_mediaQueryEvaluator = nullptr; |
464 clearFontCache(); | 453 clearFontCache(); |
465 } | 454 } |
466 | 455 |
467 void StyleEngine::clearFontCache() { | 456 void StyleEngine::clearFontCache() { |
468 if (m_fontSelector) | 457 if (m_fontSelector) |
469 m_fontSelector->fontFaceCache()->clearCSSConnected(); | 458 m_fontSelector->fontFaceCache()->clearCSSConnected(); |
470 if (m_resolver) | 459 if (m_resolver) |
471 m_resolver->invalidateMatchedPropertiesCache(); | 460 m_resolver->invalidateMatchedPropertiesCache(); |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 } | 1131 } |
1143 | 1132 |
1144 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1133 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
1145 for (auto sheet : m_injectedAuthorStyleSheets) { | 1134 for (auto sheet : m_injectedAuthorStyleSheets) { |
1146 visitor->traceWrappers(sheet); | 1135 visitor->traceWrappers(sheet); |
1147 } | 1136 } |
1148 visitor->traceWrappers(m_documentStyleSheetCollection); | 1137 visitor->traceWrappers(m_documentStyleSheetCollection); |
1149 } | 1138 } |
1150 | 1139 |
1151 } // namespace blink | 1140 } // namespace blink |
OLD | NEW |