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

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

Issue 15871005: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing comments. 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
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 StyleResolver(Document*, bool matchAuthorAndUserStyles); 141 StyleResolver(Document*, bool matchAuthorAndUserStyles);
142 ~StyleResolver(); 142 ~StyleResolver();
143 143
144 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups. 144 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
145 void pushParentElement(Element*); 145 void pushParentElement(Element*);
146 void popParentElement(Element*); 146 void popParentElement(Element*);
147 void pushParentShadowRoot(const ShadowRoot*); 147 void pushParentShadowRoot(const ShadowRoot*);
148 void popParentShadowRoot(const ShadowRoot*); 148 void popParentShadowRoot(const ShadowRoot*);
149 149
150 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing, 150 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
151 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0 ); 151 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0 , int childIndex = 0);
152
153 // childIndex's origin is 1, and avoids unnecessary tree walks to resolve nt h/nth-last selectors.
154 PassRefPtr<RenderStyle> styleForElement(Element* element, int childIndex)
155 {
156 return styleForElement(element, 0, AllowStyleSharing, MatchAllRules, 0, childIndex);
157 }
152 158
153 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&) ; 159 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&) ;
154 160
155 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle); 161 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle);
156 162
157 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 163 PassRefPtr<RenderStyle> styleForPage(int pageIndex);
158 PassRefPtr<RenderStyle> defaultStyleForElement(); 164 PassRefPtr<RenderStyle> defaultStyleForElement();
159 PassRefPtr<RenderStyle> styleForText(Text*); 165 PassRefPtr<RenderStyle> styleForText(Text*);
160 166
161 static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0); 167 static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0);
(...skipping 17 matching lines...) Expand all
179 DocumentRuleSets& ruleSets() { return m_ruleSets; } 185 DocumentRuleSets& ruleSets() { return m_ruleSets; }
180 const DocumentRuleSets& ruleSets() const { return m_ruleSets; } 186 const DocumentRuleSets& ruleSets() const { return m_ruleSets; }
181 SelectorFilter& selectorFilter() { return m_selectorFilter; } 187 SelectorFilter& selectorFilter() { return m_selectorFilter; }
182 188
183 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope) 189 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope)
184 { 190 {
185 return m_styleTree.ensureScopedStyleResolver(scope ? scope : document()) ; 191 return m_styleTree.ensureScopedStyleResolver(scope ? scope : document()) ;
186 } 192 }
187 193
188 private: 194 private:
189 void initElement(Element*); 195 void initElement(Element*, int childIndex = 0);
eseidel 2013/06/04 06:29:35 This method is so horrible and must die. StyleRes
eseidel 2013/06/04 06:29:35 Why 0? isn't that the firstChild?
190 RenderStyle* locateSharedStyle(); 196 RenderStyle* locateSharedStyle();
191 bool styleSharingCandidateMatchesRuleSet(RuleSet*); 197 bool styleSharingCandidateMatchesRuleSet(RuleSet*);
192 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; 198 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
193 StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const; 199 StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const;
194 bool canShareStyleWithElement(StyledElement*) const; 200 bool canShareStyleWithElement(StyledElement*) const;
195 201
196 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyf rame*, KeyframeValue&); 202 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyf rame*, KeyframeValue&);
197 203
198 public: 204 public:
199 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element). 205 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element).
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 PseudoId ignoreDynamicPseudo = NOPSEUDO; 481 PseudoId ignoreDynamicPseudo = NOPSEUDO;
476 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 482 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
477 return true; 483 return true;
478 } 484 }
479 return false; 485 return false;
480 } 486 }
481 487
482 } // namespace WebCore 488 } // namespace WebCore
483 489
484 #endif // StyleResolver_h 490 #endif // StyleResolver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698