Chromium Code Reviews| Index: Source/core/css/invalidation/DescendantInvalidationSet.cpp |
| diff --git a/Source/core/css/invalidation/DescendantInvalidationSet.cpp b/Source/core/css/invalidation/DescendantInvalidationSet.cpp |
| index 232f3cfe9b14348d607baf9ee7162d9ea459874d..d8ba4ec93637afc815afe81539edb749627bc13f 100644 |
| --- a/Source/core/css/invalidation/DescendantInvalidationSet.cpp |
| +++ b/Source/core/css/invalidation/DescendantInvalidationSet.cpp |
| @@ -33,6 +33,9 @@ |
| #include "core/css/resolver/StyleResolver.h" |
| #include "core/dom/Element.h" |
| +#include "core/inspector/InspectorTraceEvents.h" |
| +#include "platform/TracedValue.h" |
| +#include "wtf/text/StringBuilder.h" |
| namespace blink { |
| @@ -48,24 +51,32 @@ bool DescendantInvalidationSet::invalidatesElement(Element& element) const |
| if (m_allDescendantsMightBeInvalid) |
| return true; |
| - if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) |
| + if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) { |
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationSetMatchedTagName, element.tagQName().localName()); |
| return true; |
| + } |
| - if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution())) |
| + if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution())) { |
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationSetMatchedId, element.idForStyleResolution()); |
| return true; |
| + } |
| if (element.hasClass() && m_classes) { |
| const SpaceSplitString& classNames = element.classNames(); |
| for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->begin(); it != m_classes->end(); ++it) { |
| - if (classNames.contains(*it)) |
| + if (classNames.contains(*it)) { |
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationSetMatchedClass, *it); |
| return true; |
| + } |
| } |
| } |
| if (element.hasAttributes() && m_attributes) { |
| for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->begin(); it != m_attributes->end(); ++it) { |
| - if (element.hasAttribute(*it)) |
| + if (element.hasAttribute(*it)) { |
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationSetMatchedAttribute, *it); |
| return true; |
| + } |
| } |
| } |
| @@ -193,33 +204,60 @@ void DescendantInvalidationSet::trace(Visitor* visitor) |
| #endif |
| } |
| -#ifndef NDEBUG |
| -void DescendantInvalidationSet::show() const |
| +void DescendantInvalidationSet::toTracedValue(TracedValue* value) const |
| { |
| - fprintf(stderr, "DescendantInvalidationSet { "); |
| + value->beginArray(); |
| + |
| if (m_allDescendantsMightBeInvalid) |
| - fprintf(stderr, "* "); |
| + value->pushString("*"); |
|
caseq
2014/10/01 07:50:49
Can we please get it more structured -- i.e. inste
kouhei (in TOK)
2014/10/02 02:16:46
Done.
|
| if (m_customPseudoInvalid) |
| - fprintf(stderr, "::custom "); |
| + value->pushString("::custom"); |
| if (m_treeBoundaryCrossing) |
| - fprintf(stderr, "::shadow/deep/ "); |
| + value->pushString("::shadow/deep/"); |
| if (m_ids) { |
| - for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_ids->begin(); it != m_ids->end(); ++it) |
| - fprintf(stderr, "#%s ", (*it).ascii().data()); |
| + for (const auto& id : *m_ids) { |
| + StringBuilder builder; |
| + builder.append("#"); |
| + builder.append(id); |
| + value->pushString(builder.toString()); |
| + } |
| } |
| if (m_classes) { |
| - for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->begin(); it != m_classes->end(); ++it) |
| - fprintf(stderr, ".%s ", (*it).ascii().data()); |
| + for (const auto& className : *m_classes) { |
| + StringBuilder builder; |
| + builder.append("."); |
| + builder.append(className); |
| + value->pushString(builder.toString()); |
| + } |
| } |
| if (m_tagNames) { |
| - for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_tagNames->begin(); it != m_tagNames->end(); ++it) |
| - fprintf(stderr, "<%s> ", (*it).ascii().data()); |
| + for (const auto& tagName : *m_tagNames) { |
| + StringBuilder builder; |
| + builder.append("<"); |
| + builder.append(tagName); |
| + builder.append(">"); |
| + value->pushString(builder.toString()); |
| + } |
| } |
| if (m_attributes) { |
| - for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->begin(); it != m_attributes->end(); ++it) |
| - fprintf(stderr, "[%s] ", (*it).ascii().data()); |
| + for (const auto& attribute : *m_attributes) { |
| + StringBuilder builder; |
| + builder.append("["); |
| + builder.append(attribute); |
| + builder.append("]"); |
| + value->pushString(builder.toString()); |
| + } |
| } |
| - fprintf(stderr, "}\n"); |
| + |
| + value->endArray(); |
| +} |
| + |
| +#ifndef NDEBUG |
| +void DescendantInvalidationSet::show() const |
| +{ |
| + RefPtr<TracedValue> value = TracedValue::create(); |
| + toTracedValue(value.get()); |
| + fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); |
| } |
| #endif // NDEBUG |