Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/text/AtomicStringHash.h" | 40 #include "wtf/text/AtomicStringHash.h" |
| 41 #include "wtf/text/StringHash.h" | 41 #include "wtf/text/StringHash.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class Element; | 45 class Element; |
| 46 class TracedValue; | 46 class TracedValue; |
| 47 | 47 |
| 48 // Tracks data to determine which elements of a DOM subtree need to have style | 48 // Tracks data to determine which descendants in a DOM subtree, or |
| 49 // recalculated. | 49 // siblings and their descendants, need to have style recalculated. |
| 50 class CORE_EXPORT InvalidationSet final : public RefCountedWillBeGarbageCollecte d<InvalidationSet> { | 50 class CORE_EXPORT InvalidationSet final : public RefCountedWillBeGarbageCollecte d<InvalidationSet> { |
| 51 WTF_MAKE_NONCOPYABLE(InvalidationSet); | 51 WTF_MAKE_NONCOPYABLE(InvalidationSet); |
| 52 public: | 52 public: |
| 53 static PassRefPtrWillBeRawPtr<InvalidationSet> create() | 53 static PassRefPtrWillBeRawPtr<InvalidationSet> create() |
| 54 { | 54 { |
| 55 return adoptRefWillBeNoop(new InvalidationSet); | 55 return adoptRefWillBeNoop(new InvalidationSet); |
| 56 } | 56 } |
| 57 | 57 |
| 58 static void cacheTracingFlag(); | 58 static void cacheTracingFlag(); |
| 59 | 59 |
| 60 bool invalidatesElement(Element&) const; | 60 bool invalidatesElement(Element&) const; |
| 61 | 61 |
| 62 void combine(const InvalidationSet& other); | 62 void combine(const InvalidationSet& other); |
| 63 | 63 |
| 64 void addClass(const AtomicString& className); | 64 void addClass(const AtomicString& className); |
| 65 void addId(const AtomicString& id); | 65 void addId(const AtomicString& id); |
| 66 void addTagName(const AtomicString& tagName); | 66 void addTagName(const AtomicString& tagName); |
| 67 void addAttribute(const AtomicString& attributeLocalName); | 67 void addAttribute(const AtomicString& attributeLocalName); |
| 68 | 68 |
| 69 const InvalidationSet* descendants() const { return m_descendantInvalidation Set.get(); } | |
| 70 | |
| 71 InvalidationSet& ensureDescendantInvalidationSet(); | |
| 72 | |
| 69 void setWholeSubtreeInvalid(); | 73 void setWholeSubtreeInvalid(); |
| 70 bool wholeSubtreeInvalid() const { return m_allDescendantsMightBeInvalid; } | 74 bool wholeSubtreeInvalid() const { return m_allDescendantsMightBeInvalid; } |
| 71 | 75 |
| 72 void setInvalidatesSelf() { m_invalidatesSelf = true; } | 76 void setInvalidatesSelf() { m_invalidatesSelf = true; } |
| 73 bool invalidatesSelf() const { return m_invalidatesSelf; } | 77 bool invalidatesSelf() const { return m_invalidatesSelf; } |
| 74 | 78 |
| 75 void setTreeBoundaryCrossing() { m_treeBoundaryCrossing = true; } | 79 void setTreeBoundaryCrossing() { m_treeBoundaryCrossing = true; } |
| 76 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 80 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
| 77 | 81 |
| 78 void setInsertionPointCrossing() { m_insertionPointCrossing = true; } | 82 void setInsertionPointCrossing() { m_insertionPointCrossing = true; } |
| 79 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 83 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
| 80 | 84 |
| 81 void setCustomPseudoInvalid() { m_customPseudoInvalid = true; } | 85 void setCustomPseudoInvalid() { m_customPseudoInvalid = true; } |
| 82 bool customPseudoInvalid() const { return m_customPseudoInvalid; } | 86 bool customPseudoInvalid() const { return m_customPseudoInvalid; } |
| 83 | 87 |
| 88 unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSele ctors; } | |
| 89 void updateMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentS electors = std::max(value, m_maxDirectAdjacentSelectors); } | |
| 90 | |
| 84 bool isEmpty() const { return !m_classes && !m_ids && !m_tagNames && !m_attr ibutes && !m_customPseudoInvalid; } | 91 bool isEmpty() const { return !m_classes && !m_ids && !m_tagNames && !m_attr ibutes && !m_customPseudoInvalid; } |
| 85 | 92 |
| 86 DECLARE_TRACE(); | 93 DECLARE_TRACE(); |
| 87 | 94 |
| 88 void toTracedValue(TracedValue*) const; | 95 void toTracedValue(TracedValue*) const; |
| 89 | 96 |
| 90 #ifndef NDEBUG | 97 #ifndef NDEBUG |
| 91 void show() const; | 98 void show() const; |
| 92 #endif | 99 #endif |
| 93 | 100 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 112 unsigned m_invalidatesSelf : 1; | 119 unsigned m_invalidatesSelf : 1; |
| 113 | 120 |
| 114 // If true, all descendants which are custom pseudo elements must be invalid ated. | 121 // If true, all descendants which are custom pseudo elements must be invalid ated. |
| 115 unsigned m_customPseudoInvalid : 1; | 122 unsigned m_customPseudoInvalid : 1; |
| 116 | 123 |
| 117 // If true, the invalidation must traverse into ShadowRoots with this set. | 124 // If true, the invalidation must traverse into ShadowRoots with this set. |
| 118 unsigned m_treeBoundaryCrossing : 1; | 125 unsigned m_treeBoundaryCrossing : 1; |
| 119 | 126 |
| 120 // If true, insertion point descendants must be invalidated. | 127 // If true, insertion point descendants must be invalidated. |
| 121 unsigned m_insertionPointCrossing : 1; | 128 unsigned m_insertionPointCrossing : 1; |
| 129 | |
| 130 // Only for sibling invalidation sets, indicates the maximum possible number of siblings affected. | |
| 131 unsigned m_maxDirectAdjacentSelectors; | |
|
rune
2015/10/02 13:17:59
Can we use sub-classing instead?
SiblingInvalidat
Eric Willigers
2015/10/14 00:25:40
Done.
| |
| 132 | |
| 133 // Only for sibling invalidation sets, indicates the descendants of siblings . | |
| 134 RefPtrWillBeMember<InvalidationSet> m_descendantInvalidationSet; | |
| 135 | |
| 136 friend class RuleFeatureSetTest; | |
| 137 }; | |
| 138 | |
| 139 using InvalidationSetVector = WillBeHeapVector<RefPtrWillBeMember<InvalidationSe t>>; | |
| 140 | |
| 141 struct InvalidationLists { | |
| 142 STACK_ALLOCATED(); | |
| 143 | |
| 144 InvalidationSetVector descendants; | |
| 145 InvalidationSetVector siblings; | |
| 122 }; | 146 }; |
| 123 | 147 |
| 124 } // namespace blink | 148 } // namespace blink |
| 125 | 149 |
| 126 #endif // InvalidationSet_h | 150 #endif // InvalidationSet_h |
| OLD | NEW |