Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 846183002: Remove tracking of pending sheets. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 #include "sky/engine/core/css/StyleSheetContents.h" 34 #include "sky/engine/core/css/StyleSheetContents.h"
35 #include "sky/engine/core/dom/Document.h" 35 #include "sky/engine/core/dom/Document.h"
36 #include "sky/engine/core/dom/Element.h" 36 #include "sky/engine/core/dom/Element.h"
37 #include "sky/engine/core/dom/ElementTraversal.h" 37 #include "sky/engine/core/dom/ElementTraversal.h"
38 #include "sky/engine/core/dom/StyleSheetCollection.h" 38 #include "sky/engine/core/dom/StyleSheetCollection.h"
39 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 39 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
40 #include "sky/engine/core/frame/Settings.h" 40 #include "sky/engine/core/frame/Settings.h"
41 #include "sky/engine/core/html/HTMLStyleElement.h" 41 #include "sky/engine/core/html/HTMLStyleElement.h"
42 #include "sky/engine/core/html/imports/HTMLImportsController.h" 42 #include "sky/engine/core/html/imports/HTMLImportsController.h"
43 #include "sky/engine/core/page/Page.h" 43 #include "sky/engine/core/page/Page.h"
44 #include "sky/engine/core/rendering/RenderView.h"
44 45
45 namespace blink { 46 namespace blink {
46 47
47 StyleEngine::StyleEngine(Document& document) 48 StyleEngine::StyleEngine(Document& document)
48 : m_document(&document) 49 : m_document(&document)
50 , m_resolver(adoptPtr(new StyleResolver(*m_document)))
49 , m_fontSelector(CSSFontSelector::create(&document)) 51 , m_fontSelector(CSSFontSelector::create(&document))
50 { 52 {
51 m_fontSelector->registerForInvalidationCallbacks(this); 53 m_fontSelector->registerForInvalidationCallbacks(this);
52 m_activeTreeScopes.add(&document); 54 m_activeTreeScopes.add(&document);
53 } 55 }
54 56
55 StyleEngine::~StyleEngine() 57 StyleEngine::~StyleEngine()
56 { 58 {
57 m_fontSelector->clearDocument(); 59 m_fontSelector->clearDocument();
58 m_fontSelector->unregisterForInvalidationCallbacks(this); 60 m_fontSelector->unregisterForInvalidationCallbacks(this);
59 } 61 }
60 62
61 void StyleEngine::addTreeScope(TreeScope& scope) 63 void StyleEngine::addTreeScope(TreeScope& scope)
62 { 64 {
63 m_activeTreeScopes.add(&scope); 65 m_activeTreeScopes.add(&scope);
64 } 66 }
65 67
66 void StyleEngine::removeTreeScope(TreeScope& scope) 68 void StyleEngine::removeTreeScope(TreeScope& scope)
67 { 69 {
68 m_activeTreeScopes.remove(&scope); 70 m_activeTreeScopes.remove(&scope);
69 } 71 }
70 72
71 void StyleEngine::updateActiveStyleSheets() 73 void StyleEngine::updateActiveStyleSheets()
72 { 74 {
73 ASSERT(!m_document->inStyleRecalc()); 75 ASSERT(!m_document->inStyleRecalc());
74 ASSERT(m_resolver); 76 ASSERT(m_resolver);
75 77
76 for (TreeScope* treeScope : m_activeTreeScopes) 78 for (TreeScope* treeScope : m_activeTreeScopes)
77 treeScope->styleSheets().updateActiveStyleSheets(*m_resolver); 79 treeScope->styleSheets().updateActiveStyleSheets(*m_resolver);
78 }
79 80
80 void StyleEngine::appendActiveAuthorStyleSheets() 81 m_document->renderView()->style()->font().update(fontSelector());
81 {
82 for (TreeScope* treeScope : m_activeTreeScopes)
83 m_resolver->appendAuthorStyleSheets(treeScope->styleSheets().activeAutho rStyleSheets());
84
85 m_resolver->finishAppendAuthorStyleSheets();
86 }
87
88 void StyleEngine::createResolver()
89 {
90 // It is a programming error to attempt to resolve style on a Document
91 // which is not in a frame. Code which hits this should have checked
92 // Document::isActive() before calling into code which could get here.
93
94 ASSERT(m_document->frame());
95
96 m_resolver = adoptPtr(new StyleResolver(*m_document));
97
98 appendActiveAuthorStyleSheets();
99 }
100
101 void StyleEngine::clearResolver()
102 {
103 ASSERT(!m_document->inStyleRecalc());
104 m_resolver.clear();
105 } 82 }
106 83
107 unsigned StyleEngine::resolverAccessCount() const 84 unsigned StyleEngine::resolverAccessCount() const
108 { 85 {
109 return m_resolver ? m_resolver->accessCount() : 0; 86 return m_resolver->accessCount();
110 } 87 }
111 88
112 void StyleEngine::resolverChanged() 89 void StyleEngine::resolverChanged()
113 { 90 {
114 if (!m_document->isActive()) 91 if (!m_document->isActive())
115 return; 92 return;
116 if (m_resolver) 93 updateActiveStyleSheets();
117 updateActiveStyleSheets();
118 } 94 }
119 95
120 void StyleEngine::clearFontCache() 96 void StyleEngine::clearFontCache()
121 { 97 {
122 m_fontSelector->fontFaceCache()->clearCSSConnected(); 98 m_fontSelector->fontFaceCache()->clearCSSConnected();
123 if (m_resolver) 99 m_resolver->invalidateMatchedPropertiesCache();
124 m_resolver->invalidateMatchedPropertiesCache();
125 } 100 }
126 101
127 void StyleEngine::updateGenericFontFamilySettings() 102 void StyleEngine::updateGenericFontFamilySettings()
128 { 103 {
129 // FIXME: we should not update generic font family settings when 104 // FIXME: we should not update generic font family settings when
130 // document is inactive. 105 // document is inactive.
131 ASSERT(m_document->isActive()); 106 ASSERT(m_document->isActive());
132 107
133 m_fontSelector->updateGenericFontFamilySettings(*m_document); 108 m_fontSelector->updateGenericFontFamilySettings(*m_document);
134 if (m_resolver) 109 m_resolver->invalidateMatchedPropertiesCache();
135 m_resolver->invalidateMatchedPropertiesCache();
136 } 110 }
137 111
138 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t) 112 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t)
139 { 113 {
140 RefPtr<CSSStyleSheet> styleSheet; 114 RefPtr<CSSStyleSheet> styleSheet;
141 AtomicString textContent(text); 115 AtomicString textContent(text);
142 116
143 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheet Cache.add(textContent, nullptr); 117 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheet Cache.add(textContent, nullptr);
144 if (result.isNewEntry || !result.storedValue->value) { 118 if (result.isNewEntry || !result.storedValue->value) {
145 styleSheet = CSSStyleSheet::create(e, KURL()); 119 styleSheet = CSSStyleSheet::create(e, KURL());
(...skipping 17 matching lines...) Expand all
163 HashMap<StyleSheetContents*, AtomicString>::iterator it = m_sheetToTextCache .find(contents); 137 HashMap<StyleSheetContents*, AtomicString>::iterator it = m_sheetToTextCache .find(contents);
164 if (it == m_sheetToTextCache.end()) 138 if (it == m_sheetToTextCache.end())
165 return; 139 return;
166 140
167 m_textToSheetCache.remove(it->value); 141 m_textToSheetCache.remove(it->value);
168 m_sheetToTextCache.remove(contents); 142 m_sheetToTextCache.remove(contents);
169 } 143 }
170 144
171 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 145 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
172 { 146 {
173 if (m_resolver) 147 m_resolver->invalidateMatchedPropertiesCache();
174 m_resolver->invalidateMatchedPropertiesCache();
175 m_document->setNeedsStyleRecalc(SubtreeStyleChange); 148 m_document->setNeedsStyleRecalc(SubtreeStyleChange);
176 } 149 }
177 150
178 } 151 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698