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

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

Issue 23601011: Have StyleResolver / StyleResolverState deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update StyleResolverState as well Created 7 years, 3 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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Stores value=propertySet.getPropertyCSSValue(id).get(). 165 // Stores value=propertySet.getPropertyCSSValue(id).get().
166 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); 166 CSSPropertyValue(CSSPropertyID, const StylePropertySet&);
167 CSSPropertyID property; 167 CSSPropertyID property;
168 CSSValue* value; 168 CSSValue* value;
169 }; 169 };
170 170
171 // This class selects a RenderStyle for a given element based on a collection of stylesheets. 171 // This class selects a RenderStyle for a given element based on a collection of stylesheets.
172 class StyleResolver { 172 class StyleResolver {
173 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; 173 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED;
174 public: 174 public:
175 StyleResolver(Document*, bool matchAuthorAndUserStyles); 175 StyleResolver(Document&, bool matchAuthorAndUserStyles);
176 ~StyleResolver(); 176 ~StyleResolver();
177 177
178 // FIXME: StyleResolver should not be keeping tree-walk state. 178 // FIXME: StyleResolver should not be keeping tree-walk state.
179 // These should move to some global tree-walk state, or should be contained in a 179 // These should move to some global tree-walk state, or should be contained in a
180 // TreeWalkContext or similar which is passed in to StyleResolver methods wh en available. 180 // TreeWalkContext or similar which is passed in to StyleResolver methods wh en available.
181 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups. 181 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
182 void pushParentElement(Element*); 182 void pushParentElement(Element*);
183 void popParentElement(Element*); 183 void popParentElement(Element*);
184 void pushParentShadowRoot(const ShadowRoot*); 184 void pushParentShadowRoot(const ShadowRoot*);
185 void popParentShadowRoot(const ShadowRoot*); 185 void popParentShadowRoot(const ShadowRoot*);
186 186
187 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing, 187 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
188 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0 ); 188 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0 );
189 189
190 // FIXME: The following logic related to animations and keyframes should be factored out of StyleResolver 190 // FIXME: The following logic related to animations and keyframes should be factored out of StyleResolver
191 // The body of calculateCSSAnimationUpdate can move to CSSAnimations.cpp and take just const element, const style, 191 // The body of calculateCSSAnimationUpdate can move to CSSAnimations.cpp and take just const element, const style,
192 // and const ScopedStyleTree 192 // and const ScopedStyleTree
193 void calculateCSSAnimationUpdate(StyleResolverState&); 193 void calculateCSSAnimationUpdate(StyleResolverState&);
194 void resolveKeyframes(const Element*, const RenderStyle*, const StringImpl* animationName, KeyframeAnimationEffect::KeyframeVector&); 194 void resolveKeyframes(const Element*, const RenderStyle*, const StringImpl* animationName, KeyframeAnimationEffect::KeyframeVector&);
195 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&) ; 195 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&) ;
196 const StyleRuleKeyframes* matchScopedKeyframesRule(const Element*, const Str ingImpl* animationName); 196 const StyleRuleKeyframes* matchScopedKeyframesRule(const Element*, const Str ingImpl* animationName);
197 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const StyleKeyframe*); 197 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const StyleKeyframe*);
198 198
199 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle); 199 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle);
200 200
201 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 201 PassRefPtr<RenderStyle> styleForPage(int pageIndex);
202 PassRefPtr<RenderStyle> defaultStyleForElement(); 202 PassRefPtr<RenderStyle> defaultStyleForElement();
203 PassRefPtr<RenderStyle> styleForText(Text*); 203 PassRefPtr<RenderStyle> styleForText(Text*);
204 204
205 static PassRefPtr<RenderStyle> styleForDocument(const Document*, CSSFontSele ctor* = 0); 205 static PassRefPtr<RenderStyle> styleForDocument(const Document&, CSSFontSele ctor* = 0);
206 206
207 // FIXME: This only has 5 callers and should be removed. Callers should be e xplicit about 207 // FIXME: This only has 5 callers and should be removed. Callers should be e xplicit about
208 // their dependency on Document* instead of grabbing one through StyleResolv er. 208 // their dependency on Document* instead of grabbing one through StyleResolv er.
209 Document* document() { return m_document; } 209 Document& document() { return m_document; }
210 210
211 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() di rectly after we factor StyleRsolver further. 211 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() di rectly after we factor StyleRsolver further.
212 // https://bugs.webkit.org/show_bug.cgi?id=108890 212 // https://bugs.webkit.org/show_bug.cgi?id=108890
213 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle Sheet> >&); 213 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle Sheet> >&);
214 void resetAuthorStyle(const ContainerNode*); 214 void resetAuthorStyle(const ContainerNode*);
215 void resetAtHostRules(const ContainerNode*); 215 void resetAtHostRules(const ContainerNode*);
216 void finishAppendAuthorStyleSheets(); 216 void finishAppendAuthorStyleSheets();
217 217
218 DocumentRuleSets& ruleSets() { return m_ruleSets; } 218 DocumentRuleSets& ruleSets() { return m_ruleSets; }
219 const DocumentRuleSets& ruleSets() const { return m_ruleSets; } 219 const DocumentRuleSets& ruleSets() const { return m_ruleSets; }
220 SelectorFilter& selectorFilter() { return m_selectorFilter; } 220 SelectorFilter& selectorFilter() { return m_selectorFilter; }
221 221
222 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB uildInDocumentOrder(enabled); } 222 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB uildInDocumentOrder(enabled); }
223 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI nDocumentOrder(); } 223 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI nDocumentOrder(); }
224 224
225 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope) 225 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope)
226 { 226 {
227 return m_styleTree.ensureScopedStyleResolver(scope ? scope : document()) ; 227 return m_styleTree.ensureScopedStyleResolver(scope ? scope : &document() );
228 } 228 }
229 229
230 // FIXME: Used by SharingStyleFinder, but should be removed. 230 // FIXME: Used by SharingStyleFinder, but should be removed.
231 bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, Rende rStyle*, RuleSet*); 231 bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, Rende rStyle*, RuleSet*);
232 232
233 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element). 233 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element).
234 enum CSSRuleFilter { 234 enum CSSRuleFilter {
235 UAAndUserCSSRules = 1 << 1, 235 UAAndUserCSSRules = 1 << 1,
236 AuthorCSSRules = 1 << 2, 236 AuthorCSSRules = 1 << 2,
237 EmptyCSSRules = 1 << 3, 237 EmptyCSSRules = 1 << 3,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 static inline bool isPropertyForPass(CSSPropertyID); 303 static inline bool isPropertyForPass(CSSPropertyID);
304 template <StyleApplicationPass pass> 304 template <StyleApplicationPass pass>
305 void applyMatchedProperties(StyleResolverState&, const MatchResult&, bool im portant, int startIndex, int endIndex, bool inheritedOnly); 305 void applyMatchedProperties(StyleResolverState&, const MatchResult&, bool im portant, int startIndex, int endIndex, bool inheritedOnly);
306 template <StyleApplicationPass pass> 306 template <StyleApplicationPass pass>
307 void applyProperties(StyleResolverState&, const StylePropertySet* properties , StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = Prop ertyWhitelistNone); 307 void applyProperties(StyleResolverState&, const StylePropertySet* properties , StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = Prop ertyWhitelistNone);
308 template <StyleApplicationPass pass> 308 template <StyleApplicationPass pass>
309 bool applyAnimatedProperties(StyleResolverState&, const DocumentTimeline*); 309 bool applyAnimatedProperties(StyleResolverState&, const DocumentTimeline*);
310 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag e, const String& pageName); 310 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag e, const String& pageName);
311 void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vecto r<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); 311 void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vecto r<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName);
312 void collectViewportRules(); 312 void collectViewportRules();
313 Settings* documentSettings() { return m_document->settings(); } 313 Settings* documentSettings() { return m_document.settings(); }
314 314
315 bool isLeftPage(int pageIndex) const; 315 bool isLeftPage(int pageIndex) const;
316 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } 316 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); }
317 bool isFirstPage(int pageIndex) const; 317 bool isFirstPage(int pageIndex) const;
318 String pageName(int pageIndex) const; 318 String pageName(int pageIndex) const;
319 319
320 DocumentRuleSets m_ruleSets; 320 DocumentRuleSets m_ruleSets;
321 321
322 // FIXME: This likely belongs on RuleSet. 322 // FIXME: This likely belongs on RuleSet.
323 typedef HashMap<StringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap; 323 typedef HashMap<StringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
324 KeyframesRuleMap m_keyframesRuleMap; 324 KeyframesRuleMap m_keyframesRuleMap;
325 325
326 static RenderStyle* s_styleNotYetAvailable; 326 static RenderStyle* s_styleNotYetAvailable;
327 327
328 void cacheBorderAndBackground(); 328 void cacheBorderAndBackground();
329 329
330 MatchedPropertiesCache m_matchedPropertiesCache; 330 MatchedPropertiesCache m_matchedPropertiesCache;
331 331
332 OwnPtr<MediaQueryEvaluator> m_medium; 332 OwnPtr<MediaQueryEvaluator> m_medium;
333 RefPtr<RenderStyle> m_rootDefaultStyle; 333 RefPtr<RenderStyle> m_rootDefaultStyle;
334 334
335 Document* m_document; 335 Document& m_document;
336 SelectorFilter m_selectorFilter; 336 SelectorFilter m_selectorFilter;
337 337
338 bool m_matchAuthorAndUserStyles; 338 bool m_matchAuthorAndUserStyles;
339 339
340 RefPtr<CSSFontSelector> m_fontSelector; 340 RefPtr<CSSFontSelector> m_fontSelector;
341 Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults; 341 Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults;
342 342
343 RefPtr<ViewportStyleResolver> m_viewportStyleResolver; 343 RefPtr<ViewportStyleResolver> m_viewportStyleResolver;
344 344
345 ScopedStyleTree m_styleTree; 345 ScopedStyleTree m_styleTree;
(...skipping 24 matching lines...) Expand all
370 PseudoId ignoreDynamicPseudo = NOPSEUDO; 370 PseudoId ignoreDynamicPseudo = NOPSEUDO;
371 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 371 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
372 return true; 372 return true;
373 } 373 }
374 return false; 374 return false;
375 } 375 }
376 376
377 } // namespace WebCore 377 } // namespace WebCore
378 378
379 #endif // StyleResolver_h 379 #endif // StyleResolver_h
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderCustom.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698