Chromium Code Reviews| Index: Source/core/dom/shadow/ContentDistributor.cpp |
| diff --git a/Source/core/dom/shadow/ContentDistributor.cpp b/Source/core/dom/shadow/ContentDistributor.cpp |
| index 95db1751219ac81bd038c27c41c112ce980fd92e..330fc63ee6f844cc2ab337d7ace19620577eb9e8 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<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. |
| @@ -342,12 +345,10 @@ void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint |
| insertionPoint->setDistribution(distribution); |
| } |
| -void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot) |
| +void ContentDistributor::ensureDistribution(Element* host) |
| { |
| - ASSERT(shadowRoot); |
| - |
| 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; |
| @@ -362,12 +363,15 @@ void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot) |
| void ContentDistributor::invalidateDistribution(Element* host) |
| { |
| + Vector<Node*> nodesNeedingReattach; |
|
esprehn
2013/06/14 22:22:10
I'd probably give this an inline capacity like the
Hajime Morrita
2013/06/17 01:58:24
Done.
|
| 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(); |
| + n->lazyReattachIfAttached(); |
| + for (size_t i = 0; i < nodesNeedingReattach.size(); ++i) |
| + nodesNeedingReattach[i]->lazyReattachIfAttached(); |
| host->setNeedsStyleRecalc(); |
| } |
| @@ -428,6 +432,14 @@ void ContentDistributor::willAffectSelector(Element* host) |
| invalidateDistribution(host); |
| } |
| +void ContentDistributor::setNeedsStyleRecalcIfDistributedTo(Element* host, InsertionPoint* insertionPoint) |
|
esprehn
2013/06/14 22:22:10
host is unused, please remove.
Hajime Morrita
2013/06/17 01:58:24
Done.
|
| +{ |
| + for (NodeInsertionPointMap::iterator i = m_nodeToInsertionPoint.begin(); i != m_nodeToInsertionPoint.end(); ++i) { |
| + if (i->value == insertionPoint) |
| + const_cast<Node*>(i->key)->setNeedsStyleRecalc(SyntheticStyleChange); |
| + } |
| +} |
| + |
| void ContentDistributor::didShadowBoundaryChange(Element* host) |
| { |
| setValidity(Undetermined); |