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

Unified Diff: Source/core/dom/shadow/ContentDistributor.cpp

Issue 15680005: Element::recalcStyle() overly reattach()-es InsertionPoints. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated test and test expectations Created 7 years, 7 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/dom/shadow/ContentDistributor.cpp
diff --git a/Source/core/dom/shadow/ContentDistributor.cpp b/Source/core/dom/shadow/ContentDistributor.cpp
index 70f6d5b740f594614fc5d59fc10d23930620b2c0..83cddd4b0edfbdc852370052ca8a800b8be90566 100644
--- a/Source/core/dom/shadow/ContentDistributor.cpp
+++ b/Source/core/dom/shadow/ContentDistributor.cpp
@@ -265,7 +265,7 @@ void ContentDistributor::distribute(Element* host)
}
}
-bool ContentDistributor::invalidate(Element* host)
+bool ContentDistributor::invalidate(Element* host, Vector<RefPtr<Node> >& nodesNeedingReattach)
{
ASSERT(needsInvalidation());
bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint.isEmpty();
@@ -275,7 +275,10 @@ bool ContentDistributor::invalidate(Element* host)
scope->setInsertionPointAssignedTo(0);
const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
for (size_t i = 0; i < insertionPoints.size(); ++i) {
- needsReattach = needsReattach || true;
+ needsReattach = true;
+ for (Node* child = insertionPoints[i]->firstChild(); child; child = child->nextSibling())
+ nodesNeedingReattach.append(child);
+
insertionPoints[i]->clearDistribution();
// After insertionPoint's distribution is invalidated, its reprojection should also be invalidated.
@@ -347,9 +350,19 @@ void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint
void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
{
ASSERT(shadowRoot);
+ return ensureDistribution(shadowRoot->host());
+}
+
+void ContentDistributor::ensureDistribution(ElementShadow* shadow)
+{
+ ASSERT(shadow);
+ return ensureDistribution(shadow->host());
+}
+void ContentDistributor::ensureDistribution(Element* host)
+{
Vector<ElementShadow*, 8> elementShadows;
- for (Element* current = shadowRoot->host(); current; current = current->shadowHost()) {
+ for (Element* current = host; current; current = current->shadowHost()) {
ElementShadow* elementShadow = current->shadow();
if (!elementShadow->distributor().needsDistribution())
break;
@@ -364,12 +377,15 @@ void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
void ContentDistributor::invalidateDistribution(Element* host)
{
+ Vector<RefPtr<Node> > nodesNeedingReattach;
bool didNeedInvalidation = needsInvalidation();
- bool needsReattach = didNeedInvalidation ? invalidate(host) : false;
+ bool needsReattach = didNeedInvalidation ? invalidate(host, nodesNeedingReattach) : false;
if (needsReattach && host->attached()) {
for (Node* n = host->firstChild(); n; n = n->nextSibling())
n->lazyReattach();
+ for (size_t i = 0; i < nodesNeedingReattach.size(); ++i)
+ nodesNeedingReattach[i]->lazyReattach();
host->setNeedsStyleRecalc();
}

Powered by Google App Engine
This is Rietveld 408576698