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

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

Issue 2420413005: Collect @viewport before constructing RuleSets. (Closed)
Patch Set: Rebased Created 4 years, 2 months 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/StyleEngine.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
index c056371b2c233b06f2db93f8bc9f27580b36a9b4..531253c4f769e31e74050b4c17570d5048b6a7b0 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -37,6 +37,7 @@
#include "core/css/StyleSheetContents.h"
#include "core/css/invalidation/InvalidationSet.h"
#include "core/css/resolver/ScopedStyleResolver.h"
+#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/DocumentStyleSheetCollector.h"
#include "core/dom/Element.h"
#include "core/dom/ElementTraversal.h"
@@ -64,13 +65,15 @@ StyleEngine::StyleEngine(Document& document)
m_isMaster(!document.importsController() ||
document.importsController()->master() == &document),
m_documentStyleSheetCollection(
- DocumentStyleSheetCollection::create(document)),
- // We don't need to create CSSFontSelector for imported document or
- // HTMLTemplateElement's document, because those documents have no frame.
- m_fontSelector(document.frame() ? CSSFontSelector::create(&document)
- : nullptr) {
- if (m_fontSelector)
+ DocumentStyleSheetCollection::create(document)) {
+ if (document.frame()) {
+ // We don't need to create CSSFontSelector for imported document or
+ // HTMLTemplateElement's document, because those documents have no frame.
+ m_fontSelector = CSSFontSelector::create(&document);
m_fontSelector->registerForInvalidationCallbacks(this);
+ }
+ if (document.isInMainFrame())
+ m_viewportResolver = ViewportStyleResolver::create(document);
}
StyleEngine::~StyleEngine() {}
@@ -393,6 +396,8 @@ void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) {
void StyleEngine::appendActiveAuthorStyleSheets() {
DCHECK(isMaster());
+ viewportRulesChanged();
+
m_resolver->appendAuthorStyleSheets(
documentStyleSheetCollection().activeAuthorStyleSheets());
for (TreeScope* treeScope : m_activeTreeScopes) {
@@ -442,6 +447,7 @@ void StyleEngine::clearMasterResolver() {
void StyleEngine::didDetach() {
clearResolver();
+ m_viewportResolver.clear();
}
bool StyleEngine::shouldClearResolver() const {
@@ -947,6 +953,29 @@ void StyleEngine::ensureFullscreenUAStyle() {
m_resolver->resetRuleFeatures();
}
+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());
+}
+
+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());
+}
+
DEFINE_TRACE(StyleEngine) {
visitor->trace(m_document);
visitor->trace(m_injectedAuthorStyleSheets);
@@ -954,6 +983,7 @@ DEFINE_TRACE(StyleEngine) {
visitor->trace(m_documentStyleSheetCollection);
visitor->trace(m_styleSheetCollectionMap);
visitor->trace(m_resolver);
+ visitor->trace(m_viewportResolver);
visitor->trace(m_styleInvalidator);
visitor->trace(m_dirtyTreeScopes);
visitor->trace(m_activeTreeScopes);
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698