Chromium Code Reviews| 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..74e53903c54611d0b4403314a16a877742e3d411 100644 |
| --- a/Source/core/css/invalidation/StyleInvalidator.cpp |
| +++ b/Source/core/css/invalidation/StyleInvalidator.cpp |
| @@ -13,10 +13,13 @@ |
| #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; |
| + |
| void StyleInvalidator::invalidate(Document& document) |
| { |
| RecursionData recursionData; |
| @@ -61,6 +64,11 @@ void StyleInvalidator::clearPendingInvalidations() |
| m_pendingInvalidationMap.clear(); |
| } |
| +void StyleInvalidator::init() |
| +{ |
| + s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking")); |
| +} |
| + |
| StyleInvalidator::StyleInvalidator() |
| { |
| } |
| @@ -82,12 +90,15 @@ 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) { |
| + if (UNLIKELY(*s_tracingEnabled)) |
|
pdr.
2014/10/14 01:36:47
Can you break this unlikely out into a macro using
kouhei (in TOK)
2014/10/14 02:02:10
Done.
|
| + TRACE_STYLE_INVALIDATOR_INVALIDATION(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,13 @@ 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 { |
| + if (UNLIKELY(*s_tracingEnabled)) |
| + TRACE_STYLE_INVALIDATOR_INVALIDATION(element, PreventStyleSharingForParent); |
| element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator)); |
| + } |
| } |
| element.clearChildNeedsStyleInvalidation(); |