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(); |
} |