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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 12 matching lines...) Expand all
23 * along with this library; see the file COPYING.LIB. If not, write to 23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #include "sky/engine/config.h" 28 #include "sky/engine/config.h"
29 #include "sky/engine/core/dom/StyleEngine.h" 29 #include "sky/engine/core/dom/StyleEngine.h"
30 30
31 #include "sky/engine/core/css/CSSFontSelector.h" 31 #include "sky/engine/core/css/CSSFontSelector.h"
32 #include "sky/engine/core/css/CSSStyleSheet.h" 32 #include "sky/engine/core/css/CSSStyleSheet.h"
33 #include "sky/engine/core/css/FontFace.h"
33 #include "sky/engine/core/css/FontFaceCache.h" 34 #include "sky/engine/core/css/FontFaceCache.h"
34 #include "sky/engine/core/css/StyleSheetContents.h" 35 #include "sky/engine/core/css/StyleSheetContents.h"
35 #include "sky/engine/core/dom/Document.h" 36 #include "sky/engine/core/dom/Document.h"
36 #include "sky/engine/core/dom/Element.h" 37 #include "sky/engine/core/dom/Element.h"
37 #include "sky/engine/core/dom/ElementTraversal.h" 38 #include "sky/engine/core/dom/ElementTraversal.h"
38 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 39 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
39 #include "sky/engine/core/frame/Settings.h" 40 #include "sky/engine/core/frame/Settings.h"
40 #include "sky/engine/core/html/HTMLStyleElement.h" 41 #include "sky/engine/core/html/HTMLStyleElement.h"
41 #include "sky/engine/core/html/imports/HTMLImportsController.h" 42 #include "sky/engine/core/html/imports/HTMLImportsController.h"
42 #include "sky/engine/core/page/Page.h" 43 #include "sky/engine/core/page/Page.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ASSERT(!m_document->inStyleRecalc()); 75 ASSERT(!m_document->inStyleRecalc());
75 ASSERT(m_resolver); 76 ASSERT(m_resolver);
76 77
77 StyleResolver& resolver = m_document->ensureStyleResolver(); 78 StyleResolver& resolver = m_document->ensureStyleResolver();
78 79
79 resolver.resetMediaQueryAffectedByViewportChange(); 80 resolver.resetMediaQueryAffectedByViewportChange();
80 81
81 for (TreeScope* treeScope : m_activeTreeScopes) 82 for (TreeScope* treeScope : m_activeTreeScopes)
82 treeScope->scopedStyleResolver().updateActiveStyleSheets(); 83 treeScope->scopedStyleResolver().updateActiveStyleSheets();
83 84
84 m_document->renderView()->style()->font().update(fontSelector()); 85 updateDocumentFonts();
85 } 86 }
86 87
87 void StyleEngine::resolverChanged() 88 void StyleEngine::resolverChanged()
88 { 89 {
89 if (!m_document->isActive()) 90 if (!m_document->isActive())
90 return; 91 return;
91 updateActiveStyleSheets(); 92 updateActiveStyleSheets();
92 } 93 }
93 94
95 void StyleEngine::updateDocumentFonts()
96 {
97 // TODO(esprehn): We should really support @font-face in ShadowRoot too.
98
99 const auto& sheets = m_document->scopedStyleResolver().authorStyleSheets();
100
101 for (const auto& sheet : sheets) {
102 RuleSet& ruleSet = sheet->contents()->ruleSet();
103 for (const auto& rule : ruleSet.fontFaceRules()) {
104 if (RefPtr<FontFace> fontFace = FontFace::create(m_document, rule))
105 m_fontSelector->fontFaceCache()->add(m_fontSelector.get(), rule, fontFace);
106 }
107 if (!ruleSet.fontFaceRules().isEmpty())
108 m_resolver->invalidateMatchedPropertiesCache();
109 }
110
111 m_document->renderView()->style()->font().update(m_fontSelector.get());
112 }
113
94 void StyleEngine::clearFontCache() 114 void StyleEngine::clearFontCache()
95 { 115 {
96 m_fontSelector->fontFaceCache()->clearCSSConnected(); 116 m_fontSelector->fontFaceCache()->clearCSSConnected();
97 m_resolver->invalidateMatchedPropertiesCache(); 117 m_resolver->invalidateMatchedPropertiesCache();
98 } 118 }
99 119
100 void StyleEngine::updateGenericFontFamilySettings() 120 void StyleEngine::updateGenericFontFamilySettings()
101 { 121 {
102 // FIXME: we should not update generic font family settings when 122 // FIXME: we should not update generic font family settings when
103 // document is inactive. 123 // document is inactive.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 m_sheetToTextCache.remove(contents); 160 m_sheetToTextCache.remove(contents);
141 } 161 }
142 162
143 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 163 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
144 { 164 {
145 m_resolver->invalidateMatchedPropertiesCache(); 165 m_resolver->invalidateMatchedPropertiesCache();
146 m_document->setNeedsStyleRecalc(SubtreeStyleChange); 166 m_document->setNeedsStyleRecalc(SubtreeStyleChange);
147 } 167 }
148 168
149 } 169 }
OLDNEW
« 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