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

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

Issue 87503003: Moving fontSelector from StyleResolver to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/StyleEngine.cpp
diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp
index bea7b4954ea14bef55b78a15e653bc42595db129..0c8385f31c7fc5fa5b9d61d60ddb322a616102ea 100644
--- a/Source/core/dom/StyleEngine.cpp
+++ b/Source/core/dom/StyleEngine.cpp
@@ -30,6 +30,7 @@
#include "HTMLNames.h"
#include "SVGNames.h"
+#include "core/css/CSSFontSelector.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/StyleInvalidationAnalysis.h"
#include "core/css/StyleSheetContents.h"
@@ -70,6 +71,9 @@ StyleEngine::StyleEngine(Document& document)
, m_didCalculateResolver(false)
, m_lastResolverAccessCount(0)
, m_resolverThrowawayTimer(this, &StyleEngine::resolverThrowawayTimerFired)
+ // 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) : 0)
{
}
@@ -467,9 +471,11 @@ void StyleEngine::createResolver()
// Document::isActive() before calling into code which could get here.
ASSERT(m_document.frame());
+ ASSERT(m_fontSelector);
m_resolver = adoptPtr(new StyleResolver(m_document));
appendActiveAuthorStyleSheets();
+ m_fontSelector->registerForInvalidationCallbacks(m_resolver.get());
combineCSSFeatureFlags(m_resolver->ensureRuleFeatureSet());
}
@@ -477,6 +483,9 @@ void StyleEngine::clearResolver()
{
ASSERT(!m_document.inStyleRecalc());
ASSERT(isMaster() || !m_resolver);
+ ASSERT(m_fontSelector || !m_resolver);
+ if (m_resolver)
+ m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get());
m_resolver.clear();
}
@@ -498,11 +507,6 @@ void StyleEngine::resolverThrowawayTimerFired(Timer<StyleEngine>*)
m_lastResolverAccessCount = resolverAccessCount();
}
-CSSFontSelector* StyleEngine::fontSelector()
-{
- return m_resolver ? m_resolver->fontSelector() : 0;
-}
-
void StyleEngine::didAttach()
{
m_resolverThrowawayTimer.startRepeating(60);
@@ -546,4 +550,26 @@ StyleResolverChange StyleEngine::resolverChanged(RecalcStyleTime time, StyleReso
return change;
}
+void StyleEngine::resetFontSelector()
+{
+ if (!m_fontSelector)
+ return;
+
+ m_fontSelector->clearDocument();
+ if (m_resolver) {
+ m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get());
+ m_resolver->invalidateMatchedPropertiesCache();
+ }
+
+ // If the document has been already detached, we don't need to recreate
+ // CSSFontSelector.
+ if (m_document.isActive()) {
+ m_fontSelector = CSSFontSelector::create(&m_document);
+ if (m_resolver)
+ m_fontSelector->registerForInvalidationCallbacks(m_resolver.get());
+ } else {
+ m_fontSelector = 0;
+ }
+}
+
}
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698