Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/core/dom/shadow/ElementShadow.cpp

Issue 289273002: Oilpan: make DocumentFragment a heap allocated object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaks to avoid conflicts with ongoing ShadowRoot CLs Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 ElementShadow::~ElementShadow() 137 ElementShadow::~ElementShadow()
138 { 138 {
139 #if !ENABLE(OILPAN) 139 #if !ENABLE(OILPAN)
140 removeDetachedShadowRoots(); 140 removeDetachedShadowRoots();
141 #endif 141 #endif
142 } 142 }
143 143
144 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow RootType type) 144 ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow RootType type)
145 { 145 {
146 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.document(), ty pe); 146 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.do cument(), type);
147 147
148 if (type == ShadowRoot::AuthorShadowRoot && (!youngestShadowRoot() || younge stShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot)) 148 if (type == ShadowRoot::AuthorShadowRoot && (!youngestShadowRoot() || younge stShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot))
149 shadowHost.willAddFirstAuthorShadowRoot(); 149 shadowHost.willAddFirstAuthorShadowRoot();
150 150
151 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) 151 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root())
152 root->lazyReattachIfAttached(); 152 root->lazyReattachIfAttached();
153 153
154 shadowRoot->setParentOrShadowHostNode(&shadowHost); 154 shadowRoot->setParentOrShadowHostNode(&shadowHost);
155 shadowRoot->setParentTreeScope(shadowHost.treeScope()); 155 shadowRoot->setParentTreeScope(shadowHost.treeScope());
156 m_shadowRoots.push(shadowRoot.get()); 156 m_shadowRoots.push(shadowRoot.get());
157 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); 157 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot);
158 setNeedsDistributionRecalc(); 158 setNeedsDistributionRecalc();
159 159
160 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); 160 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get());
161 161
162 ASSERT(m_shadowRoots.head()); 162 ASSERT(m_shadowRoots.head());
163 ASSERT(shadowRoot.get() == m_shadowRoots.head()); 163 ASSERT(shadowRoot.get() == m_shadowRoots.head());
164 return *m_shadowRoots.head(); 164 return *m_shadowRoots.head();
165 } 165 }
166 166
167 #if !ENABLE(OILPAN) 167 #if !ENABLE(OILPAN)
168 void ElementShadow::removeDetachedShadowRoots() 168 void ElementShadow::removeDetachedShadowRoots()
169 { 169 {
170 // Dont protect this ref count. 170 // Dont protect this ref count.
171 Element* shadowHost = host(); 171 Element* shadowHost = host();
172 ASSERT(shadowHost); 172 ASSERT(shadowHost);
173 173
174 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { 174 while (RefPtrWillBeRawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) {
175 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); 175 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get());
176 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); 176 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get());
177 m_shadowRoots.removeHead(); 177 m_shadowRoots.removeHead();
178 oldRoot->setParentOrShadowHostNode(0); 178 oldRoot->setParentOrShadowHostNode(0);
179 oldRoot->setParentTreeScope(shadowHost->document()); 179 oldRoot->setParentTreeScope(shadowHost->document());
180 oldRoot->setPrev(0); 180 oldRoot->setPrev(0);
181 oldRoot->setNext(0); 181 oldRoot->setNext(0);
182 } 182 }
183 } 183 }
184 #endif 184 #endif
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 void ElementShadow::trace(Visitor* visitor) 357 void ElementShadow::trace(Visitor* visitor)
358 { 358 {
359 visitor->trace(m_nodeToInsertionPoints); 359 visitor->trace(m_nodeToInsertionPoints);
360 // 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.
361 // 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
362 // rest will be traced from there. 362 // rest will be traced from there.
363 visitor->trace(m_shadowRoots.head()); 363 visitor->trace(m_shadowRoots.head());
364 } 364 }
365 365
366 } // namespace 366 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698