| 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 16 matching lines...) Expand all Loading... |
| 27 #include "sky/engine/wtf/HashSet.h" | 27 #include "sky/engine/wtf/HashSet.h" |
| 28 #include "sky/engine/wtf/text/AtomicStringHash.h" | 28 #include "sky/engine/wtf/text/AtomicStringHash.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 class CSSSelectorList; | 32 class CSSSelectorList; |
| 33 class Element; | 33 class Element; |
| 34 class QualifiedName; | 34 class QualifiedName; |
| 35 class RuleData; | 35 class RuleData; |
| 36 class SpaceSplitString; | 36 class SpaceSplitString; |
| 37 class StyleRule; | |
| 38 | |
| 39 struct RuleFeature { | |
| 40 RuleFeature(StyleRule* rule, unsigned selectorIndex) | |
| 41 : rule(rule) | |
| 42 , selectorIndex(selectorIndex) | |
| 43 { | |
| 44 } | |
| 45 | |
| 46 StyleRule* rule; | |
| 47 unsigned selectorIndex; | |
| 48 }; | |
| 49 | 37 |
| 50 class RuleFeatureSet { | 38 class RuleFeatureSet { |
| 51 public: | 39 public: |
| 52 RuleFeatureSet(); | 40 RuleFeatureSet(); |
| 53 ~RuleFeatureSet(); | 41 ~RuleFeatureSet(); |
| 54 | 42 |
| 55 void add(const RuleFeatureSet&); | 43 void add(const RuleFeatureSet&); |
| 56 void clear(); | 44 void clear(); |
| 57 | 45 |
| 58 void collectFeaturesFromSelector(const CSSSelector&); | 46 void collectFeaturesFromSelector(const CSSSelector&); |
| 59 void collectFeaturesFromRuleData(const RuleData&); | |
| 60 | 47 |
| 61 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const | 48 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const |
| 62 { | 49 { |
| 63 ASSERT(!attributeName.isEmpty()); | 50 ASSERT(!attributeName.isEmpty()); |
| 64 return m_attributeNames.contains(attributeName); | 51 return m_attributeNames.contains(attributeName); |
| 65 } | 52 } |
| 66 | 53 |
| 67 inline bool hasSelectorForClass(const AtomicString& classValue) const | 54 inline bool hasSelectorForClass(const AtomicString& classValue) const |
| 68 { | 55 { |
| 69 ASSERT(!classValue.isEmpty()); | 56 ASSERT(!classValue.isEmpty()); |
| 70 return m_classNames.contains(classValue); | 57 return m_classNames.contains(classValue); |
| 71 } | 58 } |
| 72 | 59 |
| 73 inline bool hasSelectorForId(const AtomicString& idValue) const | 60 inline bool hasSelectorForId(const AtomicString& idValue) const |
| 74 { | 61 { |
| 75 ASSERT(!idValue.isEmpty()); | 62 ASSERT(!idValue.isEmpty()); |
| 76 return m_idNames.contains(idValue); | 63 return m_idNames.contains(idValue); |
| 77 } | 64 } |
| 78 | 65 |
| 79 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element&); | 66 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element&); |
| 80 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element&); | 67 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element&); |
| 81 | 68 |
| 82 void scheduleStyleInvalidationForClassChange(const AtomicString& className,
Element& element); | 69 void scheduleStyleInvalidationForClassChange(const AtomicString& className,
Element& element); |
| 83 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element&); | 70 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element&); |
| 84 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A
tomicString& newId, Element&); | 71 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A
tomicString& newId, Element&); |
| 85 | 72 |
| 86 Vector<RuleFeature> attributeRules; | |
| 87 | |
| 88 private: | 73 private: |
| 89 void addSelectorFeatures(const CSSSelector&); | 74 void addSelectorFeatures(const CSSSelector&); |
| 90 void collectFeaturesFromSelectorList(const CSSSelectorList*); | 75 void collectFeaturesFromSelectorList(const CSSSelectorList*); |
| 91 | 76 |
| 92 HashSet<AtomicString> m_classNames; | 77 HashSet<AtomicString> m_classNames; |
| 93 HashSet<AtomicString> m_attributeNames; | 78 HashSet<AtomicString> m_attributeNames; |
| 94 HashSet<AtomicString> m_idNames; | 79 HashSet<AtomicString> m_idNames; |
| 95 }; | 80 }; |
| 96 | 81 |
| 97 | |
| 98 } // namespace blink | 82 } // namespace blink |
| 99 | 83 |
| 100 namespace WTF { | |
| 101 | |
| 102 template <> struct VectorTraits<blink::RuleFeature> : VectorTraitsBase<blink::Ru
leFeature> { | |
| 103 static const bool needsDestruction = false; | |
| 104 static const bool canInitializeWithMemset = true; | |
| 105 static const bool canMoveWithMemcpy = true; | |
| 106 }; | |
| 107 | |
| 108 } // namespace WTF | |
| 109 | |
| 110 #endif // SKY_ENGINE_CORE_CSS_RULEFEATURE_H_ | 84 #endif // SKY_ENGINE_CORE_CSS_RULEFEATURE_H_ |
| OLD | NEW |