Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include "config.h" | 6 #include "config.h" |
| 7 | 7 |
| 8 #include "core/css/invalidation/StyleInvalidator.h" | 8 #include "core/css/invalidation/StyleInvalidator.h" |
| 9 | 9 |
| 10 #include "core/css/invalidation/DescendantInvalidationSet.h" | 10 #include "core/css/invalidation/DescendantInvalidationSet.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 { | 21 { |
| 22 if (Element* documentElement = document.documentElement()) | 22 if (Element* documentElement = document.documentElement()) |
| 23 invalidate(*documentElement); | 23 invalidate(*documentElement); |
| 24 document.clearChildNeedsStyleInvalidation(); | 24 document.clearChildNeedsStyleInvalidation(); |
| 25 document.clearNeedsStyleInvalidation(); | 25 document.clearNeedsStyleInvalidation(); |
| 26 clearPendingInvalidations(); | 26 clearPendingInvalidations(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void StyleInvalidator::scheduleInvalidation(PassRefPtr<DescendantInvalidationSet > invalidationSet, Element& element) | 29 void StyleInvalidator::scheduleInvalidation(PassRefPtr<DescendantInvalidationSet > invalidationSet, Element& element) |
| 30 { | 30 { |
| 31 ASSERT(element.inActiveDocument() && element.styleChangeType() < SubtreeStyl eChange); | |
|
esprehn
2014/05/08 05:19:06
Lets split this into two ASSERTs, one per line. Wh
chrishtr
2014/05/08 05:29:18
Done.
| |
| 31 InvalidationList& list = ensurePendingInvalidationList(element); | 32 InvalidationList& list = ensurePendingInvalidationList(element); |
| 32 // If we're already going to invalidate the whole subtree we don't need to s tore any new sets. | 33 // If we're already going to invalidate the whole subtree we don't need to s tore any new sets. |
| 33 if (!list.isEmpty() && list.last()->wholeSubtreeInvalid()) | 34 if (!list.isEmpty() && list.last()->wholeSubtreeInvalid()) |
| 34 return; | 35 return; |
| 35 // If this set would invalidate the whole subtree we can discard all existin g sets. | 36 // If this set would invalidate the whole subtree we can discard all existin g sets. |
| 36 if (invalidationSet->wholeSubtreeInvalid()) | 37 if (invalidationSet->wholeSubtreeInvalid()) |
| 37 list.clear(); | 38 list.clear(); |
| 38 list.append(invalidationSet); | 39 list.append(invalidationSet); |
| 39 element.setNeedsStyleInvalidation(); | 40 element.setNeedsStyleInvalidation(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL ist(Element& element) | 43 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL ist(Element& element) |
| 43 { | 44 { |
| 44 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(& element, nullptr); | 45 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(& element, nullptr); |
| 45 if (addResult.isNewEntry) | 46 if (addResult.isNewEntry) |
| 46 addResult.storedValue->value = adoptPtr(new InvalidationList); | 47 addResult.storedValue->value = adoptPtr(new InvalidationList); |
| 47 return *addResult.storedValue->value; | 48 return *addResult.storedValue->value; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void StyleInvalidator::clearInvalidation(Node& node) | 51 void StyleInvalidator::clearInvalidation(Node& node) |
| 51 { | 52 { |
| 52 if (node.isElementNode() && node.needsStyleInvalidation()) | 53 if (node.isElementNode() && node.needsStyleInvalidation()) |
| 53 m_pendingInvalidationMap.remove(toElement(&node)); | 54 m_pendingInvalidationMap.remove(toElement(&node)); |
| 54 node.clearChildNeedsStyleInvalidation(); | |
| 55 node.clearNeedsStyleInvalidation(); | |
| 56 } | 55 } |
| 57 | 56 |
| 58 void StyleInvalidator::clearPendingInvalidations() | 57 void StyleInvalidator::clearPendingInvalidations() |
| 59 { | 58 { |
| 60 m_pendingInvalidationMap.clear(); | 59 m_pendingInvalidationMap.clear(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 StyleInvalidator::StyleInvalidator() | 62 StyleInvalidator::StyleInvalidator() |
| 64 { | 63 { |
| 65 } | 64 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 element.setNeedsStyleRecalc(LocalStyleChange); | 148 element.setNeedsStyleRecalc(LocalStyleChange); |
| 150 } | 149 } |
| 151 | 150 |
| 152 element.clearChildNeedsStyleInvalidation(); | 151 element.clearChildNeedsStyleInvalidation(); |
| 153 element.clearNeedsStyleInvalidation(); | 152 element.clearNeedsStyleInvalidation(); |
| 154 | 153 |
| 155 return thisElementNeedsStyleRecalc; | 154 return thisElementNeedsStyleRecalc; |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace WebCore | 157 } // namespace WebCore |
| OLD | NEW |