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

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

Issue 580373002: [Invalidation Tracking] Trace StyleInvalidator setNeedsStyleRecalc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add missing files 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/StyleInvalidator.cpp
diff --git a/Source/core/css/invalidation/StyleInvalidator.cpp b/Source/core/css/invalidation/StyleInvalidator.cpp
index cefc3d7b17650398f523f56d1e6adc0d4ec46b8d..dbb122de381934acaf8a0808fa9e52e454692fc2 100644
--- a/Source/core/css/invalidation/StyleInvalidator.cpp
+++ b/Source/core/css/invalidation/StyleInvalidator.cpp
@@ -13,6 +13,7 @@
#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 {
@@ -20,8 +21,15 @@ namespace blink {
void StyleInvalidator::invalidate(Document& document)
{
RecursionData recursionData;
- if (Element* documentElement = document.documentElement())
- invalidate(*documentElement, recursionData);
+ if (Element* documentElement = document.documentElement()) {
+ bool isTracingEnabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), &isTracingEnabled);
+
+ if (isTracingEnabled)
+ invalidate<StyleInvalidationTracingEnabled>(*documentElement, recursionData);
+ else
+ invalidate<StyleInvalidationTracingDisabled>(*documentElement, recursionData);
+ }
document.clearChildNeedsStyleInvalidation();
document.clearNeedsStyleInvalidation();
clearPendingInvalidations();
@@ -82,21 +90,27 @@ void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvali
m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid();
}
+template <StyleInvalidationTracingEnabledFlag styleInvalidationTracingEnabled>
bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& element)
{
ASSERT(!m_wholeSubtreeInvalid);
- if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom)
+ if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) {
+ if (styleInvalidationTracingEnabled == StyleInvalidationTracingEnabled)
+ TRACE_STYLE_INVALIDATOR_INVALIDATION(element, InvalidateCustomPseudo);
+
return true;
+ }
for (InvalidationSets::iterator it = m_invalidationSets.begin(); it != m_invalidationSets.end(); ++it) {
- if ((*it)->invalidatesElement(element))
+ if ((*it)->invalidatesElement<styleInvalidationTracingEnabled>(element))
return true;
}
return false;
}
+template <StyleInvalidationTracingEnabledFlag styleInvalidationTracingEnabled>
bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, StyleInvalidator::RecursionData& recursionData)
{
if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSubtreeInvalid()) {
@@ -108,12 +122,19 @@ bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, Sty
for (InvalidationList::const_iterator it = invalidationList->begin(); it != invalidationList->end(); ++it)
recursionData.pushInvalidationSet(**it);
// FIXME: It's really only necessary to clone the render style for this element, not full style recalc.
+ if (styleInvalidationTracingEnabled == StyleInvalidationTracingEnabled) {
+ TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
+ "StyleInvalidatorInvalidationTracking",
+ "data", InspectorStyleInvalidatorInvalidateEvent::invalidationList(element, *invalidationList));
+ }
return true;
}
}
- return recursionData.matchesCurrentInvalidationSets(element);
+
+ return recursionData.matchesCurrentInvalidationSets<styleInvalidationTracingEnabled>(element);
}
+template <StyleInvalidationTracingEnabledFlag styleInvalidationTracingEnabled>
bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::RecursionData& recursionData)
{
bool someChildrenNeedStyleRecalc = false;
@@ -121,37 +142,41 @@ bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::Re
if (!recursionData.treeBoundaryCrossing() && !root->childNeedsStyleInvalidation() && !root->needsStyleInvalidation())
continue;
for (Element* child = ElementTraversal::firstChild(*root); child; child = ElementTraversal::nextSibling(*child)) {
- bool childRecalced = invalidate(*child, recursionData);
+ bool childRecalced = invalidate<styleInvalidationTracingEnabled>(*child, recursionData);
someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRecalced;
}
root->clearChildNeedsStyleInvalidation();
root->clearNeedsStyleInvalidation();
}
for (Element* child = ElementTraversal::firstChild(element); child; child = ElementTraversal::nextSibling(*child)) {
- bool childRecalced = invalidate(*child, recursionData);
+ bool childRecalced = invalidate<styleInvalidationTracingEnabled>(*child, recursionData);
someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRecalced;
}
return someChildrenNeedStyleRecalc;
}
+template <StyleInvalidationTracingEnabledFlag styleInvalidationTracingEnabled>
bool StyleInvalidator::invalidate(Element& element, StyleInvalidator::RecursionData& recursionData)
{
RecursionCheckpoint checkpoint(&recursionData);
- bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement(element, recursionData);
+ bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement<styleInvalidationTracingEnabled>(element, recursionData);
bool someChildrenNeedStyleRecalc = false;
if (recursionData.hasInvalidationSets() || element.childNeedsStyleInvalidation())
- someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData);
+ someChildrenNeedStyleRecalc = invalidateChildren<styleInvalidationTracingEnabled>(element, recursionData);
if (thisElementNeedsStyleRecalc) {
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 (styleInvalidationTracingEnabled == StyleInvalidationTracingEnabled)
+ TRACE_STYLE_INVALIDATOR_INVALIDATION(element, PreventStyleSharingForParent);
element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
+ }
}
element.clearChildNeedsStyleInvalidation();

Powered by Google App Engine
This is Rietveld 408576698