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

Unified Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 851873002: Move @font-face logic from ScopedStyleResolver to StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/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: sky/engine/core/dom/StyleEngine.cpp
diff --git a/sky/engine/core/dom/StyleEngine.cpp b/sky/engine/core/dom/StyleEngine.cpp
index fedaeb6e2566a1d6a35eeab188006306045a1bb2..895edc0d66779b58622d7309a1ed993949eb197e 100644
--- a/sky/engine/core/dom/StyleEngine.cpp
+++ b/sky/engine/core/dom/StyleEngine.cpp
@@ -30,6 +30,7 @@
#include "sky/engine/core/css/CSSFontSelector.h"
#include "sky/engine/core/css/CSSStyleSheet.h"
+#include "sky/engine/core/css/FontFace.h"
#include "sky/engine/core/css/FontFaceCache.h"
#include "sky/engine/core/css/StyleSheetContents.h"
#include "sky/engine/core/dom/Document.h"
@@ -81,7 +82,7 @@ void StyleEngine::updateActiveStyleSheets()
for (TreeScope* treeScope : m_activeTreeScopes)
treeScope->scopedStyleResolver().updateActiveStyleSheets();
- m_document->renderView()->style()->font().update(fontSelector());
+ updateDocumentFonts();
}
void StyleEngine::resolverChanged()
@@ -91,6 +92,25 @@ void StyleEngine::resolverChanged()
updateActiveStyleSheets();
}
+void StyleEngine::updateDocumentFonts()
+{
+ // TODO(esprehn): We should really support @font-face in ShadowRoot too.
+
+ const auto& sheets = m_document->scopedStyleResolver().authorStyleSheets();
+
+ for (const auto& sheet : sheets) {
+ RuleSet& ruleSet = sheet->contents()->ruleSet();
+ for (const auto& rule : ruleSet.fontFaceRules()) {
+ if (RefPtr<FontFace> fontFace = FontFace::create(m_document, rule))
+ m_fontSelector->fontFaceCache()->add(m_fontSelector.get(), rule, fontFace);
+ }
+ if (!ruleSet.fontFaceRules().isEmpty())
+ m_resolver->invalidateMatchedPropertiesCache();
+ }
+
+ m_document->renderView()->style()->font().update(m_fontSelector.get());
+}
+
void StyleEngine::clearFontCache()
{
m_fontSelector->fontFaceCache()->clearCSSConnected();
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698