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

Side by Side Diff: Source/core/svg/SVGElementInstance.cpp

Issue 262093006: Oilpan: Make the Node hierarchy RefCountedGarbageCollected instead of TreeShared. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments. 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), selectstart); 79 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), selectstart);
80 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), submit); 80 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), submit);
81 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), unload); 81 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(SVGElementInstance, correspondingElem ent(), unload);
82 82
83 PassRefPtr<SVGElementInstance> SVGElementInstance::create(SVGUseElement* corresp ondingUseElement, SVGUseElement* directUseElement, PassRefPtr<SVGElement> origin alElement) 83 PassRefPtr<SVGElementInstance> SVGElementInstance::create(SVGUseElement* corresp ondingUseElement, SVGUseElement* directUseElement, PassRefPtr<SVGElement> origin alElement)
84 { 84 {
85 return adoptRef(new SVGElementInstance(correspondingUseElement, directUseEle ment, originalElement)); 85 return adoptRef(new SVGElementInstance(correspondingUseElement, directUseEle ment, originalElement));
86 } 86 }
87 87
88 SVGElementInstance::SVGElementInstance(SVGUseElement* correspondingUseElement, S VGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement) 88 SVGElementInstance::SVGElementInstance(SVGUseElement* correspondingUseElement, S VGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement)
89 : m_parentInstance(0) 89 : m_parentInstance(nullptr)
90 , m_correspondingUseElement(correspondingUseElement) 90 , m_correspondingUseElement(correspondingUseElement)
91 , m_directUseElement(directUseElement) 91 , m_directUseElement(directUseElement)
92 , m_element(originalElement) 92 , m_element(originalElement.get()) // FIXME: Oilpan: Remove the .get() call.
93 , m_previousSibling(0) 93 , m_shadowTreeElement(nullptr)
94 , m_nextSibling(0) 94 , m_previousSibling(nullptr)
95 , m_firstChild(0) 95 , m_nextSibling(nullptr)
96 , m_lastChild(0) 96 , m_firstChild(nullptr)
97 , m_lastChild(nullptr)
97 { 98 {
98 ASSERT(m_correspondingUseElement); 99 ASSERT(m_correspondingUseElement);
99 ASSERT(m_element); 100 ASSERT(m_element);
100 ScriptWrappable::init(this); 101 ScriptWrappable::init(this);
101 102
102 #ifndef NDEBUG 103 #ifndef NDEBUG
103 instanceCounter.increment(); 104 instanceCounter.increment();
104 #endif 105 #endif
105 } 106 }
106 107
107 SVGElementInstance::~SVGElementInstance() 108 SVGElementInstance::~SVGElementInstance()
108 { 109 {
109 // Call detach because we may be deleted directly if we are a child of a det ached instance.
110 detach();
111
112 #ifndef NDEBUG 110 #ifndef NDEBUG
113 instanceCounter.decrement(); 111 instanceCounter.decrement();
114 #endif 112 #endif
115 113
114 #if !ENABLE(OILPAN)
115 // Call detach because we may be deleted directly if we are a child of a det ached instance.
116 detach();
116 m_element = nullptr; 117 m_element = nullptr;
118 #endif
117 } 119 }
118 120
119 // It's important not to inline removedLastRef, because we don't want to inline the code to 121 // It's important not to inline removedLastRef, because we don't want to inline the code to
120 // delete an SVGElementInstance at each deref call site. 122 // delete an SVGElementInstance at each deref call site.
121 void SVGElementInstance::removedLastRef() 123 void SVGElementInstance::removedLastRef()
122 { 124 {
123 #if !ENABLE(OILPAN) 125 #if !ENABLE(OILPAN)
124 #if SECURITY_ASSERT_ENABLED 126 #if SECURITY_ASSERT_ENABLED
125 m_deletionHasBegun = true; 127 m_deletionHasBegun = true;
126 #endif 128 #endif
(...skipping 12 matching lines...) Expand all
139 // Deregister as instance for passed element, if we haven't already. 141 // Deregister as instance for passed element, if we haven't already.
140 if (m_element->instancesForElement().contains(shadowTreeElement())) 142 if (m_element->instancesForElement().contains(shadowTreeElement()))
141 m_element->removeInstanceMapping(this); 143 m_element->removeInstanceMapping(this);
142 // DO NOT clear ref to m_element because JavaScriptCore uses it for garbage collection 144 // DO NOT clear ref to m_element because JavaScriptCore uses it for garbage collection
143 145
144 m_shadowTreeElement = nullptr; 146 m_shadowTreeElement = nullptr;
145 147
146 m_directUseElement = 0; 148 m_directUseElement = 0;
147 m_correspondingUseElement = 0; 149 m_correspondingUseElement = 0;
148 150
151 #if !ENABLE(OILPAN)
149 removeDetachedChildrenInContainer<SVGElementInstance, SVGElementInstance>(*t his); 152 removeDetachedChildrenInContainer<SVGElementInstance, SVGElementInstance>(*t his);
153 #endif
150 } 154 }
151 155
152 void SVGElementInstance::setShadowTreeElement(SVGElement* element) 156 void SVGElementInstance::setShadowTreeElement(SVGElement* element)
153 { 157 {
154 ASSERT(element); 158 ASSERT(element);
155 m_shadowTreeElement = element; 159 m_shadowTreeElement = element;
156 // Register as instance for passed element. 160 // Register as instance for passed element.
157 m_element->mapInstanceToElement(this); 161 m_element->mapInstanceToElement(this);
158 162
159 } 163 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 244 }
241 245
242 EventTargetData& SVGElementInstance::ensureEventTargetData() 246 EventTargetData& SVGElementInstance::ensureEventTargetData()
243 { 247 {
244 // EventTarget would use these methods if we were actually using its add/rem oveEventListener logic. 248 // EventTarget would use these methods if we were actually using its add/rem oveEventListener logic.
245 // As we're forwarding those calls to the correspondingElement(), no one sho uld ever call this function. 249 // As we're forwarding those calls to the correspondingElement(), no one sho uld ever call this function.
246 ASSERT_NOT_REACHED(); 250 ASSERT_NOT_REACHED();
247 return *eventTargetData(); 251 return *eventTargetData();
248 } 252 }
249 253
254 void SVGElementInstance::trace(Visitor* visitor)
255 {
256 visitor->trace(m_parentInstance);
257 visitor->trace(m_element);
258 visitor->trace(m_shadowTreeElement);
259 visitor->trace(m_previousSibling);
260 visitor->trace(m_nextSibling);
261 visitor->trace(m_firstChild);
262 visitor->trace(m_lastChild);
263 }
264
250 SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* tar getElement) 265 SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* tar getElement)
251 : m_targetElement(targetElement) 266 : m_targetElement(targetElement)
252 { 267 {
253 if (m_targetElement) 268 if (m_targetElement)
254 m_targetElement->setInstanceUpdatesBlocked(true); 269 m_targetElement->setInstanceUpdatesBlocked(true);
255 } 270 }
256 271
257 SVGElementInstance::InstanceUpdateBlocker::~InstanceUpdateBlocker() 272 SVGElementInstance::InstanceUpdateBlocker::~InstanceUpdateBlocker()
258 { 273 {
259 if (m_targetElement) 274 if (m_targetElement)
260 m_targetElement->setInstanceUpdatesBlocked(false); 275 m_targetElement->setInstanceUpdatesBlocked(false);
261 } 276 }
262 277
263 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698