void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) { ASSERT(isMaster()); ASSERT(!document().inStyleRecalc()); if (!document().isActive()) return; if (shouldUpdateDocumentStyleSheetCollection(updateMode)) documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode); if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeScopes : m_dirtyTreeScopes; HashSet<TreeScope*> treeScopesRemoved; for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) { TreeScope* treeScope = *it; ASSERT(treeScope != m_document); ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); ASSERT(collection); collection->updateActiveStyleSheets(this, updateMode); if (!collection->hasStyleSheetCandidateNodes()) treeScopesRemoved.add(treeScope); } m_activeTreeScopes.removeAll(treeScopesRemoved); } InspectorInstrumentation::activeStyleSheetsUpdated(m_document); m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); m_dirtyTreeScopes.clear(); m_documentScopeDirty = false; }
void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode updateMode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved) { ASSERT(treeScope != m_document); ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); ASSERT(collection); collection->updateActiveStyleSheets(*this, updateMode); if (!collection->hasStyleSheetCandidateNodes()) { treeScopesRemoved.add(treeScope); // When removing TreeScope from ActiveTreeScopes, // its resolver should be destroyed by invoking resetAuthorStyle. ASSERT(!treeScope->scopedStyleResolver()); } }
bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) { ASSERT(isMaster()); ASSERT(!m_document.inStyleRecalc()); if (!m_document.isActive()) return false; bool requiresFullStyleRecalc = false; if (m_documentScopeDirty || updateMode == FullStyleUpdate) requiresFullStyleRecalc = m_documentStyleSheetCollection.updateActiveStyleSheets(this, updateMode); if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeScopes : m_dirtyTreeScopes; HashSet<TreeScope*> treeScopesRemoved; for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) { TreeScope* treeScope = *it; ASSERT(treeScope != m_document); ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); ASSERT(collection); collection->updateActiveStyleSheets(this, updateMode); if (!collection->hasStyleSheetCandidateNodes()) treeScopesRemoved.add(treeScope); } if (!treeScopesRemoved.isEmpty()) for (HashSet<TreeScope*>::iterator it = treeScopesRemoved.begin(); it != treeScopesRemoved.end(); ++it) m_activeTreeScopes.remove(*it); } InspectorInstrumentation::activeStyleSheetsUpdated(&m_document); m_usesRemUnits = m_documentStyleSheetCollection.usesRemUnits(); m_dirtyTreeScopes.clear(); m_documentScopeDirty = false; return requiresFullStyleRecalc; }