| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 unsigned position() const { return m_position; } | 51 unsigned position() const { return m_position; } |
| 52 StyleRule* rule() const { return m_rule; } | 52 StyleRule* rule() const { return m_rule; } |
| 53 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } | 53 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } |
| 54 unsigned selectorIndex() const { return m_selectorIndex; } | 54 unsigned selectorIndex() const { return m_selectorIndex; } |
| 55 | 55 |
| 56 bool isLastInArray() const { return m_isLastInArray; } | 56 bool isLastInArray() const { return m_isLastInArray; } |
| 57 void setLastInArray(bool flag) { m_isLastInArray = flag; } | 57 void setLastInArray(bool flag) { m_isLastInArray = flag; } |
| 58 | 58 |
| 59 bool containsAttributeSelector() const { return m_containsAttributeSelector;
} | 59 bool containsAttributeSelector() const { return m_containsAttributeSelector;
} |
| 60 | 60 |
| 61 void trace(Visitor*); | |
| 62 | |
| 63 private: | 61 private: |
| 64 RawPtr<StyleRule> m_rule; | 62 RawPtr<StyleRule> m_rule; |
| 65 unsigned m_selectorIndex : 12; | 63 unsigned m_selectorIndex : 12; |
| 66 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a
primitive array. | 64 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a
primitive array. |
| 67 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. | 65 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. |
| 68 // Some simple testing showed <100,000 RuleData's on large sites. | 66 // Some simple testing showed <100,000 RuleData's on large sites. |
| 69 unsigned m_position : 17; | 67 unsigned m_position : 17; |
| 70 unsigned m_containsAttributeSelector : 1; | 68 unsigned m_containsAttributeSelector : 1; |
| 71 }; | 69 }; |
| 72 | 70 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 { | 102 { |
| 105 if (!m_pendingRules) | 103 if (!m_pendingRules) |
| 106 return; | 104 return; |
| 107 compactRules(); | 105 compactRules(); |
| 108 } | 106 } |
| 109 | 107 |
| 110 #ifndef NDEBUG | 108 #ifndef NDEBUG |
| 111 void show(); | 109 void show(); |
| 112 #endif | 110 #endif |
| 113 | 111 |
| 114 void trace(Visitor*); | |
| 115 | |
| 116 private: | 112 private: |
| 117 typedef HashMap<AtomicString, OwnPtr<LinkedStack<RuleData> > > PendingRuleMa
p; | 113 typedef HashMap<AtomicString, OwnPtr<LinkedStack<RuleData> > > PendingRuleMa
p; |
| 118 typedef HashMap<AtomicString, OwnPtr<TerminatedArray<RuleData> > > CompactRu
leMap; | 114 typedef HashMap<AtomicString, OwnPtr<TerminatedArray<RuleData> > > CompactRu
leMap; |
| 119 | 115 |
| 120 RuleSet() | 116 RuleSet() |
| 121 : m_ruleCount(0) | 117 : m_ruleCount(0) |
| 122 { | 118 { |
| 123 } | 119 } |
| 124 | 120 |
| 125 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&)
; | 121 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&)
; |
| 126 void addFontFaceRule(StyleRuleFontFace*); | 122 void addFontFaceRule(StyleRuleFontFace*); |
| 127 void addKeyframesRule(StyleRuleKeyframes*); | 123 void addKeyframesRule(StyleRuleKeyframes*); |
| 128 | 124 |
| 129 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, AddRuleFlags); | 125 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, AddRuleFlags); |
| 130 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&); | 126 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&); |
| 131 | 127 |
| 132 void compactRules(); | 128 void compactRules(); |
| 133 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); | 129 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); |
| 134 | 130 |
| 135 class PendingRuleMaps { | 131 class PendingRuleMaps { |
| 136 public: | 132 public: |
| 137 static PassOwnPtr<PendingRuleMaps> create() { return adoptPtr(new Pendin
gRuleMaps); } | 133 static PassOwnPtr<PendingRuleMaps> create() { return adoptPtr(new Pendin
gRuleMaps); } |
| 138 | 134 |
| 139 PendingRuleMap idRules; | 135 PendingRuleMap idRules; |
| 140 PendingRuleMap classRules; | 136 PendingRuleMap classRules; |
| 141 PendingRuleMap tagRules; | 137 PendingRuleMap tagRules; |
| 142 PendingRuleMap shadowPseudoElementRules; | 138 PendingRuleMap shadowPseudoElementRules; |
| 143 | 139 |
| 144 void trace(Visitor*); | |
| 145 | |
| 146 private: | 140 private: |
| 147 PendingRuleMaps() { } | 141 PendingRuleMaps() { } |
| 148 }; | 142 }; |
| 149 | 143 |
| 150 PendingRuleMaps* ensurePendingRules() | 144 PendingRuleMaps* ensurePendingRules() |
| 151 { | 145 { |
| 152 if (!m_pendingRules) | 146 if (!m_pendingRules) |
| 153 m_pendingRules = PendingRuleMaps::create(); | 147 m_pendingRules = PendingRuleMaps::create(); |
| 154 return m_pendingRules.get(); | 148 return m_pendingRules.get(); |
| 155 } | 149 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 171 #ifndef NDEBUG | 165 #ifndef NDEBUG |
| 172 Vector<RuleData> m_allRules; | 166 Vector<RuleData> m_allRules; |
| 173 #endif | 167 #endif |
| 174 }; | 168 }; |
| 175 | 169 |
| 176 } // namespace blink | 170 } // namespace blink |
| 177 | 171 |
| 178 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); | 172 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); |
| 179 | 173 |
| 180 #endif // RuleSet_h | 174 #endif // RuleSet_h |
| OLD | NEW |