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

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

Issue 774953002: Always Reconstruct when stylesheets change. (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') | sky/engine/core/dom/TreeScopeStyleSheetCollection.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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 189 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
190 190
191 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e); 191 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e);
192 ASSERT(collection); 192 ASSERT(collection);
193 collection->removeStyleSheetCandidateNode(node, scopingNode); 193 collection->removeStyleSheetCandidateNode(node, scopingNode);
194 194
195 markTreeScopeDirty(treeScope); 195 markTreeScopeDirty(treeScope);
196 m_activeTreeScopes.remove(&treeScope); 196 m_activeTreeScopes.remove(&treeScope);
197 } 197 }
198 198
199 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo de updateMode) const
200 {
201 return m_documentScopeDirty || updateMode == FullStyleUpdate;
202 }
203
204 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) const
205 {
206 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate;
207 }
208
209 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes) 199 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes)
210 { 200 {
211 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) { 201 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
212 TreeScope& treeScope = **it; 202 TreeScope& treeScope = **it;
213 ASSERT(treeScope != m_document); 203 ASSERT(treeScope != m_document);
214 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(treeScope)); 204 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(treeScope));
215 ASSERT(collection); 205 ASSERT(collection);
216 collection->clearMediaQueryRuleSetStyleSheets(); 206 collection->clearMediaQueryRuleSetStyleSheets();
217 } 207 }
218 } 208 }
219 209
220 void StyleEngine::clearMediaQueryRuleSetStyleSheets() 210 void StyleEngine::clearMediaQueryRuleSetStyleSheets()
221 { 211 {
222 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets(); 212 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets();
223 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); 213 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes);
224 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes); 214 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes);
225 } 215 }
226 216
227 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) 217 void StyleEngine::updateActiveStyleSheets()
228 { 218 {
229 ASSERT(isMaster()); 219 ASSERT(isMaster());
230 ASSERT(!document().inStyleRecalc()); 220 ASSERT(!document().inStyleRecalc());
231 221
232 if (!document().isActive()) 222 if (!document().isActive())
233 return; 223 return;
234 224
235 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) 225 documentStyleSheetCollection()->updateActiveStyleSheets(this);
236 documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode );
237 226
238 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { 227 TreeScopeSet treeScopes = m_activeTreeScopes;
239 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc opes : m_dirtyTreeScopes; 228 HashSet<TreeScope*> treeScopesRemoved;
240 HashSet<TreeScope*> treeScopesRemoved;
241 229
242 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en d(); ++it) { 230 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
243 TreeScope* treeScope = *it; 231 TreeScope* treeScope = *it;
244 ASSERT(treeScope != m_document); 232 ASSERT(treeScope != m_document);
245 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); 233 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(*treeScope));
246 ASSERT(collection); 234 ASSERT(collection);
247 collection->updateActiveStyleSheets(this, updateMode); 235 collection->updateActiveStyleSheets(this);
248 if (!collection->hasStyleSheetCandidateNodes()) 236 if (!collection->hasStyleSheetCandidateNodes())
249 treeScopesRemoved.add(treeScope); 237 treeScopesRemoved.add(treeScope);
250 }
251 m_activeTreeScopes.removeAll(treeScopesRemoved);
252 } 238 }
239 m_activeTreeScopes.removeAll(treeScopesRemoved);
253 240
254 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); 241 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits();
255 242
256 m_dirtyTreeScopes.clear(); 243 m_dirtyTreeScopes.clear();
257 m_documentScopeDirty = false; 244 m_documentScopeDirty = false;
258 } 245 }
259 246
260 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) 247 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot)
261 { 248 {
262 if (shadowRoot->scopedStyleResolver()) 249 if (shadowRoot->scopedStyleResolver())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 unsigned StyleEngine::resolverAccessCount() const 300 unsigned StyleEngine::resolverAccessCount() const
314 { 301 {
315 return m_resolver ? m_resolver->accessCount() : 0; 302 return m_resolver ? m_resolver->accessCount() : 0;
316 } 303 }
317 304
318 void StyleEngine::didDetach() 305 void StyleEngine::didDetach()
319 { 306 {
320 clearResolver(); 307 clearResolver();
321 } 308 }
322 309
323 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) 310 void StyleEngine::resolverChanged()
324 { 311 {
325 if (!isMaster()) { 312 if (!isMaster()) {
326 if (Document* master = this->master()) 313 if (Document* master = this->master())
327 master->styleResolverChanged(mode); 314 master->styleResolverChanged();
328 return; 315 return;
329 } 316 }
330 317
331 // Don't bother updating, since we haven't loaded all our style info yet 318 // Don't bother updating, since we haven't loaded all our style info yet
332 // and haven't calculated the style selector for the first time. 319 // and haven't calculated the style selector for the first time.
333 if (!document().isActive()) { 320 if (!document().isActive()) {
334 clearResolver(); 321 clearResolver();
335 return; 322 return;
336 } 323 }
337 324
338 updateActiveStyleSheets(mode); 325 updateActiveStyleSheets();
339 } 326 }
340 327
341 void StyleEngine::clearFontCache() 328 void StyleEngine::clearFontCache()
342 { 329 {
343 if (m_fontSelector) 330 if (m_fontSelector)
344 m_fontSelector->fontFaceCache()->clearCSSConnected(); 331 m_fontSelector->fontFaceCache()->clearCSSConnected();
345 if (m_resolver) 332 if (m_resolver)
346 m_resolver->invalidateMatchedPropertiesCache(); 333 m_resolver->invalidateMatchedPropertiesCache();
347 } 334 }
348 335
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 { 442 {
456 if (!document().isActive()) 443 if (!document().isActive())
457 return; 444 return;
458 445
459 if (m_resolver) 446 if (m_resolver)
460 m_resolver->invalidateMatchedPropertiesCache(); 447 m_resolver->invalidateMatchedPropertiesCache();
461 document().setNeedsStyleRecalc(SubtreeStyleChange); 448 document().setNeedsStyleRecalc(SubtreeStyleChange);
462 } 449 }
463 450
464 } 451 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/TreeScopeStyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698