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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 ElementShadow::~ElementShadow() | 136 ElementShadow::~ElementShadow() |
137 { | 137 { |
138 #if !ENABLE(OILPAN) | 138 #if !ENABLE(OILPAN) |
139 removeDetachedShadowRoots(); | 139 removeDetachedShadowRoots(); |
140 #endif | 140 #endif |
141 } | 141 } |
142 | 142 |
143 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow
RootType type) | 143 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow
RootType type) |
144 { | 144 { |
145 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.document(), ty
pe); | 145 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.do
cument(), type); |
146 | 146 |
147 if (type == ShadowRoot::AuthorShadowRoot && (!youngestShadowRoot() || younge
stShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot)) | 147 if (type == ShadowRoot::AuthorShadowRoot && (!youngestShadowRoot() || younge
stShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot)) |
148 shadowHost.willAddFirstAuthorShadowRoot(); | 148 shadowHost.willAddFirstAuthorShadowRoot(); |
149 | 149 |
150 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 150 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
151 root->lazyReattachIfAttached(); | 151 root->lazyReattachIfAttached(); |
152 | 152 |
153 shadowRoot->setParentOrShadowHostNode(&shadowHost); | 153 shadowRoot->setParentOrShadowHostNode(&shadowHost); |
154 shadowRoot->setParentTreeScope(shadowHost.treeScope()); | 154 shadowRoot->setParentTreeScope(shadowHost.treeScope()); |
155 m_shadowRoots.push(shadowRoot.get()); | 155 m_shadowRoots.push(shadowRoot.get()); |
156 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); | 156 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); |
157 setNeedsDistributionRecalc(); | 157 setNeedsDistributionRecalc(); |
158 | 158 |
159 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); | 159 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); |
160 | 160 |
161 ASSERT(m_shadowRoots.head()); | 161 ASSERT(m_shadowRoots.head()); |
162 ASSERT(shadowRoot.get() == m_shadowRoots.head()); | 162 ASSERT(shadowRoot.get() == m_shadowRoots.head()); |
163 return *m_shadowRoots.head(); | 163 return *m_shadowRoots.head(); |
164 } | 164 } |
165 | 165 |
166 #if !ENABLE(OILPAN) | 166 #if !ENABLE(OILPAN) |
167 void ElementShadow::removeDetachedShadowRoots() | 167 void ElementShadow::removeDetachedShadowRoots() |
168 { | 168 { |
169 // Dont protect this ref count. | 169 // Dont protect this ref count. |
170 Element* shadowHost = host(); | 170 Element* shadowHost = host(); |
171 ASSERT(shadowHost); | 171 ASSERT(shadowHost); |
172 | 172 |
173 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { | 173 while (RefPtrWillBeRawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
174 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); | 174 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); |
175 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); | 175 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); |
176 m_shadowRoots.removeHead(); | 176 m_shadowRoots.removeHead(); |
177 oldRoot->setParentOrShadowHostNode(0); | 177 oldRoot->setParentOrShadowHostNode(0); |
178 oldRoot->setParentTreeScope(shadowHost->document()); | 178 oldRoot->setParentTreeScope(shadowHost->document()); |
179 oldRoot->setPrev(0); | 179 oldRoot->setPrev(0); |
180 oldRoot->setNext(0); | 180 oldRoot->setNext(0); |
181 } | 181 } |
182 } | 182 } |
183 #endif | 183 #endif |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 void ElementShadow::trace(Visitor* visitor) | 356 void ElementShadow::trace(Visitor* visitor) |
357 { | 357 { |
358 // Shadow roots are linked with previous and next pointers which are traced. | 358 // 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 | 359 // It is therefore enough to trace one of the shadow roots here and the |
360 // rest will be traced from there. | 360 // rest will be traced from there. |
361 visitor->trace(m_shadowRoots.head()); | 361 visitor->trace(m_shadowRoots.head()); |
362 } | 362 } |
363 | 363 |
364 } // namespace | 364 } // namespace |
OLD | NEW |