Chromium Code Reviews| 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 "wtf/text/StringBuilder.h" | |
| 36 | 38 |
| 37 namespace blink { | 39 namespace blink { |
| 38 | 40 |
| 39 DescendantInvalidationSet::DescendantInvalidationSet() | 41 DescendantInvalidationSet::DescendantInvalidationSet() |
| 40 : m_allDescendantsMightBeInvalid(false) | 42 : m_allDescendantsMightBeInvalid(false) |
| 41 , m_customPseudoInvalid(false) | 43 , m_customPseudoInvalid(false) |
| 42 , m_treeBoundaryCrossing(false) | 44 , m_treeBoundaryCrossing(false) |
| 43 { | 45 { |
| 44 } | 46 } |
| 45 | 47 |
| 46 bool DescendantInvalidationSet::invalidatesElement(Element& element) const | 48 bool DescendantInvalidationSet::invalidatesElement(Element& element) const |
| 47 { | 49 { |
| 48 if (m_allDescendantsMightBeInvalid) | 50 if (m_allDescendantsMightBeInvalid) |
| 49 return true; | 51 return true; |
| 50 | 52 |
| 51 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) | 53 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) { |
| 54 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS etMatchedTagName, element.tagQName().localName()); | |
| 52 return true; | 55 return true; |
| 56 } | |
| 53 | 57 |
| 54 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution ())) | 58 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution ())) { |
| 59 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS etMatchedId, element.idForStyleResolution()); | |
| 55 return true; | 60 return true; |
| 61 } | |
| 56 | 62 |
| 57 if (element.hasClass() && m_classes) { | 63 if (element.hasClass() && m_classes) { |
| 58 const SpaceSplitString& classNames = element.classNames(); | 64 const SpaceSplitString& classNames = element.classNames(); |
| 59 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg in(); it != m_classes->end(); ++it) { | 65 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg in(); it != m_classes->end(); ++it) { |
| 60 if (classNames.contains(*it)) | 66 if (classNames.contains(*it)) { |
| 67 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval idationSetMatchedClass, *it); | |
| 61 return true; | 68 return true; |
| 69 } | |
| 62 } | 70 } |
| 63 } | 71 } |
| 64 | 72 |
| 65 if (element.hasAttributes() && m_attributes) { | 73 if (element.hasAttributes() && m_attributes) { |
| 66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes-> begin(); it != m_attributes->end(); ++it) { | 74 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes-> begin(); it != m_attributes->end(); ++it) { |
| 67 if (element.hasAttribute(*it)) | 75 if (element.hasAttribute(*it)) { |
| 76 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval idationSetMatchedAttribute, *it); | |
| 68 return true; | 77 return true; |
| 78 } | |
| 69 } | 79 } |
| 70 } | 80 } |
| 71 | 81 |
| 72 return false; | 82 return false; |
| 73 } | 83 } |
| 74 | 84 |
| 75 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) | 85 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) |
| 76 { | 86 { |
| 77 // No longer bother combining data structures, since the whole subtree is de emed invalid. | 87 // No longer bother combining data structures, since the whole subtree is de emed invalid. |
| 78 if (wholeSubtreeInvalid()) | 88 if (wholeSubtreeInvalid()) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 void DescendantInvalidationSet::trace(Visitor* visitor) | 196 void DescendantInvalidationSet::trace(Visitor* visitor) |
| 187 { | 197 { |
| 188 #if ENABLE(OILPAN) | 198 #if ENABLE(OILPAN) |
| 189 visitor->trace(m_classes); | 199 visitor->trace(m_classes); |
| 190 visitor->trace(m_ids); | 200 visitor->trace(m_ids); |
| 191 visitor->trace(m_tagNames); | 201 visitor->trace(m_tagNames); |
| 192 visitor->trace(m_attributes); | 202 visitor->trace(m_attributes); |
| 193 #endif | 203 #endif |
| 194 } | 204 } |
| 195 | 205 |
| 206 String DescendantInvalidationSet::toDebugString() const | |
| 207 { | |
| 208 StringBuilder builder; | |
| 209 builder.append("DescendantInvalidationSet { "); | |
| 210 if (m_allDescendantsMightBeInvalid) | |
| 211 builder.append("* "); | |
| 212 if (m_customPseudoInvalid) | |
| 213 builder.append("::custom "); | |
| 214 if (m_treeBoundaryCrossing) | |
| 215 builder.append("::shadow/deep/ "); | |
| 216 if (m_ids) { | |
| 217 for (const auto& id : *m_ids) { | |
| 218 builder.append("#"); | |
| 219 builder.append(id); | |
| 220 builder.append(" "); | |
| 221 } | |
| 222 } | |
| 223 if (m_classes) { | |
| 224 for (const auto& className : *m_classes) { | |
| 225 builder.append("."); | |
| 226 builder.append(className); | |
| 227 builder.append(" "); | |
| 228 } | |
| 229 } | |
| 230 if (m_tagNames) { | |
| 231 for (const auto& tagName : *m_tagNames) { | |
| 232 builder.append("<"); | |
| 233 builder.append(tagName); | |
| 234 builder.append("> "); | |
| 235 } | |
| 236 } | |
| 237 if (m_attributes) { | |
| 238 for (const auto& attribute : *m_attributes) { | |
| 239 builder.append("["); | |
| 240 builder.append(attribute); | |
| 241 builder.append("] "); | |
| 242 } | |
| 243 } | |
| 244 builder.append("}"); | |
| 245 | |
| 246 return builder.toString(); | |
| 247 } | |
| 248 | |
| 196 #ifndef NDEBUG | 249 #ifndef NDEBUG |
| 197 void DescendantInvalidationSet::show() const | 250 void DescendantInvalidationSet::show() const |
| 198 { | 251 { |
| 199 fprintf(stderr, "DescendantInvalidationSet { "); | 252 fprintf(stderr, "%s\n", toString().ascii().data()); |
|
caseq
2014/09/30 12:24:00
toDebugString() perhaps?
kouhei (in TOK)
2014/10/01 04:16:14
Done.
| |
| 200 if (m_allDescendantsMightBeInvalid) | |
| 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"); | |
| 223 } | 253 } |
| 224 #endif // NDEBUG | 254 #endif // NDEBUG |
| 225 | 255 |
| 226 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |