OLD | NEW |
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 Loading... |
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 findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*>
sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) | 155 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets
) |
156 { | 156 { |
157 bool hasFontFaceRule = false; | |
158 | |
159 for (unsigned i = 0; i < sheets.size(); ++i) { | 157 for (unsigned i = 0; i < sheets.size(); ++i) { |
160 ASSERT(sheets[i]); | 158 ASSERT(sheets[i]); |
161 if (sheets[i]->hasFontFaceRule()) { | 159 if (sheets[i]->hasFontFaceRule()) |
162 // FIXME: We don't need this for styles in shadow tree. | 160 return true; |
163 sheets[i]->findFontFaceRules(fontFaceRules); | |
164 hasFontFaceRule = true; | |
165 } | |
166 } | 161 } |
167 return hasFontFaceRule; | 162 return false; |
| 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; |
168 } | 173 } |
169 | 174 |
170 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change) | 175 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change) |
171 { | 176 { |
172 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) | 177 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) |
173 return; | 178 return; |
174 | 179 |
175 if (updateMode != AnalyzedStyleUpdate) | 180 if (updateMode != AnalyzedStyleUpdate) |
176 return; | 181 return; |
177 | 182 |
178 // Find out which stylesheets are new. | 183 // Find out which stylesheets are new. |
179 Vector<StyleSheetContents*> addedSheets; | 184 Vector<StyleSheetContents*> addedSheets; |
180 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { | 185 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { |
181 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); | 186 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); |
182 } else { | 187 } else { |
183 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); | 188 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); |
184 if (updateType != Additive) { | 189 if (updateType != Additive) { |
185 change.styleResolverUpdateType = updateType; | 190 change.styleResolverUpdateType = updateType; |
186 } else { | 191 } else { |
187 change.styleResolverUpdateType = Reset; | 192 if (styleSheetContentsHasFontFaceRule(addedSheets)) { |
188 // If @font-face is removed, needs full style recalc. | 193 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect
or; |
189 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font
FaceRulesToRemove)) | |
190 return; | 194 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; |
191 } | 204 } |
192 } | 205 } |
193 | 206 |
194 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since | 207 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since |
195 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since | 208 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since |
196 // it only looks at the addedSheets. | 209 // it only looks at the addedSheets. |
197 | 210 |
198 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. | 211 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. |
199 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away | 212 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away |
200 // the StyleResolver if we don't need to. | 213 // the StyleResolver if we don't need to. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 256 } |
244 return false; | 257 return false; |
245 } | 258 } |
246 | 259 |
247 void StyleSheetCollection::updateUsesRemUnits() | 260 void StyleSheetCollection::updateUsesRemUnits() |
248 { | 261 { |
249 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 262 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
250 } | 263 } |
251 | 264 |
252 } | 265 } |
OLD | NEW |