| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets
) | 124 static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*>
sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) |
| 125 { | 125 { |
| 126 bool hasFontFaceRule = false; |
| 127 |
| 126 for (unsigned i = 0; i < sheets.size(); ++i) { | 128 for (unsigned i = 0; i < sheets.size(); ++i) { |
| 127 ASSERT(sheets[i]); | 129 ASSERT(sheets[i]); |
| 128 if (sheets[i]->hasFontFaceRule()) | 130 if (sheets[i]->hasFontFaceRule()) { |
| 129 return true; | 131 // FIXME: We don't need this for styles in shadow tree. |
| 132 sheets[i]->findFontFaceRules(fontFaceRules); |
| 133 hasFontFaceRule = true; |
| 134 } |
| 130 } | 135 } |
| 131 return false; | 136 return hasFontFaceRule; |
| 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; | |
| 142 } | 137 } |
| 143 | 138 |
| 144 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM
ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha
nge) | 139 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM
ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha
nge) |
| 145 { | 140 { |
| 146 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) | 141 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) |
| 147 return; | 142 return; |
| 148 | 143 |
| 149 if (updateMode != AnalyzedStyleUpdate) | 144 if (updateMode != AnalyzedStyleUpdate) |
| 150 return; | 145 return; |
| 151 | 146 |
| 152 // Find out which stylesheets are new. | 147 // Find out which stylesheets are new. |
| 153 Vector<StyleSheetContents*> addedSheets; | 148 Vector<StyleSheetContents*> addedSheets; |
| 154 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { | 149 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet
s().size()) { |
| 155 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); | 150 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS
heets, newCollection.activeAuthorStyleSheets(), addedSheets); |
| 156 } else { | 151 } else { |
| 157 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); | 152 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac
tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); |
| 158 if (updateType != Additive) { | 153 if (updateType != Additive) { |
| 159 change.styleResolverUpdateType = updateType; | 154 change.styleResolverUpdateType = updateType; |
| 160 } else { | 155 } else { |
| 161 if (styleSheetContentsHasFontFaceRule(addedSheets)) { | 156 change.styleResolverUpdateType = Reset; |
| 162 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect
or; | 157 // If @font-face is removed, needs full style recalc. |
| 158 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font
FaceRulesToRemove)) |
| 163 return; | 159 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; | |
| 173 } | 160 } |
| 174 } | 161 } |
| 175 | 162 |
| 176 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since | 163 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early
here since |
| 177 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since | 164 // we need to recalc the whole document. It's wrong to use StyleInvalidation
Analysis since |
| 178 // it only looks at the addedSheets. | 165 // it only looks at the addedSheets. |
| 179 | 166 |
| 180 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. | 167 // No point in doing the analysis work if we're just going to recalc the who
le document anyways. |
| 181 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away | 168 // This needs to be done after the compareStyleSheets calls above to ensure
we don't throw away |
| 182 // the StyleResolver if we don't need to. | 169 // the StyleResolver if we don't need to. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 212 } |
| 226 return false; | 213 return false; |
| 227 } | 214 } |
| 228 | 215 |
| 229 void TreeScopeStyleSheetCollection::updateUsesRemUnits() | 216 void TreeScopeStyleSheetCollection::updateUsesRemUnits() |
| 230 { | 217 { |
| 231 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| 232 } | 219 } |
| 233 | 220 |
| 234 } | 221 } |
| OLD | NEW |