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 if (styleSheetContentsHasFontFaceRule(addedSheets)) { |
155 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; | 165 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; |
156 return; | 166 return; |
157 } | 167 } |
168 // FIXME: since currently all stylesheets are re-added after resetin g styleresolver, | |
169 // fontSelector should be always reset. After creating RuleSet for e ach StyleSheetContents, | |
170 // we can avoid appending all stylesheetcontents in reset case. | |
ojan
2013/11/21 00:57:48
I'm hoping that once this is done we can get rid o
tasak
2013/11/22 05:16:25
Yeah, I think, this patch is a temporary one.
| |
171 // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)". | |
172 if (cssStyleSheetHasFontFaceRule(newStyleSheets)) | |
173 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect or; | |
158 change.styleResolverUpdateType = Reset; | 174 change.styleResolverUpdateType = Reset; |
ojan
2013/11/22 01:08:54
Hmmm...not lgtm actually. Now that I look more clo
tasak
2013/11/22 05:16:25
Yeah, It's my fault.
I'm now trying to land the f
| |
159 } | 175 } |
160 } | 176 } |
161 | 177 |
162 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e arly here | 178 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e arly here |
163 // as destroying the StyleResolver will recalc the whole document anyway? | 179 // as destroying the StyleResolver will recalc the whole document anyway? |
164 | 180 |
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. | 181 // 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()) | 182 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) |
167 return; | 183 return; |
168 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); | 184 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); |
(...skipping 26 matching lines...) Expand all Loading... | |
195 } | 211 } |
196 return false; | 212 return false; |
197 } | 213 } |
198 | 214 |
199 void StyleSheetCollection::updateUsesRemUnits() | 215 void StyleSheetCollection::updateUsesRemUnits() |
200 { | 216 { |
201 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 217 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
202 } | 218 } |
203 | 219 |
204 } | 220 } |
OLD | NEW |