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 20 matching lines...) Expand all Loading... |
31 #include "core/css/StyleSheetList.h" | 31 #include "core/css/StyleSheetList.h" |
32 #include "core/dom/ContainerNodeAlgorithms.h" | 32 #include "core/dom/ContainerNodeAlgorithms.h" |
33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
34 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.h" |
35 #include "core/dom/shadow/ContentDistribution.h" | 35 #include "core/dom/shadow/ContentDistribution.h" |
36 #include "core/html/HTMLContentElement.h" | 36 #include "core/html/HTMLContentElement.h" |
37 #include "core/html/HTMLShadowElement.h" | 37 #include "core/html/HTMLShadowElement.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 class DistributionPool { | 41 class DistributionPool FINAL { |
| 42 STACK_ALLOCATED(); |
42 public: | 43 public: |
43 explicit DistributionPool(const ContainerNode&); | 44 explicit DistributionPool(const ContainerNode&); |
44 void clear(); | 45 void clear(); |
45 ~DistributionPool(); | 46 ~DistributionPool(); |
46 void distributeTo(InsertionPoint*, ElementShadow*); | 47 void distributeTo(InsertionPoint*, ElementShadow*); |
47 void populateChildren(const ContainerNode&); | 48 void populateChildren(const ContainerNode&); |
48 | 49 |
49 private: | 50 private: |
50 void detachNonDistributedNodes(); | 51 void detachNonDistributedNodes(); |
51 Vector<Node*, 32> m_nodes; | 52 WillBeHeapVector<RawPtrWillBeMember<Node>, 32> m_nodes; |
52 Vector<bool, 32> m_distributed; | 53 Vector<bool, 32> m_distributed; |
53 }; | 54 }; |
54 | 55 |
55 inline DistributionPool::DistributionPool(const ContainerNode& parent) | 56 inline DistributionPool::DistributionPool(const ContainerNode& parent) |
56 { | 57 { |
57 populateChildren(parent); | 58 populateChildren(parent); |
58 } | 59 } |
59 | 60 |
60 inline void DistributionPool::clear() | 61 inline void DistributionPool::clear() |
61 { | 62 { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 252 } |
252 | 253 |
253 void ElementShadow::distribute() | 254 void ElementShadow::distribute() |
254 { | 255 { |
255 host()->setNeedsStyleRecalc(SubtreeStyleChange); | 256 host()->setNeedsStyleRecalc(SubtreeStyleChange); |
256 Vector<HTMLShadowElement*, 32> shadowInsertionPoints; | 257 Vector<HTMLShadowElement*, 32> shadowInsertionPoints; |
257 DistributionPool pool(*host()); | 258 DistributionPool pool(*host()); |
258 | 259 |
259 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 260 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { |
260 HTMLShadowElement* shadowInsertionPoint = 0; | 261 HTMLShadowElement* shadowInsertionPoint = 0; |
261 const Vector<RefPtr<InsertionPoint> >& insertionPoints = root->descendan
tInsertionPoints(); | 262 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint> >& insertionPo
ints = root->descendantInsertionPoints(); |
262 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 263 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
263 InsertionPoint* point = insertionPoints[i].get(); | 264 InsertionPoint* point = insertionPoints[i].get(); |
264 if (!point->isActive()) | 265 if (!point->isActive()) |
265 continue; | 266 continue; |
266 if (isHTMLShadowElement(*point)) { | 267 if (isHTMLShadowElement(*point)) { |
267 ASSERT(!shadowInsertionPoint); | 268 ASSERT(!shadowInsertionPoint); |
268 shadowInsertionPoint = toHTMLShadowElement(point); | 269 shadowInsertionPoint = toHTMLShadowElement(point); |
269 shadowInsertionPoints.append(shadowInsertionPoint); | 270 shadowInsertionPoints.append(shadowInsertionPoint); |
270 } else { | 271 } else { |
271 pool.distributeTo(point, this); | 272 pool.distributeTo(point, this); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 void ElementShadow::clearDistribution() | 349 void ElementShadow::clearDistribution() |
349 { | 350 { |
350 m_nodeToInsertionPoints.clear(); | 351 m_nodeToInsertionPoints.clear(); |
351 | 352 |
352 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 353 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
353 root->setShadowInsertionPointOfYoungerShadowRoot(nullptr); | 354 root->setShadowInsertionPointOfYoungerShadowRoot(nullptr); |
354 } | 355 } |
355 | 356 |
356 void ElementShadow::trace(Visitor* visitor) | 357 void ElementShadow::trace(Visitor* visitor) |
357 { | 358 { |
| 359 visitor->trace(m_nodeToInsertionPoints); |
358 // Shadow roots are linked with previous and next pointers which are traced. | 360 // Shadow roots are linked with previous and next pointers which are traced. |
359 // It is therefore enough to trace one of the shadow roots here and the | 361 // It is therefore enough to trace one of the shadow roots here and the |
360 // rest will be traced from there. | 362 // rest will be traced from there. |
361 visitor->trace(m_shadowRoots.head()); | 363 visitor->trace(m_shadowRoots.head()); |
362 } | 364 } |
363 | 365 |
364 } // namespace | 366 } // namespace |
OLD | NEW |