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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 DescendantInvalidationSet::DescendantInvalidationSet() | 39 DescendantInvalidationSet::DescendantInvalidationSet() |
40 : m_allDescendantsMightBeInvalid(false) | 40 : m_allDescendantsMightBeInvalid(false) |
41 { | 41 { |
42 } | 42 } |
43 | 43 |
44 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) | 44 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) |
45 { | 45 { |
46 m_allDescendantsMightBeInvalid = m_allDescendantsMightBeInvalid || other.m_a
llDescendantsMightBeInvalid; | |
47 // No longer bother combining data structures, since the whole subtree is de
emed invalid. | 46 // No longer bother combining data structures, since the whole subtree is de
emed invalid. |
48 if (m_allDescendantsMightBeInvalid) | 47 if (wholeSubtreeInvalid()) |
49 return; | 48 return; |
50 | 49 |
| 50 if (other.wholeSubtreeInvalid()) { |
| 51 setWholeSubtreeInvalid(); |
| 52 return; |
| 53 } |
| 54 |
51 if (other.m_classes) { | 55 if (other.m_classes) { |
52 HashSet<AtomicString>::const_iterator end = other.m_classes->end(); | 56 HashSet<AtomicString>::const_iterator end = other.m_classes->end(); |
53 for (HashSet<AtomicString>::const_iterator it = other.m_classes->begin()
; it != end; ++it) | 57 for (HashSet<AtomicString>::const_iterator it = other.m_classes->begin()
; it != end; ++it) |
54 addClass(*it); | 58 addClass(*it); |
55 } | 59 } |
56 | 60 |
57 if (other.m_ids) { | 61 if (other.m_ids) { |
58 HashSet<AtomicString>::const_iterator end = other.m_ids->end(); | 62 HashSet<AtomicString>::const_iterator end = other.m_ids->end(); |
59 for (HashSet<AtomicString>::const_iterator it = other.m_ids->begin(); it
!= end; ++it) | 63 for (HashSet<AtomicString>::const_iterator it = other.m_ids->begin(); it
!= end; ++it) |
60 addId(*it); | 64 addId(*it); |
(...skipping 22 matching lines...) Expand all Loading... |
83 | 87 |
84 HashSet<AtomicString>& DescendantInvalidationSet::ensureTagNameSet() | 88 HashSet<AtomicString>& DescendantInvalidationSet::ensureTagNameSet() |
85 { | 89 { |
86 if (!m_tagNames) | 90 if (!m_tagNames) |
87 m_tagNames = adoptPtr(new HashSet<AtomicString>); | 91 m_tagNames = adoptPtr(new HashSet<AtomicString>); |
88 return *m_tagNames; | 92 return *m_tagNames; |
89 } | 93 } |
90 | 94 |
91 void DescendantInvalidationSet::addClass(const AtomicString& className) | 95 void DescendantInvalidationSet::addClass(const AtomicString& className) |
92 { | 96 { |
| 97 if (wholeSubtreeInvalid()) |
| 98 return; |
93 ensureClassSet().add(className); | 99 ensureClassSet().add(className); |
94 } | 100 } |
95 | 101 |
96 void DescendantInvalidationSet::addId(const AtomicString& id) | 102 void DescendantInvalidationSet::addId(const AtomicString& id) |
97 { | 103 { |
| 104 if (wholeSubtreeInvalid()) |
| 105 return; |
98 ensureIdSet().add(id); | 106 ensureIdSet().add(id); |
99 } | 107 } |
100 | 108 |
101 void DescendantInvalidationSet::addTagName(const AtomicString& tagName) | 109 void DescendantInvalidationSet::addTagName(const AtomicString& tagName) |
102 { | 110 { |
| 111 if (wholeSubtreeInvalid()) |
| 112 return; |
103 ensureTagNameSet().add(tagName); | 113 ensureTagNameSet().add(tagName); |
104 } | 114 } |
105 | 115 |
106 void DescendantInvalidationSet::getClasses(Vector<AtomicString>& classes) | 116 void DescendantInvalidationSet::getClasses(Vector<AtomicString>& classes) const |
107 { | 117 { |
108 if (!m_classes) | 118 if (!m_classes) |
109 return; | 119 return; |
110 for (HashSet<AtomicString>::const_iterator it = m_classes->begin(); it != m_
classes->end(); ++it) | 120 for (HashSet<AtomicString>::const_iterator it = m_classes->begin(); it != m_
classes->end(); ++it) |
111 classes.append(*it); | 121 classes.append(*it); |
112 } | 122 } |
113 | 123 |
114 } // namespace WebCore | 124 } // namespace WebCore |
OLD | NEW |