| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/css/invalidation/DescendantInvalidationSet.h" | 32 #include "core/css/invalidation/DescendantInvalidationSet.h" |
| 33 | 33 |
| 34 #include "core/css/resolver/StyleResolver.h" | 34 #include "core/css/resolver/StyleResolver.h" |
| 35 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
| 36 #include "core/inspector/InspectorTraceEvents.h" | |
| 37 #include "platform/TracedValue.h" | |
| 38 #include "wtf/text/StringBuilder.h" | |
| 39 | 36 |
| 40 namespace blink { | 37 namespace blink { |
| 41 | 38 |
| 42 DescendantInvalidationSet::DescendantInvalidationSet() | 39 DescendantInvalidationSet::DescendantInvalidationSet() |
| 43 : m_allDescendantsMightBeInvalid(false) | 40 : m_allDescendantsMightBeInvalid(false) |
| 44 , m_customPseudoInvalid(false) | 41 , m_customPseudoInvalid(false) |
| 45 , m_treeBoundaryCrossing(false) | 42 , m_treeBoundaryCrossing(false) |
| 46 { | 43 { |
| 47 } | 44 } |
| 48 | 45 |
| 49 bool DescendantInvalidationSet::invalidatesElement(Element& element) const | 46 bool DescendantInvalidationSet::invalidatesElement(Element& element) const |
| 50 { | 47 { |
| 51 if (m_allDescendantsMightBeInvalid) | 48 if (m_allDescendantsMightBeInvalid) |
| 52 return true; | 49 return true; |
| 53 | 50 |
| 54 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) { | 51 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) |
| 55 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS
etMatchedTagName, element.tagQName().localName()); | |
| 56 return true; | 52 return true; |
| 57 } | |
| 58 | 53 |
| 59 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution
())) { | 54 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution
())) |
| 60 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS
etMatchedId, element.idForStyleResolution()); | |
| 61 return true; | 55 return true; |
| 62 } | |
| 63 | 56 |
| 64 if (element.hasClass() && m_classes) { | 57 if (element.hasClass() && m_classes) { |
| 65 const SpaceSplitString& classNames = element.classNames(); | 58 const SpaceSplitString& classNames = element.classNames(); |
| 66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg
in(); it != m_classes->end(); ++it) { | 59 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg
in(); it != m_classes->end(); ++it) { |
| 67 if (classNames.contains(*it)) { | 60 if (classNames.contains(*it)) |
| 68 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval
idationSetMatchedClass, *it); | |
| 69 return true; | 61 return true; |
| 70 } | |
| 71 } | 62 } |
| 72 } | 63 } |
| 73 | 64 |
| 74 if (element.hasAttributes() && m_attributes) { | 65 if (element.hasAttributes() && m_attributes) { |
| 75 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->
begin(); it != m_attributes->end(); ++it) { | 66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->
begin(); it != m_attributes->end(); ++it) { |
| 76 if (element.hasAttribute(*it)) { | 67 if (element.hasAttribute(*it)) |
| 77 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval
idationSetMatchedAttribute, *it); | |
| 78 return true; | 68 return true; |
| 79 } | |
| 80 } | 69 } |
| 81 } | 70 } |
| 82 | 71 |
| 83 return false; | 72 return false; |
| 84 } | 73 } |
| 85 | 74 |
| 86 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) | 75 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) |
| 87 { | 76 { |
| 88 // No longer bother combining data structures, since the whole subtree is de
emed invalid. | 77 // No longer bother combining data structures, since the whole subtree is de
emed invalid. |
| 89 if (wholeSubtreeInvalid()) | 78 if (wholeSubtreeInvalid()) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void DescendantInvalidationSet::trace(Visitor* visitor) | 186 void DescendantInvalidationSet::trace(Visitor* visitor) |
| 198 { | 187 { |
| 199 #if ENABLE(OILPAN) | 188 #if ENABLE(OILPAN) |
| 200 visitor->trace(m_classes); | 189 visitor->trace(m_classes); |
| 201 visitor->trace(m_ids); | 190 visitor->trace(m_ids); |
| 202 visitor->trace(m_tagNames); | 191 visitor->trace(m_tagNames); |
| 203 visitor->trace(m_attributes); | 192 visitor->trace(m_attributes); |
| 204 #endif | 193 #endif |
| 205 } | 194 } |
| 206 | 195 |
| 207 void DescendantInvalidationSet::toTracedValue(TracedValue* value) const | |
| 208 { | |
| 209 value->beginDictionary(); | |
| 210 | |
| 211 if (m_allDescendantsMightBeInvalid) | |
| 212 value->setBoolean("allDescendantsMightBeInvalid", true); | |
| 213 if (m_customPseudoInvalid) | |
| 214 value->setBoolean("customPseudoInvalid", true); | |
| 215 if (m_treeBoundaryCrossing) | |
| 216 value->setBoolean("treeBoundaryCrossing", true); | |
| 217 | |
| 218 if (m_ids) { | |
| 219 value->beginArray("ids"); | |
| 220 for (const auto& id : *m_ids) | |
| 221 value->pushString(id); | |
| 222 value->endArray(); | |
| 223 } | |
| 224 | |
| 225 if (m_classes) { | |
| 226 value->beginArray("classes"); | |
| 227 for (const auto& className : *m_classes) | |
| 228 value->pushString(className); | |
| 229 value->endArray(); | |
| 230 } | |
| 231 | |
| 232 if (m_tagNames) { | |
| 233 value->beginArray("tagNames"); | |
| 234 for (const auto& tagName : *m_tagNames) | |
| 235 value->pushString(tagName); | |
| 236 value->endArray(); | |
| 237 } | |
| 238 | |
| 239 if (m_attributes) { | |
| 240 value->beginArray("ids"); | |
| 241 for (const auto& attribute : *m_attributes) | |
| 242 value->pushString(attribute); | |
| 243 value->endArray(); | |
| 244 } | |
| 245 | |
| 246 value->endDictionary(); | |
| 247 } | |
| 248 | |
| 249 #ifndef NDEBUG | 196 #ifndef NDEBUG |
| 250 void DescendantInvalidationSet::show() const | 197 void DescendantInvalidationSet::show() const |
| 251 { | 198 { |
| 252 RefPtr<TracedValue> value = TracedValue::create(); | 199 fprintf(stderr, "DescendantInvalidationSet { "); |
| 253 toTracedValue(value.get()); | 200 if (m_allDescendantsMightBeInvalid) |
| 254 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); | 201 fprintf(stderr, "* "); |
| 202 if (m_customPseudoInvalid) |
| 203 fprintf(stderr, "::custom "); |
| 204 if (m_treeBoundaryCrossing) |
| 205 fprintf(stderr, "::shadow/deep/ "); |
| 206 if (m_ids) { |
| 207 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_ids->begin()
; it != m_ids->end(); ++it) |
| 208 fprintf(stderr, "#%s ", (*it).ascii().data()); |
| 209 } |
| 210 if (m_classes) { |
| 211 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg
in(); it != m_classes->end(); ++it) |
| 212 fprintf(stderr, ".%s ", (*it).ascii().data()); |
| 213 } |
| 214 if (m_tagNames) { |
| 215 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_tagNames->be
gin(); it != m_tagNames->end(); ++it) |
| 216 fprintf(stderr, "<%s> ", (*it).ascii().data()); |
| 217 } |
| 218 if (m_attributes) { |
| 219 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->
begin(); it != m_attributes->end(); ++it) |
| 220 fprintf(stderr, "[%s] ", (*it).ascii().data()); |
| 221 } |
| 222 fprintf(stderr, "}\n"); |
| 255 } | 223 } |
| 256 #endif // NDEBUG | 224 #endif // NDEBUG |
| 257 | 225 |
| 258 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |