| 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/InvalidationSet.h" | 10 #include "core/css/invalidation/InvalidationSet.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void StyleInvalidator::invalidate(Document& document) | 33 void StyleInvalidator::invalidate(Document& document) |
| 34 { | 34 { |
| 35 RecursionData recursionData; | 35 RecursionData recursionData; |
| 36 if (Element* documentElement = document.documentElement()) | 36 if (Element* documentElement = document.documentElement()) |
| 37 invalidate(*documentElement, recursionData); | 37 invalidate(*documentElement, recursionData); |
| 38 document.clearChildNeedsStyleInvalidation(); | 38 document.clearChildNeedsStyleInvalidation(); |
| 39 document.clearNeedsStyleInvalidation(); | 39 document.clearNeedsStyleInvalidation(); |
| 40 clearPendingInvalidations(); | 40 clearPendingInvalidations(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void StyleInvalidator::scheduleInvalidation(PassRefPtrWillBeRawPtr<InvalidationS
et> invalidationSet, Element& element) | 43 void StyleInvalidator::scheduleInvalidation(PassRefPtr<InvalidationSet> invalida
tionSet, Element& element) |
| 44 { | 44 { |
| 45 ASSERT(element.inActiveDocument()); | 45 ASSERT(element.inActiveDocument()); |
| 46 if (element.styleChangeType() >= SubtreeStyleChange) | 46 if (element.styleChangeType() >= SubtreeStyleChange) |
| 47 return; | 47 return; |
| 48 if (invalidationSet->wholeSubtreeInvalid()) { | 48 if (invalidationSet->wholeSubtreeInvalid()) { |
| 49 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleInvalidator)); | 49 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleInvalidator)); |
| 50 clearInvalidation(element); | 50 clearInvalidation(element); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 if (invalidationSet->invalidatesSelf()) | 53 if (invalidationSet->invalidatesSelf()) |
| 54 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin
g::create(StyleChangeReason::StyleInvalidator)); | 54 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin
g::create(StyleChangeReason::StyleInvalidator)); |
| 55 | 55 |
| 56 if (invalidationSet->isEmpty()) | 56 if (invalidationSet->isEmpty()) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 InvalidationList& list = ensurePendingInvalidationList(element); | 59 InvalidationList& list = ensurePendingInvalidationList(element); |
| 60 list.append(invalidationSet); | 60 list.append(invalidationSet); |
| 61 element.setNeedsStyleInvalidation(); | 61 element.setNeedsStyleInvalidation(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) | 64 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) |
| 65 { | 65 { |
| 66 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); | 66 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); |
| 67 if (addResult.isNewEntry) | 67 if (addResult.isNewEntry) |
| 68 addResult.storedValue->value = adoptPtrWillBeNoop(new InvalidationList); | 68 addResult.storedValue->value = adoptPtr(new InvalidationList); |
| 69 return *addResult.storedValue->value; | 69 return *addResult.storedValue->value; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void StyleInvalidator::clearInvalidation(Element& element) | 72 void StyleInvalidator::clearInvalidation(Element& element) |
| 73 { | 73 { |
| 74 if (!element.needsStyleInvalidation()) | 74 if (!element.needsStyleInvalidation()) |
| 75 return; | 75 return; |
| 76 m_pendingInvalidationMap.remove(&element); | 76 m_pendingInvalidationMap.remove(&element); |
| 77 element.clearNeedsStyleInvalidation(); | 77 element.clearNeedsStyleInvalidation(); |
| 78 } | 78 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 DEFINE_TRACE(StyleInvalidator) | 200 DEFINE_TRACE(StyleInvalidator) |
| 201 { | 201 { |
| 202 #if ENABLE(OILPAN) | 202 #if ENABLE(OILPAN) |
| 203 visitor->trace(m_pendingInvalidationMap); | 203 visitor->trace(m_pendingInvalidationMap); |
| 204 #endif | 204 #endif |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace blink | 207 } // namespace blink |
| OLD | NEW |