| 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 29 matching lines...) Expand all Loading... |
| 40 class SelectorFilter; | 40 class SelectorFilter; |
| 41 class StaticCSSRuleList; | 41 class StaticCSSRuleList; |
| 42 | 42 |
| 43 typedef unsigned CascadeScope; | 43 typedef unsigned CascadeScope; |
| 44 typedef unsigned CascadeOrder; | 44 typedef unsigned CascadeOrder; |
| 45 | 45 |
| 46 const CascadeScope ignoreCascadeScope = 0; | 46 const CascadeScope ignoreCascadeScope = 0; |
| 47 const CascadeOrder ignoreCascadeOrder = 0; | 47 const CascadeOrder ignoreCascadeOrder = 0; |
| 48 | 48 |
| 49 class MatchedRule { | 49 class MatchedRule { |
| 50 WTF_MAKE_FAST_ALLOCATED; | 50 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 51 public: | 51 public: |
| 52 explicit MatchedRule(const RuleData* ruleData, unsigned specificity, Cascade
Scope cascadeScope, CascadeOrder cascadeOrder, unsigned styleSheetIndex, const C
SSStyleSheet* parentStyleSheet) | 52 MatchedRule(const RuleData* ruleData, unsigned specificity, CascadeScope cas
cadeScope, CascadeOrder cascadeOrder, unsigned styleSheetIndex, const CSSStyleSh
eet* parentStyleSheet) |
| 53 : m_ruleData(ruleData) | 53 : m_ruleData(ruleData) |
| 54 , m_specificity(specificity) | 54 , m_specificity(specificity) |
| 55 , m_cascadeScope(cascadeScope) | 55 , m_cascadeScope(cascadeScope) |
| 56 , m_parentStyleSheet(parentStyleSheet) | 56 , m_parentStyleSheet(parentStyleSheet) |
| 57 { | 57 { |
| 58 ASSERT(m_ruleData); | 58 ASSERT(m_ruleData); |
| 59 static const unsigned BitsForPositionInRuleData = 18; | 59 static const unsigned BitsForPositionInRuleData = 18; |
| 60 static const unsigned BitsForStyleSheetIndex = 32; | 60 static const unsigned BitsForStyleSheetIndex = 32; |
| 61 m_position = ((uint64_t)cascadeOrder << (BitsForStyleSheetIndex + BitsFo
rPositionInRuleData)) + ((uint64_t)styleSheetIndex << BitsForPositionInRuleData)
+ m_ruleData->position(); | 61 m_position = ((uint64_t)cascadeOrder << (BitsForStyleSheetIndex + BitsFo
rPositionInRuleData)) + ((uint64_t)styleSheetIndex << BitsForPositionInRuleData)
+ m_ruleData->position(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 const RuleData* ruleData() const { return m_ruleData; } | 64 const RuleData* ruleData() const { return m_ruleData; } |
| 65 uint32_t cascadeScope() const { return m_cascadeScope; } | 65 uint32_t cascadeScope() const { return m_cascadeScope; } |
| 66 uint64_t position() const { return m_position; } | 66 uint64_t position() const { return m_position; } |
| 67 unsigned specificity() const { return ruleData()->specificity() + m_specific
ity; } | 67 unsigned specificity() const { return ruleData()->specificity() + m_specific
ity; } |
| 68 const CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } | 68 const CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } |
| 69 void trace(Visitor* visitor) |
| 70 { |
| 71 visitor->trace(m_parentStyleSheet); |
| 72 } |
| 69 | 73 |
| 70 private: | 74 private: |
| 75 // FIXME: Oilpan: RuleData is in the oilpan heap and this pointer |
| 76 // really should be traced. However, RuleData objects are |
| 77 // allocated inside larger TerminatedArray objects and we cannot |
| 78 // trace a raw rule data pointer at this point. |
| 71 const RuleData* m_ruleData; | 79 const RuleData* m_ruleData; |
| 72 unsigned m_specificity; | 80 unsigned m_specificity; |
| 73 CascadeScope m_cascadeScope; | 81 CascadeScope m_cascadeScope; |
| 74 uint64_t m_position; | 82 uint64_t m_position; |
| 75 const CSSStyleSheet* m_parentStyleSheet; | 83 RawPtrWillBeMember<const CSSStyleSheet> m_parentStyleSheet; |
| 76 }; | 84 }; |
| 77 | 85 |
| 86 } // namespace WebCore |
| 87 |
| 88 |
| 89 namespace WTF { |
| 90 |
| 91 template <> struct VectorTraits<WebCore::MatchedRule> : VectorTraitsBase<WebCore
::MatchedRule> { |
| 92 static const bool canInitializeWithMemset = true; |
| 93 static const bool canMoveWithMemcpy = true; |
| 94 }; |
| 95 |
| 96 } // namespace WTF |
| 97 |
| 98 namespace WebCore { |
| 99 |
| 78 // FIXME: oilpan: when transition types are gone this class can be replaced with
HeapVector. | 100 // FIXME: oilpan: when transition types are gone this class can be replaced with
HeapVector. |
| 79 class StyleRuleList : public RefCounted<StyleRuleList> { | 101 class StyleRuleList : public RefCounted<StyleRuleList> { |
| 80 public: | 102 public: |
| 81 static PassRefPtr<StyleRuleList> create() { return adoptRef(new StyleRuleLis
t()); } | 103 static PassRefPtr<StyleRuleList> create() { return adoptRef(new StyleRuleLis
t()); } |
| 82 WillBePersistentHeapVector<RawPtrWillBeMember<StyleRule> > m_list; | 104 WillBePersistentHeapVector<RawPtrWillBeMember<StyleRule> > m_list; |
| 83 }; | 105 }; |
| 84 | 106 |
| 85 // ElementRuleCollector is designed to be used as a stack object. | 107 // ElementRuleCollector is designed to be used as a stack object. |
| 86 // Create one, ask what rules the ElementResolveContext matches | 108 // Create one, ask what rules the ElementResolveContext matches |
| 87 // and then let it go out of scope. | 109 // and then let it go out of scope. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const ElementResolveContext& m_context; | 165 const ElementResolveContext& m_context; |
| 144 const SelectorFilter& m_selectorFilter; | 166 const SelectorFilter& m_selectorFilter; |
| 145 RefPtr<RenderStyle> m_style; // FIXME: This can be mutated during matching! | 167 RefPtr<RenderStyle> m_style; // FIXME: This can be mutated during matching! |
| 146 | 168 |
| 147 PseudoStyleRequest m_pseudoStyleRequest; | 169 PseudoStyleRequest m_pseudoStyleRequest; |
| 148 SelectorChecker::Mode m_mode; | 170 SelectorChecker::Mode m_mode; |
| 149 bool m_canUseFastReject; | 171 bool m_canUseFastReject; |
| 150 bool m_sameOriginOnly; | 172 bool m_sameOriginOnly; |
| 151 bool m_matchingUARules; | 173 bool m_matchingUARules; |
| 152 | 174 |
| 153 OwnPtr<Vector<MatchedRule, 32> > m_matchedRules; | 175 OwnPtrWillBeMember<WillBeHeapVector<MatchedRule, 32> > m_matchedRules; |
| 154 | 176 |
| 155 // Output. | 177 // Output. |
| 156 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; | 178 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; |
| 157 RefPtr<StyleRuleList> m_styleRuleList; | 179 RefPtr<StyleRuleList> m_styleRuleList; |
| 158 MatchResult m_result; | 180 MatchResult m_result; |
| 159 }; | 181 }; |
| 160 | 182 |
| 161 } // namespace WebCore | 183 } // namespace WebCore |
| 162 | 184 |
| 163 #endif // ElementRuleCollector_h | 185 #endif // ElementRuleCollector_h |
| OLD | NEW |