| Index: Source/core/css/invalidation/StyleInvalidator.cpp
|
| diff --git a/Source/core/css/invalidation/StyleInvalidator.cpp b/Source/core/css/invalidation/StyleInvalidator.cpp
|
| index 69f720f1171c5bf30d975cfd01b23abf6aea03f0..8d506a5a375a70a155f346b035b20d8b69c84dbb 100644
|
| --- a/Source/core/css/invalidation/StyleInvalidator.cpp
|
| +++ b/Source/core/css/invalidation/StyleInvalidator.cpp
|
| @@ -13,10 +13,17 @@
|
| #include "core/dom/ElementTraversal.h"
|
| #include "core/dom/shadow/ElementShadow.h"
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| +#include "core/inspector/InspectorTraceEvents.h"
|
| #include "core/rendering/RenderObject.h"
|
|
|
| namespace blink {
|
|
|
| +static const unsigned char* s_tracingEnabled = nullptr;
|
| +
|
| +#define TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, reason) \
|
| + if (UNLIKELY(*s_tracingEnabled)) \
|
| + TRACE_STYLE_INVALIDATOR_INVALIDATION(element, reason);
|
| +
|
| void StyleInvalidator::invalidate(Document& document)
|
| {
|
| RecursionData recursionData;
|
| @@ -63,6 +70,8 @@ void StyleInvalidator::clearPendingInvalidations()
|
|
|
| StyleInvalidator::StyleInvalidator()
|
| {
|
| + s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"));
|
| + DescendantInvalidationSet::cacheTracingFlag();
|
| }
|
|
|
| StyleInvalidator::~StyleInvalidator()
|
| @@ -82,12 +91,14 @@ void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali
|
| m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid();
|
| }
|
|
|
| -bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& element)
|
| +ALWAYS_INLINE bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& element)
|
| {
|
| ASSERT(!m_wholeSubtreeInvalid);
|
|
|
| - if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom)
|
| + if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) {
|
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, InvalidateCustomPseudo);
|
| return true;
|
| + }
|
|
|
| for (const auto& invalidationSet : m_invalidationSets) {
|
| if (invalidationSet->invalidatesElement(element))
|
| @@ -97,7 +108,7 @@ bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& el
|
| return false;
|
| }
|
|
|
| -bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, StyleInvalidator::RecursionData& recursionData)
|
| +ALWAYS_INLINE bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, StyleInvalidator::RecursionData& recursionData)
|
| {
|
| if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSubtreeInvalid()) {
|
| recursionData.setWholeSubtreeInvalid();
|
| @@ -108,9 +119,15 @@ bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, Sty
|
| for (const auto& invalidationSet : *invalidationList)
|
| recursionData.pushInvalidationSet(*invalidationSet);
|
| // FIXME: It's really only necessary to clone the render style for this element, not full style recalc.
|
| + if (UNLIKELY(*s_tracingEnabled)) {
|
| + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
|
| + "StyleInvalidatorInvalidationTracking",
|
| + "data", InspectorStyleInvalidatorInvalidateEvent::invalidationList(element, *invalidationList));
|
| + }
|
| return true;
|
| }
|
| }
|
| +
|
| return recursionData.matchesCurrentInvalidationSets(element);
|
| }
|
|
|
| @@ -148,10 +165,12 @@ bool StyleInvalidator::invalidate(Element& element, StyleInvalidator::RecursionD
|
| element.setNeedsStyleRecalc(recursionData.wholeSubtreeInvalid() ? SubtreeStyleChange : LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
|
| } else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecalc) {
|
| // Clone the RenderStyle in order to preserve correct style sharing, if possible. Otherwise recalc style.
|
| - if (RenderObject* renderer = element.renderer())
|
| + if (RenderObject* renderer = element.renderer()) {
|
| renderer->setStyleInternal(RenderStyle::clone(renderer->style()));
|
| - else
|
| + } else {
|
| + TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, PreventStyleSharingForParent);
|
| element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
|
| + }
|
| }
|
|
|
| element.clearChildNeedsStyleInvalidation();
|
|
|