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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 distributeNodeChildrenTo(shadowElement, root->olderShadowRoot()); 258 distributeNodeChildrenTo(shadowElement, root->olderShadowRoot());
259 root->olderShadowRoot()->ensureScopeDistribution()->setInsertionPoin tAssignedTo(shadowElement); 259 root->olderShadowRoot()->ensureScopeDistribution()->setInsertionPoin tAssignedTo(shadowElement);
260 } else { 260 } else {
261 distributeSelectionsTo(shadowElement, pool, distributed); 261 distributeSelectionsTo(shadowElement, pool, distributed);
262 if (ElementShadow* shadow = shadowElement->parentNode()->isElementNo de() ? toElement(shadowElement->parentNode())->shadow() : 0) 262 if (ElementShadow* shadow = shadowElement->parentNode()->isElementNo de() ? toElement(shadowElement->parentNode())->shadow() : 0)
263 shadow->invalidateDistribution(); 263 shadow->invalidateDistribution();
264 } 264 }
265 } 265 }
266 } 266 }
267 267
268 bool ContentDistributor::invalidate(Element* host) 268 bool ContentDistributor::invalidate(Element* host, Vector<RefPtr<Node> >& nodesN eedingReattach)
269 { 269 {
270 ASSERT(needsInvalidation()); 270 ASSERT(needsInvalidation());
271 bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint .isEmpty(); 271 bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint .isEmpty();
272 272
273 for (ShadowRoot* root = host->youngestShadowRoot(); root; root = root->older ShadowRoot()) { 273 for (ShadowRoot* root = host->youngestShadowRoot(); root; root = root->older ShadowRoot()) {
274 if (ScopeContentDistribution* scope = root->scopeDistribution()) { 274 if (ScopeContentDistribution* scope = root->scopeDistribution()) {
275 scope->setInsertionPointAssignedTo(0); 275 scope->setInsertionPointAssignedTo(0);
276 const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensu reInsertionPointList(root); 276 const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensu reInsertionPointList(root);
277 for (size_t i = 0; i < insertionPoints.size(); ++i) { 277 for (size_t i = 0; i < insertionPoints.size(); ++i) {
278 needsReattach = needsReattach || true; 278 needsReattach = true;
279 for (Node* child = insertionPoints[i]->firstChild(); child; chil d = child->nextSibling())
280 nodesNeedingReattach.append(child);
281
279 insertionPoints[i]->clearDistribution(); 282 insertionPoints[i]->clearDistribution();
280 283
281 // After insertionPoint's distribution is invalidated, its repro jection should also be invalidated. 284 // After insertionPoint's distribution is invalidated, its repro jection should also be invalidated.
282 if (!insertionPoints[i]->isActive()) 285 if (!insertionPoints[i]->isActive())
283 continue; 286 continue;
284 287
285 if (Element* parent = insertionPoints[i]->parentElement()) { 288 if (Element* parent = insertionPoints[i]->parentElement()) {
286 if (ElementShadow* shadow = parent->shadow()) 289 if (ElementShadow* shadow = parent->shadow())
287 shadow->invalidateDistribution(); 290 shadow->invalidateDistribution();
288 } 291 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 m_nodeToInsertionPoint.add(node, insertionPoint); 343 m_nodeToInsertionPoint.add(node, insertionPoint);
341 } 344 }
342 } 345 }
343 346
344 insertionPoint->setDistribution(distribution); 347 insertionPoint->setDistribution(distribution);
345 } 348 }
346 349
347 void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot) 350 void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
348 { 351 {
349 ASSERT(shadowRoot); 352 ASSERT(shadowRoot);
353 return ensureDistribution(shadowRoot->host());
354 }
350 355
356 void ContentDistributor::ensureDistribution(ElementShadow* shadow)
357 {
358 ASSERT(shadow);
359 return ensureDistribution(shadow->host());
360 }
361
362 void ContentDistributor::ensureDistribution(Element* host)
363 {
351 Vector<ElementShadow*, 8> elementShadows; 364 Vector<ElementShadow*, 8> elementShadows;
352 for (Element* current = shadowRoot->host(); current; current = current->shad owHost()) { 365 for (Element* current = host; current; current = current->shadowHost()) {
353 ElementShadow* elementShadow = current->shadow(); 366 ElementShadow* elementShadow = current->shadow();
354 if (!elementShadow->distributor().needsDistribution()) 367 if (!elementShadow->distributor().needsDistribution())
355 break; 368 break;
356 369
357 elementShadows.append(elementShadow); 370 elementShadows.append(elementShadow);
358 } 371 }
359 372
360 for (size_t i = elementShadows.size(); i > 0; --i) 373 for (size_t i = elementShadows.size(); i > 0; --i)
361 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost()); 374 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost());
362 } 375 }
363 376
364 377
365 void ContentDistributor::invalidateDistribution(Element* host) 378 void ContentDistributor::invalidateDistribution(Element* host)
366 { 379 {
380 Vector<RefPtr<Node> > nodesNeedingReattach;
367 bool didNeedInvalidation = needsInvalidation(); 381 bool didNeedInvalidation = needsInvalidation();
368 bool needsReattach = didNeedInvalidation ? invalidate(host) : false; 382 bool needsReattach = didNeedInvalidation ? invalidate(host, nodesNeedingReat tach) : false;
369 383
370 if (needsReattach && host->attached()) { 384 if (needsReattach && host->attached()) {
371 for (Node* n = host->firstChild(); n; n = n->nextSibling()) 385 for (Node* n = host->firstChild(); n; n = n->nextSibling())
372 n->lazyReattach(); 386 n->lazyReattach();
387 for (size_t i = 0; i < nodesNeedingReattach.size(); ++i)
388 nodesNeedingReattach[i]->lazyReattach();
373 host->setNeedsStyleRecalc(); 389 host->setNeedsStyleRecalc();
374 } 390 }
375 391
376 if (didNeedInvalidation) { 392 if (didNeedInvalidation) {
377 ASSERT(m_validity == Invalidating); 393 ASSERT(m_validity == Invalidating);
378 m_validity = Invalidated; 394 m_validity = Invalidated;
379 } 395 }
380 } 396 }
381 397
382 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow) 398 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 invalidateDistribution(host); 446 invalidateDistribution(host);
431 } 447 }
432 448
433 void ContentDistributor::didShadowBoundaryChange(Element* host) 449 void ContentDistributor::didShadowBoundaryChange(Element* host)
434 { 450 {
435 setValidity(Undetermined); 451 setValidity(Undetermined);
436 invalidateDistribution(host); 452 invalidateDistribution(host);
437 } 453 }
438 454
439 } 455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698