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

Side by Side Diff: Source/core/css/resolver/ScopedStyleResolver.h

Issue 16194002: Make ScopedStyleResolver use apply-author-styles of a given element's treescope. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rewrite layout test Created 7 years, 6 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope); 113 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope);
114 ScopedStyleResolver* scopedStyleResolverFor(const ContainerNode* scope); 114 ScopedStyleResolver* scopedStyleResolverFor(const ContainerNode* scope);
115 ScopedStyleResolver* addScopedStyleResolver(const ContainerNode* scope, bool & isNewEntry); 115 ScopedStyleResolver* addScopedStyleResolver(const ContainerNode* scope, bool & isNewEntry);
116 void clear(); 116 void clear();
117 117
118 // for fast-path. 118 // for fast-path.
119 bool hasOnlyScopeResolverForDocument() const { return m_scopeResolverForDocu ment && m_authorStyles.size() == 1; } 119 bool hasOnlyScopeResolverForDocument() const { return m_scopeResolverForDocu ment && m_authorStyles.size() == 1; }
120 ScopedStyleResolver* scopedStyleResolverForDocument() { return m_scopeResolv erForDocument; } 120 ScopedStyleResolver* scopedStyleResolverForDocument() { return m_scopeResolv erForDocument; }
121 121
122 void resolveScopeStyles(const Element*, Vector<std::pair<ScopedStyleResolver *, bool>, 8>& resolvers); 122 void resolveScopeStyles(const Element*, Vector<ScopedStyleResolver*, 8>&);
123 ScopedStyleResolver* scopedResolverFor(const Element*); 123 ScopedStyleResolver* scopedResolverFor(const Element*);
124 124
125 void pushStyleCache(const ContainerNode* scope, const ContainerNode* parent) ; 125 void pushStyleCache(const ContainerNode* scope, const ContainerNode* parent) ;
126 void popStyleCache(const ContainerNode* scope); 126 void popStyleCache(const ContainerNode* scope);
127 127
128 void collectFeaturesTo(RuleFeatureSet& features); 128 void collectFeaturesTo(RuleFeatureSet& features);
129 129
130 void reportMemoryUsage(MemoryObjectInfo*) const; 130 void reportMemoryUsage(MemoryObjectInfo*) const;
131 private: 131 private:
132 void setupScopeStylesTree(ScopedStyleResolver* target); 132 void setupScopeStylesTree(ScopedStyleResolver* target);
133 133
134 bool cacheIsValid(const ContainerNode* parent) const { return parent && pare nt == m_cache.nodeForScopeStyles; } 134 bool cacheIsValid(const ContainerNode* parent) const { return parent && pare nt == m_cache.nodeForScopeStyles; }
135 void resolveStyleCache(const ContainerNode* scope); 135 void resolveStyleCache(const ContainerNode* scope);
136 ScopedStyleResolver* enclosingScopedStyleResolverFor(const ContainerNode* sc ope, int& authorStyleBoundsIndex); 136 ScopedStyleResolver* enclosingScopedStyleResolverFor(const ContainerNode* sc ope);
137 137
138 private: 138 private:
139 HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> > m_authorStyles; 139 HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> > m_authorStyles;
140 ScopedStyleResolver* m_scopeResolverForDocument; 140 ScopedStyleResolver* m_scopeResolverForDocument;
141 141
142 struct ScopeStyleCache { 142 struct ScopeStyleCache {
143 ScopedStyleResolver* scopeResolver; 143 ScopedStyleResolver* scopeResolver;
144 int scopeResolverBoundsIndex;
145 const ContainerNode* nodeForScopeStyles; 144 const ContainerNode* nodeForScopeStyles;
146 int authorStyleBoundsIndex;
147 145
148 void clear() 146 void clear()
149 { 147 {
150 scopeResolver = 0; 148 scopeResolver = 0;
151 scopeResolverBoundsIndex = 0;
152 nodeForScopeStyles = 0; 149 nodeForScopeStyles = 0;
153 authorStyleBoundsIndex = 0;
154 } 150 }
155 }; 151 };
156 ScopeStyleCache m_cache; 152 ScopeStyleCache m_cache;
157 }; 153 };
158 154
159 inline ScopedStyleResolver* ScopedStyleTree::scopedResolverFor(const Element* el ement) 155 inline ScopedStyleResolver* ScopedStyleTree::scopedResolverFor(const Element* el ement)
160 { 156 {
161 if (!cacheIsValid(element)) 157 if (!cacheIsValid(element))
162 resolveStyleCache(element); 158 resolveStyleCache(element);
163 159
164 return m_cache.scopeResolver; 160 return m_cache.scopeResolver;
165 } 161 }
166 162
167 } // namespace WebCore 163 } // namespace WebCore
168 164
169 #endif // ScopedStyleResolver_h 165 #endif // ScopedStyleResolver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698