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/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 m_pendingInvalidationMap.clear(); | 52 m_pendingInvalidationMap.clear(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 StyleInvalidator::StyleInvalidator() | 55 StyleInvalidator::StyleInvalidator() |
| 56 { } | 56 { } |
| 57 | 57 |
| 58 void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali dationSet& invalidationSet) | 58 void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali dationSet& invalidationSet) |
| 59 { | 59 { |
| 60 invalidationSet.getClasses(m_invalidationClasses); | 60 invalidationSet.getClasses(m_invalidationClasses); |
| 61 invalidationSet.getAttributes(m_invalidationAttributes); | 61 invalidationSet.getAttributes(m_invalidationAttributes); |
| 62 invalidationSet.getIds(m_invalidationIds); | |
| 62 m_foundInvalidationSet = true; | 63 m_foundInvalidationSet = true; |
| 63 } | 64 } |
| 64 | 65 |
| 65 bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& el ement) | 66 bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& el ement) |
| 66 { | 67 { |
| 67 if (element.hasClass()) { | 68 if (element.hasClass()) { |
| 68 const SpaceSplitString& classNames = element.classNames(); | 69 const SpaceSplitString& classNames = element.classNames(); |
| 69 for (Vector<AtomicString>::const_iterator it = m_invalidationClasses.beg in(); it != m_invalidationClasses.end(); ++it) { | 70 for (Vector<AtomicString>::const_iterator it = m_invalidationClasses.beg in(); it != m_invalidationClasses.end(); ++it) { |
| 70 if (classNames.contains(*it)) | 71 if (classNames.contains(*it)) |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 if (element.hasAttributes()) { | 75 if (element.hasAttributes()) { |
| 75 for (Vector<AtomicString>::const_iterator it = m_invalidationAttributes. begin(); it != m_invalidationAttributes.end(); ++it) { | 76 for (Vector<AtomicString>::const_iterator it = m_invalidationAttributes. begin(); it != m_invalidationAttributes.end(); ++it) { |
| 76 if (element.hasAttribute(*it)) | 77 if (element.hasAttribute(*it)) |
| 77 return true; | 78 return true; |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 if (element.hasID()) { |
| 82 const AtomicString& id = element.idForStyleResolution(); | |
| 83 for (Vector<AtomicString>::const_iterator it = m_invalidationIds.begin() ; it != m_invalidationIds.end(); ++it) { | |
| 84 if (id == *it) | |
|
esprehn
2014/04/01 23:11:19
You don't need this loop,
if (m_invalidationIds.c
chrishtr
2014/04/01 23:20:08
Good point! Fixed.
| |
| 85 return true; | |
| 86 } | |
| 87 } | |
| 81 return false; | 88 return false; |
| 82 } | 89 } |
| 83 | 90 |
| 84 bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element) | 91 bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element) |
| 85 { | 92 { |
| 86 bool thisElementNeedsStyleRecalc = false; | 93 bool thisElementNeedsStyleRecalc = false; |
| 87 if (element.needsStyleInvalidation()) { | 94 if (element.needsStyleInvalidation()) { |
| 88 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) { | 95 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) { |
| 89 // FIXME: it's really only necessary to clone the render style for t his element, not full style recalc. | 96 // FIXME: it's really only necessary to clone the render style for t his element, not full style recalc. |
| 90 thisElementNeedsStyleRecalc = true; | 97 thisElementNeedsStyleRecalc = true; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 } | 155 } |
| 149 } | 156 } |
| 150 | 157 |
| 151 element.clearChildNeedsStyleInvalidation(); | 158 element.clearChildNeedsStyleInvalidation(); |
| 152 element.clearNeedsStyleInvalidation(); | 159 element.clearNeedsStyleInvalidation(); |
| 153 | 160 |
| 154 return thisElementNeedsStyleRecalc; | 161 return thisElementNeedsStyleRecalc; |
| 155 } | 162 } |
| 156 | 163 |
| 157 } // namespace WebCore | 164 } // namespace WebCore |
| OLD | NEW |