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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; | 103 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; |
104 public: | 104 public: |
105 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } | 105 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } |
106 | 106 |
107 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl
eResolver* = 0, const ContainerNode* = 0); | 107 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl
eResolver* = 0, const ContainerNode* = 0); |
108 void addStyleRule(StyleRule*, AddRuleFlags); | 108 void addStyleRule(StyleRule*, AddRuleFlags); |
109 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); | 109 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); |
110 | 110 |
111 const RuleFeatureSet& features() const { return m_features; } | 111 const RuleFeatureSet& features() const { return m_features; } |
112 | 112 |
113 const RuleData* idRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRule
s); return m_idRules.get(key); } | 113 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re
turn m_idRules.get(key); } |
114 const RuleData* classRules(AtomicStringImpl* key) const { ASSERT(!m_pendingR
ules); return m_classRules.get(key); } | 114 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules);
return m_classRules.get(key); } |
115 const RuleData* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRul
es); return m_tagRules.get(key); } | 115 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r
eturn m_tagRules.get(key); } |
116 const RuleData* shadowPseudoElementRules(AtomicStringImpl* key) const { ASSE
RT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); } | 116 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_
pendingRules); return m_shadowPseudoElementRules.get(key); } |
117 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } | 117 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } |
118 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } | 118 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } |
119 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } | 119 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } |
120 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } | 120 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } |
121 const Vector<StyleRulePage*>& pageRules() const { ASSERT(!m_pendingRules); r
eturn m_pageRules; } | 121 const Vector<StyleRulePage*>& pageRules() const { ASSERT(!m_pendingRules); r
eturn m_pageRules; } |
122 | 122 |
123 unsigned ruleCount() const { return m_ruleCount; } | 123 unsigned ruleCount() const { return m_ruleCount; } |
124 | 124 |
125 void compactRulesIfNeeded() | 125 void compactRulesIfNeeded() |
126 { | 126 { |
127 if (!m_pendingRules) | 127 if (!m_pendingRules) |
128 return; | 128 return; |
129 compactRules(); | 129 compactRules(); |
130 } | 130 } |
131 | 131 |
132 void reportMemoryUsage(MemoryObjectInfo*) const; | 132 void reportMemoryUsage(MemoryObjectInfo*) const; |
133 | 133 |
134 struct RuleSetSelectorPair { | 134 struct RuleSetSelectorPair { |
135 RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> rul
eSet) : selector(selector), ruleSet(ruleSet) { } | 135 RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> rul
eSet) : selector(selector), ruleSet(ruleSet) { } |
136 RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selecto
r), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { } | 136 RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selecto
r), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { } |
137 void reportMemoryUsage(MemoryObjectInfo*) const; | 137 void reportMemoryUsage(MemoryObjectInfo*) const; |
138 | 138 |
139 const CSSSelector* selector; | 139 const CSSSelector* selector; |
140 OwnPtr<RuleSet> ruleSet; | 140 OwnPtr<RuleSet> ruleSet; |
141 }; | 141 }; |
142 | 142 |
143 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; | 143 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; |
144 | 144 |
145 private: | 145 private: |
146 typedef HashMap<AtomicStringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingR
uleMap; | 146 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap
; |
147 typedef HashMap<AtomicStringImpl*, OwnPtr<RuleData> > CompactRuleMap; | 147 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; |
148 | 148 |
149 RuleSet() | 149 RuleSet() |
150 : m_ruleCount(0) | 150 : m_ruleCount(0) |
151 { | 151 { |
152 } | 152 } |
153 | 153 |
154 void addToRuleSet(AtomicStringImpl* key, PendingRuleMap&, const RuleData&); | 154 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); |
155 void addPageRule(StyleRulePage*); | 155 void addPageRule(StyleRulePage*); |
156 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); | 156 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); |
157 | 157 |
158 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec
urityOrigin, AddRuleFlags); | 158 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec
urityOrigin, AddRuleFlags); |
159 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); | 159 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); |
160 | 160 |
161 void compactRules(); | 161 void compactRules(); |
162 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); | 162 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); |
163 | 163 |
164 struct PendingRuleMaps { | 164 struct PendingRuleMaps { |
(...skipping 21 matching lines...) Expand all Loading... |
186 RuleFeatureSet m_features; | 186 RuleFeatureSet m_features; |
187 Vector<StyleRulePage*> m_pageRules; | 187 Vector<StyleRulePage*> m_pageRules; |
188 | 188 |
189 unsigned m_ruleCount; | 189 unsigned m_ruleCount; |
190 OwnPtr<PendingRuleMaps> m_pendingRules; | 190 OwnPtr<PendingRuleMaps> m_pendingRules; |
191 }; | 191 }; |
192 | 192 |
193 } // namespace WebCore | 193 } // namespace WebCore |
194 | 194 |
195 #endif // RuleSet_h | 195 #endif // RuleSet_h |
OLD | NEW |