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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp

Issue 1913833002: Current work-in-progress crbug.com/567021 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed html import issue. Created 4 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 side-by-side diff with in-line comments
Download patch
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 fa84e9e997b1793540c568ecd97633d14e90c8eb..1bd5732603c926dac2a58fbee5ecf11a67fefc69 100644
--- a/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
@@ -45,7 +45,6 @@ DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope)
}
void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(
- StyleEngine& engine,
DocumentStyleSheetCollector& collector) {
for (Node* n : m_styleSheetCandidateNodes) {
StyleSheetCandidate candidate(*n);
@@ -70,64 +69,37 @@ void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(
continue;
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().ruleSetForSheet(*cssSheet)));
}
}
void DocumentStyleSheetCollection::collectStyleSheets(
- StyleEngine& engine,
DocumentStyleSheetCollector& collector) {
- DCHECK_EQ(&document().styleEngine(), &engine);
- collector.appendActiveStyleSheets(engine.injectedAuthorStyleSheets());
- collectStyleSheetsFromCandidates(engine, collector);
- if (engine.inspectorStyleSheet())
- collector.appendActiveStyleSheet(engine.inspectorStyleSheet());
+ for (auto& sheet : document().styleEngine().injectedAuthorStyleSheets()) {
+ collector.appendActiveStyleSheet(std::make_pair(
+ sheet, document().styleEngine().ruleSetForSheet(*sheet)));
+ }
+ collectStyleSheetsFromCandidates(collector);
+ if (CSSStyleSheet* inspectorSheet =
+ document().styleEngine().inspectorStyleSheet()) {
+ collector.appendActiveStyleSheet(std::make_pair(
+ inspectorSheet,
+ document().styleEngine().ruleSetForSheet(*inspectorSheet)));
+ }
}
-void DocumentStyleSheetCollection::updateActiveStyleSheets(
- StyleEngine& engine,
- StyleResolverUpdateMode updateMode) {
+void DocumentStyleSheetCollection::updateActiveStyleSheets() {
// StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
StyleSheetCollection* collection = StyleSheetCollection::create();
ActiveDocumentStyleSheetCollector collector(*collection);
- collectStyleSheets(engine, collector);
-
- StyleSheetChange change;
- analyzeStyleSheetChange(updateMode, collection->activeAuthorStyleSheets(),
- 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);
- engine.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);
- collection->dispose();
+ collectStyleSheets(collector);
+ applyActiveStyleSheetChanges(*collection);
}
void DocumentStyleSheetCollection::collectViewportRules(

Powered by Google App Engine
This is Rietveld 408576698