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 11 matching lines...) Expand all Loading... |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/dom/StyleSheetCollection.h" | 28 #include "core/dom/StyleSheetCollection.h" |
29 | 29 |
30 #include "core/css/CSSStyleSheet.h" | 30 #include "core/css/CSSStyleSheet.h" |
31 #include "core/css/StyleInvalidationAnalysis.h" | 31 #include "core/css/StyleInvalidationAnalysis.h" |
| 32 #include "core/css/StyleRuleImport.h" |
32 #include "core/css/StyleSheetContents.h" | 33 #include "core/css/StyleSheetContents.h" |
33 #include "core/css/resolver/StyleResolver.h" | 34 #include "core/css/resolver/StyleResolver.h" |
34 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
35 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
36 #include "core/dom/StyleEngine.h" | 37 #include "core/dom/StyleEngine.h" |
37 #include "core/html/HTMLStyleElement.h" | 38 #include "core/html/HTMLStyleElement.h" |
38 #include "core/page/Settings.h" | 39 #include "core/page/Settings.h" |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 hasActiveLoadingStylesheet = true; | 114 hasActiveLoadingStylesheet = true; |
114 } | 115 } |
115 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { | 116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { |
116 m_hadActiveLoadingStylesheet = false; | 117 m_hadActiveLoadingStylesheet = false; |
117 return true; | 118 return true; |
118 } | 119 } |
119 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; | 120 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; |
120 return false; | 121 return false; |
121 } | 122 } |
122 | 123 |
123 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr
<CSSStyleSheet> >& newStyleSheets, StyleResolverUpdateType& styleResolverUpdateT
ype, bool& requiresFullStyleRecalc) | 124 static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets
) |
124 { | 125 { |
125 styleResolverUpdateType = Reconstruct; | 126 for (unsigned i = 0; i < sheets.size(); ++i) { |
126 requiresFullStyleRecalc = true; | 127 ASSERT(sheets[i]); |
| 128 if (sheets[i]->hasFontFaceRule()) |
| 129 return true; |
| 130 } |
| 131 return false; |
| 132 } |
127 | 133 |
| 134 void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
eMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr
<CSSStyleSheet> >& newStyleSheets, StyleSheetChange& change) |
| 135 { |
128 if (activeLoadingStyleSheetLoaded(newStyleSheets)) | 136 if (activeLoadingStyleSheetLoaded(newStyleSheets)) |
129 return; | 137 return; |
130 | 138 |
131 if (updateMode != AnalyzedStyleUpdate) | 139 if (updateMode != AnalyzedStyleUpdate) |
132 return; | 140 return; |
133 if (!document()->styleResolverIfExists()) | 141 if (!document()->styleResolverIfExists()) |
134 return; | 142 return; |
135 | 143 |
136 // Find out which stylesheets are new. | 144 // Find out which stylesheets are new. |
137 Vector<StyleSheetContents*> addedSheets; | 145 Vector<StyleSheetContents*> addedSheets; |
138 if (oldStyleSheets.size() <= newStyleSheets.size()) { | 146 if (oldStyleSheets.size() <= newStyleSheets.size()) { |
139 styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleShe
ets, addedSheets); | 147 change.styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newS
tyleSheets, addedSheets); |
140 } else { | 148 } else { |
141 StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets,
oldStyleSheets, addedSheets); | 149 StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets,
oldStyleSheets, addedSheets); |
142 styleResolverUpdateType = updateType != Additive ? updateType : Reset; | 150 if (updateType != Additive) { |
| 151 change.styleResolverUpdateType = updateType; |
| 152 } else { |
| 153 if (styleSheetContentsHasFontFaceRule(addedSheets)) { |
| 154 change.styleResolverUpdateType = ResetStyleResolverAndFontSelect
or; |
| 155 return; |
| 156 } |
| 157 change.styleResolverUpdateType = Reset; |
| 158 } |
143 } | 159 } |
144 | 160 |
145 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e
arly here | 161 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e
arly here |
146 // as destroying the StyleResolver will recalc the whole document anyway? | 162 // as destroying the StyleResolver will recalc the whole document anyway? |
147 | 163 |
148 // If we are already parsing the body and so may have significant amount of
elements, put some effort into trying to avoid style recalcs. | 164 // If we are already parsing the body and so may have significant amount of
elements, put some effort into trying to avoid style recalcs. |
149 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) | 165 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) |
150 return; | 166 return; |
151 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); | 167 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); |
152 if (invalidationAnalysis.dirtiesAllStyle()) | 168 if (invalidationAnalysis.dirtiesAllStyle()) |
153 return; | 169 return; |
154 invalidationAnalysis.invalidateStyle(*document()); | 170 invalidationAnalysis.invalidateStyle(*document()); |
155 requiresFullStyleRecalc = false; | 171 change.requiresFullStyleRecalc = false; |
| 172 return; |
156 } | 173 } |
157 | 174 |
158 void StyleSheetCollection::resetAllRuleSetsInTreeScope(StyleResolver* styleResol
ver) | 175 void StyleSheetCollection::resetAllRuleSetsInTreeScope(StyleResolver* styleResol
ver) |
159 { | 176 { |
160 // FIXME: If many web developers use style scoped, implement reset RuleSets
in per-scoping node manner. | 177 // FIXME: If many web developers use style scoped, implement reset RuleSets
in per-scoping node manner. |
161 if (DocumentOrderedList* styleScopedScopingNodes = scopingNodesForStyleScope
d()) { | 178 if (DocumentOrderedList* styleScopedScopingNodes = scopingNodesForStyleScope
d()) { |
162 for (DocumentOrderedList::iterator it = styleScopedScopingNodes->begin()
; it != styleScopedScopingNodes->end(); ++it) | 179 for (DocumentOrderedList::iterator it = styleScopedScopingNodes->begin()
; it != styleScopedScopingNodes->end(); ++it) |
163 styleResolver->resetAuthorStyle(toContainerNode(*it)); | 180 styleResolver->resetAuthorStyle(toContainerNode(*it)); |
164 } | 181 } |
165 if (ListHashSet<Node*, 4>* removedNodes = scopingNodesRemoved()) { | 182 if (ListHashSet<Node*, 4>* removedNodes = scopingNodesRemoved()) { |
(...skipping 11 matching lines...) Expand all Loading... |
177 } | 194 } |
178 return false; | 195 return false; |
179 } | 196 } |
180 | 197 |
181 void StyleSheetCollection::updateUsesRemUnits() | 198 void StyleSheetCollection::updateUsesRemUnits() |
182 { | 199 { |
183 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 200 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
184 } | 201 } |
185 | 202 |
186 } | 203 } |
OLD | NEW |