| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 hasActiveLoadingStylesheet = true; | 151 hasActiveLoadingStylesheet = true; |
| 152 } | 152 } |
| 153 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { | 153 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { |
| 154 m_hadActiveLoadingStylesheet = false; | 154 m_hadActiveLoadingStylesheet = false; |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; | 157 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets
) | 161 static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*>
sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) |
| 162 { | 162 { |
| 163 bool hasFontFaceRule = false; |
| 164 |
| 163 for (unsigned i = 0; i < sheets.size(); ++i) { | 165 for (unsigned i = 0; i < sheets.size(); ++i) { |
| 164 ASSERT(sheets[i]); | 166 ASSERT(sheets[i]); |
| 165 if (sheets[i]->hasFontFaceRule()) | 167 if (sheets[i]->hasFontFaceRule()) { |
| 166 return true; | 168 // FIXME: We don't need this for styles in shadow tree. |
| 169 sheets[i]->findFontFaceRules(fontFaceRules); |
| 170 hasFontFaceRule = true; |
| 171 } |
| 167 } | 172 } |
| 168 return false; | 173 return hasFontFaceRule; |
| 169 } | |
| 170 | |
| 171 static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sh
eets) | |
| 172 { | |
| 173 for (unsigned i = 0; i < sheets.size(); ++i) { | |
| 174 ASSERT(sheets[i]); | |
| 175 if (sheets[i]->contents()->hasFontFaceRule()) | |
| 176 return true; | |
| 177 } | |
| 178 return false; | |
| 179 } | 174 } |
| 180 | 175 |
| 181 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change) | 176 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change) |
| 182 { | 177 { |
| 183 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) | 178 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) |
| 184 return; | 179 return; |
| 185 | 180 |
| 186 if (updateMode != AnalyzedStyleUpdate) | 181 if (updateMode != AnalyzedStyleUpdate) |
| 187 return; | 182 return; |
| 188 | 183 |
| 189 // Find out which stylesheets are new. | 184 // Find out which stylesheets are new. |
| 190 Vector<StyleSheetContents*> addedSheets; | 185 Vector<StyleSheetContents*> addedSheets; |
| 191 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { | 186 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { |
| 192 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); | 187 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); |
| 193 } else { | 188 } else { |
| 194 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); | 189 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); |
| 195 if (updateType != Additive) { | 190 if (updateType != Additive) { |
| 196 change.styleResolverUpdateType = updateType; | 191 change.styleResolverUpdateType = updateType; |
| 197 } else { | 192 } else { |
| 198 if (styleSheetContentsHasFontFaceRule(addedSheets)) { | 193 change.styleResolverUpdateType = Reset; |
| 199 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect
or; | 194 // If @font-face is removed, needs full style recalc. |
| 195 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font
FaceRulesToRemove)) |
| 200 return; | 196 return; |
| 201 } | |
| 202 // FIXME: since currently all stylesheets are re-added after resetin
g styleresolver, | |
| 203 // fontSelector should be always reset. After creating RuleSet for e
ach StyleSheetContents, | |
| 204 // we can avoid appending all stylesheetcontents in reset case. | |
| 205 // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)". | |
| 206 if (cssStyleSheetHasFontFaceRule(newCollection.activeAuthorStyleShee
ts())) | |
| 207 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect
or; | |
| 208 else | |
| 209 change.styleResolverUpdateType = Reset; | |
| 210 } | 197 } |
| 211 } | 198 } |
| 212 | 199 |
| 213 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since | 200 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since |
| 214 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since | 201 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since |
| 215 // it only looks at the addedSheets. | 202 // it only looks at the addedSheets. |
| 216 | 203 |
| 217 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. | 204 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. |
| 218 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away | 205 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away |
| 219 // the StyleResolver if we don't need to. | 206 // the StyleResolver if we don't need to. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 249 } |
| 263 return false; | 250 return false; |
| 264 } | 251 } |
| 265 | 252 |
| 266 void StyleSheetCollection::updateUsesRemUnits() | 253 void StyleSheetCollection::updateUsesRemUnits() |
| 267 { | 254 { |
| 268 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 255 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| 269 } | 256 } |
| 270 | 257 |
| 271 } | 258 } |
| OLD | NEW |