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

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

Issue 946993002: Avoid style invalidation for empty sets. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added dummy selectors to tests to force descendant invalidation Created 5 years, 10 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
« no previous file with comments | « Source/core/css/invalidation/DescendantInvalidationSetTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/invalidation/StyleInvalidator.cpp
diff --git a/Source/core/css/invalidation/StyleInvalidator.cpp b/Source/core/css/invalidation/StyleInvalidator.cpp
index f9822257e39a9bb1c9cbdc640b52058df67497c8..98573d942bbef6cd52c545578bf872fc95f06298 100644
--- a/Source/core/css/invalidation/StyleInvalidator.cpp
+++ b/Source/core/css/invalidation/StyleInvalidator.cpp
@@ -43,14 +43,19 @@ void StyleInvalidator::invalidate(Document& document)
void StyleInvalidator::scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet, Element& element)
{
ASSERT(element.inActiveDocument());
- ASSERT(element.styleChangeType() < SubtreeStyleChange);
- InvalidationList& list = ensurePendingInvalidationList(element);
- // If we're already going to invalidate the whole subtree we don't need to store any new sets.
- if (!list.isEmpty() && list.last()->wholeSubtreeInvalid())
+ if (element.styleChangeType() >= SubtreeStyleChange)
+ return;
+ if (invalidationSet->wholeSubtreeInvalid()) {
+ element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
+ clearInvalidation(element);
return;
- // If this set would invalidate the whole subtree we can discard all existing sets.
- if (invalidationSet->wholeSubtreeInvalid())
- list.clear();
+ }
+ if (invalidationSet->isEmpty()) {
+ element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
+ return;
+ }
+
+ InvalidationList& list = ensurePendingInvalidationList(element);
list.append(invalidationSet);
element.setNeedsStyleInvalidation();
}
@@ -87,22 +92,18 @@ StyleInvalidator::~StyleInvalidator()
void StyleInvalidator::RecursionData::pushInvalidationSet(const DescendantInvalidationSet& invalidationSet)
{
ASSERT(!m_wholeSubtreeInvalid);
+ ASSERT(!invalidationSet.wholeSubtreeInvalid());
+ ASSERT(!invalidationSet.isEmpty());
if (invalidationSet.treeBoundaryCrossing())
m_treeBoundaryCrossing = true;
if (invalidationSet.insertionPointCrossing())
m_insertionPointCrossing = true;
- if (invalidationSet.wholeSubtreeInvalid()) {
- m_wholeSubtreeInvalid = true;
- return;
- }
m_invalidationSets.append(&invalidationSet);
m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid();
}
ALWAYS_INLINE bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& element)
{
- ASSERT(!m_wholeSubtreeInvalid);
-
if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) {
TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED(element, InvalidateCustomPseudo);
return true;
@@ -172,7 +173,8 @@ bool StyleInvalidator::invalidate(Element& element, StyleInvalidator::RecursionD
someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData);
if (thisElementNeedsStyleRecalc) {
- element.setNeedsStyleRecalc(recursionData.wholeSubtreeInvalid() ? SubtreeStyleChange : LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
+ ASSERT(!recursionData.wholeSubtreeInvalid());
+ element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleInvalidator));
} else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecalc) {
// Clone the LayoutStyle in order to preserve correct style sharing, if possible. Otherwise recalc style.
if (LayoutObject* renderer = element.renderer()) {
« no previous file with comments | « Source/core/css/invalidation/DescendantInvalidationSetTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698