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

Side by Side Diff: Source/core/dom/StyleSheetCollection.cpp

Issue 82583005: Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added 2 layout tests 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 unified diff | Download patch | Annotate | Revision Log
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, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 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) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 hasActiveLoadingStylesheet = true; 145 hasActiveLoadingStylesheet = true;
146 } 146 }
147 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 147 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
148 m_hadActiveLoadingStylesheet = false; 148 m_hadActiveLoadingStylesheet = false;
149 return true; 149 return true;
150 } 150 }
151 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 151 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
152 return false; 152 return false;
153 } 153 }
154 154
155 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets ) 155 static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*> sheets, Vector<const StyleRuleFontFace*>& fontFaceRules)
156 { 156 {
157 bool hasFontFaceRule = false;
158
157 for (unsigned i = 0; i < sheets.size(); ++i) { 159 for (unsigned i = 0; i < sheets.size(); ++i) {
158 ASSERT(sheets[i]); 160 ASSERT(sheets[i]);
159 if (sheets[i]->hasFontFaceRule()) 161 if (sheets[i]->hasFontFaceRule()) {
160 return true; 162 // FIXME: We don't need this for styles in shadow tree.
163 sheets[i]->findFontFaceRules(fontFaceRules);
164 hasFontFaceRule = true;
165 }
161 } 166 }
162 return false; 167 return hasFontFaceRule;
163 }
164
165 static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sh eets)
166 {
167 for (unsigned i = 0; i < sheets.size(); ++i) {
168 ASSERT(sheets[i]);
169 if (sheets[i]->contents()->hasFontFaceRule())
170 return true;
171 }
172 return false;
173 } 168 }
174 169
175 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change) 170 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change)
176 { 171 {
177 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) 172 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
178 return; 173 return;
179 174
180 if (updateMode != AnalyzedStyleUpdate) 175 if (updateMode != AnalyzedStyleUpdate)
181 return; 176 return;
182 177
183 // Find out which stylesheets are new. 178 // Find out which stylesheets are new.
184 Vector<StyleSheetContents*> addedSheets; 179 Vector<StyleSheetContents*> addedSheets;
185 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) { 180 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) {
186 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets); 181 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets);
187 } else { 182 } else {
188 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); 183 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
189 if (updateType != Additive) { 184 if (updateType != Additive) {
190 change.styleResolverUpdateType = updateType; 185 change.styleResolverUpdateType = updateType;
191 } else { 186 } else {
192 if (styleSheetContentsHasFontFaceRule(addedSheets)) { 187 change.styleResolverUpdateType = Reset;
193 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; 188 // If @font-face is removed, needs full style recalc.
189 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove))
194 return; 190 return;
195 }
196 // FIXME: since currently all stylesheets are re-added after resetin g styleresolver,
197 // fontSelector should be always reset. After creating RuleSet for e ach StyleSheetContents,
198 // we can avoid appending all stylesheetcontents in reset case.
199 // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)".
200 if (cssStyleSheetHasFontFaceRule(newCollection.activeAuthorStyleShee ts()))
201 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or;
202 else
203 change.styleResolverUpdateType = Reset;
204 } 191 }
205 } 192 }
206 193
207 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since 194 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since
208 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since 195 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since
209 // it only looks at the addedSheets. 196 // it only looks at the addedSheets.
210 197
211 // No point in doing the analysis work if we're just going to recalc the who le document anyways. 198 // No point in doing the analysis work if we're just going to recalc the who le document anyways.
212 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away 199 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away
213 // the StyleResolver if we don't need to. 200 // the StyleResolver if we don't need to.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 243 }
257 return false; 244 return false;
258 } 245 }
259 246
260 void StyleSheetCollection::updateUsesRemUnits() 247 void StyleSheetCollection::updateUsesRemUnits()
261 { 248 {
262 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); 249 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
263 } 250 }
264 251
265 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698