| Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
|
| index a84beaea52080ef05ff4b5f06869307a455d20ac..82e9aae40c61d1999b8464dd24799f9147abb2db 100644
|
| --- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
|
| @@ -151,7 +151,10 @@ CSSStyleSheet& StyleEngine::ensureInspectorStyleSheet() {
|
| StyleSheetContents::create(CSSParserContext(*m_document, nullptr));
|
| m_inspectorStyleSheet = CSSStyleSheet::create(contents, *m_document);
|
| markDocumentDirty();
|
| - resolverChanged(AnalyzedStyleUpdate);
|
| + // TODO(rune@opera.com): Making the active stylesheets up-to-date here is
|
| + // required by some inspector tests, at least. I theory this should not be
|
| + // necessary. Need to investigate to figure out if/why.
|
| + updateActiveStyle();
|
| return *m_inspectorStyleSheet;
|
| }
|
|
|
| @@ -267,13 +270,14 @@ void StyleEngine::mediaQueryAffectingValueChanged(
|
| ShadowTreeStyleSheetCollection* collection =
|
| toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope));
|
| DCHECK(collection);
|
| - collection->clearMediaQueryRuleSetStyleSheets();
|
| + if (collection->mediaQueryAffectingValueChanged())
|
| + setNeedsActiveStyleUpdate(*treeScope);
|
| }
|
| }
|
|
|
| void StyleEngine::mediaQueryAffectingValueChanged() {
|
| - resolverChanged(FullStyleUpdate);
|
| - documentStyleSheetCollection().clearMediaQueryRuleSetStyleSheets();
|
| + if (documentStyleSheetCollection().mediaQueryAffectingValueChanged())
|
| + setNeedsActiveStyleUpdate(document());
|
| mediaQueryAffectingValueChanged(m_activeTreeScopes);
|
| if (m_resolver)
|
| m_resolver->updateMediaType();
|
| @@ -285,19 +289,18 @@ void StyleEngine::updateStyleSheetsInImport(
|
| HeapVector<Member<StyleSheet>> sheetsForList;
|
| ImportedDocumentStyleSheetCollector subcollector(parentCollector,
|
| sheetsForList);
|
| - documentStyleSheetCollection().collectStyleSheets(*this, subcollector);
|
| + documentStyleSheetCollection().collectStyleSheets(subcollector);
|
| documentStyleSheetCollection().swapSheetsForSheetList(sheetsForList);
|
| }
|
|
|
| void StyleEngine::updateActiveStyleSheetsInShadow(
|
| - StyleResolverUpdateMode updateMode,
|
| TreeScope* treeScope,
|
| UnorderedTreeScopeSet& treeScopesRemoved) {
|
| DCHECK_NE(treeScope, m_document);
|
| ShadowTreeStyleSheetCollection* collection =
|
| toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope));
|
| DCHECK(collection);
|
| - collection->updateActiveStyleSheets(*this, updateMode);
|
| + collection->updateActiveStyleSheets();
|
| if (!collection->hasStyleSheetCandidateNodes()) {
|
| treeScopesRemoved.add(treeScope);
|
| // When removing TreeScope from ActiveTreeScopes,
|
| @@ -306,29 +309,28 @@ void StyleEngine::updateActiveStyleSheetsInShadow(
|
| }
|
| }
|
|
|
| -void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) {
|
| +void StyleEngine::updateActiveStyleSheets() {
|
| + if (!needsActiveStyleSheetUpdate())
|
| + return;
|
| +
|
| DCHECK(isMaster());
|
| DCHECK(!document().inStyleRecalc());
|
| -
|
| - if (!document().isActive())
|
| - return;
|
| + DCHECK(document().isActive());
|
|
|
| TRACE_EVENT0("blink,blink_style", "StyleEngine::updateActiveStyleSheets");
|
|
|
| if (shouldUpdateDocumentStyleSheetCollection())
|
| - documentStyleSheetCollection().updateActiveStyleSheets(*this, updateMode);
|
| + documentStyleSheetCollection().updateActiveStyleSheets();
|
|
|
| if (shouldUpdateShadowTreeStyleSheetCollection()) {
|
| UnorderedTreeScopeSet treeScopesRemoved;
|
|
|
| if (m_allTreeScopesDirty) {
|
| for (TreeScope* treeScope : m_activeTreeScopes)
|
| - updateActiveStyleSheetsInShadow(updateMode, treeScope,
|
| - treeScopesRemoved);
|
| + updateActiveStyleSheetsInShadow(treeScope, treeScopesRemoved);
|
| } else {
|
| for (TreeScope* treeScope : m_dirtyTreeScopes)
|
| - updateActiveStyleSheetsInShadow(updateMode, treeScope,
|
| - treeScopesRemoved);
|
| + updateActiveStyleSheetsInShadow(treeScope, treeScopesRemoved);
|
| }
|
| for (TreeScope* treeScope : treeScopesRemoved)
|
| m_activeTreeScopes.remove(treeScope);
|
| @@ -341,31 +343,31 @@ void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) {
|
| m_allTreeScopesDirty = false;
|
| }
|
|
|
| -void StyleEngine::updateActiveStyleSheets() {
|
| - // TODO(rune@opera.com): collect ActiveStyleSheets here.
|
| -}
|
| -
|
| void StyleEngine::updateViewport() {
|
| if (m_viewportResolver)
|
| m_viewportResolver->updateViewport(documentStyleSheetCollection());
|
| }
|
|
|
| bool StyleEngine::needsActiveStyleUpdate() const {
|
| - return m_viewportResolver && m_viewportResolver->needsUpdate();
|
| + return (m_viewportResolver && m_viewportResolver->needsUpdate()) ||
|
| + needsActiveStyleSheetUpdate() || m_globalRuleSet.isDirty();
|
| }
|
|
|
| void StyleEngine::updateActiveStyle() {
|
| + DCHECK(document().isActive());
|
| updateViewport();
|
| updateActiveStyleSheets();
|
| m_globalRuleSet.update(document());
|
| }
|
|
|
| -const HeapVector<Member<CSSStyleSheet>>
|
| -StyleEngine::activeStyleSheetsForInspector() const {
|
| +const ActiveStyleSheetVector StyleEngine::activeStyleSheetsForInspector() {
|
| + if (document().isActive())
|
| + updateActiveStyle();
|
| +
|
| if (m_activeTreeScopes.isEmpty())
|
| return documentStyleSheetCollection().activeAuthorStyleSheets();
|
|
|
| - HeapVector<Member<CSSStyleSheet>> activeStyleSheets;
|
| + ActiveStyleSheetVector activeStyleSheets;
|
|
|
| activeStyleSheets.appendVector(
|
| documentStyleSheetCollection().activeAuthorStyleSheets());
|
| @@ -382,12 +384,6 @@ StyleEngine::activeStyleSheetsForInspector() const {
|
| }
|
|
|
| void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) {
|
| - if (StyleResolver* styleResolver = resolver()) {
|
| - if (TreeScopeStyleSheetCollection* collection =
|
| - styleSheetCollectionFor(*shadowRoot))
|
| - styleResolver->removePendingAuthorStyleSheets(
|
| - collection->activeAuthorStyleSheets());
|
| - }
|
| m_styleSheetCollectionMap.remove(shadowRoot);
|
| m_activeTreeScopes.remove(shadowRoot);
|
| m_dirtyTreeScopes.remove(shadowRoot);
|
| @@ -414,28 +410,6 @@ void StyleEngine::resetAuthorStyle(TreeScope& treeScope) {
|
| treeScope.clearScopedStyleResolver();
|
| }
|
|
|
| -void StyleEngine::finishAppendAuthorStyleSheets() {
|
| - m_globalRuleSet.markDirty();
|
| - m_globalRuleSet.update(document());
|
| -
|
| - if (!document().layoutViewItem().isNull() &&
|
| - document().layoutViewItem().style())
|
| - document().layoutViewItem().style()->font().update(fontSelector());
|
| -}
|
| -
|
| -void StyleEngine::appendActiveAuthorStyleSheets() {
|
| - DCHECK(isMaster());
|
| -
|
| - m_resolver->appendAuthorStyleSheets(
|
| - documentStyleSheetCollection().activeAuthorStyleSheets());
|
| - for (TreeScope* treeScope : m_activeTreeScopes) {
|
| - if (TreeScopeStyleSheetCollection* collection =
|
| - m_styleSheetCollectionMap.get(treeScope))
|
| - m_resolver->appendAuthorStyleSheets(
|
| - collection->activeAuthorStyleSheets());
|
| - }
|
| -}
|
| -
|
| void StyleEngine::setRuleUsageTracker(StyleRuleUsageTracker* tracker) {
|
| m_tracker = tracker;
|
|
|
| @@ -455,13 +429,7 @@ RuleSet* StyleEngine::ruleSetForSheet(CSSStyleSheet& sheet) {
|
|
|
| void StyleEngine::createResolver() {
|
| m_resolver = StyleResolver::create(*m_document);
|
| -
|
| m_resolver->setRuleUsageTracker(m_tracker);
|
| -
|
| - // A scoped style resolver for document will be created during
|
| - // appendActiveAuthorStyleSheets if needed.
|
| - appendActiveAuthorStyleSheets();
|
| - finishAppendAuthorStyleSheets();
|
| }
|
|
|
| void StyleEngine::clearResolver() {
|
| @@ -494,41 +462,12 @@ void StyleEngine::clearResolver() {
|
| }
|
| }
|
|
|
| -void StyleEngine::clearMasterResolver() {
|
| - if (Document* master = this->master())
|
| - master->styleEngine().clearResolver();
|
| -}
|
| -
|
| void StyleEngine::didDetach() {
|
| clearResolver();
|
| m_viewportResolver = nullptr;
|
| m_mediaQueryEvaluator = nullptr;
|
| }
|
|
|
| -bool StyleEngine::shouldClearResolver() const {
|
| - return !m_didCalculateResolver && !haveScriptBlockingStylesheetsLoaded();
|
| -}
|
| -
|
| -void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) {
|
| - if (!isMaster()) {
|
| - if (Document* master = this->master())
|
| - master->styleEngine().resolverChanged(mode);
|
| - return;
|
| - }
|
| -
|
| - // Don't bother updating, since we haven't loaded all our style info yet
|
| - // and haven't calculated the style selector for the first time.
|
| - if (!document().isActive() || shouldClearResolver()) {
|
| - clearResolver();
|
| - return;
|
| - }
|
| -
|
| - if (mode == FullStyleUpdate)
|
| - markAllTreeScopesDirty();
|
| - m_didCalculateResolver = true;
|
| - updateActiveStyleSheets(mode);
|
| -}
|
| -
|
| void StyleEngine::clearFontCache() {
|
| if (m_fontSelector)
|
| m_fontSelector->fontFaceCache()->clearCSSConnected();
|
|
|