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<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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(ShadowRoot* shadowRoot) |
| 346 { | 349 { |
| 347 ASSERT(shadowRoot); | 350 ASSERT(shadowRoot); |
| 351 return ensureDistribution(shadowRoot->host()); | |
| 352 } | |
| 348 | 353 |
| 354 void ContentDistributor::ensureDistribution(ElementShadow* shadow) | |
|
esprehn
2013/06/14 08:32:29
I'd prefer if this was just a method of Element it
Hajime Morrita
2013/06/14 09:59:14
makes sense. will do.
| |
| 355 { | |
| 356 ASSERT(shadow); | |
| 357 return ensureDistribution(shadow->host()); | |
| 358 } | |
| 359 | |
| 360 void ContentDistributor::ensureDistribution(Element* host) | |
| 361 { | |
| 349 Vector<ElementShadow*, 8> elementShadows; | 362 Vector<ElementShadow*, 8> elementShadows; |
| 350 for (Element* current = shadowRoot->host(); current; current = current->shad owHost()) { | 363 for (Element* current = host; current; current = current->shadowHost()) { |
| 351 ElementShadow* elementShadow = current->shadow(); | 364 ElementShadow* elementShadow = current->shadow(); |
| 352 if (!elementShadow->distributor().needsDistribution()) | 365 if (!elementShadow->distributor().needsDistribution()) |
| 353 break; | 366 break; |
| 354 | 367 |
| 355 elementShadows.append(elementShadow); | 368 elementShadows.append(elementShadow); |
| 356 } | 369 } |
| 357 | 370 |
| 358 for (size_t i = elementShadows.size(); i > 0; --i) | 371 for (size_t i = elementShadows.size(); i > 0; --i) |
| 359 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost()); | 372 elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->h ost()); |
| 360 } | 373 } |
| 361 | 374 |
| 362 | 375 |
| 363 void ContentDistributor::invalidateDistribution(Element* host) | 376 void ContentDistributor::invalidateDistribution(Element* host) |
| 364 { | 377 { |
| 378 Vector<RefPtr<Node> > nodesNeedingReattach; | |
|
esprehn
2013/06/14 08:32:29
These shouldn't need to be RefPtr. I don't think a
Hajime Morrita
2013/06/14 09:59:14
It shouldn't run any script. WIll turn to raw poin
| |
| 365 bool didNeedInvalidation = needsInvalidation(); | 379 bool didNeedInvalidation = needsInvalidation(); |
| 366 bool needsReattach = didNeedInvalidation ? invalidate(host) : false; | 380 bool needsReattach = didNeedInvalidation ? invalidate(host, nodesNeedingReat tach) : false; |
| 367 | 381 |
| 368 if (needsReattach && host->attached()) { | 382 if (needsReattach && host->attached()) { |
| 369 for (Node* n = host->firstChild(); n; n = n->nextSibling()) | 383 for (Node* n = host->firstChild(); n; n = n->nextSibling()) |
| 370 n->lazyReattach(); | 384 n->lazyReattachIfAttached(); |
| 385 for (size_t i = 0; i < nodesNeedingReattach.size(); ++i) | |
| 386 nodesNeedingReattach[i]->lazyReattachIfAttached(); | |
| 371 host->setNeedsStyleRecalc(); | 387 host->setNeedsStyleRecalc(); |
| 372 } | 388 } |
| 373 | 389 |
| 374 if (didNeedInvalidation) { | 390 if (didNeedInvalidation) { |
| 375 ASSERT(m_validity == Invalidating); | 391 ASSERT(m_validity == Invalidating); |
| 376 m_validity = Invalidated; | 392 m_validity = Invalidated; |
| 377 } | 393 } |
| 378 } | 394 } |
| 379 | 395 |
| 380 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow) | 396 const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementSh adow* shadow) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 { | 437 { |
| 422 for (ElementShadow* shadow = host->shadow(); shadow; shadow = shadow->contai ningShadow()) { | 438 for (ElementShadow* shadow = host->shadow(); shadow; shadow = shadow->contai ningShadow()) { |
| 423 if (shadow->distributor().needsSelectFeatureSet()) | 439 if (shadow->distributor().needsSelectFeatureSet()) |
| 424 break; | 440 break; |
| 425 shadow->distributor().setNeedsSelectFeatureSet(); | 441 shadow->distributor().setNeedsSelectFeatureSet(); |
| 426 } | 442 } |
| 427 | 443 |
| 428 invalidateDistribution(host); | 444 invalidateDistribution(host); |
| 429 } | 445 } |
| 430 | 446 |
| 447 void ContentDistributor::setNeedsStyleRecalcIfDistributedTo(Element* host, Inser tionPoint* insertionPoint) | |
| 448 { | |
| 449 for (NodeInsertionPointMap::iterator i = m_nodeToInsertionPoint.begin(); i ! = m_nodeToInsertionPoint.end(); ++i) { | |
| 450 if (i->value == insertionPoint) | |
| 451 const_cast<Node*>(i->key)->setNeedsStyleRecalc(SyntheticStyleChange) ; | |
|
esprehn
2013/06/14 08:32:29
Can you just remove the const from the key in the
| |
| 452 } | |
| 453 } | |
| 454 | |
| 431 void ContentDistributor::didShadowBoundaryChange(Element* host) | 455 void ContentDistributor::didShadowBoundaryChange(Element* host) |
| 432 { | 456 { |
| 433 setValidity(Undetermined); | 457 setValidity(Undetermined); |
| 434 invalidateDistribution(host); | 458 invalidateDistribution(host); |
| 435 } | 459 } |
| 436 | 460 |
| 437 } | 461 } |
| OLD | NEW |