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

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

Issue 812593004: Remove dirtyTreeScopes tracking code from StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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') | no next file » | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 { 98 {
99 if (treeScope == m_document) 99 if (treeScope == m_document)
100 return documentStyleSheetCollection(); 100 return documentStyleSheetCollection();
101 101
102 StyleSheetCollectionMap::iterator it = m_styleSheetCollectionMap.find(&treeS cope); 102 StyleSheetCollectionMap::iterator it = m_styleSheetCollectionMap.find(&treeS cope);
103 if (it == m_styleSheetCollectionMap.end()) 103 if (it == m_styleSheetCollectionMap.end())
104 return 0; 104 return 0;
105 return it->value.get(); 105 return it->value.get();
106 } 106 }
107 107
108 void StyleEngine::modifiedStyleSheet(CSSStyleSheet* sheet)
109 {
110 if (!sheet)
111 return;
112
113 Node* node = sheet->ownerNode();
114 if (!node || !node->inDocument())
115 return;
116
117 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument;
118 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
119
120 markTreeScopeDirty(treeScope);
121 }
122
123 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) 108 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser)
124 { 109 {
125 if (!node->inDocument()) 110 if (!node->inDocument())
126 return; 111 return;
127 112
128 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; 113 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument;
129 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 114 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
130 StyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope); 115 StyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope);
131 ASSERT(collection); 116 ASSERT(collection);
132 collection->addStyleSheetCandidateNode(node, createdByParser); 117 collection->addStyleSheetCandidateNode(node, createdByParser);
133 118
134 markTreeScopeDirty(treeScope);
135 if (treeScope != m_document) 119 if (treeScope != m_document)
136 m_activeTreeScopes.add(&treeScope); 120 m_activeTreeScopes.add(&treeScope);
137 } 121 }
138 122
139 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope) 123 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope)
140 { 124 {
141 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 125 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
142 126
143 StyleSheetCollection* collection = styleSheetCollectionFor(treeScope); 127 StyleSheetCollection* collection = styleSheetCollectionFor(treeScope);
144 ASSERT(collection); 128 ASSERT(collection);
145 collection->removeStyleSheetCandidateNode(node, scopingNode); 129 collection->removeStyleSheetCandidateNode(node, scopingNode);
146 130
147 markTreeScopeDirty(treeScope);
148 m_activeTreeScopes.remove(&treeScope); 131 m_activeTreeScopes.remove(&treeScope);
149 } 132 }
150 133
151 void StyleEngine::updateActiveStyleSheets() 134 void StyleEngine::updateActiveStyleSheets()
152 { 135 {
153 ASSERT(!m_document->inStyleRecalc()); 136 ASSERT(!m_document->inStyleRecalc());
154 137
155 if (!m_document->isActive()) 138 if (!m_document->isActive())
156 return; 139 return;
157 140
158 documentStyleSheetCollection()->updateActiveStyleSheets(this); 141 documentStyleSheetCollection()->updateActiveStyleSheets(this);
159 142
160 TreeScopeSet treeScopes = m_activeTreeScopes; 143 TreeScopeSet treeScopes = m_activeTreeScopes;
161 HashSet<TreeScope*> treeScopesRemoved; 144 HashSet<TreeScope*> treeScopesRemoved;
162 145
163 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) { 146 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
164 TreeScope* treeScope = *it; 147 TreeScope* treeScope = *it;
165 ASSERT(treeScope != m_document); 148 ASSERT(treeScope != m_document);
166 StyleSheetCollection* collection = styleSheetCollectionFor(*treeScope); 149 StyleSheetCollection* collection = styleSheetCollectionFor(*treeScope);
167 ASSERT(collection); 150 ASSERT(collection);
168 collection->updateActiveStyleSheets(this); 151 collection->updateActiveStyleSheets(this);
169 if (!collection->hasStyleSheetCandidateNodes()) 152 if (!collection->hasStyleSheetCandidateNodes())
170 treeScopesRemoved.add(treeScope); 153 treeScopesRemoved.add(treeScope);
171 } 154 }
172 m_activeTreeScopes.removeAll(treeScopesRemoved); 155 m_activeTreeScopes.removeAll(treeScopesRemoved);
173
174 m_dirtyTreeScopes.clear();
175 } 156 }
176 157
177 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) 158 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot)
178 { 159 {
179 m_styleSheetCollectionMap.remove(shadowRoot); 160 m_styleSheetCollectionMap.remove(shadowRoot);
180 } 161 }
181 162
182 void StyleEngine::appendActiveAuthorStyleSheets() 163 void StyleEngine::appendActiveAuthorStyleSheets()
183 { 164 {
184 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu thorStyleSheets()); 165 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu thorStyleSheets());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (!m_fontSelector) 241 if (!m_fontSelector)
261 return; 242 return;
262 243
263 FontFaceCache* cache = m_fontSelector->fontFaceCache(); 244 FontFaceCache* cache = m_fontSelector->fontFaceCache();
264 for (unsigned i = 0; i < fontFaceRules.size(); ++i) 245 for (unsigned i = 0; i < fontFaceRules.size(); ++i)
265 cache->remove(fontFaceRules[i]); 246 cache->remove(fontFaceRules[i]);
266 if (m_resolver) 247 if (m_resolver)
267 m_resolver->invalidateMatchedPropertiesCache(); 248 m_resolver->invalidateMatchedPropertiesCache();
268 } 249 }
269 250
270 void StyleEngine::markTreeScopeDirty(TreeScope& scope)
271 {
272 // TODO(esprehn): Make document not special.
273 if (scope == m_document)
274 return;
275 m_dirtyTreeScopes.add(&scope);
276 }
277
278 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t) 251 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t)
279 { 252 {
280 RefPtr<CSSStyleSheet> styleSheet; 253 RefPtr<CSSStyleSheet> styleSheet;
281 AtomicString textContent(text); 254 AtomicString textContent(text);
282 255
283 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheet Cache.add(textContent, nullptr); 256 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheet Cache.add(textContent, nullptr);
284 if (result.isNewEntry || !result.storedValue->value) { 257 if (result.isNewEntry || !result.storedValue->value) {
285 styleSheet = CSSStyleSheet::create(e, KURL()); 258 styleSheet = CSSStyleSheet::create(e, KURL());
286 styleSheet->contents()->parseString(text); 259 styleSheet->contents()->parseString(text);
287 if (result.isNewEntry) { 260 if (result.isNewEntry) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 299 }
327 300
328 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 301 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
329 { 302 {
330 if (m_resolver) 303 if (m_resolver)
331 m_resolver->invalidateMatchedPropertiesCache(); 304 m_resolver->invalidateMatchedPropertiesCache();
332 m_document->setNeedsStyleRecalc(SubtreeStyleChange); 305 m_document->setNeedsStyleRecalc(SubtreeStyleChange);
333 } 306 }
334 307
335 } 308 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698