| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 InvalidateDescendants, | 51 InvalidateDescendants, |
| 52 InvalidateSiblings | 52 InvalidateSiblings |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Tracks data to determine which descendants in a DOM subtree, or | 55 // Tracks data to determine which descendants in a DOM subtree, or |
| 56 // siblings and their descendants, need to have style recalculated. | 56 // siblings and their descendants, need to have style recalculated. |
| 57 class CORE_EXPORT InvalidationSet : public RefCounted<InvalidationSet> { | 57 class CORE_EXPORT InvalidationSet : public RefCounted<InvalidationSet> { |
| 58 WTF_MAKE_NONCOPYABLE(InvalidationSet); | 58 WTF_MAKE_NONCOPYABLE(InvalidationSet); |
| 59 USING_FAST_MALLOC_WITH_TYPE_NAME(blink::InvalidationSet); | 59 USING_FAST_MALLOC_WITH_TYPE_NAME(blink::InvalidationSet); |
| 60 public: | 60 public: |
| 61 virtual ~InvalidationSet() {} | 61 bool isDescendantInvalidationSet() const { return m_type == InvalidateDescen
dants; } |
| 62 | 62 bool isSiblingInvalidationSet() const { return m_type == InvalidateSiblings;
} |
| 63 virtual bool isDescendantInvalidationSet() const { return false; } | |
| 64 virtual bool isSiblingInvalidationSet() const { return false; } | |
| 65 | 63 |
| 66 static void cacheTracingFlag(); | 64 static void cacheTracingFlag(); |
| 67 | 65 |
| 68 bool invalidatesElement(Element&) const; | 66 bool invalidatesElement(Element&) const; |
| 69 | 67 |
| 70 void addClass(const AtomicString& className); | 68 void addClass(const AtomicString& className); |
| 71 void addId(const AtomicString& id); | 69 void addId(const AtomicString& id); |
| 72 void addTagName(const AtomicString& tagName); | 70 void addTagName(const AtomicString& tagName); |
| 73 void addAttribute(const AtomicString& attributeLocalName); | 71 void addAttribute(const AtomicString& attributeLocalName); |
| 74 | 72 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 93 | 91 |
| 94 #ifndef NDEBUG | 92 #ifndef NDEBUG |
| 95 void show() const; | 93 void show() const; |
| 96 #endif | 94 #endif |
| 97 | 95 |
| 98 const HashSet<AtomicString>& classSetForTesting() const { ASSERT(m_classes);
return *m_classes; } | 96 const HashSet<AtomicString>& classSetForTesting() const { ASSERT(m_classes);
return *m_classes; } |
| 99 const HashSet<AtomicString>& idSetForTesting() const { ASSERT(m_ids); return
*m_ids; } | 97 const HashSet<AtomicString>& idSetForTesting() const { ASSERT(m_ids); return
*m_ids; } |
| 100 const HashSet<AtomicString>& tagNameSetForTesting() const { ASSERT(m_tagName
s); return *m_tagNames; } | 98 const HashSet<AtomicString>& tagNameSetForTesting() const { ASSERT(m_tagName
s); return *m_tagNames; } |
| 101 const HashSet<AtomicString>& attributeSetForTesting() const { ASSERT(m_attri
butes); return *m_attributes; } | 99 const HashSet<AtomicString>& attributeSetForTesting() const { ASSERT(m_attri
butes); return *m_attributes; } |
| 102 | 100 |
| 101 void deref() |
| 102 { |
| 103 if (!derefBase()) |
| 104 return; |
| 105 destroy(); |
| 106 } |
| 107 |
| 103 protected: | 108 protected: |
| 104 InvalidationSet(); | 109 InvalidationSet(InvalidationType); |
| 105 | 110 |
| 106 void combine(const InvalidationSet& other); | 111 void combine(const InvalidationSet& other); |
| 107 | 112 |
| 108 private: | 113 private: |
| 114 void destroy(); |
| 115 |
| 109 HashSet<AtomicString>& ensureClassSet(); | 116 HashSet<AtomicString>& ensureClassSet(); |
| 110 HashSet<AtomicString>& ensureIdSet(); | 117 HashSet<AtomicString>& ensureIdSet(); |
| 111 HashSet<AtomicString>& ensureTagNameSet(); | 118 HashSet<AtomicString>& ensureTagNameSet(); |
| 112 HashSet<AtomicString>& ensureAttributeSet(); | 119 HashSet<AtomicString>& ensureAttributeSet(); |
| 113 | 120 |
| 114 // FIXME: optimize this if it becomes a memory issue. | 121 // FIXME: optimize this if it becomes a memory issue. |
| 115 OwnPtr<HashSet<AtomicString>> m_classes; | 122 OwnPtr<HashSet<AtomicString>> m_classes; |
| 116 OwnPtr<HashSet<AtomicString>> m_ids; | 123 OwnPtr<HashSet<AtomicString>> m_ids; |
| 117 OwnPtr<HashSet<AtomicString>> m_tagNames; | 124 OwnPtr<HashSet<AtomicString>> m_tagNames; |
| 118 OwnPtr<HashSet<AtomicString>> m_attributes; | 125 OwnPtr<HashSet<AtomicString>> m_attributes; |
| 119 | 126 |
| 127 unsigned m_type : 1; |
| 128 |
| 120 // If true, all descendants might be invalidated, so a full subtree recalc i
s required. | 129 // If true, all descendants might be invalidated, so a full subtree recalc i
s required. |
| 121 unsigned m_allDescendantsMightBeInvalid : 1; | 130 unsigned m_allDescendantsMightBeInvalid : 1; |
| 122 | 131 |
| 123 // If true, the element itself is invalid. | 132 // If true, the element itself is invalid. |
| 124 unsigned m_invalidatesSelf : 1; | 133 unsigned m_invalidatesSelf : 1; |
| 125 | 134 |
| 126 // If true, all descendants which are custom pseudo elements must be invalid
ated. | 135 // If true, all descendants which are custom pseudo elements must be invalid
ated. |
| 127 unsigned m_customPseudoInvalid : 1; | 136 unsigned m_customPseudoInvalid : 1; |
| 128 | 137 |
| 129 // If true, the invalidation must traverse into ShadowRoots with this set. | 138 // If true, the invalidation must traverse into ShadowRoots with this set. |
| 130 unsigned m_treeBoundaryCrossing : 1; | 139 unsigned m_treeBoundaryCrossing : 1; |
| 131 | 140 |
| 132 // If true, insertion point descendants must be invalidated. | 141 // If true, insertion point descendants must be invalidated. |
| 133 unsigned m_insertionPointCrossing : 1; | 142 unsigned m_insertionPointCrossing : 1; |
| 134 }; | 143 }; |
| 135 | 144 |
| 136 class CORE_EXPORT DescendantInvalidationSet final : public InvalidationSet { | 145 class CORE_EXPORT DescendantInvalidationSet final : public InvalidationSet { |
| 137 public: | 146 public: |
| 138 static PassRefPtr<DescendantInvalidationSet> create() | 147 static PassRefPtr<DescendantInvalidationSet> create() |
| 139 { | 148 { |
| 140 return adoptRef(new DescendantInvalidationSet); | 149 return adoptRef(new DescendantInvalidationSet); |
| 141 } | 150 } |
| 142 | 151 |
| 143 bool isDescendantInvalidationSet() const final { return true; } | |
| 144 | |
| 145 void combine(const DescendantInvalidationSet& other) | 152 void combine(const DescendantInvalidationSet& other) |
| 146 { | 153 { |
| 147 InvalidationSet::combine(other); | 154 InvalidationSet::combine(other); |
| 148 } | 155 } |
| 149 | 156 |
| 150 private: | 157 private: |
| 151 DescendantInvalidationSet() {} | 158 DescendantInvalidationSet() |
| 159 : InvalidationSet(InvalidateDescendants) {} |
| 152 }; | 160 }; |
| 153 | 161 |
| 154 class CORE_EXPORT SiblingInvalidationSet final : public InvalidationSet { | 162 class CORE_EXPORT SiblingInvalidationSet final : public InvalidationSet { |
| 155 public: | 163 public: |
| 156 static PassRefPtr<SiblingInvalidationSet> create() | 164 static PassRefPtr<SiblingInvalidationSet> create() |
| 157 { | 165 { |
| 158 return adoptRef(new SiblingInvalidationSet); | 166 return adoptRef(new SiblingInvalidationSet); |
| 159 } | 167 } |
| 160 | 168 |
| 161 bool isSiblingInvalidationSet() const final { return true; } | |
| 162 | |
| 163 void combine(const SiblingInvalidationSet& other); | 169 void combine(const SiblingInvalidationSet& other); |
| 164 | 170 |
| 165 DescendantInvalidationSet& descendants() { return *m_descendantInvalidationS
et; } | 171 DescendantInvalidationSet& descendants() { return *m_descendantInvalidationS
et; } |
| 166 const DescendantInvalidationSet& descendants() const { return *m_descendantI
nvalidationSet; } | 172 const DescendantInvalidationSet& descendants() const { return *m_descendantI
nvalidationSet; } |
| 167 | 173 |
| 168 unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSele
ctors; } | 174 unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSele
ctors; } |
| 169 void updateMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentS
electors = std::max(value, m_maxDirectAdjacentSelectors); } | 175 void updateMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentS
electors = std::max(value, m_maxDirectAdjacentSelectors); } |
| 170 | 176 |
| 171 private: | 177 private: |
| 172 SiblingInvalidationSet(); | 178 SiblingInvalidationSet(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 184 InvalidationSetVector descendants; | 190 InvalidationSetVector descendants; |
| 185 InvalidationSetVector siblings; | 191 InvalidationSetVector siblings; |
| 186 }; | 192 }; |
| 187 | 193 |
| 188 DEFINE_TYPE_CASTS(DescendantInvalidationSet, InvalidationSet, value, value->isDe
scendantInvalidationSet(), value.isDescendantInvalidationSet()); | 194 DEFINE_TYPE_CASTS(DescendantInvalidationSet, InvalidationSet, value, value->isDe
scendantInvalidationSet(), value.isDescendantInvalidationSet()); |
| 189 DEFINE_TYPE_CASTS(SiblingInvalidationSet, InvalidationSet, value, value->isSibli
ngInvalidationSet(), value.isSiblingInvalidationSet()); | 195 DEFINE_TYPE_CASTS(SiblingInvalidationSet, InvalidationSet, value, value->isSibli
ngInvalidationSet(), value.isSiblingInvalidationSet()); |
| 190 | 196 |
| 191 } // namespace blink | 197 } // namespace blink |
| 192 | 198 |
| 193 #endif // InvalidationSet_h | 199 #endif // InvalidationSet_h |
| OLD | NEW |