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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 m_styleSheetCollectionMap.get(treeScope)) | 366 m_styleSheetCollectionMap.get(treeScope)) |
367 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets()); | 367 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets()); |
368 } | 368 } |
369 | 369 |
370 // FIXME: Inspector needs a vector which has all active stylesheets. | 370 // FIXME: Inspector needs a vector which has all active stylesheets. |
371 // However, creating such a large vector might cause performance regression. | 371 // However, creating such a large vector might cause performance regression. |
372 // Need to implement some smarter solution. | 372 // Need to implement some smarter solution. |
373 return activeStyleSheets; | 373 return activeStyleSheets; |
374 } | 374 } |
375 | 375 |
376 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) { | |
377 m_styleSheetCollectionMap.remove(shadowRoot); | |
378 m_activeTreeScopes.remove(shadowRoot); | |
379 m_dirtyTreeScopes.remove(shadowRoot); | |
380 } | |
381 | |
382 void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) { | 376 void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) { |
383 if (StyleResolver* styleResolver = resolver()) { | 377 if (StyleResolver* styleResolver = resolver()) { |
384 styleResolver->resetRuleFeatures(); | 378 styleResolver->resetRuleFeatures(); |
385 | 379 |
386 if (TreeScopeStyleSheetCollection* collection = | 380 if (TreeScopeStyleSheetCollection* collection = |
387 styleSheetCollectionFor(*shadowRoot)) | 381 styleSheetCollectionFor(*shadowRoot)) |
388 styleResolver->removePendingAuthorStyleSheets( | 382 styleResolver->removePendingAuthorStyleSheets( |
389 collection->activeAuthorStyleSheets()); | 383 collection->activeAuthorStyleSheets()); |
390 } | 384 } |
391 shadowRoot->clearScopedStyleResolver(); | 385 shadowRoot->clearScopedStyleResolver(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 // A scoped style resolver for document will be created during | 432 // A scoped style resolver for document will be created during |
439 // appendActiveAuthorStyleSheets if needed. | 433 // appendActiveAuthorStyleSheets if needed. |
440 appendActiveAuthorStyleSheets(); | 434 appendActiveAuthorStyleSheets(); |
441 } | 435 } |
442 | 436 |
443 void StyleEngine::clearResolver() { | 437 void StyleEngine::clearResolver() { |
444 DCHECK(!document().inStyleRecalc()); | 438 DCHECK(!document().inStyleRecalc()); |
445 DCHECK(isMaster() || !m_resolver); | 439 DCHECK(isMaster() || !m_resolver); |
446 | 440 |
447 document().clearScopedStyleResolver(); | 441 document().clearScopedStyleResolver(); |
448 // StyleEngine::shadowRootRemovedFromDocument removes not-in-document | 442 // TODO(rune@opera.com): The clearing of all shadow tree scoped style |
449 // treescopes from activeTreeScopes. StyleEngine::didRemoveShadowRoot | 443 // resolvers below should not be necessary. It was introduced to fix a crash |
450 // removes treescopes which are being destroyed from activeTreeScopes. | 444 // bug (https://crbug.com/447976) when clearResolver is called from didDetach |
451 // So we need to clearScopedStyleResolver for treescopes which have been | 445 // on document destruction. That was pre-oilpan, and removing the for-loop |
452 // just removed from document. If document is destroyed before invoking | 446 // below does not re-introduce that crash. If m_activeTreeScopes keeps too |
453 // updateActiveStyleSheets, the treescope has a scopedStyleResolver which | 447 // much memory alive after detach, we should probably clear m_activeTreeScopes |
454 // has destroyed StyleSheetContents. | 448 // in didDetach instead. |
| 449 // |
| 450 // The current code will clear too much if clearResolver is called from |
| 451 // clearMasterResolver as a result of a Reconstruct in |
| 452 // DocumentStyleSheetCollection. Such a reconstruct should not necessarily |
| 453 // affect scoped resolvers from shadow trees at all. |
455 for (TreeScope* treeScope : m_activeTreeScopes) | 454 for (TreeScope* treeScope : m_activeTreeScopes) |
456 treeScope->clearScopedStyleResolver(); | 455 treeScope->clearScopedStyleResolver(); |
457 | 456 |
458 m_treeBoundaryCrossingScopes.clear(); | 457 m_treeBoundaryCrossingScopes.clear(); |
459 | 458 |
460 if (m_resolver) { | 459 if (m_resolver) { |
461 TRACE_EVENT1("blink", "StyleEngine::clearResolver", "frame", | 460 TRACE_EVENT1("blink", "StyleEngine::clearResolver", "frame", |
462 document().frame()); | 461 document().frame()); |
463 m_resolver->dispose(); | 462 m_resolver->dispose(); |
464 m_resolver.clear(); | 463 m_resolver.clear(); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 } | 1019 } |
1021 | 1020 |
1022 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1021 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
1023 for (auto sheet : m_injectedAuthorStyleSheets) { | 1022 for (auto sheet : m_injectedAuthorStyleSheets) { |
1024 visitor->traceWrappers(sheet); | 1023 visitor->traceWrappers(sheet); |
1025 } | 1024 } |
1026 visitor->traceWrappers(m_documentStyleSheetCollection); | 1025 visitor->traceWrappers(m_documentStyleSheetCollection); |
1027 } | 1026 } |
1028 | 1027 |
1029 } // namespace blink | 1028 } // namespace blink |
OLD | NEW |