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

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

Issue 17054002: Element::recalcStyle() overly reattach()-es InsertionPoints. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 7 years, 6 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/dom/shadow/ContentDistributor.h ('k') | Source/core/dom/shadow/ElementShadow.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b9033b1c23efa32a4ae60ab65529144042114afc 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*, 8>& 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*, 8> 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();
+ 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(InsertionPoint* insertionPoint)
+{
+ 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);
« no previous file with comments | « Source/core/dom/shadow/ContentDistributor.h ('k') | Source/core/dom/shadow/ElementShadow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698