Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: Source/core/css/invalidation/DescendantInvalidationSet.cpp

Issue 580373002: [Invalidation Tracking] Trace StyleInvalidator setNeedsStyleRecalc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: attributes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/invalidation/DescendantInvalidationSet.cpp
diff --git a/Source/core/css/invalidation/DescendantInvalidationSet.cpp b/Source/core/css/invalidation/DescendantInvalidationSet.cpp
index 189882565a5ab123e12889f128a64ca8bb10b9f3..572926ea97fbb09603c350164a9785e1c50d0d14 100644
--- a/Source/core/css/invalidation/DescendantInvalidationSet.cpp
+++ b/Source/core/css/invalidation/DescendantInvalidationSet.cpp
@@ -33,9 +33,24 @@
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Element.h"
+#include "core/inspector/InspectorTraceEvents.h"
+#include "platform/TracedValue.h"
+#include "wtf/Compiler.h"
+#include "wtf/text/StringBuilder.h"
namespace blink {
+static const unsigned char* s_tracingEnabled = nullptr;
+
+#define TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, reason, singleSelectorPart) \
+ if (UNLIKELY(*s_tracingEnabled)) \
+ TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, reason, singleSelectorPart);
+
+void DescendantInvalidationSet::cacheTracingFlag()
+{
+ s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"));
+}
+
DescendantInvalidationSet::DescendantInvalidationSet()
: m_allDescendantsMightBeInvalid(false)
, m_customPseudoInvalid(false)
@@ -48,24 +63,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_IF_ENABLED(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_IF_ENABLED(element, InvalidationSetMatchedId, element.idForStyleResolution());
return true;
+ }
if (element.hasClass() && m_classes) {
const SpaceSplitString& classNames = element.classNames();
for (const auto& className : *m_classes) {
- if (classNames.contains(className))
+ if (classNames.contains(className)) {
+ TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, InvalidationSetMatchedClass, className);
return true;
+ }
}
}
if (element.hasAttributes() && m_attributes) {
for (const auto& attribute : *m_attributes) {
- if (element.hasAttribute(attribute))
+ if (element.hasAttribute(attribute)) {
+ TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, InvalidationSetMatchedAttribute, attribute);
return true;
+ }
}
}
@@ -189,33 +212,54 @@ void DescendantInvalidationSet::trace(Visitor* visitor)
#endif
}
-#ifndef NDEBUG
-void DescendantInvalidationSet::show() const
+void DescendantInvalidationSet::toTracedValue(TracedValue* value) const
{
- fprintf(stderr, "DescendantInvalidationSet { ");
+ value->beginDictionary();
+
if (m_allDescendantsMightBeInvalid)
- fprintf(stderr, "* ");
+ value->setBoolean("allDescendantsMightBeInvalid", true);
if (m_customPseudoInvalid)
- fprintf(stderr, "::custom ");
+ value->setBoolean("customPseudoInvalid", true);
if (m_treeBoundaryCrossing)
- fprintf(stderr, "::shadow/deep/ ");
+ value->setBoolean("treeBoundaryCrossing", true);
+
if (m_ids) {
+ value->beginArray("ids");
for (const auto& id : *m_ids)
- fprintf(stderr, "#%s ", id.ascii().data());
+ value->pushString(id);
+ value->endArray();
}
+
if (m_classes) {
+ value->beginArray("classes");
for (const auto& className : *m_classes)
- fprintf(stderr, ".%s ", className.ascii().data());
+ value->pushString(className);
+ value->endArray();
}
+
if (m_tagNames) {
+ value->beginArray("tagNames");
for (const auto& tagName : *m_tagNames)
- fprintf(stderr, "<%s> ", tagName.ascii().data());
+ value->pushString(tagName);
+ value->endArray();
}
+
if (m_attributes) {
+ value->beginArray("attributes");
for (const auto& attribute : *m_attributes)
- fprintf(stderr, "[%s] ", attribute.ascii().data());
+ value->pushString(attribute);
+ value->endArray();
}
- fprintf(stderr, "}\n");
+
+ value->endDictionary();
+}
+
+#ifndef NDEBUG
+void DescendantInvalidationSet::show() const
+{
+ RefPtr<TracedValue> value = TracedValue::create();
+ toTracedValue(value.get());
+ fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data());
}
#endif // NDEBUG
« no previous file with comments | « Source/core/css/invalidation/DescendantInvalidationSet.h ('k') | Source/core/css/invalidation/StyleInvalidator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698