OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/css/resolver/ScopedStyleTree.h" | 28 #include "core/css/resolver/ScopedStyleTree.h" |
29 | 29 |
30 #include "core/css/RuleFeature.h" | 30 #include "core/css/RuleFeature.h" |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/shadow/ElementShadow.h" | 32 #include "core/dom/shadow/ElementShadow.h" |
33 #include "core/dom/shadow/ShadowRoot.h" | 33 #include "core/dom/shadow/ShadowRoot.h" |
34 | 34 |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
| 37 class StyleSheetContents; |
| 38 |
37 ScopedStyleResolver* ScopedStyleTree::ensureScopedStyleResolver(ContainerNode& s
copingNode) | 39 ScopedStyleResolver* ScopedStyleTree::ensureScopedStyleResolver(ContainerNode& s
copingNode) |
38 { | 40 { |
39 bool isNewEntry; | 41 bool isNewEntry; |
40 ScopedStyleResolver* scopedStyleResolver = addScopedStyleResolver(scopingNod
e, isNewEntry); | 42 ScopedStyleResolver* scopedStyleResolver = addScopedStyleResolver(scopingNod
e, isNewEntry); |
41 if (isNewEntry) | 43 if (isNewEntry) |
42 setupScopedStylesTree(scopedStyleResolver); | 44 setupScopedStylesTree(scopedStyleResolver); |
43 return scopedStyleResolver; | 45 return scopedStyleResolver; |
44 } | 46 } |
45 | 47 |
46 ScopedStyleResolver* ScopedStyleTree::scopedStyleResolverFor(const ContainerNode
& scopingNode) | 48 ScopedStyleResolver* ScopedStyleTree::scopedStyleResolverFor(const ContainerNode
& scopingNode) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (!cacheIsValid(&scopingNode)) | 186 if (!cacheIsValid(&scopingNode)) |
185 return; | 187 return; |
186 | 188 |
187 if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopi
ngNode) | 189 if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopi
ngNode) |
188 m_cache.scopedResolver = m_cache.scopedResolver->parent(); | 190 m_cache.scopedResolver = m_cache.scopedResolver->parent(); |
189 m_cache.nodeForScopedStyles = scopingNode.parentOrShadowHostNode(); | 191 m_cache.nodeForScopedStyles = scopingNode.parentOrShadowHostNode(); |
190 } | 192 } |
191 | 193 |
192 void ScopedStyleTree::collectFeaturesTo(RuleFeatureSet& features) | 194 void ScopedStyleTree::collectFeaturesTo(RuleFeatureSet& features) |
193 { | 195 { |
| 196 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; |
194 for (HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> >::iterator i
t = m_authorStyles.begin(); it != m_authorStyles.end(); ++it) | 197 for (HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> >::iterator i
t = m_authorStyles.begin(); it != m_authorStyles.end(); ++it) |
195 it->value->collectFeaturesTo(features); | 198 it->value->collectFeaturesTo(features, visitedSharedStyleSheetContents); |
196 } | 199 } |
197 | 200 |
198 inline void ScopedStyleTree::reparentNodes(const ScopedStyleResolver* oldParent,
ScopedStyleResolver* newParent) | 201 inline void ScopedStyleTree::reparentNodes(const ScopedStyleResolver* oldParent,
ScopedStyleResolver* newParent) |
199 { | 202 { |
200 // FIXME: this takes O(N) (N = number of all scoping nodes). | 203 // FIXME: this takes O(N) (N = number of all scoping nodes). |
201 for (HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> >::iterator i
t = m_authorStyles.begin(); it != m_authorStyles.end(); ++it) { | 204 for (HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> >::iterator i
t = m_authorStyles.begin(); it != m_authorStyles.end(); ++it) { |
202 if (it->value->parent() == oldParent) | 205 if (it->value->parent() == oldParent) |
203 it->value->setParent(newParent); | 206 it->value->setParent(newParent); |
204 } | 207 } |
205 } | 208 } |
206 | 209 |
207 void ScopedStyleTree::remove(const ContainerNode* scopingNode) | 210 void ScopedStyleTree::remove(const ContainerNode* scopingNode) |
208 { | 211 { |
209 if (!scopingNode || scopingNode->isDocumentNode()) | 212 if (!scopingNode || scopingNode->isDocumentNode()) |
210 return; | 213 return; |
211 | 214 |
212 ScopedStyleResolver* resolverRemoved = lookupScopedStyleResolverFor(scopingN
ode); | 215 ScopedStyleResolver* resolverRemoved = lookupScopedStyleResolverFor(scopingN
ode); |
213 if (!resolverRemoved) | 216 if (!resolverRemoved) |
214 return; | 217 return; |
215 | 218 |
216 reparentNodes(resolverRemoved, resolverRemoved->parent()); | 219 reparentNodes(resolverRemoved, resolverRemoved->parent()); |
217 if (m_cache.scopedResolver == resolverRemoved) | 220 if (m_cache.scopedResolver == resolverRemoved) |
218 m_cache.clear(); | 221 m_cache.clear(); |
219 | 222 |
220 m_authorStyles.remove(scopingNode); | 223 m_authorStyles.remove(scopingNode); |
221 } | 224 } |
222 | 225 |
223 } // namespace WebCore | 226 } // namespace WebCore |
OLD | NEW |