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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGUseElement.cpp

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix known issues Created 4 years, 10 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) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(SVGLengthMode::Height))) 59 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(SVGLengthMode::Height)))
60 , m_haveFiredLoadEvent(false) 60 , m_haveFiredLoadEvent(false)
61 , m_needsShadowTreeRecreation(false) 61 , m_needsShadowTreeRecreation(false)
62 { 62 {
63 ASSERT(hasCustomStyleCallbacks()); 63 ASSERT(hasCustomStyleCallbacks());
64 64
65 addToPropertyMap(m_x); 65 addToPropertyMap(m_x);
66 addToPropertyMap(m_y); 66 addToPropertyMap(m_y);
67 addToPropertyMap(m_width); 67 addToPropertyMap(m_width);
68 addToPropertyMap(m_height); 68 addToPropertyMap(m_height);
69
70 #if ENABLE(OILPAN)
71 ThreadState::current()->registerPreFinalizer(this);
72 #endif
69 } 73 }
70 74
71 PassRefPtrWillBeRawPtr<SVGUseElement> SVGUseElement::create(Document& document) 75 PassRefPtrWillBeRawPtr<SVGUseElement> SVGUseElement::create(Document& document)
72 { 76 {
73 // Always build a user agent #shadow-root for SVGUseElement. 77 // Always build a user agent #shadow-root for SVGUseElement.
74 RefPtrWillBeRawPtr<SVGUseElement> use = adoptRefWillBeNoop(new SVGUseElement (document)); 78 RefPtrWillBeRawPtr<SVGUseElement> use = adoptRefWillBeNoop(new SVGUseElement (document));
75 use->ensureUserAgentShadowRoot(); 79 use->ensureUserAgentShadowRoot();
76 return use.release(); 80 return use.release();
77 } 81 }
78 82
79 SVGUseElement::~SVGUseElement() 83 SVGUseElement::~SVGUseElement()
80 { 84 {
81 setDocumentResource(0);
82 #if !ENABLE(OILPAN) 85 #if !ENABLE(OILPAN)
83 clearShadowTree(); 86 clearShadowTree();
84 cancelShadowTreeRecreation(); 87 cancelShadowTreeRecreation();
85 svgUseLoadEventSender().cancelEvent(this); 88 svgUseLoadEventSender().cancelEvent(this);
89 dispose();
86 #endif 90 #endif
87 } 91 }
88 92
93 void SVGUseElement::dispose()
94 {
95 setDocumentResource(nullptr);
96 }
97
89 DEFINE_TRACE(SVGUseElement) 98 DEFINE_TRACE(SVGUseElement)
90 { 99 {
91 visitor->trace(m_x); 100 visitor->trace(m_x);
92 visitor->trace(m_y); 101 visitor->trace(m_y);
93 visitor->trace(m_width); 102 visitor->trace(m_width);
94 visitor->trace(m_height); 103 visitor->trace(m_height);
95 visitor->trace(m_targetElementInstance); 104 visitor->trace(m_targetElementInstance);
105 visitor->trace(m_resource);
96 SVGGraphicsElement::trace(visitor); 106 SVGGraphicsElement::trace(visitor);
97 SVGURIReference::trace(visitor); 107 SVGURIReference::trace(visitor);
98 } 108 }
99 109
100 #if ENABLE(ASSERT) 110 #if ENABLE(ASSERT)
101 static inline bool isWellFormedDocument(Document* document) 111 static inline bool isWellFormedDocument(Document* document)
102 { 112 {
103 if (document->isXMLDocument()) 113 if (document->isXMLDocument())
104 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ; 114 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ;
105 return true; 115 return true;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 235
226 if (SVGURIReference::isKnownAttribute(attrName)) { 236 if (SVGURIReference::isKnownAttribute(attrName)) {
227 SVGElement::InvalidationGuard invalidationGuard(this); 237 SVGElement::InvalidationGuard invalidationGuard(this);
228 if (isStructurallyExternal()) { 238 if (isStructurallyExternal()) {
229 KURL url = document().completeURL(hrefString()); 239 KURL url = document().completeURL(hrefString());
230 if (url.hasFragmentIdentifier()) { 240 if (url.hasFragmentIdentifier()) {
231 FetchRequest request(ResourceRequest(url), localName()); 241 FetchRequest request(ResourceRequest(url), localName());
232 setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher())); 242 setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher()));
233 } 243 }
234 } else { 244 } else {
235 setDocumentResource(0); 245 setDocumentResource(nullptr);
236 } 246 }
237 247
238 invalidateShadowTree(); 248 invalidateShadowTree();
239 249
240 return; 250 return;
241 } 251 }
242 252
243 SVGGraphicsElement::svgAttributeChanged(attrName); 253 SVGGraphicsElement::svgAttributeChanged(attrName);
244 } 254 }
245 255
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 811
802 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance) 812 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance)
803 { 813 {
804 for (const SVGElement* element = targetInstance; element; element = Traversa l<SVGElement>::next(*element, targetInstance)) { 814 for (const SVGElement* element = targetInstance; element; element = Traversa l<SVGElement>::next(*element, targetInstance)) {
805 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti llLoading()) 815 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti llLoading())
806 return true; 816 return true;
807 } 817 }
808 return false; 818 return false;
809 } 819 }
810 820
811 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource) 821 void SVGUseElement::setDocumentResource(PassRefPtrWillBeRawPtr<DocumentResource> resource)
812 { 822 {
813 if (m_resource == resource) 823 if (m_resource == resource)
814 return; 824 return;
815 825
816 if (m_resource) 826 if (m_resource)
817 m_resource->removeClient(this); 827 m_resource->removeClient(this);
818 828
819 m_resource = resource; 829 m_resource = resource;
820 if (m_resource) 830 if (m_resource)
821 m_resource->addClient(this); 831 m_resource->addClient(this);
822 } 832 }
823 833
824 } // namespace blink 834 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698