Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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<Node*>& nodesNeedingRe attach) |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } | 338 } |
| 336 } else { | 339 } else { |
| 337 distribution.append(node); | 340 distribution.append(node); |
| 338 m_nodeToInsertionPoint.add(node, insertionPoint); | 341 m_nodeToInsertionPoint.add(node, insertionPoint); |
| 339 } | 342 } |
| 340 } | 343 } |
| 341 | 344 |
| 342 insertionPoint->setDistribution(distribution); | 345 insertionPoint->setDistribution(distribution); |
| 343 } | 346 } |
| 344 | 347 |
| 345 void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot) | 348 void ContentDistributor::ensureDistribution(Element* host) |
| 346 { | 349 { |
| 347 ASSERT(shadowRoot); | |
| 348 | |
| 349 Vector<ElementShadow*, 8> elementShadows; | 350 Vector<ElementShadow*, 8> elementShadows; |
| 350 for (Element* current = shadowRoot->host(); current; current = current->shad owHost()) { | 351 for (Element* current = host; current; current = current->shadowHost()) { |
| 351 ElementShadow* elementShadow = current->shadow(); | 352 ElementShadow* elementShadow = current->shadow(); |
| 352 if (!elementShadow->distributor().needsDistribution()) | 353 if (!elementShadow->distributor().needsDistribution()) |
| 353 break; | 354 break; |
| 354 | 355 |
| 355 elementShadows.append(elementShadow); | 356 elementShadows.append(elementShadow); |
| 356 } | 357 } |
| 357 | 358 |
| 358 for (size_t i = elementShadows.size(); i > 0; --i) | 359 for (size_t i = elementShadows.size(); i > 0; --i) |
| 359 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost()); | 360 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost()); |
| 360 } | 361 } |
| 361 | 362 |
| 362 | 363 |
| 363 void ContentDistributor::invalidateDistribution(Element* host) | 364 void ContentDistributor::invalidateDistribution(Element* host) |
| 364 { | 365 { |
| 366 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.
| |
| 365 bool didNeedInvalidation = needsInvalidation(); | 367 bool didNeedInvalidation = needsInvalidation(); |
| 366 bool needsReattach = didNeedInvalidation ? invalidate(host) : false; | 368 bool needsReattach = didNeedInvalidation ? invalidate(host, nodesNeedingReat tach) : false; |
| 367 | 369 |
| 368 if (needsReattach && host->attached()) { | 370 if (needsReattach && host->attached()) { |
| 369 for (Node* n = host->firstChild(); n; n = n->nextSibling()) | 371 for (Node* n = host->firstChild(); n; n = n->nextSibling()) |
| 370 n->lazyReattach(); | 372 n->lazyReattachIfAttached(); |
| 373 for (size_t i = 0; i < nodesNeedingReattach.size(); ++i) | |
| 374 nodesNeedingReattach[i]->lazyReattachIfAttached(); | |
| 371 host->setNeedsStyleRecalc(); | 375 host->setNeedsStyleRecalc(); |
| 372 } | 376 } |
| 373 | 377 |
| 374 if (didNeedInvalidation) { | 378 if (didNeedInvalidation) { |
| 375 ASSERT(m_validity == Invalidating); | 379 ASSERT(m_validity == Invalidating); |
| 376 m_validity = Invalidated; | 380 m_validity = Invalidated; |
| 377 } | 381 } |
| 378 } | 382 } |
| 379 | 383 |
| 380 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow) | 384 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 { | 425 { |
| 422 for (ElementShadow* shadow = host->shadow(); shadow; shadow = shadow->contai ningShadow()) { | 426 for (ElementShadow* shadow = host->shadow(); shadow; shadow = shadow->contai ningShadow()) { |
| 423 if (shadow->distributor().needsSelectFeatureSet()) | 427 if (shadow->distributor().needsSelectFeatureSet()) |
| 424 break; | 428 break; |
| 425 shadow->distributor().setNeedsSelectFeatureSet(); | 429 shadow->distributor().setNeedsSelectFeatureSet(); |
| 426 } | 430 } |
| 427 | 431 |
| 428 invalidateDistribution(host); | 432 invalidateDistribution(host); |
| 429 } | 433 } |
| 430 | 434 |
| 435 void ContentDistributor::setNeedsStyleRecalcIfDistributedTo(Element* host, Inser tionPoint* insertionPoint) | |
|
esprehn
2013/06/14 22:22:10
host is unused, please remove.
Hajime Morrita
2013/06/17 01:58:24
Done.
| |
| 436 { | |
| 437 for (NodeInsertionPointMap::iterator i = m_nodeToInsertionPoint.begin(); i ! = m_nodeToInsertionPoint.end(); ++i) { | |
| 438 if (i->value == insertionPoint) | |
| 439 const_cast<Node*>(i->key)->setNeedsStyleRecalc(SyntheticStyleChange) ; | |
| 440 } | |
| 441 } | |
| 442 | |
| 431 void ContentDistributor::didShadowBoundaryChange(Element* host) | 443 void ContentDistributor::didShadowBoundaryChange(Element* host) |
| 432 { | 444 { |
| 433 setValidity(Undetermined); | 445 setValidity(Undetermined); |
| 434 invalidateDistribution(host); | 446 invalidateDistribution(host); |
| 435 } | 447 } |
| 436 | 448 |
| 437 } | 449 } |
| OLD | NEW |