| 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 20 matching lines...) Expand all Loading... |
| 31 #include "wtf/HashMap.h" | 31 #include "wtf/HashMap.h" |
| 32 #include "wtf/LinkedStack.h" | 32 #include "wtf/LinkedStack.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 enum AddRuleFlags { | 36 enum AddRuleFlags { |
| 37 RuleHasNoSpecialState = 0, | 37 RuleHasNoSpecialState = 0, |
| 38 RuleHasDocumentSecurityOrigin = 1, | 38 RuleHasDocumentSecurityOrigin = 1, |
| 39 RuleCanUseFastCheckSelector = 1 << 1, | 39 RuleCanUseFastCheckSelector = 1 << 1, |
| 40 RuleIsInRegionRule = 1 << 2, | 40 RuleIsInRegionRule = 1 << 2, |
| 41 ViewportRuleIsProcessed = 1 << 3 |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 enum PropertyWhitelistType { | 44 enum PropertyWhitelistType { |
| 44 PropertyWhitelistNone = 0, | 45 PropertyWhitelistNone = 0, |
| 45 PropertyWhitelistRegion, | 46 PropertyWhitelistRegion, |
| 46 PropertyWhitelistCue | 47 PropertyWhitelistCue |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 class CSSSelector; | 50 class CSSSelector; |
| 50 class MediaQueryEvaluator; | 51 class MediaQueryEvaluator; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 unsigned d[4]; | 116 unsigned d[4]; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s
tay_small); | 119 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s
tay_small); |
| 119 | 120 |
| 120 class RuleSet { | 121 class RuleSet { |
| 121 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; | 122 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; |
| 122 public: | 123 public: |
| 123 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } | 124 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } |
| 124 | 125 |
| 125 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, bool
hasDocumentSecurityOrigin = false); | 126 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, AddR
uleFlags = RuleHasNoSpecialState); |
| 126 void addStyleRule(StyleRule*, AddRuleFlags); | 127 void addStyleRule(StyleRule*, AddRuleFlags); |
| 127 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); | 128 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); |
| 129 void addViewportRule(StyleRuleViewport*); |
| 128 | 130 |
| 129 const RuleFeatureSet& features() const { return m_features; } | 131 const RuleFeatureSet& features() const { return m_features; } |
| 130 | 132 |
| 131 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re
turn m_idRules.get(key); } | 133 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re
turn m_idRules.get(key); } |
| 132 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules);
return m_classRules.get(key); } | 134 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules);
return m_classRules.get(key); } |
| 133 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r
eturn m_tagRules.get(key); } | 135 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r
eturn m_tagRules.get(key); } |
| 134 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_
pendingRules); return m_shadowPseudoElementRules.get(key); } | 136 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_
pendingRules); return m_shadowPseudoElementRules.get(key); } |
| 135 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } | 137 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule
s); return &m_linkPseudoClassRules; } |
| 136 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } | 138 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re
turn &m_cuePseudoRules; } |
| 137 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } | 139 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul
es); return &m_focusPseudoClassRules; } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 168 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap
; | 170 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap
; |
| 169 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; | 171 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; |
| 170 | 172 |
| 171 RuleSet() | 173 RuleSet() |
| 172 : m_ruleCount(0) | 174 : m_ruleCount(0) |
| 173 { | 175 { |
| 174 } | 176 } |
| 175 | 177 |
| 176 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); | 178 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); |
| 177 void addPageRule(StyleRulePage*); | 179 void addPageRule(StyleRulePage*); |
| 178 void addViewportRule(StyleRuleViewport*); | |
| 179 void addFontFaceRule(StyleRuleFontFace*); | 180 void addFontFaceRule(StyleRuleFontFace*); |
| 180 void addKeyframesRule(StyleRuleKeyframes*); | 181 void addKeyframesRule(StyleRuleKeyframes*); |
| 181 void addHostRule(StyleRuleHost*); | 182 void addHostRule(StyleRuleHost*); |
| 182 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); | 183 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); |
| 183 | 184 |
| 184 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, bool hasDocumentSecurityOrigin, AddRuleFlags); | 185 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, AddRuleFlags); |
| 185 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); | 186 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); |
| 186 | 187 |
| 187 void compactRules(); | 188 void compactRules(); |
| 188 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); | 189 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); |
| 189 | 190 |
| 190 struct PendingRuleMaps { | 191 struct PendingRuleMaps { |
| 191 PendingRuleMap idRules; | 192 PendingRuleMap idRules; |
| 192 PendingRuleMap classRules; | 193 PendingRuleMap classRules; |
| 193 PendingRuleMap tagRules; | 194 PendingRuleMap tagRules; |
| 194 PendingRuleMap shadowPseudoElementRules; | 195 PendingRuleMap shadowPseudoElementRules; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 220 | 221 |
| 221 MediaQueryResultList m_viewportDependentMediaQueryResults; | 222 MediaQueryResultList m_viewportDependentMediaQueryResults; |
| 222 | 223 |
| 223 unsigned m_ruleCount; | 224 unsigned m_ruleCount; |
| 224 OwnPtr<PendingRuleMaps> m_pendingRules; | 225 OwnPtr<PendingRuleMaps> m_pendingRules; |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 } // namespace WebCore | 228 } // namespace WebCore |
| 228 | 229 |
| 229 #endif // RuleSet_h | 230 #endif // RuleSet_h |
| OLD | NEW |