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

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

Issue 157853002: Revert of Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/TreeScopeStyleSheetCollection.h ('k') | Source/core/frame/Settings.h » ('j') | 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, 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 hasActiveLoadingStylesheet = true; 114 hasActiveLoadingStylesheet = true;
115 } 115 }
116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
117 m_hadActiveLoadingStylesheet = false; 117 m_hadActiveLoadingStylesheet = false;
118 return true; 118 return true;
119 } 119 }
120 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 120 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
121 return false; 121 return false;
122 } 122 }
123 123
124 static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*> sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) 124 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets )
125 { 125 {
126 bool hasFontFaceRule = false;
127
128 for (unsigned i = 0; i < sheets.size(); ++i) { 126 for (unsigned i = 0; i < sheets.size(); ++i) {
129 ASSERT(sheets[i]); 127 ASSERT(sheets[i]);
130 if (sheets[i]->hasFontFaceRule()) { 128 if (sheets[i]->hasFontFaceRule())
131 // FIXME: We don't need this for styles in shadow tree. 129 return true;
132 sheets[i]->findFontFaceRules(fontFaceRules);
133 hasFontFaceRule = true;
134 }
135 } 130 }
136 return hasFontFaceRule; 131 return false;
132 }
133
134 static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sh eets)
135 {
136 for (unsigned i = 0; i < sheets.size(); ++i) {
137 ASSERT(sheets[i]);
138 if (sheets[i]->contents()->hasFontFaceRule())
139 return true;
140 }
141 return false;
137 } 142 }
138 143
139 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge) 144 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge)
140 { 145 {
141 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) 146 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
142 return; 147 return;
143 148
144 if (updateMode != AnalyzedStyleUpdate) 149 if (updateMode != AnalyzedStyleUpdate)
145 return; 150 return;
146 151
147 // Find out which stylesheets are new. 152 // Find out which stylesheets are new.
148 Vector<StyleSheetContents*> addedSheets; 153 Vector<StyleSheetContents*> addedSheets;
149 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) { 154 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) {
150 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets); 155 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets);
151 } else { 156 } else {
152 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); 157 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
153 if (updateType != Additive) { 158 if (updateType != Additive) {
154 change.styleResolverUpdateType = updateType; 159 change.styleResolverUpdateType = updateType;
155 } else { 160 } else {
156 change.styleResolverUpdateType = Reset; 161 if (styleSheetContentsHasFontFaceRule(addedSheets)) {
157 // If @font-face is removed, needs full style recalc. 162 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or;
158 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove))
159 return; 163 return;
164 }
165 // FIXME: since currently all stylesheets are re-added after resetin g styleresolver,
166 // fontSelector should be always reset. After creating RuleSet for e ach StyleSheetContents,
167 // we can avoid appending all stylesheetcontents in reset case.
168 // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)".
169 if (cssStyleSheetHasFontFaceRule(newCollection.activeAuthorStyleShee ts()))
170 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or;
171 else
172 change.styleResolverUpdateType = Reset;
160 } 173 }
161 } 174 }
162 175
163 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since 176 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since
164 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since 177 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since
165 // it only looks at the addedSheets. 178 // it only looks at the addedSheets.
166 179
167 // No point in doing the analysis work if we're just going to recalc the who le document anyways. 180 // No point in doing the analysis work if we're just going to recalc the who le document anyways.
168 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away 181 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away
169 // the StyleResolver if we don't need to. 182 // the StyleResolver if we don't need to.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 225 }
213 return false; 226 return false;
214 } 227 }
215 228
216 void TreeScopeStyleSheetCollection::updateUsesRemUnits() 229 void TreeScopeStyleSheetCollection::updateUsesRemUnits()
217 { 230 {
218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); 231 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
219 } 232 }
220 233
221 } 234 }
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScopeStyleSheetCollection.h ('k') | Source/core/frame/Settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698