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 * | 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 public: | 104 public: |
105 explicit StyleResolver(Document&); | 105 explicit StyleResolver(Document&); |
106 virtual ~StyleResolver(); | 106 virtual ~StyleResolver(); |
107 | 107 |
108 // FIXME: StyleResolver should not be keeping tree-walk state. | 108 // FIXME: StyleResolver should not be keeping tree-walk state. |
109 // These should move to some global tree-walk state, or should be contained in a | 109 // These should move to some global tree-walk state, or should be contained in a |
110 // TreeWalkContext or similar which is passed in to StyleResolver methods wh en available. | 110 // TreeWalkContext or similar which is passed in to StyleResolver methods wh en available. |
111 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups. | 111 // Using these during tree walk will allow style selector to optimize child and descendant selector lookups. |
112 void pushParentElement(Element&); | 112 void pushParentElement(Element&); |
113 void popParentElement(Element&); | 113 void popParentElement(Element&); |
114 void pushParentShadowRoot(const ShadowRoot&); | |
115 void popParentShadowRoot(const ShadowRoot&); | |
116 | 114 |
117 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing, | 115 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing, |
118 RuleMatchingBehavior = MatchAllRules); | 116 RuleMatchingBehavior = MatchAllRules); |
119 | 117 |
120 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle&, Rende rStyle* parentStyle, const StyleKeyframe*, const AtomicString& animationName); | 118 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle&, Rende rStyle* parentStyle, const StyleKeyframe*, const AtomicString& animationName); |
121 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot (Element&, CSSPropertyID, CSSValue&); | 119 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot (Element&, CSSPropertyID, CSSValue&); |
122 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot (StyleResolverState&, CSSPropertyID, CSSValue&); | 120 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot (StyleResolverState&, CSSPropertyID, CSSValue&); |
123 | 121 |
124 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle); | 122 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq uest&, RenderStyle* parentStyle); |
125 | 123 |
126 PassRefPtr<RenderStyle> styleForPage(int pageIndex); | 124 PassRefPtr<RenderStyle> styleForPage(int pageIndex); |
127 PassRefPtr<RenderStyle> defaultStyleForElement(); | 125 PassRefPtr<RenderStyle> defaultStyleForElement(); |
128 PassRefPtr<RenderStyle> styleForText(Text*); | 126 PassRefPtr<RenderStyle> styleForText(Text*); |
129 | 127 |
130 static PassRefPtr<RenderStyle> styleForDocument(Document&); | 128 static PassRefPtr<RenderStyle> styleForDocument(Document&); |
131 | 129 |
132 // FIXME: This only has 5 callers and should be removed. Callers should be e xplicit about | 130 // FIXME: This only has 5 callers and should be removed. Callers should be e xplicit about |
133 // their dependency on Document* instead of grabbing one through StyleResolv er. | 131 // their dependency on Document* instead of grabbing one through StyleResolv er. |
134 Document& document() { return m_document; } | 132 Document& document() { return m_document; } |
135 | 133 |
136 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte r we factor StyleResolver further. | 134 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte r we factor StyleResolver further. |
137 // https://bugs.webkit.org/show_bug.cgi?id=108890 | 135 // https://bugs.webkit.org/show_bug.cgi?id=108890 |
138 void appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSSt yleSheet> >&); | 136 void appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSSt yleSheet> >&); |
139 void resetAuthorStyle(const ContainerNode*); | 137 void resetAuthorStyle(TreeScope&); |
140 void finishAppendAuthorStyleSheets(); | 138 void finishAppendAuthorStyleSheets(); |
141 | 139 |
142 void processScopedRules(const RuleSet& authorRules, CSSStyleSheet*, Containe rNode& scope); | 140 void processScopedRules(const RuleSet& authorRules, CSSStyleSheet*, Containe rNode& scope); |
143 | 141 |
144 void lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeHeapVector<R efPtrWillBeMember<CSSStyleSheet> >&); | 142 void lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeHeapVector<R efPtrWillBeMember<CSSStyleSheet> >&); |
145 void removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMembe r<CSSStyleSheet> >&); | 143 void removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMembe r<CSSStyleSheet> >&); |
146 void appendPendingAuthorStyleSheets(); | 144 void appendPendingAuthorStyleSheets(); |
147 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size( ) > 0 || m_needCollectFeatures; } | 145 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size( ) > 0 || m_needCollectFeatures; } |
148 | 146 |
149 SelectorFilter& selectorFilter() { return m_selectorFilter; } | 147 SelectorFilter& selectorFilter() { return m_selectorFilter; } |
150 | 148 |
151 bool styleTreeHasOnlyScopedResolverForDocument() const { return m_styleTree. hasOnlyScopedResolverForDocument(); } | 149 bool styleTreeHasOnlyScopedResolverForDocument() const { return m_scopedStyl eResolvers.size() == 1; } |
152 | 150 |
153 void styleTreeResolveScopedKeyframesRules(const Element* element, WillBeHeap Vector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 151 void styleTreeResolveScopedKeyframesRules(const Element* element, WillBeHeap Vector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
154 { | 152 { |
155 m_styleTree.resolveScopedKeyframesRules(element, resolvers); | 153 m_styleTree.resolveScopedKeyframesRules(element, resolvers); |
156 } | 154 } |
157 | 155 |
158 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element). | 156 // These methods will give back the set of rules that matched for a given el ement (or a pseudo-element). |
159 enum CSSRuleFilter { | 157 enum CSSRuleFilter { |
160 UAAndUserCSSRules = 1 << 1, | 158 UAAndUserCSSRules = 1 << 1, |
161 AuthorCSSRules = 1 << 2, | 159 AuthorCSSRules = 1 << 2, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 MediaQueryResultList m_viewportDependentMediaQueryResults; | 291 MediaQueryResultList m_viewportDependentMediaQueryResults; |
294 | 292 |
295 Document& m_document; | 293 Document& m_document; |
296 SelectorFilter m_selectorFilter; | 294 SelectorFilter m_selectorFilter; |
297 | 295 |
298 OwnPtrWillBeMember<ViewportStyleResolver> m_viewportStyleResolver; | 296 OwnPtrWillBeMember<ViewportStyleResolver> m_viewportStyleResolver; |
299 | 297 |
300 WillBeHeapListHashSet<RawPtrWillBeMember<CSSStyleSheet>, 16> m_pendingStyleS heets; | 298 WillBeHeapListHashSet<RawPtrWillBeMember<CSSStyleSheet>, 16> m_pendingStyleS heets; |
301 | 299 |
302 ScopedStyleTree m_styleTree; | 300 ScopedStyleTree m_styleTree; |
301 // FIXME: Probably this should move to StyleEngine eventually. | |
tasak
2014/07/25 06:07:59
NIT: I agree that this should be moved to StyleEng
| |
302 WillBeHeapHashSet<RawPtrWillBeMember<const ScopedStyleResolver> > m_scopedSt yleResolvers; | |
303 | 303 |
304 // FIXME: The entire logic of collecting features on StyleResolver, as well as transferring them | 304 // FIXME: The entire logic of collecting features on StyleResolver, as well as transferring them |
305 // between various parts of machinery smells wrong. This needs to be better somehow. | 305 // between various parts of machinery smells wrong. This needs to be better somehow. |
306 RuleFeatureSet m_features; | 306 RuleFeatureSet m_features; |
307 OwnPtrWillBeMember<RuleSet> m_siblingRuleSet; | 307 OwnPtrWillBeMember<RuleSet> m_siblingRuleSet; |
308 OwnPtrWillBeMember<RuleSet> m_uncommonAttributeRuleSet; | 308 OwnPtrWillBeMember<RuleSet> m_uncommonAttributeRuleSet; |
309 | 309 |
310 // FIXME: watched selectors should be implemented using injected author styl esheets: http://crbug.com/316960 | 310 // FIXME: watched selectors should be implemented using injected author styl esheets: http://crbug.com/316960 |
311 OwnPtrWillBeMember<RuleSet> m_watchedSelectorsRules; | 311 OwnPtrWillBeMember<RuleSet> m_watchedSelectorsRules; |
312 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; | 312 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; |
313 | 313 |
314 bool m_needCollectFeatures; | 314 bool m_needCollectFeatures; |
315 | 315 |
316 StyleResourceLoader m_styleResourceLoader; | 316 StyleResourceLoader m_styleResourceLoader; |
317 | 317 |
318 unsigned m_styleSharingDepth; | 318 unsigned m_styleSharingDepth; |
319 Vector<OwnPtr<StyleSharingList>, styleSharingMaxDepth> m_styleSharingLists; | 319 Vector<OwnPtr<StyleSharingList>, styleSharingMaxDepth> m_styleSharingLists; |
320 | 320 |
321 OwnPtr<StyleResolverStats> m_styleResolverStats; | 321 OwnPtr<StyleResolverStats> m_styleResolverStats; |
322 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; | 322 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; |
323 unsigned m_styleResolverStatsSequence; | 323 unsigned m_styleResolverStatsSequence; |
324 | 324 |
325 // Use only for Internals::updateStyleAndReturnAffectedElementCount. | 325 // Use only for Internals::updateStyleAndReturnAffectedElementCount. |
326 unsigned m_accessCount; | 326 unsigned m_accessCount; |
327 }; | 327 }; |
328 | 328 |
329 } // namespace blink | 329 } // namespace blink |
330 | 330 |
331 #endif // StyleResolver_h | 331 #endif // StyleResolver_h |
OLD | NEW |