| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 , m_applyAuthorStyles(false) | 124 , m_applyAuthorStyles(false) |
| 125 , m_needsSelectFeatureSet(false) | 125 , m_needsSelectFeatureSet(false) |
| 126 { | 126 { |
| 127 } | 127 } |
| 128 | 128 |
| 129 ElementShadow::~ElementShadow() | 129 ElementShadow::~ElementShadow() |
| 130 { | 130 { |
| 131 removeAllShadowRoots(); | 131 removeAllShadowRoots(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 ShadowRoot* ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow
RootType type) | 134 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow
RootType type) |
| 135 { | 135 { |
| 136 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost.document(), t
ype); | 136 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost.document(), t
ype); |
| 137 | 137 |
| 138 shadowRoot->setParentOrShadowHostNode(&shadowHost); | 138 shadowRoot->setParentOrShadowHostNode(&shadowHost); |
| 139 shadowRoot->setParentTreeScope(&shadowHost.treeScope()); | 139 shadowRoot->setParentTreeScope(&shadowHost.treeScope()); |
| 140 m_shadowRoots.push(shadowRoot.get()); | 140 m_shadowRoots.push(shadowRoot.get()); |
| 141 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); | 141 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); |
| 142 setNeedsDistributionRecalc(); | 142 setNeedsDistributionRecalc(); |
| 143 shadowHost.lazyReattachIfAttached(); | 143 shadowHost.lazyReattachIfAttached(); |
| 144 | 144 |
| 145 // addShadowRoot() affects apply-author-styles. However, we know that the yo
ungest shadow root has not had any children yet. | 145 // addShadowRoot() affects apply-author-styles. However, we know that the yo
ungest shadow root has not had any children yet. |
| 146 // The youngest shadow root's apply-author-styles is default (false). So we
can just set m_applyAuthorStyles false. | 146 // The youngest shadow root's apply-author-styles is default (false). So we
can just set m_applyAuthorStyles false. |
| 147 m_applyAuthorStyles = false; | 147 m_applyAuthorStyles = false; |
| 148 | 148 |
| 149 shadowHost.didAddShadowRoot(*shadowRoot); | 149 shadowHost.didAddShadowRoot(*shadowRoot); |
| 150 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); | 150 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); |
| 151 | 151 |
| 152 return shadowRoot.get(); | 152 ASSERT(m_shadowRoots.head()); |
| 153 ASSERT(shadowRoot.get() == m_shadowRoots.head()); |
| 154 return *m_shadowRoots.head(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 void ElementShadow::removeAllShadowRoots() | 157 void ElementShadow::removeAllShadowRoots() |
| 156 { | 158 { |
| 157 // Dont protect this ref count. | 159 // Dont protect this ref count. |
| 158 Element* shadowHost = host(); | 160 Element* shadowHost = host(); |
| 159 ASSERT(shadowHost); | 161 ASSERT(shadowHost); |
| 160 | 162 |
| 161 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { | 163 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
| 162 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); | 164 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 362 |
| 361 void ElementShadow::clearDistribution() | 363 void ElementShadow::clearDistribution() |
| 362 { | 364 { |
| 363 m_nodeToInsertionPoints.clear(); | 365 m_nodeToInsertionPoints.clear(); |
| 364 | 366 |
| 365 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 367 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
| 366 root->setShadowInsertionPointOfYoungerShadowRoot(0); | 368 root->setShadowInsertionPointOfYoungerShadowRoot(0); |
| 367 } | 369 } |
| 368 | 370 |
| 369 } // namespace | 371 } // namespace |
| OLD | NEW |