| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Now that we're about to read from the RuleSet, we're done adding more | 116 // Now that we're about to read from the RuleSet, we're done adding more |
| 117 // rules to the set and we should make sure it's compacted. | 117 // rules to the set and we should make sure it's compacted. |
| 118 ruleSet->compactRulesIfNeeded(); | 118 ruleSet->compactRulesIfNeeded(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 const RuleSet* ruleSet; | 121 const RuleSet* ruleSet; |
| 122 const bool includeEmptyRules; | 122 const bool includeEmptyRules; |
| 123 const ContainerNode* scope; | 123 const ContainerNode* scope; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 struct CSSPropertyValue { |
| 127 CSSPropertyValue(CSSPropertyID property, CSSValue* value) |
| 128 : property(property), value(value) { } |
| 129 // Stores value=propertySet.getPropertyCSSValue(id).get(). |
| 130 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); |
| 131 CSSPropertyID property; |
| 132 CSSValue* value; |
| 133 }; |
| 134 |
| 126 // This class selects a RenderStyle for a given element based on a collection of
stylesheets. | 135 // This class selects a RenderStyle for a given element based on a collection of
stylesheets. |
| 127 class StyleResolver { | 136 class StyleResolver { |
| 128 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; | 137 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; |
| 129 public: | 138 public: |
| 130 StyleResolver(Document*, bool matchAuthorAndUserStyles); | 139 StyleResolver(Document*, bool matchAuthorAndUserStyles); |
| 131 ~StyleResolver(); | 140 ~StyleResolver(); |
| 132 | 141 |
| 133 // Using these during tree walk will allow style selector to optimize child
and descendant selector lookups. | 142 // Using these during tree walk will allow style selector to optimize child
and descendant selector lookups. |
| 134 void pushParentElement(Element*); | 143 void pushParentElement(Element*); |
| 135 void popParentElement(Element*); | 144 void popParentElement(Element*); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 private: | 183 private: |
| 175 // FIXME: Move all of these into a separate style sharing controller object. | 184 // FIXME: Move all of these into a separate style sharing controller object. |
| 176 RenderStyle* locateSharedStyle(const ElementResolveContext&); | 185 RenderStyle* locateSharedStyle(const ElementResolveContext&); |
| 177 bool styleSharingCandidateMatchesRuleSet(RuleSet*); | 186 bool styleSharingCandidateMatchesRuleSet(RuleSet*); |
| 178 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; | 187 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; |
| 179 Element* findSiblingForStyleSharing(const ElementResolveContext&, Node*, uns
igned& count) const; | 188 Element* findSiblingForStyleSharing(const ElementResolveContext&, Node*, uns
igned& count) const; |
| 180 bool canShareStyleWithElement(const ElementResolveContext&, Element* sharing
Candidate) const; | 189 bool canShareStyleWithElement(const ElementResolveContext&, Element* sharing
Candidate) const; |
| 181 bool canShareStyleWithControl(const ElementResolveContext&, Element* sharing
Candidate) const; | 190 bool canShareStyleWithControl(const ElementResolveContext&, Element* sharing
Candidate) const; |
| 182 bool sharingCandidateHasIdenticalStyleAffectingAttributes(const ElementResol
veContext&, Element* sharingCandidate) const; | 191 bool sharingCandidateHasIdenticalStyleAffectingAttributes(const ElementResol
veContext&, Element* sharingCandidate) const; |
| 183 | 192 |
| 184 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyf
rame*, KeyframeValue&); | 193 PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const
StyleKeyframe*, KeyframeValue&); |
| 185 | 194 |
| 186 public: | 195 public: |
| 187 // These methods will give back the set of rules that matched for a given el
ement (or a pseudo-element). | 196 // These methods will give back the set of rules that matched for a given el
ement (or a pseudo-element). |
| 188 enum CSSRuleFilter { | 197 enum CSSRuleFilter { |
| 189 UAAndUserCSSRules = 1 << 1, | 198 UAAndUserCSSRules = 1 << 1, |
| 190 AuthorCSSRules = 1 << 2, | 199 AuthorCSSRules = 1 << 2, |
| 191 EmptyCSSRules = 1 << 3, | 200 EmptyCSSRules = 1 << 3, |
| 192 CrossOriginCSSRules = 1 << 4, | 201 CrossOriginCSSRules = 1 << 4, |
| 193 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, | 202 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, |
| 194 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, | 203 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, |
| 195 }; | 204 }; |
| 196 PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclu
de = AllButEmptyCSSRules); | 205 PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclu
de = AllButEmptyCSSRules); |
| 197 PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, unsig
ned rulesToInclude = AllButEmptyCSSRules); | 206 PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, unsig
ned rulesToInclude = AllButEmptyCSSRules); |
| 198 | 207 |
| 199 public: | 208 public: |
| 200 void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*); | 209 // |properties| is an array with |count| elements. |
| 201 | 210 void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count
, RenderStyle*); |
| 202 void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*); | |
| 203 | 211 |
| 204 void updateFont(); | 212 void updateFont(); |
| 205 void initializeFontStyle(Settings*); | 213 void initializeFontStyle(Settings*); |
| 206 void setFontSize(FontDescription&, float size); | 214 void setFontSize(FontDescription&, float size); |
| 207 | 215 |
| 208 public: | 216 public: |
| 209 bool hasSelectorForId(const AtomicString&) const; | 217 bool hasSelectorForId(const AtomicString&) const; |
| 210 bool hasSelectorForClass(const AtomicString&) const; | 218 bool hasSelectorForClass(const AtomicString&) const; |
| 211 bool hasSelectorForAttribute(const AtomicString&) const; | 219 bool hasSelectorForAttribute(const AtomicString&) const; |
| 212 | 220 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 PseudoId ignoreDynamicPseudo = NOPSEUDO; | 370 PseudoId ignoreDynamicPseudo = NOPSEUDO; |
| 363 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | 371 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) |
| 364 return true; | 372 return true; |
| 365 } | 373 } |
| 366 return false; | 374 return false; |
| 367 } | 375 } |
| 368 | 376 |
| 369 } // namespace WebCore | 377 } // namespace WebCore |
| 370 | 378 |
| 371 #endif // StyleResolver_h | 379 #endif // StyleResolver_h |
| OLD | NEW |