| 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 SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ | 22 #ifndef SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ |
| 23 #define SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ | 23 #define SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ |
| 24 | 24 |
| 25 #include "sky/engine/core/css/RuleSet.h" |
| 25 #include "sky/engine/core/css/SelectorChecker.h" | 26 #include "sky/engine/core/css/SelectorChecker.h" |
| 26 #include "sky/engine/core/css/resolver/ElementResolveContext.h" | 27 #include "sky/engine/core/css/resolver/ElementResolveContext.h" |
| 27 #include "sky/engine/core/css/resolver/MatchRequest.h" | 28 #include "sky/engine/core/css/resolver/MatchRequest.h" |
| 28 #include "sky/engine/core/css/resolver/MatchResult.h" | 29 #include "sky/engine/core/css/resolver/MatchResult.h" |
| 29 #include "sky/engine/wtf/RefPtr.h" | 30 #include "sky/engine/wtf/RefPtr.h" |
| 30 #include "sky/engine/wtf/Vector.h" | 31 #include "sky/engine/wtf/Vector.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 class CSSStyleSheet; | 35 class CSSStyleSheet; |
| 35 class RuleData; | |
| 36 class RuleSet; | |
| 37 class ScopedStyleResolver; | 36 class ScopedStyleResolver; |
| 38 | 37 |
| 39 typedef unsigned CascadeOrder; | 38 typedef unsigned CascadeOrder; |
| 40 | 39 |
| 41 const CascadeOrder ignoreCascadeOrder = 0; | 40 const CascadeOrder ignoreCascadeOrder = 0; |
| 42 | 41 |
| 43 class MatchedRule { | 42 class MatchedRule { |
| 44 ALLOW_ONLY_INLINE_ALLOCATION(); | 43 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 45 public: | 44 public: |
| 46 MatchedRule(const RuleData* ruleData, CascadeOrder cascadeOrder, unsigned st
yleSheetIndex, const CSSStyleSheet* parentStyleSheet) | 45 MatchedRule(const RuleData* ruleData, CascadeOrder cascadeOrder, unsigned st
yleSheetIndex, const CSSStyleSheet* parentStyleSheet) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // FIXME: Currently it modifies the RenderStyle but should not! | 86 // FIXME: Currently it modifies the RenderStyle but should not! |
| 88 class ElementRuleCollector { | 87 class ElementRuleCollector { |
| 89 STACK_ALLOCATED(); | 88 STACK_ALLOCATED(); |
| 90 WTF_MAKE_NONCOPYABLE(ElementRuleCollector); | 89 WTF_MAKE_NONCOPYABLE(ElementRuleCollector); |
| 91 public: | 90 public: |
| 92 ElementRuleCollector(const ElementResolveContext&, RenderStyle* = 0); | 91 ElementRuleCollector(const ElementResolveContext&, RenderStyle* = 0); |
| 93 ~ElementRuleCollector(); | 92 ~ElementRuleCollector(); |
| 94 | 93 |
| 95 MatchResult& matchedResult(); | 94 MatchResult& matchedResult(); |
| 96 | 95 |
| 97 void collectMatchingRules(const MatchRequest&, RuleRange&, CascadeOrder = ig
noreCascadeOrder); | 96 void collectMatchingRules(const MatchRequest&, CascadeOrder = ignoreCascadeO
rder); |
| 98 void collectMatchingHostRules(const MatchRequest&, RuleRange&, CascadeOrder
cascadeOrder = ignoreCascadeOrder); | 97 void collectMatchingHostRules(const MatchRequest&, CascadeOrder cascadeOrder
= ignoreCascadeOrder); |
| 99 void sortAndTransferMatchedRules(); | 98 void sortAndTransferMatchedRules(); |
| 100 void clearMatchedRules(); | 99 void clearMatchedRules(); |
| 101 void addElementStyleProperties(const StylePropertySet*, bool isCacheable = t
rue); | 100 void addElementStyleProperties(const StylePropertySet*, bool isCacheable = t
rue); |
| 102 | 101 |
| 103 private: | 102 private: |
| 104 void collectRuleIfMatches(const RuleData&, CascadeOrder, const MatchRequest&
, RuleRange&); | 103 void collectRuleIfMatches(const RuleData&, CascadeOrder, const MatchRequest&
); |
| 105 | 104 |
| 106 template<typename RuleDataListType> | 105 template<typename RuleDataListType> |
| 107 void collectMatchingRulesForList(const RuleDataListType* rules, CascadeOrder
cascadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) | 106 void collectMatchingRulesForList(const RuleDataListType* rules, CascadeOrder
cascadeOrder, const MatchRequest& matchRequest) |
| 108 { | 107 { |
| 109 if (!rules) | 108 if (!rules) |
| 110 return; | 109 return; |
| 111 | 110 |
| 112 for (typename RuleDataListType::const_iterator it = rules->begin(), end
= rules->end(); it != end; ++it) | 111 for (typename RuleDataListType::const_iterator it = rules->begin(), end
= rules->end(); it != end; ++it) |
| 113 collectRuleIfMatches(*it, cascadeOrder, matchRequest, ruleRange); | 112 collectRuleIfMatches(*it, cascadeOrder, matchRequest); |
| 114 } | 113 } |
| 115 | 114 |
| 116 bool ruleMatches(const RuleData&); | 115 bool ruleMatches(const RuleData&); |
| 117 | 116 |
| 118 void sortMatchedRules(); | 117 void sortMatchedRules(); |
| 119 void addMatchedRule(const RuleData*, CascadeOrder, unsigned styleSheetIndex,
const CSSStyleSheet* parentStyleSheet); | 118 void addMatchedRule(const RuleData*, CascadeOrder, unsigned styleSheetIndex,
const CSSStyleSheet* parentStyleSheet); |
| 120 | 119 |
| 121 private: | 120 private: |
| 122 const ElementResolveContext& m_context; | 121 const ElementResolveContext& m_context; |
| 123 RefPtr<RenderStyle> m_style; // FIXME: This can be mutated during matching! | 122 RefPtr<RenderStyle> m_style; // FIXME: This can be mutated during matching! |
| 124 | 123 |
| 125 OwnPtr<Vector<MatchedRule, 32> > m_matchedRules; | 124 OwnPtr<Vector<MatchedRule, 32> > m_matchedRules; |
| 126 | 125 |
| 127 // Output. | 126 // Output. |
| 128 MatchResult m_result; | 127 MatchResult m_result; |
| 129 }; | 128 }; |
| 130 | 129 |
| 131 } // namespace blink | 130 } // namespace blink |
| 132 | 131 |
| 133 #endif // SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ | 132 #endif // SKY_ENGINE_CORE_CSS_ELEMENTRULECOLLECTOR_H_ |
| OLD | NEW |