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 |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) |
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
9 * Copyright (C) 2013 Google Inc. All rights reserved. | 11 * Copyright (C) 2013 Google Inc. All rights reserved. |
10 * | 12 * |
11 * This library is free software; you can redistribute it and/or | 13 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 14 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 15 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 16 * version 2 of the License, or (at your option) any later version. |
15 * | 17 * |
16 * This library is distributed in the hope that it will be useful, | 18 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return Reconstruct; | 71 return Reconstruct; |
70 } | 72 } |
71 if (++newIndex == newStyleSheetCount) | 73 if (++newIndex == newStyleSheetCount) |
72 return Reconstruct; | 74 return Reconstruct; |
73 } | 75 } |
74 bool hasInsertions = !addedSheets.isEmpty(); | 76 bool hasInsertions = !addedSheets.isEmpty(); |
75 while (newIndex < newStyleSheetCount) { | 77 while (newIndex < newStyleSheetCount) { |
76 addedSheets.append(newStylesheets[newIndex]->contents()); | 78 addedSheets.append(newStylesheets[newIndex]->contents()); |
77 ++newIndex; | 79 ++newIndex; |
78 } | 80 } |
79 // If all new sheets were added at the end of the list we can just add them to
existing StyleResolver. | 81 // If all new sheets were added at the end of the list we can just add them to |
80 // If there were insertions we need to re-add all the stylesheets so rules are
ordered correctly. | 82 // existing StyleResolver. If there were insertions we need to re-add all the |
| 83 // stylesheets so rules are ordered correctly. |
81 return hasInsertions ? Reset : Additive; | 84 return hasInsertions ? Reset : Additive; |
82 } | 85 } |
83 | 86 |
84 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded( | 87 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded( |
85 const HeapVector<Member<CSSStyleSheet>>& newStyleSheets) { | 88 const HeapVector<Member<CSSStyleSheet>>& newStyleSheets) { |
86 // StyleSheets of <style> elements that @import stylesheets are active but loa
ding. We need to trigger a full recalc when such loads are done. | 89 // StyleSheets of <style> elements that @import stylesheets are active but |
| 90 // loading. We need to trigger a full recalc when such loads are done. |
87 bool hasActiveLoadingStylesheet = false; | 91 bool hasActiveLoadingStylesheet = false; |
88 unsigned newStylesheetCount = newStyleSheets.size(); | 92 unsigned newStylesheetCount = newStyleSheets.size(); |
89 for (unsigned i = 0; i < newStylesheetCount; ++i) { | 93 for (unsigned i = 0; i < newStylesheetCount; ++i) { |
90 if (newStyleSheets[i]->isLoading()) | 94 if (newStyleSheets[i]->isLoading()) |
91 hasActiveLoadingStylesheet = true; | 95 hasActiveLoadingStylesheet = true; |
92 } | 96 } |
93 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { | 97 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { |
94 m_hadActiveLoadingStylesheet = false; | 98 m_hadActiveLoadingStylesheet = false; |
95 return true; | 99 return true; |
96 } | 100 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 change.styleResolverUpdateType = updateType; | 140 change.styleResolverUpdateType = updateType; |
137 } else { | 141 } else { |
138 change.styleResolverUpdateType = Reset; | 142 change.styleResolverUpdateType = Reset; |
139 // If @font-face is removed, needs full style recalc. | 143 // If @font-face is removed, needs full style recalc. |
140 if (findFontFaceRulesFromStyleSheetContents(addedSheets, | 144 if (findFontFaceRulesFromStyleSheetContents(addedSheets, |
141 change.fontFaceRulesToRemove)) | 145 change.fontFaceRulesToRemove)) |
142 return; | 146 return; |
143 } | 147 } |
144 } | 148 } |
145 | 149 |
146 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early he
re since | 150 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early |
147 // we need to recalc the whole document. It's wrong to use StyleSheetInvalidat
ionAnalysis since | 151 // here since we need to recalc the whole document. It's wrong to use |
148 // it only looks at the addedSheets. | 152 // StyleSheetInvalidationAnalysis since it only looks at the addedSheets. |
149 | 153 |
150 // No point in doing the analysis work if we're just going to recalc the whole
document anyways. | 154 // No point in doing the analysis work if we're just going to recalc the whole |
151 // This needs to be done after the compareStyleSheets calls above to ensure we
don't throw away | 155 // document anyways. This needs to be done after the compareStyleSheets calls |
152 // the StyleResolver if we don't need to. | 156 // above to ensure we don't throw away the StyleResolver if we don't need to. |
153 if (document().hasPendingForcedStyleRecalc()) | 157 if (document().hasPendingForcedStyleRecalc()) |
154 return; | 158 return; |
155 | 159 |
156 // If we are already parsing the body and so may have significant amount of el
ements, put some effort into trying to avoid style recalcs. | 160 // If we are already parsing the body and so may have significant amount of |
| 161 // elements, put some effort into trying to avoid style recalcs. |
157 if (!document().body() || document().hasNodesWithPlaceholderStyle()) | 162 if (!document().body() || document().hasNodesWithPlaceholderStyle()) |
158 return; | 163 return; |
159 StyleSheetInvalidationAnalysis invalidationAnalysis(*m_treeScope, | 164 StyleSheetInvalidationAnalysis invalidationAnalysis(*m_treeScope, |
160 addedSheets); | 165 addedSheets); |
161 if (invalidationAnalysis.dirtiesAllStyle()) | 166 if (invalidationAnalysis.dirtiesAllStyle()) |
162 return; | 167 return; |
163 invalidationAnalysis.invalidateStyle(); | 168 invalidationAnalysis.invalidateStyle(); |
164 change.requiresFullStyleRecalc = false; | 169 change.requiresFullStyleRecalc = false; |
165 return; | 170 return; |
166 } | 171 } |
167 | 172 |
168 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() { | 173 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() { |
169 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { | 174 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { |
170 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); | 175 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); |
171 if (contents->hasMediaQueries()) | 176 if (contents->hasMediaQueries()) |
172 contents->clearRuleSet(); | 177 contents->clearRuleSet(); |
173 } | 178 } |
174 } | 179 } |
175 | 180 |
176 DEFINE_TRACE(TreeScopeStyleSheetCollection) { | 181 DEFINE_TRACE(TreeScopeStyleSheetCollection) { |
177 visitor->trace(m_treeScope); | 182 visitor->trace(m_treeScope); |
178 visitor->trace(m_styleSheetCandidateNodes); | 183 visitor->trace(m_styleSheetCandidateNodes); |
179 StyleSheetCollection::trace(visitor); | 184 StyleSheetCollection::trace(visitor); |
180 } | 185 } |
181 | 186 |
182 } // namespace blink | 187 } // namespace blink |
OLD | NEW |