Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "platform/fonts/FontCache.h" | 54 #include "platform/fonts/FontCache.h" |
| 55 | 55 |
| 56 namespace blink { | 56 namespace blink { |
| 57 | 57 |
| 58 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 59 | 59 |
| 60 StyleEngine::StyleEngine(Document& document) | 60 StyleEngine::StyleEngine(Document& document) |
| 61 : m_document(&document) | 61 : m_document(&document) |
| 62 , m_isMaster(!document.importsController() || document.importsController()-> master() == &document) | 62 , m_isMaster(!document.importsController() || document.importsController()-> master() == &document) |
| 63 , m_documentStyleSheetCollection(DocumentStyleSheetCollection::create(docume nt)) | 63 , m_documentStyleSheetCollection(DocumentStyleSheetCollection::create(docume nt)) |
| 64 // We don't need to create CSSFontSelector for imported document or | 64 , m_fontSelector(CSSFontSelector::create(&document)) |
|
Justin Novosad
2016/09/12 18:44:59
This should be lazily allocated instead of in the
zakerinasab
2016/09/12 19:47:34
Done.
| |
| 65 // HTMLTemplateElement's document, because those documents have no frame. | |
| 66 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) | |
| 67 { | 65 { |
| 68 if (m_fontSelector) | 66 if (m_fontSelector) |
| 69 m_fontSelector->registerForInvalidationCallbacks(this); | 67 m_fontSelector->registerForInvalidationCallbacks(this); |
| 70 } | 68 } |
| 71 | 69 |
| 72 StyleEngine::~StyleEngine() | 70 StyleEngine::~StyleEngine() |
| 73 { | 71 { |
| 74 } | 72 } |
| 75 | 73 |
| 76 static bool isStyleElement(Node& node) | 74 static bool isStyleElement(Node& node) |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu thorStyleSheets()); | 381 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu thorStyleSheets()); |
| 384 for (TreeScope* treeScope : m_activeTreeScopes) { | 382 for (TreeScope* treeScope : m_activeTreeScopes) { |
| 385 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(treeScope)) | 383 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(treeScope)) |
| 386 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe ets()); | 384 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe ets()); |
| 387 } | 385 } |
| 388 m_resolver->finishAppendAuthorStyleSheets(); | 386 m_resolver->finishAppendAuthorStyleSheets(); |
| 389 } | 387 } |
| 390 | 388 |
| 391 void StyleEngine::createResolver() | 389 void StyleEngine::createResolver() |
| 392 { | 390 { |
| 393 TRACE_EVENT1("blink", "StyleEngine::createResolver", "frame", document().fra me()); | |
| 394 // It is a programming error to attempt to resolve style on a Document | |
| 395 // which is not in a frame. Code which hits this should have checked | |
| 396 // Document::isActive() before calling into code which could get here. | |
| 397 | |
| 398 DCHECK(document().frame()); | |
| 399 | |
| 400 m_resolver = StyleResolver::create(*m_document); | 391 m_resolver = StyleResolver::create(*m_document); |
| 401 | 392 |
| 402 // A scoped style resolver for document will be created during | 393 // A scoped style resolver for document will be created during |
| 403 // appendActiveAuthorStyleSheets if needed. | 394 // appendActiveAuthorStyleSheets if needed. |
| 404 appendActiveAuthorStyleSheets(); | 395 appendActiveAuthorStyleSheets(); |
| 405 } | 396 } |
| 406 | 397 |
| 407 void StyleEngine::clearResolver() | 398 void StyleEngine::clearResolver() |
| 408 { | 399 { |
| 409 DCHECK(!document().inStyleRecalc()); | 400 DCHECK(!document().inStyleRecalc()); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 842 | 833 |
| 843 DEFINE_TRACE_WRAPPERS(StyleEngine) | 834 DEFINE_TRACE_WRAPPERS(StyleEngine) |
| 844 { | 835 { |
| 845 for (auto sheet : m_injectedAuthorStyleSheets) { | 836 for (auto sheet : m_injectedAuthorStyleSheets) { |
| 846 visitor->traceWrappers(sheet); | 837 visitor->traceWrappers(sheet); |
| 847 } | 838 } |
| 848 visitor->traceWrappers(m_documentStyleSheetCollection); | 839 visitor->traceWrappers(m_documentStyleSheetCollection); |
| 849 } | 840 } |
| 850 | 841 |
| 851 } // namespace blink | 842 } // namespace blink |
| OLD | NEW |