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

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: Rebase + address review comments 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const KURL& existingURL = m_resource ? m_resource->url() : KURL(); 240 const KURL& existingURL = m_resource ? m_resource->url() : KURL();
231 if (url.hasFragmentIdentifier() && !equalIgnoringFragmentIdentifier( url, existingURL)) { 241 if (url.hasFragmentIdentifier() && !equalIgnoringFragmentIdentifier( url, existingURL)) {
232 FetchRequest request(ResourceRequest(url), localName()); 242 FetchRequest request(ResourceRequest(url), localName());
233 setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher())); 243 setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher()));
234 } 244 }
235 } else { 245 } else {
236 setDocumentResource(0); 246 setDocumentResource(nullptr);
237 } 247 }
238 248
239 invalidateShadowTree(); 249 invalidateShadowTree();
240 250
241 return; 251 return;
242 } 252 }
243 253
244 SVGGraphicsElement::svgAttributeChanged(attrName); 254 SVGGraphicsElement::svgAttributeChanged(attrName);
245 } 255 }
246 256
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 812
803 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance) 813 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance)
804 { 814 {
805 for (const SVGElement* element = targetInstance; element; element = Traversa l<SVGElement>::next(*element, targetInstance)) { 815 for (const SVGElement* element = targetInstance; element; element = Traversa l<SVGElement>::next(*element, targetInstance)) {
806 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti llLoading()) 816 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti llLoading())
807 return true; 817 return true;
808 } 818 }
809 return false; 819 return false;
810 } 820 }
811 821
812 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource) 822 void SVGUseElement::setDocumentResource(PassRefPtrWillBeRawPtr<DocumentResource> resource)
813 { 823 {
814 if (m_resource == resource) 824 if (m_resource == resource)
815 return; 825 return;
816 826
817 if (m_resource) 827 if (m_resource)
818 m_resource->removeClient(this); 828 m_resource->removeClient(this);
819 829
820 m_resource = resource; 830 m_resource = resource;
821 if (m_resource) 831 if (m_resource)
822 m_resource->addClient(this); 832 m_resource->addClient(this);
823 } 833 }
824 834
825 } // namespace blink 835 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | third_party/WebKit/Source/core/xml/XSLImportRule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698