| 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 22 matching lines...) Expand all Loading... |
| 33 #include "sky/engine/wtf/TerminatedArray.h" | 33 #include "sky/engine/wtf/TerminatedArray.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 enum AddRuleFlags { | 37 enum AddRuleFlags { |
| 38 RuleHasNoSpecialState = 0, | 38 RuleHasNoSpecialState = 0, |
| 39 RuleCanUseFastCheckSelector = 1, | 39 RuleCanUseFastCheckSelector = 1, |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 class CSSSelector; | 42 class CSSSelector; |
| 43 class MediaQueryEvaluator; | |
| 44 class StyleSheetContents; | 43 class StyleSheetContents; |
| 45 | 44 |
| 46 class RuleData { | 45 class RuleData { |
| 47 ALLOW_ONLY_INLINE_ALLOCATION(); | 46 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 48 public: | 47 public: |
| 49 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); | 48 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); |
| 50 | 49 |
| 51 unsigned position() const { return m_position; } | 50 unsigned position() const { return m_position; } |
| 52 StyleRule* rule() const { return m_rule; } | 51 StyleRule* rule() const { return m_rule; } |
| 53 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } | 52 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s
tay_small); | 72 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s
tay_small); |
| 74 | 73 |
| 75 class RuleSet { | 74 class RuleSet { |
| 76 WTF_MAKE_NONCOPYABLE(RuleSet); | 75 WTF_MAKE_NONCOPYABLE(RuleSet); |
| 77 WTF_MAKE_FAST_ALLOCATED; | 76 WTF_MAKE_FAST_ALLOCATED; |
| 78 public: | 77 public: |
| 79 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } | 78 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } |
| 80 | 79 |
| 81 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, AddR
uleFlags = RuleHasNoSpecialState); | 80 void addRulesFromSheet(StyleSheetContents*, AddRuleFlags = RuleHasNoSpecialS
tate); |
| 82 void addStyleRule(StyleRule*, AddRuleFlags); | 81 void addStyleRule(StyleRule*, AddRuleFlags); |
| 83 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); | 82 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); |
| 84 | 83 |
| 85 const RuleFeatureSet& features() const { return m_features; } | 84 const RuleFeatureSet& features() const { return m_features; } |
| 86 | 85 |
| 87 const TerminatedArray<RuleData>* idRules(const AtomicString& key) const { AS
SERT(!m_pendingRules); return m_idRules.get(key); } | 86 const TerminatedArray<RuleData>* idRules(const AtomicString& key) const { AS
SERT(!m_pendingRules); return m_idRules.get(key); } |
| 88 const TerminatedArray<RuleData>* classRules(const AtomicString& key) const {
ASSERT(!m_pendingRules); return m_classRules.get(key); } | 87 const TerminatedArray<RuleData>* classRules(const AtomicString& key) const {
ASSERT(!m_pendingRules); return m_classRules.get(key); } |
| 89 const TerminatedArray<RuleData>* tagRules(const AtomicString& key) const { A
SSERT(!m_pendingRules); return m_tagRules.get(key); } | 88 const TerminatedArray<RuleData>* tagRules(const AtomicString& key) const { A
SSERT(!m_pendingRules); return m_tagRules.get(key); } |
| 90 const TerminatedArray<RuleData>* shadowPseudoElementRules(const AtomicString
& key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(ke
y); } | 89 const TerminatedArray<RuleData>* shadowPseudoElementRules(const AtomicString
& key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(ke
y); } |
| 91 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } | 90 const Vector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); re
turn &m_universalRules; } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 110 | 109 |
| 111 RuleSet() | 110 RuleSet() |
| 112 : m_ruleCount(0) | 111 : m_ruleCount(0) |
| 113 { | 112 { |
| 114 } | 113 } |
| 115 | 114 |
| 116 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&)
; | 115 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&)
; |
| 117 void addFontFaceRule(StyleRuleFontFace*); | 116 void addFontFaceRule(StyleRuleFontFace*); |
| 118 void addKeyframesRule(StyleRuleKeyframes*); | 117 void addKeyframesRule(StyleRuleKeyframes*); |
| 119 | 118 |
| 120 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, AddRuleFlags); | 119 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, AddRuleFlags); |
| 121 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&); | 120 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&); |
| 122 | 121 |
| 123 void compactRules(); | 122 void compactRules(); |
| 124 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); | 123 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); |
| 125 | 124 |
| 126 class PendingRuleMaps { | 125 class PendingRuleMaps { |
| 127 public: | 126 public: |
| 128 static PassOwnPtr<PendingRuleMaps> create() { return adoptPtr(new Pendin
gRuleMaps); } | 127 static PassOwnPtr<PendingRuleMaps> create() { return adoptPtr(new Pendin
gRuleMaps); } |
| 129 | 128 |
| 130 PendingRuleMap idRules; | 129 PendingRuleMap idRules; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 160 #ifndef NDEBUG | 159 #ifndef NDEBUG |
| 161 Vector<RuleData> m_allRules; | 160 Vector<RuleData> m_allRules; |
| 162 #endif | 161 #endif |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 } // namespace blink | 164 } // namespace blink |
| 166 | 165 |
| 167 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); | 166 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); |
| 168 | 167 |
| 169 #endif // SKY_ENGINE_CORE_CSS_RULESET_H_ | 168 #endif // SKY_ENGINE_CORE_CSS_RULESET_H_ |
| OLD | NEW |