Index: third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp |
diff --git a/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp b/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp |
index 7558369fd2e0fc9709b130fb0c88d59c9e98bf3b..69e62a48e3255270e421098081dad8c1c1ccc7d5 100644 |
--- a/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp |
+++ b/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp |
@@ -26,7 +26,9 @@ |
#include "core/dom/DocumentStyleSheetCollection.h" |
+#include "core/css/StyleSheetContents.h" |
#include "core/css/resolver/StyleResolver.h" |
+#include "core/css/resolver/ViewportStyleResolver.h" |
#include "core/dom/Document.h" |
#include "core/dom/DocumentStyleSheetCollector.h" |
#include "core/dom/ProcessingInstruction.h" |
@@ -43,7 +45,30 @@ DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope) |
DCHECK_EQ(treeScope.rootNode(), treeScope.rootNode().document()); |
} |
-void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine& engine, DocumentStyleSheetCollector& collector) |
+void DocumentStyleSheetCollection::updateViewport() |
+{ |
+ ViewportStyleResolver& resolver = document().styleEngine().ensureViewportStyleResolver(); |
+ |
+ resolver.reset(); |
+ resolver.collectViewportRulesFromUASheets(); |
+ |
+ for (Node* node : m_styleSheetCandidateNodes) { |
+ StyleSheetCandidate candidate(*node); |
+ |
+ if (candidate.isImport()) |
+ continue; |
+ StyleSheet* sheet = candidate.sheet(); |
+ if (!sheet) |
+ continue; |
+ if (!candidate.canBeActivated(document().styleEngine().preferredStylesheetSetName())) |
+ continue; |
+ resolver.collectViewportRulesFromAuthorSheet(*toCSSStyleSheet(sheet)); |
+ } |
+ |
+ resolver.resolve(); |
+} |
+ |
+void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(DocumentStyleSheetCollector& collector) |
{ |
for (Node* n : m_styleSheetCandidateNodes) { |
StyleSheetCandidate candidate(*n); |
@@ -60,64 +85,37 @@ void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine& |
continue; |
} |
- if (candidate.isEnabledAndLoading()) { |
- // it is loading but we should still decide which style sheet set to use |
- if (candidate.hasPreferrableName()) |
- engine.setPreferredStylesheetSetNameIfNotSet(candidate.title()); |
+ if (candidate.isEnabledAndLoading()) |
continue; |
- } |
StyleSheet* sheet = candidate.sheet(); |
if (!sheet) |
continue; |
- if (candidate.hasPreferrableName()) |
- engine.setPreferredStylesheetSetNameIfNotSet(candidate.title()); |
collector.appendSheetForList(sheet); |
- if (candidate.canBeActivated(engine.preferredStylesheetSetName())) |
- collector.appendActiveStyleSheet(toCSSStyleSheet(sheet)); |
+ |
+ if (!candidate.canBeActivated(document().styleEngine().preferredStylesheetSetName())) |
+ continue; |
+ |
+ CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); |
+ collector.appendActiveStyleSheet(std::make_pair(cssSheet, &document().styleEngine().ensureRuleSetForSheet(*cssSheet))); |
} |
} |
-void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine& engine, DocumentStyleSheetCollector& collector) |
+void DocumentStyleSheetCollection::collectStyleSheets(DocumentStyleSheetCollector& collector) |
{ |
- DCHECK_EQ(&document().styleEngine(), &engine); |
- collector.appendActiveStyleSheets(engine.injectedAuthorStyleSheets()); |
- collectStyleSheetsFromCandidates(engine, collector); |
+ for (auto& sheet : document().styleEngine().injectedAuthorStyleSheets()) |
+ collector.appendActiveStyleSheet(std::make_pair(sheet, &document().styleEngine().ensureRuleSetForSheet(*sheet))); |
+ |
+ collectStyleSheetsFromCandidates(collector); |
} |
-void DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine& engine, StyleResolverUpdateMode updateMode) |
+void DocumentStyleSheetCollection::updateActiveStyleSheets() |
{ |
StyleSheetCollection collection; |
ActiveDocumentStyleSheetCollector collector(collection); |
- collectStyleSheets(engine, collector); |
- |
- StyleSheetChange change; |
- analyzeStyleSheetChange(updateMode, collection, change); |
- |
- if (change.styleResolverUpdateType == Reconstruct) { |
- engine.clearMasterResolver(); |
- // TODO(rune@opera.com): The following depends on whether StyleRuleFontFace was modified or not. |
- // We should only remove modified/removed @font-face rules, or @font-face rules from removed |
- // stylesheets. We currently avoid clearing the font cache when we have had an analyzed update |
- // and no @font-face rules were removed, in which case requiresFullStyleRecalc will be false. |
- if (change.requiresFullStyleRecalc) |
- engine.clearFontCache(); |
- } else if (StyleResolver* styleResolver = engine.resolver()) { |
- if (change.styleResolverUpdateType != Additive) { |
- DCHECK_EQ(change.styleResolverUpdateType, Reset); |
- styleResolver->resetAuthorStyle(treeScope()); |
- engine.removeFontFaceRules(change.fontFaceRulesToRemove); |
- styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets); |
- styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAuthorStyleSheets()); |
- } else { |
- styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets()); |
- } |
- } |
- if (change.requiresFullStyleRecalc) |
- document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ActiveStylesheetsUpdate)); |
- |
- collection.swap(*this); |
+ collectStyleSheets(collector); |
+ applyActiveStyleSheetChanges(collection); |
} |
DEFINE_TRACE_WRAPPERS(DocumentStyleSheetCollection) |