| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class CSSSelector; | 46 class CSSSelector; |
| 47 class ContainerNode; | 47 class ContainerNode; |
| 48 class MediaQueryEvaluator; | 48 class MediaQueryEvaluator; |
| 49 class StyleResolver; | 49 class StyleResolver; |
| 50 class StyleRuleRegion; | 50 class StyleRuleRegion; |
| 51 class StyleSheetContents; | 51 class StyleSheetContents; |
| 52 | 52 |
| 53 class RuleData { | 53 class RuleData { |
| 54 NEW_DELETE_SAME_AS_MALLOC_FREE; |
| 54 public: | 55 public: |
| 55 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); | 56 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); |
| 56 | 57 |
| 57 unsigned position() const { return m_position; } | 58 unsigned position() const { return m_position; } |
| 58 StyleRule* rule() const { return m_rule; } | 59 StyleRule* rule() const { return m_rule; } |
| 59 const CSSSelector* selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } | 60 const CSSSelector* selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } |
| 60 unsigned selectorIndex() const { return m_selectorIndex; } | 61 unsigned selectorIndex() const { return m_selectorIndex; } |
| 61 | 62 |
| 63 bool isLastInArray() const { return m_isLastInArray; } |
| 64 void setLastInArray(bool flag) { m_isLastInArray = flag; } |
| 65 |
| 62 bool hasFastCheckableSelector() const { return m_hasFastCheckableSelector; } | 66 bool hasFastCheckableSelector() const { return m_hasFastCheckableSelector; } |
| 63 bool hasMultipartSelector() const { return m_hasMultipartSelector; } | 67 bool hasMultipartSelector() const { return m_hasMultipartSelector; } |
| 64 bool hasRightmostSelectorMatchingHTMLBasedOnRuleHash() const { return m_hasR
ightmostSelectorMatchingHTMLBasedOnRuleHash; } | 68 bool hasRightmostSelectorMatchingHTMLBasedOnRuleHash() const { return m_hasR
ightmostSelectorMatchingHTMLBasedOnRuleHash; } |
| 65 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } | 69 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } |
| 66 unsigned specificity() const { return m_specificity; } | 70 unsigned specificity() const { return m_specificity; } |
| 67 unsigned linkMatchType() const { return m_linkMatchType; } | 71 unsigned linkMatchType() const { return m_linkMatchType; } |
| 68 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} | 72 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} |
| 69 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } | 73 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } |
| 70 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. | 74 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. |
| 71 static const unsigned maximumIdentifierCount = 4; | 75 static const unsigned maximumIdentifierCount = 4; |
| 72 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } | 76 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } |
| 73 | 77 |
| 74 void reportMemoryUsage(MemoryObjectInfo*) const; | 78 void reportMemoryUsage(MemoryObjectInfo*) const; |
| 75 | 79 |
| 76 private: | 80 private: |
| 77 StyleRule* m_rule; | 81 StyleRule* m_rule; |
| 78 unsigned m_selectorIndex : 13; | 82 unsigned m_selectorIndex : 12; |
| 83 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a
primitive array. |
| 79 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. | 84 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. |
| 80 // Some simple testing showed <100,000 RuleData's on large sites. | 85 // Some simple testing showed <100,000 RuleData's on large sites. |
| 81 unsigned m_position : 18; | 86 unsigned m_position : 18; |
| 82 unsigned m_hasFastCheckableSelector : 1; | 87 unsigned m_hasFastCheckableSelector : 1; |
| 83 unsigned m_specificity : 24; | 88 unsigned m_specificity : 24; |
| 84 unsigned m_hasMultipartSelector : 1; | 89 unsigned m_hasMultipartSelector : 1; |
| 85 unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1; | 90 unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1; |
| 86 unsigned m_containsUncommonAttributeSelector : 1; | 91 unsigned m_containsUncommonAttributeSelector : 1; |
| 87 unsigned m_linkMatchType : 2; // SelectorChecker::LinkMatchMask | 92 unsigned m_linkMatchType : 2; // SelectorChecker::LinkMatchMask |
| 88 unsigned m_hasDocumentSecurityOrigin : 1; | 93 unsigned m_hasDocumentSecurityOrigin : 1; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; | 109 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; |
| 105 public: | 110 public: |
| 106 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } | 111 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } |
| 107 | 112 |
| 108 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl
eResolver* = 0, const ContainerNode* = 0); | 113 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl
eResolver* = 0, const ContainerNode* = 0); |
| 109 void addStyleRule(StyleRule*, AddRuleFlags); | 114 void addStyleRule(StyleRule*, AddRuleFlags); |
| 110 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); | 115 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); |
| 111 | 116 |
| 112 const RuleFeatureSet& features() const { return m_features; } | 117 const RuleFeatureSet& features() const { return m_features; } |
| 113 | 118 |
| 114 const Vector<RuleData>* idRules(AtomicStringImpl* key) const { ASSERT(!m_pen
dingRules); return m_idRules.get(key); } | 119 const RuleData* idRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRule
s); return m_idRules.get(key); } |
| 115 const Vector<RuleData>* classRules(AtomicStringImpl* key) const { ASSERT(!m_
pendingRules); return m_classRules.get(key); } | 120 const RuleData* classRules(AtomicStringImpl* key) const { ASSERT(!m_pendingR
ules); return m_classRules.get(key); } |
| 116 const Vector<RuleData>* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pe
ndingRules); return m_tagRules.get(key); } | 121 const RuleData* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRul
es); return m_tagRules.get(key); } |
| 117 const Vector<RuleData>* shadowPseudoElementRules(AtomicStringImpl* key) cons
t { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); } | 122 const RuleData* shadowPseudoElementRules(AtomicStringImpl* key) const { ASSE
RT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); } |
| 118 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } | 123 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } |
| 119 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } | 124 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } |
| 120 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } | 125 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } |
| 121 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } | 126 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } |
| 122 const Vector<StyleRulePage*>& pageRules() const { ASSERT(!m_pendingRules); r
eturn m_pageRules; } | 127 const Vector<StyleRulePage*>& pageRules() const { ASSERT(!m_pendingRules); r
eturn m_pageRules; } |
| 123 | 128 |
| 124 unsigned ruleCount() const { return m_ruleCount; } | 129 unsigned ruleCount() const { return m_ruleCount; } |
| 125 | 130 |
| 126 void compactRulesIfNeeded() | 131 void compactRulesIfNeeded() |
| 127 { | 132 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 void reportMemoryUsage(MemoryObjectInfo*) const; | 143 void reportMemoryUsage(MemoryObjectInfo*) const; |
| 139 | 144 |
| 140 const CSSSelector* selector; | 145 const CSSSelector* selector; |
| 141 OwnPtr<RuleSet> ruleSet; | 146 OwnPtr<RuleSet> ruleSet; |
| 142 }; | 147 }; |
| 143 | 148 |
| 144 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; | 149 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; |
| 145 | 150 |
| 146 private: | 151 private: |
| 147 typedef HashMap<AtomicStringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingR
uleMap; | 152 typedef HashMap<AtomicStringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingR
uleMap; |
| 148 typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > CompactRuleMa
p; | 153 typedef HashMap<AtomicStringImpl*, OwnPtr<RuleData> > CompactRuleMap; |
| 149 | 154 |
| 150 RuleSet() | 155 RuleSet() |
| 151 : m_ruleCount(0) | 156 : m_ruleCount(0) |
| 152 { | 157 { |
| 153 } | 158 } |
| 154 | 159 |
| 155 void addToRuleSet(AtomicStringImpl* key, PendingRuleMap&, const RuleData&); | 160 void addToRuleSet(AtomicStringImpl* key, PendingRuleMap&, const RuleData&); |
| 156 void addPageRule(StyleRulePage*); | 161 void addPageRule(StyleRulePage*); |
| 157 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); | 162 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); |
| 158 | 163 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 187 RuleFeatureSet m_features; | 192 RuleFeatureSet m_features; |
| 188 Vector<StyleRulePage*> m_pageRules; | 193 Vector<StyleRulePage*> m_pageRules; |
| 189 | 194 |
| 190 unsigned m_ruleCount; | 195 unsigned m_ruleCount; |
| 191 OwnPtr<PendingRuleMaps> m_pendingRules; | 196 OwnPtr<PendingRuleMaps> m_pendingRules; |
| 192 }; | 197 }; |
| 193 | 198 |
| 194 } // namespace WebCore | 199 } // namespace WebCore |
| 195 | 200 |
| 196 #endif // RuleSet_h | 201 #endif // RuleSet_h |
| OLD | NEW |