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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 ElementShadow::~ElementShadow() | 143 ElementShadow::~ElementShadow() |
144 { | 144 { |
145 } | 145 } |
146 | 146 |
147 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRootType typ
e) | 147 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRootType typ
e) |
148 { | 148 { |
149 EventDispatchForbiddenScope assertNoEventDispatch; | 149 EventDispatchForbiddenScope assertNoEventDispatch; |
150 ScriptForbiddenScope forbidScript; | 150 ScriptForbiddenScope forbidScript; |
151 | 151 |
152 if (type == ShadowRootType::V0) { | 152 if (type == ShadowRootType::V0 && !m_shadowRoots.isEmpty()) { |
153 if (m_shadowRoots.isEmpty()) { | 153 DCHECK_NE(ShadowRootType::UserAgent, m_shadowRoots.head()->type()); |
154 shadowHost.willAddFirstAuthorShadowRoot(); | 154 Deprecation::countDeprecation(shadowHost.document(), UseCounter::Element
CreateShadowRootMultiple); |
155 } else if (m_shadowRoots.head()->type() == ShadowRootType::UserAgent) { | |
156 shadowHost.willAddFirstAuthorShadowRoot(); | |
157 Deprecation::countDeprecation(shadowHost.document(), UseCounter::Ele
mentCreateShadowRootMultipleWithUserAgentShadowRoot); | |
158 } else { | |
159 Deprecation::countDeprecation(shadowHost.document(), UseCounter::Ele
mentCreateShadowRootMultiple); | |
160 } | |
161 } else if (type == ShadowRootType::Open || type == ShadowRootType::Closed) { | |
162 shadowHost.willAddFirstAuthorShadowRoot(); | |
163 } | 155 } |
164 | 156 |
165 for (ShadowRoot* root = m_shadowRoots.head(); root; root = root->olderShadow
Root()) | 157 for (ShadowRoot* root = m_shadowRoots.head(); root; root = root->olderShadow
Root()) |
166 root->lazyReattachIfAttached(); | 158 root->lazyReattachIfAttached(); |
167 | 159 |
168 ShadowRoot* shadowRoot = ShadowRoot::create(shadowHost.document(), type); | 160 ShadowRoot* shadowRoot = ShadowRoot::create(shadowHost.document(), type); |
169 shadowRoot->setParentOrShadowHostNode(&shadowHost); | 161 shadowRoot->setParentOrShadowHostNode(&shadowHost); |
170 shadowRoot->setParentTreeScope(shadowHost.treeScope()); | 162 shadowRoot->setParentTreeScope(shadowHost.treeScope()); |
171 m_shadowRoots.push(shadowRoot); | 163 m_shadowRoots.push(shadowRoot); |
172 setNeedsDistributionRecalc(); | 164 setNeedsDistributionRecalc(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 { | 354 { |
363 visitor->trace(m_nodeToInsertionPoints); | 355 visitor->trace(m_nodeToInsertionPoints); |
364 visitor->trace(m_selectFeatures); | 356 visitor->trace(m_selectFeatures); |
365 // Shadow roots are linked with previous and next pointers which are traced. | 357 // Shadow roots are linked with previous and next pointers which are traced. |
366 // It is therefore enough to trace one of the shadow roots here and the | 358 // It is therefore enough to trace one of the shadow roots here and the |
367 // rest will be traced from there. | 359 // rest will be traced from there. |
368 visitor->trace(m_shadowRoots.head()); | 360 visitor->trace(m_shadowRoots.head()); |
369 } | 361 } |
370 | 362 |
371 } // namespace blink | 363 } // namespace blink |
OLD | NEW |