Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: Source/core/css/resolver/ScopedStyleTree.cpp

Issue 415743005: Move ScopedStyleResolver and ScopedStyleTree to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
35 namespace blink { 35 namespace blink {
36 36
37 class StyleSheetContents; 37 class StyleSheetContents;
38 38
39 ScopedStyleTree::ScopedStyleTree() 39 ScopedStyleTree::ScopedStyleTree()
40 { 40 {
41 } 41 }
42 42
43 ScopedStyleTree::~ScopedStyleTree() 43 ScopedStyleTree::~ScopedStyleTree()
44 { 44 {
45 for (HashMap<const ContainerNode*, ScopedStyleResolver*>::iterator it = m_au thorStyles.begin(); it != m_authorStyles.end(); ++it) 45 #if !ENABLE(OILPAN)
46 for (HashMap<RawPtr<const ContainerNode>, RawPtr<ScopedStyleResolver> >::ite rator it = m_authorStyles.begin(); it != m_authorStyles.end(); ++it)
46 it->key->treeScope().clearScopedStyleResolver(); 47 it->key->treeScope().clearScopedStyleResolver();
48 #endif
47 } 49 }
48 50
49 ScopedStyleResolver* ScopedStyleTree::ensureScopedStyleResolver(ContainerNode& s copingNode) 51 ScopedStyleResolver* ScopedStyleTree::ensureScopedStyleResolver(ContainerNode& s copingNode)
50 { 52 {
51 ASSERT(scopingNode.isShadowRoot() || scopingNode.isDocumentNode()); 53 ASSERT(scopingNode.isShadowRoot() || scopingNode.isDocumentNode());
52 54
53 m_authorStyles.add(&scopingNode, &scopingNode.treeScope().ensureScopedStyleR esolver()); 55 m_authorStyles.add(&scopingNode, &scopingNode.treeScope().ensureScopedStyleR esolver());
54 return scopingNode.treeScope().scopedStyleResolver(); 56 return scopingNode.treeScope().scopedStyleResolver();
55 } 57 }
56 58
57 ScopedStyleResolver* ScopedStyleTree::scopedStyleResolverFor(const ContainerNode & scopingNode) 59 ScopedStyleResolver* ScopedStyleTree::scopedStyleResolverFor(const ContainerNode & scopingNode)
58 { 60 {
59 if (!isShadowHost(&scopingNode) 61 if (!isShadowHost(&scopingNode)
60 && !scopingNode.isDocumentNode() 62 && !scopingNode.isDocumentNode()
61 && !scopingNode.isShadowRoot()) 63 && !scopingNode.isShadowRoot())
62 return 0; 64 return 0;
63 return scopingNode.treeScope().scopedStyleResolver(); 65 return scopingNode.treeScope().scopedStyleResolver();
64 } 66 }
65 67
66 void ScopedStyleTree::resolveScopedStyles(const Element* element, Vector<ScopedS tyleResolver*, 8>& resolvers) 68 void ScopedStyleTree::resolveScopedStyles(const Element* element, WillBeHeapVect or<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers)
67 { 69 {
68 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope dResolver; scopedResolver = scopedResolver->parent()) 70 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope dResolver; scopedResolver = scopedResolver->parent())
69 resolvers.append(scopedResolver); 71 resolvers.append(scopedResolver);
70 } 72 }
71 73
72 void ScopedStyleTree::collectScopedResolversForHostedShadowTrees(const Element* element, Vector<ScopedStyleResolver*, 8>& resolvers) 74 void ScopedStyleTree::collectScopedResolversForHostedShadowTrees(const Element* element, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers )
73 { 75 {
74 ElementShadow* shadow = element->shadow(); 76 ElementShadow* shadow = element->shadow();
75 if (!shadow) 77 if (!shadow)
76 return; 78 return;
77 79
78 // Adding scoped resolver for active shadow roots for shadow host styling. 80 // Adding scoped resolver for active shadow roots for shadow host styling.
79 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad owRoot = shadowRoot->olderShadowRoot()) { 81 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad owRoot = shadowRoot->olderShadowRoot()) {
80 if (shadowRoot->numberOfStyles() > 0) { 82 if (shadowRoot->numberOfStyles() > 0) {
81 if (ScopedStyleResolver* resolver = scopedStyleResolverFor(*shadowRo ot)) 83 if (ScopedStyleResolver* resolver = scopedStyleResolverFor(*shadowRo ot))
82 resolvers.append(resolver); 84 resolvers.append(resolver);
83 } 85 }
84 } 86 }
85 } 87 }
86 88
87 void ScopedStyleTree::resolveScopedKeyframesRules(const Element* element, Vector <ScopedStyleResolver*, 8>& resolvers) 89 void ScopedStyleTree::resolveScopedKeyframesRules(const Element* element, WillBe HeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers)
88 { 90 {
89 Document& document = element->document(); 91 Document& document = element->document();
90 TreeScope& treeScope = element->treeScope(); 92 TreeScope& treeScope = element->treeScope();
91 bool applyAuthorStyles = treeScope.applyAuthorStyles(); 93 bool applyAuthorStyles = treeScope.applyAuthorStyles();
92 94
93 // Add resolvers for shadow roots hosted by the given element. 95 // Add resolvers for shadow roots hosted by the given element.
94 collectScopedResolversForHostedShadowTrees(element, resolvers); 96 collectScopedResolversForHostedShadowTrees(element, resolvers);
95 97
96 // Add resolvers while walking up DOM tree from the given element. 98 // Add resolvers while walking up DOM tree from the given element.
97 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope dResolver; scopedResolver = scopedResolver->parent()) { 99 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope dResolver; scopedResolver = scopedResolver->parent()) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return; 139 return;
138 140
139 if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopi ngNode) 141 if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopi ngNode)
140 m_cache.scopedResolver = m_cache.scopedResolver->parent(); 142 m_cache.scopedResolver = m_cache.scopedResolver->parent();
141 m_cache.nodeForScopedStyles = scopingNode.parentOrShadowHostNode(); 143 m_cache.nodeForScopedStyles = scopingNode.parentOrShadowHostNode();
142 } 144 }
143 145
144 void ScopedStyleTree::collectFeaturesTo(RuleFeatureSet& features) 146 void ScopedStyleTree::collectFeaturesTo(RuleFeatureSet& features)
145 { 147 {
146 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; 148 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents;
147 for (HashMap<const ContainerNode*, ScopedStyleResolver*>::iterator it = m_au thorStyles.begin(); it != m_authorStyles.end(); ++it) 149 for (WillBeHeapHashMap<RawPtrWillBeMember<const ContainerNode>, RawPtrWillBe Member<ScopedStyleResolver> >::iterator it = m_authorStyles.begin(); it != m_aut horStyles.end(); ++it)
148 it->value->collectFeaturesTo(features, visitedSharedStyleSheetContents); 150 it->value->collectFeaturesTo(features, visitedSharedStyleSheetContents);
149 } 151 }
150 152
151 void ScopedStyleTree::remove(const ContainerNode* scopingNode) 153 void ScopedStyleTree::remove(const ContainerNode* scopingNode)
152 { 154 {
153 if (!scopingNode || scopingNode->isDocumentNode()) 155 if (!scopingNode || scopingNode->isDocumentNode())
154 return; 156 return;
155 157
156 ScopedStyleResolver* resolver = scopingNode->treeScope().scopedStyleResolver (); 158 ScopedStyleResolver* resolver = scopingNode->treeScope().scopedStyleResolver ();
157 if (!resolver) 159 if (!resolver)
158 return; 160 return;
159 161
160 if (m_cache.scopedResolver == resolver) 162 if (m_cache.scopedResolver == resolver)
161 m_cache.clear(); 163 m_cache.clear();
162 164
163 // resolver is going to be freed below. 165 // resolver is going to be freed below.
164 resolver = 0; 166 resolver = 0;
165 m_authorStyles.remove(scopingNode); 167 m_authorStyles.remove(scopingNode);
166 scopingNode->treeScope().clearScopedStyleResolver(); 168 scopingNode->treeScope().clearScopedStyleResolver();
167 } 169 }
168 170
171 void ScopedStyleTree::trace(Visitor* visitor)
172 {
173 visitor->trace(m_authorStyles);
174 visitor->trace(m_cache);
175 }
176
169 } // namespace blink 177 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698