| 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()); |
| 32 ASSERT(element.styleChangeType() < SubtreeStyleChange); |
| 31 InvalidationList& list = ensurePendingInvalidationList(element); | 33 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. | 34 // 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()) | 35 if (!list.isEmpty() && list.last()->wholeSubtreeInvalid()) |
| 34 return; | 36 return; |
| 35 // If this set would invalidate the whole subtree we can discard all existin
g sets. | 37 // If this set would invalidate the whole subtree we can discard all existin
g sets. |
| 36 if (invalidationSet->wholeSubtreeInvalid()) | 38 if (invalidationSet->wholeSubtreeInvalid()) |
| 37 list.clear(); | 39 list.clear(); |
| 38 list.append(invalidationSet); | 40 list.append(invalidationSet); |
| 39 element.setNeedsStyleInvalidation(); | 41 element.setNeedsStyleInvalidation(); |
| 40 } | 42 } |
| 41 | 43 |
| 42 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) | 44 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) |
| 43 { | 45 { |
| 44 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); | 46 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); |
| 45 if (addResult.isNewEntry) | 47 if (addResult.isNewEntry) |
| 46 addResult.storedValue->value = adoptPtr(new InvalidationList); | 48 addResult.storedValue->value = adoptPtr(new InvalidationList); |
| 47 return *addResult.storedValue->value; | 49 return *addResult.storedValue->value; |
| 48 } | 50 } |
| 49 | 51 |
| 50 void StyleInvalidator::clearInvalidation(Node& node) | 52 void StyleInvalidator::clearInvalidation(Node& node) |
| 51 { | 53 { |
| 52 if (node.isElementNode() && node.needsStyleInvalidation()) | 54 if (node.isElementNode() && node.needsStyleInvalidation()) |
| 53 m_pendingInvalidationMap.remove(toElement(&node)); | 55 m_pendingInvalidationMap.remove(toElement(&node)); |
| 54 node.clearChildNeedsStyleInvalidation(); | |
| 55 node.clearNeedsStyleInvalidation(); | |
| 56 } | 56 } |
| 57 | 57 |
| 58 void StyleInvalidator::clearPendingInvalidations() | 58 void StyleInvalidator::clearPendingInvalidations() |
| 59 { | 59 { |
| 60 m_pendingInvalidationMap.clear(); | 60 m_pendingInvalidationMap.clear(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 StyleInvalidator::StyleInvalidator() | 63 StyleInvalidator::StyleInvalidator() |
| 64 { | 64 { |
| 65 } | 65 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 element.setNeedsStyleRecalc(LocalStyleChange); | 149 element.setNeedsStyleRecalc(LocalStyleChange); |
| 150 } | 150 } |
| 151 | 151 |
| 152 element.clearChildNeedsStyleInvalidation(); | 152 element.clearChildNeedsStyleInvalidation(); |
| 153 element.clearNeedsStyleInvalidation(); | 153 element.clearNeedsStyleInvalidation(); |
| 154 | 154 |
| 155 return thisElementNeedsStyleRecalc; | 155 return thisElementNeedsStyleRecalc; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace WebCore | 158 } // namespace WebCore |
| OLD | NEW |