| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 STACK_ALLOCATED(); | 44 STACK_ALLOCATED(); |
| 45 public: | 45 public: |
| 46 explicit DistributionPool(const ContainerNode&); | 46 explicit DistributionPool(const ContainerNode&); |
| 47 void clear(); | 47 void clear(); |
| 48 ~DistributionPool(); | 48 ~DistributionPool(); |
| 49 void distributeTo(InsertionPoint*, ElementShadow*); | 49 void distributeTo(InsertionPoint*, ElementShadow*); |
| 50 void populateChildren(const ContainerNode&); | 50 void populateChildren(const ContainerNode&); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 void detachNonDistributedNodes(); | 53 void detachNonDistributedNodes(); |
| 54 WillBeHeapVector<RawPtrWillBeMember<Node>, 32> m_nodes; | 54 HeapVector<Member<Node>, 32> m_nodes; |
| 55 Vector<bool, 32> m_distributed; | 55 Vector<bool, 32> m_distributed; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 inline DistributionPool::DistributionPool(const ContainerNode& parent) | 58 inline DistributionPool::DistributionPool(const ContainerNode& parent) |
| 59 { | 59 { |
| 60 populateChildren(parent); | 60 populateChildren(parent); |
| 61 } | 61 } |
| 62 | 62 |
| 63 inline void DistributionPool::clear() | 63 inline void DistributionPool::clear() |
| 64 { | 64 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 inline void DistributionPool::detachNonDistributedNodes() | 122 inline void DistributionPool::detachNonDistributedNodes() |
| 123 { | 123 { |
| 124 for (size_t i = 0; i < m_nodes.size(); ++i) { | 124 for (size_t i = 0; i < m_nodes.size(); ++i) { |
| 125 if (m_distributed[i]) | 125 if (m_distributed[i]) |
| 126 continue; | 126 continue; |
| 127 if (m_nodes[i]->layoutObject()) | 127 if (m_nodes[i]->layoutObject()) |
| 128 m_nodes[i]->lazyReattachIfAttached(); | 128 m_nodes[i]->lazyReattachIfAttached(); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 PassOwnPtrWillBeRawPtr<ElementShadow> ElementShadow::create() | 132 RawPtr<ElementShadow> ElementShadow::create() |
| 133 { | 133 { |
| 134 return adoptPtrWillBeNoop(new ElementShadow()); | 134 return new ElementShadow(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 ElementShadow::ElementShadow() | 137 ElementShadow::ElementShadow() |
| 138 : m_needsDistributionRecalc(false) | 138 : m_needsDistributionRecalc(false) |
| 139 , m_needsSelectFeatureSet(false) | 139 , m_needsSelectFeatureSet(false) |
| 140 { | 140 { |
| 141 } | 141 } |
| 142 | 142 |
| 143 ElementShadow::~ElementShadow() | 143 ElementShadow::~ElementShadow() |
| 144 { | 144 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 161 } else { | 161 } else { |
| 162 Deprecation::countDeprecation(shadowHost.document(), UseCounter::Ele
mentCreateShadowRootMultiple); | 162 Deprecation::countDeprecation(shadowHost.document(), UseCounter::Ele
mentCreateShadowRootMultiple); |
| 163 } | 163 } |
| 164 } else if (type == ShadowRootType::Open || type == ShadowRootType::Closed) { | 164 } else if (type == ShadowRootType::Open || type == ShadowRootType::Closed) { |
| 165 shadowHost.willAddFirstAuthorShadowRoot(); | 165 shadowHost.willAddFirstAuthorShadowRoot(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 for (ShadowRoot* root = m_shadowRoots.head(); root; root = root->olderShadow
Root()) | 168 for (ShadowRoot* root = m_shadowRoots.head(); root; root = root->olderShadow
Root()) |
| 169 root->lazyReattachIfAttached(); | 169 root->lazyReattachIfAttached(); |
| 170 | 170 |
| 171 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.do
cument(), type); | 171 RawPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.document(), ty
pe); |
| 172 shadowRoot->setParentOrShadowHostNode(&shadowHost); | 172 shadowRoot->setParentOrShadowHostNode(&shadowHost); |
| 173 shadowRoot->setParentTreeScope(shadowHost.treeScope()); | 173 shadowRoot->setParentTreeScope(shadowHost.treeScope()); |
| 174 m_shadowRoots.push(shadowRoot.get()); | 174 m_shadowRoots.push(shadowRoot.get()); |
| 175 setNeedsDistributionRecalc(); | 175 setNeedsDistributionRecalc(); |
| 176 | 176 |
| 177 shadowRoot->insertedInto(&shadowHost); | 177 shadowRoot->insertedInto(&shadowHost); |
| 178 shadowHost.setChildNeedsStyleRecalc(); | 178 shadowHost.setChildNeedsStyleRecalc(); |
| 179 shadowHost.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::Shadow)); | 179 shadowHost.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::Shadow)); |
| 180 | 180 |
| 181 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); | 181 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); |
| 182 | 182 |
| 183 return *shadowRoot; | 183 return *shadowRoot; |
| 184 } | 184 } |
| 185 | 185 |
| 186 #if !ENABLE(OILPAN) | 186 #if !ENABLE(OILPAN) |
| 187 void ElementShadow::removeDetachedShadowRoots() | 187 void ElementShadow::removeDetachedShadowRoots() |
| 188 { | 188 { |
| 189 // Dont protect this ref count. | 189 // Dont protect this ref count. |
| 190 Element* shadowHost = host(); | 190 Element* shadowHost = host(); |
| 191 ASSERT(shadowHost); | 191 ASSERT(shadowHost); |
| 192 | 192 |
| 193 while (RefPtrWillBeRawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { | 193 while (RawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
| 194 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); | 194 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); |
| 195 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); | 195 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); |
| 196 m_shadowRoots.removeHead(); | 196 m_shadowRoots.removeHead(); |
| 197 oldRoot->setParentOrShadowHostNode(0); | 197 oldRoot->setParentOrShadowHostNode(0); |
| 198 oldRoot->setParentTreeScope(shadowHost->document()); | 198 oldRoot->setParentTreeScope(shadowHost->document()); |
| 199 oldRoot->setPrev(0); | 199 oldRoot->setPrev(0); |
| 200 oldRoot->setNext(0); | 200 oldRoot->setNext(0); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 #endif | 203 #endif |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 void ElementShadow::distribute() | 281 void ElementShadow::distribute() |
| 282 { | 282 { |
| 283 if (isV1()) | 283 if (isV1()) |
| 284 distributeV1(); | 284 distributeV1(); |
| 285 else | 285 else |
| 286 distributeV0(); | 286 distributeV0(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void ElementShadow::distributeV0() | 289 void ElementShadow::distributeV0() |
| 290 { | 290 { |
| 291 WillBeHeapVector<RawPtrWillBeMember<HTMLShadowElement>, 32> shadowInsertionP
oints; | 291 HeapVector<Member<HTMLShadowElement>, 32> shadowInsertionPoints; |
| 292 DistributionPool pool(*host()); | 292 DistributionPool pool(*host()); |
| 293 | 293 |
| 294 for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShado
wRoot()) { | 294 for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShado
wRoot()) { |
| 295 HTMLShadowElement* shadowInsertionPoint = 0; | 295 HTMLShadowElement* shadowInsertionPoint = 0; |
| 296 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& insertionPoi
nts = root->descendantInsertionPoints(); | 296 const HeapVector<Member<InsertionPoint>>& insertionPoints = root->descen
dantInsertionPoints(); |
| 297 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 297 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 298 InsertionPoint* point = insertionPoints[i].get(); | 298 InsertionPoint* point = insertionPoints[i].get(); |
| 299 if (!point->isActive()) | 299 if (!point->isActive()) |
| 300 continue; | 300 continue; |
| 301 if (isHTMLShadowElement(*point)) { | 301 if (isHTMLShadowElement(*point)) { |
| 302 ASSERT(!shadowInsertionPoint); | 302 ASSERT(!shadowInsertionPoint); |
| 303 shadowInsertionPoint = toHTMLShadowElement(point); | 303 shadowInsertionPoint = toHTMLShadowElement(point); |
| 304 shadowInsertionPoints.append(shadowInsertionPoint); | 304 shadowInsertionPoints.append(shadowInsertionPoint); |
| 305 } else { | 305 } else { |
| 306 pool.distributeTo(point, this); | 306 pool.distributeTo(point, this); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 334 if (!m_slotAssignment) | 334 if (!m_slotAssignment) |
| 335 m_slotAssignment = SlotAssignment::create(); | 335 m_slotAssignment = SlotAssignment::create(); |
| 336 m_slotAssignment->resolveAssignment(youngestShadowRoot()); | 336 m_slotAssignment->resolveAssignment(youngestShadowRoot()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void ElementShadow::didDistributeNode(const Node* node, InsertionPoint* insertio
nPoint) | 339 void ElementShadow::didDistributeNode(const Node* node, InsertionPoint* insertio
nPoint) |
| 340 { | 340 { |
| 341 #if ENABLE(OILPAN) | 341 #if ENABLE(OILPAN) |
| 342 NodeToDestinationInsertionPoints::AddResult result = m_nodeToInsertionPoints
.add(node, nullptr); | 342 NodeToDestinationInsertionPoints::AddResult result = m_nodeToInsertionPoints
.add(node, nullptr); |
| 343 if (result.isNewEntry) | 343 if (result.isNewEntry) |
| 344 result.storedValue->value = adoptPtrWillBeNoop(new DestinationInsertionP
oints()); | 344 result.storedValue->value = new DestinationInsertionPoints(); |
| 345 result.storedValue->value->append(insertionPoint); | 345 result.storedValue->value->append(insertionPoint); |
| 346 #else | 346 #else |
| 347 NodeToDestinationInsertionPoints::AddResult result = m_nodeToInsertionPoints
.add(node, DestinationInsertionPoints()); | 347 NodeToDestinationInsertionPoints::AddResult result = m_nodeToInsertionPoints
.add(node, DestinationInsertionPoints()); |
| 348 result.storedValue->value.append(insertionPoint); | 348 result.storedValue->value.append(insertionPoint); |
| 349 #endif | 349 #endif |
| 350 } | 350 } |
| 351 | 351 |
| 352 const SelectRuleFeatureSet& ElementShadow::ensureSelectFeatureSet() | 352 const SelectRuleFeatureSet& ElementShadow::ensureSelectFeatureSet() |
| 353 { | 353 { |
| 354 if (!m_needsSelectFeatureSet) | 354 if (!m_needsSelectFeatureSet) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 visitor->trace(m_selectFeatures); | 401 visitor->trace(m_selectFeatures); |
| 402 // Shadow roots are linked with previous and next pointers which are traced. | 402 // Shadow roots are linked with previous and next pointers which are traced. |
| 403 // It is therefore enough to trace one of the shadow roots here and the | 403 // It is therefore enough to trace one of the shadow roots here and the |
| 404 // rest will be traced from there. | 404 // rest will be traced from there. |
| 405 visitor->trace(m_shadowRoots.head()); | 405 visitor->trace(m_shadowRoots.head()); |
| 406 visitor->trace(m_slotAssignment); | 406 visitor->trace(m_slotAssignment); |
| 407 #endif | 407 #endif |
| 408 } | 408 } |
| 409 | 409 |
| 410 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |