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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #ifndef StyleResolver_h | 22 #ifndef StyleResolver_h |
23 #define StyleResolver_h | 23 #define StyleResolver_h |
24 | 24 |
| 25 #include "core/animation/KeyframeAnimationEffect.h" |
25 #include "core/css/DocumentRuleSets.h" | 26 #include "core/css/DocumentRuleSets.h" |
26 #include "core/css/InspectorCSSOMWrappers.h" | 27 #include "core/css/InspectorCSSOMWrappers.h" |
27 #include "core/css/PseudoStyleRequest.h" | 28 #include "core/css/PseudoStyleRequest.h" |
28 #include "core/css/RuleFeature.h" | 29 #include "core/css/RuleFeature.h" |
29 #include "core/css/RuleSet.h" | 30 #include "core/css/RuleSet.h" |
30 #include "core/css/SelectorChecker.h" | 31 #include "core/css/SelectorChecker.h" |
31 #include "core/css/SelectorFilter.h" | 32 #include "core/css/SelectorFilter.h" |
32 #include "core/css/SiblingTraversalStrategies.h" | 33 #include "core/css/SiblingTraversalStrategies.h" |
33 #include "core/css/resolver/MatchedPropertiesCache.h" | 34 #include "core/css/resolver/MatchedPropertiesCache.h" |
34 #include "core/css/resolver/ScopedStyleResolver.h" | 35 #include "core/css/resolver/ScopedStyleResolver.h" |
35 #include "core/css/resolver/StyleBuilder.h" | 36 #include "core/css/resolver/StyleBuilder.h" |
36 #include "core/css/resolver/StyleResolverState.h" | 37 #include "core/css/resolver/StyleResolverState.h" |
37 #include "core/css/resolver/StyleResourceLoader.h" | 38 #include "core/css/resolver/StyleResourceLoader.h" |
38 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
39 #include "wtf/HashSet.h" | 40 #include "wtf/HashSet.h" |
40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
41 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
| 46 class CSSAnimationUpdate; |
45 class CSSFontSelector; | 47 class CSSFontSelector; |
46 class CSSRuleList; | 48 class CSSRuleList; |
47 class CSSSelector; | 49 class CSSSelector; |
48 class CSSStyleSheet; | 50 class CSSStyleSheet; |
49 class CSSValue; | 51 class CSSValue; |
50 class ContainerNode; | 52 class ContainerNode; |
51 class Document; | 53 class Document; |
52 class DocumentTimeline; | 54 class DocumentTimeline; |
53 class Element; | 55 class Element; |
54 class ElementRuleCollector; | 56 class ElementRuleCollector; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // 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. |
179 // 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. |
180 void pushParentElement(Element*); | 182 void pushParentElement(Element*); |
181 void popParentElement(Element*); | 183 void popParentElement(Element*); |
182 void pushParentShadowRoot(const ShadowRoot*); | 184 void pushParentShadowRoot(const ShadowRoot*); |
183 void popParentShadowRoot(const ShadowRoot*); | 185 void popParentShadowRoot(const ShadowRoot*); |
184 | 186 |
185 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle =
0, StyleSharingBehavior = AllowStyleSharing, | 187 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle =
0, StyleSharingBehavior = AllowStyleSharing, |
186 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0
); | 188 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0
); |
187 | 189 |
| 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, |
| 192 // and const ScopedStyleTree |
| 193 PassOwnPtr<CSSAnimationUpdate> calculateCSSAnimationUpdate(StyleResolverStat
e&); |
| 194 void resolveKeyframes(Element*, const StringImpl* animationName, KeyframeAni
mationEffect::KeyframeVector&); |
| 195 const StylePropertySet* firstKeyframeStyles(const Element*, const StringImpl
* animationName); |
188 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&)
; | 196 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&)
; |
| 197 const StyleRuleKeyframes* matchScopedKeyframesRule(const Element*, const Str
ingImpl* animationName); |
| 198 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const
StyleKeyframe*, KeyframeValue&); |
189 | 199 |
190 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq
uest&, RenderStyle* parentStyle); | 200 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq
uest&, RenderStyle* parentStyle); |
191 | 201 |
192 PassRefPtr<RenderStyle> styleForPage(int pageIndex); | 202 PassRefPtr<RenderStyle> styleForPage(int pageIndex); |
193 PassRefPtr<RenderStyle> defaultStyleForElement(); | 203 PassRefPtr<RenderStyle> defaultStyleForElement(); |
194 PassRefPtr<RenderStyle> styleForText(Text*); | 204 PassRefPtr<RenderStyle> styleForText(Text*); |
195 | 205 |
196 static PassRefPtr<RenderStyle> styleForDocument(const Document*, CSSFontSele
ctor* = 0); | 206 static PassRefPtr<RenderStyle> styleForDocument(const Document*, CSSFontSele
ctor* = 0); |
197 | 207 |
198 // FIXME: This only has 5 callers and should be removed. Callers should be e
xplicit about | 208 // FIXME: This only has 5 callers and should be removed. Callers should be e
xplicit about |
(...skipping 16 matching lines...) Expand all Loading... |
215 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI
nDocumentOrder(); } | 225 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI
nDocumentOrder(); } |
216 | 226 |
217 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope) | 227 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope) |
218 { | 228 { |
219 return m_styleTree.ensureScopedStyleResolver(scope ? scope : document())
; | 229 return m_styleTree.ensureScopedStyleResolver(scope ? scope : document())
; |
220 } | 230 } |
221 | 231 |
222 // FIXME: Used by SharingStyleFinder, but should be removed. | 232 // FIXME: Used by SharingStyleFinder, but should be removed. |
223 bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, Rende
rStyle*, RuleSet*); | 233 bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, Rende
rStyle*, RuleSet*); |
224 | 234 |
225 const StyleRuleKeyframes* matchScopedKeyframesRule(Element*, const StringImp
l* animationName); | |
226 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const
StyleKeyframe*, KeyframeValue&); | |
227 | |
228 // These methods will give back the set of rules that matched for a given el
ement (or a pseudo-element). | 235 // These methods will give back the set of rules that matched for a given el
ement (or a pseudo-element). |
229 enum CSSRuleFilter { | 236 enum CSSRuleFilter { |
230 UAAndUserCSSRules = 1 << 1, | 237 UAAndUserCSSRules = 1 << 1, |
231 AuthorCSSRules = 1 << 2, | 238 AuthorCSSRules = 1 << 2, |
232 EmptyCSSRules = 1 << 3, | 239 EmptyCSSRules = 1 << 3, |
233 CrossOriginCSSRules = 1 << 4, | 240 CrossOriginCSSRules = 1 << 4, |
234 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, | 241 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, |
235 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, | 242 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, |
236 }; | 243 }; |
237 PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclu
de = AllButEmptyCSSRules); | 244 PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclu
de = AllButEmptyCSSRules); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 HighPriorityProperties, | 303 HighPriorityProperties, |
297 LowPriorityProperties | 304 LowPriorityProperties |
298 }; | 305 }; |
299 template <StyleResolver::StyleApplicationPass pass> | 306 template <StyleResolver::StyleApplicationPass pass> |
300 static inline bool isPropertyForPass(CSSPropertyID); | 307 static inline bool isPropertyForPass(CSSPropertyID); |
301 template <StyleApplicationPass pass> | 308 template <StyleApplicationPass pass> |
302 void applyMatchedProperties(StyleResolverState&, const MatchResult&, bool im
portant, int startIndex, int endIndex, bool inheritedOnly); | 309 void applyMatchedProperties(StyleResolverState&, const MatchResult&, bool im
portant, int startIndex, int endIndex, bool inheritedOnly); |
303 template <StyleApplicationPass pass> | 310 template <StyleApplicationPass pass> |
304 void applyProperties(StyleResolverState&, const StylePropertySet* properties
, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = Prop
ertyWhitelistNone); | 311 void applyProperties(StyleResolverState&, const StylePropertySet* properties
, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = Prop
ertyWhitelistNone); |
305 template <StyleApplicationPass pass> | 312 template <StyleApplicationPass pass> |
306 void applyAnimatedProperties(StyleResolverState&, const Element*, const Docu
mentTimeline*); | 313 void applyAnimatedProperties(StyleResolverState&, const Element*, const Docu
mentTimeline*, const CSSAnimationUpdate*); |
307 void resolveVariables(StyleResolverState&, CSSPropertyID, CSSValue*, Vector<
std::pair<CSSPropertyID, String> >& knownExpressions); | 314 void resolveVariables(StyleResolverState&, CSSPropertyID, CSSValue*, Vector<
std::pair<CSSPropertyID, String> >& knownExpressions); |
308 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag
e, const String& pageName); | 315 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag
e, const String& pageName); |
309 void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vecto
r<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); | 316 void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vecto
r<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); |
310 void collectViewportRules(); | 317 void collectViewportRules(); |
311 Settings* documentSettings() { return m_document->settings(); } | 318 Settings* documentSettings() { return m_document->settings(); } |
312 | 319 |
313 bool isLeftPage(int pageIndex) const; | 320 bool isLeftPage(int pageIndex) const; |
314 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } | 321 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } |
315 bool isFirstPage(int pageIndex) const; | 322 bool isFirstPage(int pageIndex) const; |
316 String pageName(int pageIndex) const; | 323 String pageName(int pageIndex) const; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 PseudoId ignoreDynamicPseudo = NOPSEUDO; | 378 PseudoId ignoreDynamicPseudo = NOPSEUDO; |
372 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | 379 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) |
373 return true; | 380 return true; |
374 } | 381 } |
375 return false; | 382 return false; |
376 } | 383 } |
377 | 384 |
378 } // namespace WebCore | 385 } // namespace WebCore |
379 | 386 |
380 #endif // StyleResolver_h | 387 #endif // StyleResolver_h |
OLD | NEW |