Chromium Code Reviews| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { | 117 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { |
| 118 m_hadActiveLoadingStylesheet = false; | 118 m_hadActiveLoadingStylesheet = false; |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; | 121 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets ) | 125 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets ) |
| 126 { | 126 { |
| 127 for (unsigned i = 0; i < sheets.size(); ++i) { | 127 for (unsigned i = 0; i < sheets.size(); ++i) { |
| 128 ASSERT(sheets[i]); | 128 ASSERT(sheets[i]); |
| 129 if (sheets[i]->hasFontFaceRule()) | 129 if (sheets[i]->hasFontFaceRule()) |
| 130 return true; | 130 return true; |
| 131 } | 131 } |
| 132 return false; | 132 return false; |
| 133 } | 133 } |
| 134 | 134 |
| 135 static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sh eets) | |
| 136 { | |
| 137 for (unsigned i = 0; i < sheets.size(); ++i) { | |
| 138 ASSERT(sheets[i]); | |
| 139 if (sheets[i]->contents()->hasFontFaceRule()) | |
| 140 return true; | |
| 141 } | |
| 142 return false; | |
| 143 } | |
| 144 | |
| 135 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat eMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr <CSSStyleSheet> >& newStyleSheets, StyleSheetChange& change) | 145 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat eMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr <CSSStyleSheet> >& newStyleSheets, StyleSheetChange& change) |
| 136 { | 146 { |
| 137 if (activeLoadingStyleSheetLoaded(newStyleSheets)) | 147 if (activeLoadingStyleSheetLoaded(newStyleSheets)) |
| 138 return; | 148 return; |
| 139 | 149 |
| 140 if (updateMode != AnalyzedStyleUpdate) | 150 if (updateMode != AnalyzedStyleUpdate) |
| 141 return; | 151 return; |
| 142 if (!document()->styleResolverIfExists()) | 152 if (!document()->styleResolverIfExists()) |
| 143 return; | 153 return; |
| 144 | 154 |
| 145 // Find out which stylesheets are new. | 155 // Find out which stylesheets are new. |
| 146 Vector<StyleSheetContents*> addedSheets; | 156 Vector<StyleSheetContents*> addedSheets; |
| 147 if (oldStyleSheets.size() <= newStyleSheets.size()) { | 157 if (oldStyleSheets.size() <= newStyleSheets.size()) { |
| 148 change.styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newS tyleSheets, addedSheets); | 158 change.styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newS tyleSheets, addedSheets); |
| 149 } else { | 159 } else { |
| 150 StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets, oldStyleSheets, addedSheets); | 160 StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets, oldStyleSheets, addedSheets); |
| 151 if (updateType != Additive) { | 161 if (updateType != Additive) { |
| 152 change.styleResolverUpdateType = updateType; | 162 change.styleResolverUpdateType = updateType; |
| 153 } else { | 163 } else { |
| 154 if (styleSheetContentsHasFontFaceRule(addedSheets)) { | 164 // FIXME: since currently all stylesheets are re-added after resetin g styleresolver, |
| 165 // fontSelector should be always reset. After creating RuleSet for e ach StyleSheetContents, | |
| 166 // we can avoid appending all stylesheetcontents in reset case. | |
| 167 // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)". | |
| 168 if (styleSheetContentsHasFontFaceRule(addedSheets) || cssStyleSheetH asFontFaceRule(newStyleSheets)) { | |
| 155 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; | 169 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; |
| 156 return; | 170 return; |
| 157 } | 171 } |
|
tasak
2013/11/15 15:22:29
I found that the following code is better:
if (st
| |
| 158 change.styleResolverUpdateType = Reset; | 172 change.styleResolverUpdateType = Reset; |
| 159 } | 173 } |
| 160 } | 174 } |
| 161 | 175 |
| 162 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e arly here | 176 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e arly here |
| 163 // as destroying the StyleResolver will recalc the whole document anyway? | 177 // as destroying the StyleResolver will recalc the whole document anyway? |
| 164 | 178 |
| 165 // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs. | 179 // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs. |
| 166 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) | 180 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) |
| 167 return; | 181 return; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 195 } | 209 } |
| 196 return false; | 210 return false; |
| 197 } | 211 } |
| 198 | 212 |
| 199 void StyleSheetCollection::updateUsesRemUnits() | 213 void StyleSheetCollection::updateUsesRemUnits() |
| 200 { | 214 { |
| 201 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 215 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| 202 } | 216 } |
| 203 | 217 |
| 204 } | 218 } |
| OLD | NEW |