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

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

Issue 2484863003: Make updateStyleAndLayoutTree ready for async stylesheet update. (Closed)
Patch Set: Rebased Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4c3682279b8f7b5f6a07fc55edee45a08a6da56e..00b7648b4e1a7bca2d65b40d050a4bec99821368 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -119,6 +119,16 @@ TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(
const HeapVector<TraceWrapperMember<StyleSheet>>&
StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope) {
+ // TODO(rune@opera.com): we could split styleSheets and active stylesheet
+ // update to have a lighter update while accessing the styleSheets list.
+ DCHECK(master());
+ if (master()->isActive()) {
+ if (isMaster())
+ updateActiveStyle();
+ else
+ master()->styleEngine().updateActiveStyle();
+ }
+
if (treeScope == m_document)
return documentStyleSheetCollection().styleSheetsForStyleSheetList();
@@ -333,6 +343,25 @@ void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) {
m_documentScopeDirty = 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();
+}
+
+void StyleEngine::updateActiveStyle() {
+ updateViewport();
+ updateActiveStyleSheets();
+ m_globalRuleSet.update(document());
+}
+
const HeapVector<Member<CSSStyleSheet>>
StyleEngine::activeStyleSheetsForInspector() const {
if (m_activeTreeScopes.isEmpty())
@@ -399,8 +428,6 @@ void StyleEngine::finishAppendAuthorStyleSheets() {
void StyleEngine::appendActiveAuthorStyleSheets() {
DCHECK(isMaster());
- viewportRulesChanged();
-
m_resolver->appendAuthorStyleSheets(
documentStyleSheetCollection().activeAuthorStyleSheets());
for (TreeScope* treeScope : m_activeTreeScopes) {
@@ -536,6 +563,8 @@ void StyleEngine::markTreeScopeDirty(TreeScope& scope) {
void StyleEngine::markDocumentDirty() {
m_documentScopeDirty = true;
+ if (RuntimeEnabledFeatures::cssViewportEnabled())
+ viewportRulesChanged();
if (document().importLoader())
document().importsController()->master()->styleEngine().markDocumentDirty();
}
@@ -998,26 +1027,13 @@ bool StyleEngine::hasRulesForId(const AtomicString& id) const {
}
void StyleEngine::initialViewportChanged() {
- if (!m_viewportResolver)
- return;
-
- m_viewportResolver->initialViewportChanged();
-
- // TODO(rune@opera.com): for async stylesheet update, updateViewport() should
- // be called as part of the lifecycle update for active style. Synchronous for
- // now.
- m_viewportResolver->updateViewport(documentStyleSheetCollection());
+ if (m_viewportResolver)
+ m_viewportResolver->initialViewportChanged();
}
void StyleEngine::viewportRulesChanged() {
- if (!m_viewportResolver)
- return;
- m_viewportResolver->setNeedsCollectRules();
-
- // TODO(rune@opera.com): for async stylesheet update, updateViewport() should
- // be called as part of the lifecycle update for active style. Synchronous for
- // now.
- m_viewportResolver->updateViewport(documentStyleSheetCollection());
+ if (m_viewportResolver)
+ m_viewportResolver->setNeedsCollectRules();
}
PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle(
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698