OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Loading... |
34 #include "core/css/RuleFeature.h" | 34 #include "core/css/RuleFeature.h" |
35 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class SpaceSplitString; | 39 class SpaceSplitString; |
40 | 40 |
41 class SelectRuleFeatureSet { | 41 class SelectRuleFeatureSet { |
42 DISALLOW_ALLOCATION(); | 42 DISALLOW_ALLOCATION(); |
43 public: | 43 public: |
44 SelectRuleFeatureSet(); | |
45 | |
46 void add(const SelectRuleFeatureSet&); | 44 void add(const SelectRuleFeatureSet&); |
47 void clear(); | 45 void clear(); |
48 void collectFeaturesFromSelector(const CSSSelector&); | 46 void collectFeaturesFromSelector(const CSSSelector&); |
49 | 47 |
50 bool hasSelectorForId(const AtomicString&) const; | 48 bool hasSelectorForId(const AtomicString&) const; |
51 bool hasSelectorForClass(const AtomicString&) const; | 49 bool hasSelectorForClass(const AtomicString&) const; |
52 bool hasSelectorForAttribute(const AtomicString&) const; | 50 bool hasSelectorForAttribute(const AtomicString&) const; |
| 51 bool hasSelectorForPseudoType(CSSSelector::PseudoType) const; |
53 | 52 |
54 bool hasSelectorForChecked() const { return hasSelectorFor(AffectedSelectorC
hecked); } | 53 bool hasSelectorForChecked() const { return hasSelectorForPseudoType(CSSSele
ctor::PseudoChecked); } |
55 bool hasSelectorForEnabled() const { return hasSelectorFor(AffectedSelectorE
nabled); } | 54 bool hasSelectorForEnabled() const { return hasSelectorForPseudoType(CSSSele
ctor::PseudoEnabled); } |
56 bool hasSelectorForDisabled() const { return hasSelectorFor(AffectedSelector
Disabled); } | 55 bool hasSelectorForDisabled() const { return hasSelectorForPseudoType(CSSSel
ector::PseudoDisabled); } |
57 bool hasSelectorForIndeterminate() const { return hasSelectorFor(AffectedSel
ectorIndeterminate); } | 56 bool hasSelectorForIndeterminate() const { return hasSelectorForPseudoType(C
SSSelector::PseudoIndeterminate); } |
58 bool hasSelectorForLink() const { return hasSelectorFor(AffectedSelectorLink
); } | 57 bool hasSelectorForLink() const { return hasSelectorForPseudoType(CSSSelecto
r::PseudoLink); } |
59 bool hasSelectorForTarget() const { return hasSelectorFor(AffectedSelectorTa
rget); } | 58 bool hasSelectorForTarget() const { return hasSelectorForPseudoType(CSSSelec
tor::PseudoTarget); } |
60 bool hasSelectorForVisited() const { return hasSelectorFor(AffectedSelectorV
isited); } | 59 bool hasSelectorForVisited() const { return hasSelectorForPseudoType(CSSSele
ctor::PseudoVisited); } |
61 | |
62 bool hasSelectorFor(AffectedSelectorMask features) const { return m_featureF
lags & features; } | |
63 | 60 |
64 bool checkSelectorsForClassChange(const SpaceSplitString& changedClasses) co
nst; | 61 bool checkSelectorsForClassChange(const SpaceSplitString& changedClasses) co
nst; |
65 bool checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const
SpaceSplitString& newClasses) const; | 62 bool checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const
SpaceSplitString& newClasses) const; |
66 | 63 |
67 void trace(Visitor* visitor) { visitor->trace(m_cssRuleFeatureSet); } | 64 void trace(Visitor* visitor) { visitor->trace(m_cssRuleFeatureSet); } |
68 | 65 |
69 private: | 66 private: |
70 void setSelectRuleFeature(AffectedSelectorType feature) { m_featureFlags |=
feature; } | |
71 | |
72 RuleFeatureSet m_cssRuleFeatureSet; | 67 RuleFeatureSet m_cssRuleFeatureSet; |
73 int m_featureFlags; | |
74 }; | 68 }; |
75 | 69 |
76 inline bool SelectRuleFeatureSet::hasSelectorForId(const AtomicString& idValue)
const | 70 inline bool SelectRuleFeatureSet::hasSelectorForId(const AtomicString& idValue)
const |
77 { | 71 { |
78 ASSERT(!idValue.isEmpty()); | 72 ASSERT(!idValue.isEmpty()); |
79 return m_cssRuleFeatureSet.hasSelectorForId(idValue); | 73 return m_cssRuleFeatureSet.hasSelectorForId(idValue); |
80 } | 74 } |
81 | 75 |
82 inline bool SelectRuleFeatureSet::hasSelectorForClass(const AtomicString& classV
alue) const | 76 inline bool SelectRuleFeatureSet::hasSelectorForClass(const AtomicString& classV
alue) const |
83 { | 77 { |
84 ASSERT(!classValue.isEmpty()); | 78 ASSERT(!classValue.isEmpty()); |
85 return m_cssRuleFeatureSet.hasSelectorForClass(classValue); | 79 return m_cssRuleFeatureSet.hasSelectorForClass(classValue); |
86 } | 80 } |
87 | 81 |
88 inline bool SelectRuleFeatureSet::hasSelectorForAttribute(const AtomicString& at
tributeName) const | 82 inline bool SelectRuleFeatureSet::hasSelectorForAttribute(const AtomicString& at
tributeName) const |
89 { | 83 { |
90 ASSERT(!attributeName.isEmpty()); | 84 ASSERT(!attributeName.isEmpty()); |
91 return m_cssRuleFeatureSet.hasSelectorForAttribute(attributeName); | 85 return m_cssRuleFeatureSet.hasSelectorForAttribute(attributeName); |
92 } | 86 } |
93 | 87 |
| 88 inline bool SelectRuleFeatureSet::hasSelectorForPseudoType(CSSSelector::PseudoTy
pe pseudo) const |
| 89 { |
| 90 return m_cssRuleFeatureSet.hasSelectorForPseudoType(pseudo); |
| 91 } |
| 92 |
94 } | 93 } |
95 | 94 |
96 #endif | 95 #endif |
OLD | NEW |