| 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 25 matching lines...) Expand all Loading... |
| 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<DescendantInv
alidationSet> invalidationSet, Element& element) | 43 void StyleInvalidator::scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInv
alidationSet> invalidationSet, Element& element) |
| 44 { | 44 { |
| 45 ASSERT(element.inActiveDocument()); | 45 ASSERT(element.inActiveDocument()); |
| 46 ASSERT(element.styleChangeType() < SubtreeStyleChange); | 46 if (element.styleChangeType() >= SubtreeStyleChange) |
| 47 return; |
| 48 if (invalidationSet->wholeSubtreeInvalid()) { |
| 49 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleInvalidator)); |
| 50 clearInvalidation(element); |
| 51 return; |
| 52 } |
| 53 if (invalidationSet->isEmpty()) { |
| 54 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin
g::create(StyleChangeReason::StyleInvalidator)); |
| 55 return; |
| 56 } |
| 57 |
| 47 InvalidationList& list = ensurePendingInvalidationList(element); | 58 InvalidationList& list = ensurePendingInvalidationList(element); |
| 48 // If we're already going to invalidate the whole subtree we don't need to s
tore any new sets. | |
| 49 if (!list.isEmpty() && list.last()->wholeSubtreeInvalid()) | |
| 50 return; | |
| 51 // If this set would invalidate the whole subtree we can discard all existin
g sets. | |
| 52 if (invalidationSet->wholeSubtreeInvalid()) | |
| 53 list.clear(); | |
| 54 list.append(invalidationSet); | 59 list.append(invalidationSet); |
| 55 element.setNeedsStyleInvalidation(); | 60 element.setNeedsStyleInvalidation(); |
| 56 } | 61 } |
| 57 | 62 |
| 58 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) | 63 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL
ist(Element& element) |
| 59 { | 64 { |
| 60 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); | 65 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(&
element, nullptr); |
| 61 if (addResult.isNewEntry) | 66 if (addResult.isNewEntry) |
| 62 addResult.storedValue->value = adoptPtrWillBeNoop(new InvalidationList); | 67 addResult.storedValue->value = adoptPtrWillBeNoop(new InvalidationList); |
| 63 return *addResult.storedValue->value; | 68 return *addResult.storedValue->value; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 80 DescendantInvalidationSet::cacheTracingFlag(); | 85 DescendantInvalidationSet::cacheTracingFlag(); |
| 81 } | 86 } |
| 82 | 87 |
| 83 StyleInvalidator::~StyleInvalidator() | 88 StyleInvalidator::~StyleInvalidator() |
| 84 { | 89 { |
| 85 } | 90 } |
| 86 | 91 |
| 87 void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali
dationSet& invalidationSet) | 92 void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali
dationSet& invalidationSet) |
| 88 { | 93 { |
| 89 ASSERT(!m_wholeSubtreeInvalid); | 94 ASSERT(!m_wholeSubtreeInvalid); |
| 95 ASSERT(!invalidationSet.wholeSubtreeInvalid()); |
| 96 ASSERT(!invalidationSet.isEmpty()); |
| 90 if (invalidationSet.treeBoundaryCrossing()) | 97 if (invalidationSet.treeBoundaryCrossing()) |
| 91 m_treeBoundaryCrossing = true; | 98 m_treeBoundaryCrossing = true; |
| 92 if (invalidationSet.insertionPointCrossing()) | 99 if (invalidationSet.insertionPointCrossing()) |
| 93 m_insertionPointCrossing = true; | 100 m_insertionPointCrossing = true; |
| 94 if (invalidationSet.wholeSubtreeInvalid()) { | |
| 95 m_wholeSubtreeInvalid = true; | |
| 96 return; | |
| 97 } | |
| 98 m_invalidationSets.append(&invalidationSet); | 101 m_invalidationSets.append(&invalidationSet); |
| 99 m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid(); | 102 m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid(); |
| 100 } | 103 } |
| 101 | 104 |
| 102 ALWAYS_INLINE bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSe
ts(Element& element) | 105 ALWAYS_INLINE bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSe
ts(Element& element) |
| 103 { | 106 { |
| 104 ASSERT(!m_wholeSubtreeInvalid); | |
| 105 | |
| 106 if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) { | 107 if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) { |
| 107 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, InvalidateCusto
mPseudo); | 108 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, InvalidateCusto
mPseudo); |
| 108 return true; | 109 return true; |
| 109 } | 110 } |
| 110 | 111 |
| 111 if (m_insertionPointCrossing && element.isInsertionPoint()) | 112 if (m_insertionPointCrossing && element.isInsertionPoint()) |
| 112 return true; | 113 return true; |
| 113 | 114 |
| 114 for (const auto& invalidationSet : m_invalidationSets) { | 115 for (const auto& invalidationSet : m_invalidationSets) { |
| 115 if (invalidationSet->invalidatesElement(element)) | 116 if (invalidationSet->invalidatesElement(element)) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 { | 166 { |
| 166 RecursionCheckpoint checkpoint(&recursionData); | 167 RecursionCheckpoint checkpoint(&recursionData); |
| 167 | 168 |
| 168 bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement(eleme
nt, recursionData); | 169 bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement(eleme
nt, recursionData); |
| 169 | 170 |
| 170 bool someChildrenNeedStyleRecalc = false; | 171 bool someChildrenNeedStyleRecalc = false; |
| 171 if (recursionData.hasInvalidationSets() || element.childNeedsStyleInvalidati
on()) | 172 if (recursionData.hasInvalidationSets() || element.childNeedsStyleInvalidati
on()) |
| 172 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData)
; | 173 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData)
; |
| 173 | 174 |
| 174 if (thisElementNeedsStyleRecalc) { | 175 if (thisElementNeedsStyleRecalc) { |
| 175 element.setNeedsStyleRecalc(recursionData.wholeSubtreeInvalid() ? Subtre
eStyleChange : LocalStyleChange, StyleChangeReasonForTracing::create(StyleChange
Reason::StyleInvalidator)); | 176 ASSERT(!recursionData.wholeSubtreeInvalid()); |
| 177 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin
g::create(StyleChangeReason::StyleInvalidator)); |
| 176 } else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecal
c) { | 178 } else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecal
c) { |
| 177 // Clone the LayoutStyle in order to preserve correct style sharing, if
possible. Otherwise recalc style. | 179 // Clone the LayoutStyle in order to preserve correct style sharing, if
possible. Otherwise recalc style. |
| 178 if (LayoutObject* renderer = element.renderer()) { | 180 if (LayoutObject* renderer = element.renderer()) { |
| 179 renderer->setStyleInternal(LayoutStyle::clone(renderer->styleRef()))
; | 181 renderer->setStyleInternal(LayoutStyle::clone(renderer->styleRef()))
; |
| 180 } else { | 182 } else { |
| 181 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, PreventStyl
eSharingForParent); | 183 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, PreventStyl
eSharingForParent); |
| 182 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::StyleInvalidator)); | 184 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::StyleInvalidator)); |
| 183 } | 185 } |
| 184 } | 186 } |
| 185 | 187 |
| 186 if (recursionData.insertionPointCrossing() && element.isInsertionPoint()) | 188 if (recursionData.insertionPointCrossing() && element.isInsertionPoint()) |
| 187 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleInvalidator)); | 189 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleInvalidator)); |
| 188 | 190 |
| 189 element.clearChildNeedsStyleInvalidation(); | 191 element.clearChildNeedsStyleInvalidation(); |
| 190 element.clearNeedsStyleInvalidation(); | 192 element.clearNeedsStyleInvalidation(); |
| 191 | 193 |
| 192 return thisElementNeedsStyleRecalc; | 194 return thisElementNeedsStyleRecalc; |
| 193 } | 195 } |
| 194 | 196 |
| 195 void StyleInvalidator::trace(Visitor* visitor) | 197 void StyleInvalidator::trace(Visitor* visitor) |
| 196 { | 198 { |
| 197 #if ENABLE(OILPAN) | 199 #if ENABLE(OILPAN) |
| 198 visitor->trace(m_pendingInvalidationMap); | 200 visitor->trace(m_pendingInvalidationMap); |
| 199 #endif | 201 #endif |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |