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. |
| 4 * All rights reserved. |
4 * | 5 * |
5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
9 * | 10 * |
10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 14 * Library General Public License for more details. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 }; | 67 }; |
67 | 68 |
68 enum RuleMatchingBehavior { MatchAllRules, MatchAllRulesExcludingSMIL }; | 69 enum RuleMatchingBehavior { MatchAllRules, MatchAllRulesExcludingSMIL }; |
69 | 70 |
70 const unsigned styleSharingListSize = 15; | 71 const unsigned styleSharingListSize = 15; |
71 const unsigned styleSharingMaxDepth = 32; | 72 const unsigned styleSharingMaxDepth = 32; |
72 using StyleSharingList = HeapDeque<Member<Element>, styleSharingListSize>; | 73 using StyleSharingList = HeapDeque<Member<Element>, styleSharingListSize>; |
73 using ActiveInterpolationsMap = | 74 using ActiveInterpolationsMap = |
74 HashMap<PropertyHandle, Vector<RefPtr<Interpolation>, 1>>; | 75 HashMap<PropertyHandle, Vector<RefPtr<Interpolation>, 1>>; |
75 | 76 |
76 // This class selects a ComputedStyle for a given element based on a collection
of stylesheets. | 77 // This class selects a ComputedStyle for a given element based on a collection |
| 78 // of stylesheets. |
77 class CORE_EXPORT StyleResolver final | 79 class CORE_EXPORT StyleResolver final |
78 : public GarbageCollectedFinalized<StyleResolver> { | 80 : public GarbageCollectedFinalized<StyleResolver> { |
79 WTF_MAKE_NONCOPYABLE(StyleResolver); | 81 WTF_MAKE_NONCOPYABLE(StyleResolver); |
80 | 82 |
81 public: | 83 public: |
82 static StyleResolver* create(Document& document) { | 84 static StyleResolver* create(Document& document) { |
83 return new StyleResolver(document); | 85 return new StyleResolver(document); |
84 } | 86 } |
85 ~StyleResolver(); | 87 ~StyleResolver(); |
86 void dispose(); | 88 void dispose(); |
(...skipping 14 matching lines...) Expand all Loading... |
101 PassRefPtr<ComputedStyle> pseudoStyleForElement( | 103 PassRefPtr<ComputedStyle> pseudoStyleForElement( |
102 Element*, | 104 Element*, |
103 const PseudoStyleRequest&, | 105 const PseudoStyleRequest&, |
104 const ComputedStyle* parentStyle); | 106 const ComputedStyle* parentStyle); |
105 | 107 |
106 PassRefPtr<ComputedStyle> styleForPage(int pageIndex); | 108 PassRefPtr<ComputedStyle> styleForPage(int pageIndex); |
107 PassRefPtr<ComputedStyle> styleForText(Text*); | 109 PassRefPtr<ComputedStyle> styleForText(Text*); |
108 | 110 |
109 static PassRefPtr<ComputedStyle> styleForDocument(Document&); | 111 static PassRefPtr<ComputedStyle> styleForDocument(Document&); |
110 | 112 |
111 // FIXME: It could be better to call appendAuthorStyleSheets() directly after
we factor StyleResolver further. | 113 // FIXME: It could be better to call appendAuthorStyleSheets() directly after |
| 114 // we factor StyleResolver further. |
112 // https://bugs.webkit.org/show_bug.cgi?id=108890 | 115 // https://bugs.webkit.org/show_bug.cgi?id=108890 |
113 void appendAuthorStyleSheets(const HeapVector<Member<CSSStyleSheet>>&); | 116 void appendAuthorStyleSheets(const HeapVector<Member<CSSStyleSheet>>&); |
114 void resetAuthorStyle(TreeScope&); | 117 void resetAuthorStyle(TreeScope&); |
115 void resetRuleFeatures(); | 118 void resetRuleFeatures(); |
116 void finishAppendAuthorStyleSheets(); | 119 void finishAppendAuthorStyleSheets(); |
117 | 120 |
118 void lazyAppendAuthorStyleSheets(unsigned firstNew, | 121 void lazyAppendAuthorStyleSheets(unsigned firstNew, |
119 const HeapVector<Member<CSSStyleSheet>>&); | 122 const HeapVector<Member<CSSStyleSheet>>&); |
120 void removePendingAuthorStyleSheets(const HeapVector<Member<CSSStyleSheet>>&); | 123 void removePendingAuthorStyleSheets(const HeapVector<Member<CSSStyleSheet>>&); |
121 void appendPendingAuthorStyleSheets(); | 124 void appendPendingAuthorStyleSheets(); |
122 bool hasPendingAuthorStyleSheets() const { | 125 bool hasPendingAuthorStyleSheets() const { |
123 return m_pendingStyleSheets.size() > 0 || m_needCollectFeatures; | 126 return m_pendingStyleSheets.size() > 0 || m_needCollectFeatures; |
124 } | 127 } |
125 | 128 |
126 // TODO(esprehn): StyleResolver should probably not contain tree walking | 129 // TODO(esprehn): StyleResolver should probably not contain tree walking |
127 // state, instead we should pass a context object during recalcStyle. | 130 // state, instead we should pass a context object during recalcStyle. |
128 SelectorFilter& selectorFilter() { return m_selectorFilter; } | 131 SelectorFilter& selectorFilter() { return m_selectorFilter; } |
129 | 132 |
130 StyleRuleKeyframes* findKeyframesRule(const Element*, | 133 StyleRuleKeyframes* findKeyframesRule(const Element*, |
131 const AtomicString& animationName); | 134 const AtomicString& animationName); |
132 | 135 |
133 // These methods will give back the set of rules that matched for a given elem
ent (or a pseudo-element). | 136 // These methods will give back the set of rules that matched for a given |
| 137 // element (or a pseudo-element). |
134 enum CSSRuleFilter { | 138 enum CSSRuleFilter { |
135 UAAndUserCSSRules = 1 << 1, | 139 UAAndUserCSSRules = 1 << 1, |
136 AuthorCSSRules = 1 << 2, | 140 AuthorCSSRules = 1 << 2, |
137 EmptyCSSRules = 1 << 3, | 141 EmptyCSSRules = 1 << 3, |
138 CrossOriginCSSRules = 1 << 4, | 142 CrossOriginCSSRules = 1 << 4, |
139 AllButEmptyCSSRules = | 143 AllButEmptyCSSRules = |
140 UAAndUserCSSRules | AuthorCSSRules | CrossOriginCSSRules, | 144 UAAndUserCSSRules | AuthorCSSRules | CrossOriginCSSRules, |
141 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, | 145 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, |
142 }; | 146 }; |
143 CSSRuleList* cssRulesForElement( | 147 CSSRuleList* cssRulesForElement( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 MediaQueryResultList m_viewportDependentMediaQueryResults; | 279 MediaQueryResultList m_viewportDependentMediaQueryResults; |
276 MediaQueryResultList m_deviceDependentMediaQueryResults; | 280 MediaQueryResultList m_deviceDependentMediaQueryResults; |
277 | 281 |
278 Member<Document> m_document; | 282 Member<Document> m_document; |
279 SelectorFilter m_selectorFilter; | 283 SelectorFilter m_selectorFilter; |
280 | 284 |
281 Member<ViewportStyleResolver> m_viewportStyleResolver; | 285 Member<ViewportStyleResolver> m_viewportStyleResolver; |
282 | 286 |
283 HeapListHashSet<Member<CSSStyleSheet>, 16> m_pendingStyleSheets; | 287 HeapListHashSet<Member<CSSStyleSheet>, 16> m_pendingStyleSheets; |
284 | 288 |
285 // FIXME: The entire logic of collecting features on StyleResolver, as well as
transferring them | 289 // FIXME: The entire logic of collecting features on StyleResolver, as well as |
286 // between various parts of machinery smells wrong. This needs to be better so
mehow. | 290 // transferring them between various parts of machinery smells wrong. This |
| 291 // needs to be better somehow. |
287 RuleFeatureSet m_features; | 292 RuleFeatureSet m_features; |
288 Member<RuleSet> m_siblingRuleSet; | 293 Member<RuleSet> m_siblingRuleSet; |
289 Member<RuleSet> m_uncommonAttributeRuleSet; | 294 Member<RuleSet> m_uncommonAttributeRuleSet; |
290 Member<RuleSet> m_watchedSelectorsRules; | 295 Member<RuleSet> m_watchedSelectorsRules; |
291 | 296 |
292 DocumentOrderedList m_treeBoundaryCrossingScopes; | 297 DocumentOrderedList m_treeBoundaryCrossingScopes; |
293 | 298 |
294 bool m_needCollectFeatures; | 299 bool m_needCollectFeatures; |
295 bool m_printMediaType; | 300 bool m_printMediaType; |
296 bool m_hasFullscreenUAStyle = false; | 301 bool m_hasFullscreenUAStyle = false; |
297 | 302 |
298 unsigned m_styleSharingDepth; | 303 unsigned m_styleSharingDepth; |
299 HeapVector<Member<StyleSharingList>, styleSharingMaxDepth> | 304 HeapVector<Member<StyleSharingList>, styleSharingMaxDepth> |
300 m_styleSharingLists; | 305 m_styleSharingLists; |
301 }; | 306 }; |
302 | 307 |
303 } // namespace blink | 308 } // namespace blink |
304 | 309 |
305 #endif // StyleResolver_h | 310 #endif // StyleResolver_h |
OLD | NEW |