| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 pool.append(insertionPoint->at(i)); | 187 pool.append(insertionPoint->at(i)); |
| 188 } else { | 188 } else { |
| 189 for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fa
llbackNode = fallbackNode->nextSibling()) | 189 for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fa
llbackNode = fallbackNode->nextSibling()) |
| 190 pool.append(fallbackNode); | 190 pool.append(fallbackNode); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ElementShadow::distribute() | 194 void ElementShadow::distribute() |
| 195 { | 195 { |
| 196 Vector<Node*> pool; | 196 Vector<Node*> pool; |
| 197 pool.reserveInitialCapacity(32); |
| 197 for (Node* node = host()->firstChild(); node; node = node->nextSibling()) | 198 for (Node* node = host()->firstChild(); node; node = node->nextSibling()) |
| 198 populate(node, pool); | 199 populate(node, pool); |
| 199 | 200 |
| 200 host()->setNeedsStyleRecalc(); | 201 host()->setNeedsStyleRecalc(); |
| 201 | 202 |
| 202 Vector<bool> distributed(pool.size()); | 203 Vector<bool> distributed; |
| 203 distributed.fill(false); | 204 distributed.fill(false, pool.size()); |
| 204 | 205 |
| 205 Vector<HTMLShadowElement*, 8> activeShadowInsertionPoints; | 206 Vector<HTMLShadowElement*, 32> activeShadowInsertionPoints; |
| 206 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 207 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { |
| 207 HTMLShadowElement* firstActiveShadowInsertionPoint = 0; | 208 HTMLShadowElement* firstActiveShadowInsertionPoint = 0; |
| 208 | 209 |
| 209 const Vector<RefPtr<InsertionPoint> >& insertionPoints = root->childInse
rtionPoints(); | 210 const Vector<RefPtr<InsertionPoint> >& insertionPoints = root->childInse
rtionPoints(); |
| 210 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 211 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 211 InsertionPoint* point = insertionPoints[i].get(); | 212 InsertionPoint* point = insertionPoints[i].get(); |
| 212 if (!point->isActive()) | 213 if (!point->isActive()) |
| 213 continue; | 214 continue; |
| 214 | 215 |
| 215 if (isHTMLShadowElement(point)) { | 216 if (isHTMLShadowElement(point)) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 276 } |
| 276 | 277 |
| 277 void ElementShadow::distributeNodeChildrenTo(InsertionPoint* insertionPoint, Con
tainerNode* containerNode) | 278 void ElementShadow::distributeNodeChildrenTo(InsertionPoint* insertionPoint, Con
tainerNode* containerNode) |
| 278 { | 279 { |
| 279 ContentDistribution distribution; | 280 ContentDistribution distribution; |
| 280 for (Node* node = containerNode->firstChild(); node; node = node->nextSiblin
g()) { | 281 for (Node* node = containerNode->firstChild(); node; node = node->nextSiblin
g()) { |
| 281 if (isActiveInsertionPoint(node)) { | 282 if (isActiveInsertionPoint(node)) { |
| 282 InsertionPoint* innerInsertionPoint = toInsertionPoint(node); | 283 InsertionPoint* innerInsertionPoint = toInsertionPoint(node); |
| 283 if (innerInsertionPoint->hasDistribution()) { | 284 if (innerInsertionPoint->hasDistribution()) { |
| 284 for (size_t i = 0; i < innerInsertionPoint->size(); ++i) { | 285 for (size_t i = 0; i < innerInsertionPoint->size(); ++i) { |
| 285 distribution.append(innerInsertionPoint->at(i)); | 286 Node* nodeToAdd = innerInsertionPoint->at(i); |
| 286 m_nodeToInsertionPoint.add(innerInsertionPoint->at(i), inser
tionPoint); | 287 distribution.append(nodeToAdd); |
| 288 m_nodeToInsertionPoint.add(nodeToAdd, insertionPoint); |
| 287 } | 289 } |
| 288 } else { | 290 } else { |
| 289 for (Node* child = innerInsertionPoint->firstChild(); child; chi
ld = child->nextSibling()) { | 291 for (Node* child = innerInsertionPoint->firstChild(); child; chi
ld = child->nextSibling()) { |
| 290 distribution.append(child); | 292 distribution.append(child); |
| 291 m_nodeToInsertionPoint.add(child, insertionPoint); | 293 m_nodeToInsertionPoint.add(child, insertionPoint); |
| 292 } | 294 } |
| 293 } | 295 } |
| 294 } else { | 296 } else { |
| 295 distribution.append(node); | 297 distribution.append(node); |
| 296 m_nodeToInsertionPoint.add(node, insertionPoint); | 298 m_nodeToInsertionPoint.add(node, insertionPoint); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 350 |
| 349 void ElementShadow::clearDistribution() | 351 void ElementShadow::clearDistribution() |
| 350 { | 352 { |
| 351 m_nodeToInsertionPoint.clear(); | 353 m_nodeToInsertionPoint.clear(); |
| 352 | 354 |
| 353 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 355 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
| 354 root->setInsertionPoint(0); | 356 root->setInsertionPoint(0); |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace | 359 } // namespace |
| OLD | NEW |