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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourceContainer.cpp

Issue 181713003: Have Document::accessSVGExtensions() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 #include "core/rendering/RenderLayer.h" 25 #include "core/rendering/RenderLayer.h"
26 #include "core/rendering/RenderView.h" 26 #include "core/rendering/RenderView.h"
27 #include "core/rendering/svg/SVGRenderingContext.h" 27 #include "core/rendering/svg/SVGRenderingContext.h"
28 #include "core/rendering/svg/SVGResourcesCache.h" 28 #include "core/rendering/svg/SVGResourcesCache.h"
29 #include "core/svg/SVGGraphicsElement.h" 29 #include "core/svg/SVGGraphicsElement.h"
30 30
31 #include "wtf/TemporaryChange.h" 31 #include "wtf/TemporaryChange.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 static inline SVGDocumentExtensions* svgExtensionsFromElement(SVGElement* elemen t) 35 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen t)
36 { 36 {
37 ASSERT(element); 37 ASSERT(element);
38 return element->document().accessSVGExtensions(); 38 return element->document().accessSVGExtensions();
39 } 39 }
40 40
41 RenderSVGResourceContainer::RenderSVGResourceContainer(SVGElement* node) 41 RenderSVGResourceContainer::RenderSVGResourceContainer(SVGElement* node)
42 : RenderSVGHiddenContainer(node) 42 : RenderSVGHiddenContainer(node)
43 , m_isInLayout(false) 43 , m_isInLayout(false)
44 , m_id(node->getIdAttribute()) 44 , m_id(node->getIdAttribute())
45 , m_invalidationMask(0) 45 , m_invalidationMask(0)
46 , m_registered(false) 46 , m_registered(false)
47 , m_isInvalidating(false) 47 , m_isInvalidating(false)
48 { 48 {
49 } 49 }
50 50
51 RenderSVGResourceContainer::~RenderSVGResourceContainer() 51 RenderSVGResourceContainer::~RenderSVGResourceContainer()
52 { 52 {
53 if (m_registered) 53 if (m_registered)
54 svgExtensionsFromElement(element())->removeResource(m_id); 54 svgExtensionsFromElement(element()).removeResource(m_id);
55 } 55 }
56 56
57 void RenderSVGResourceContainer::layout() 57 void RenderSVGResourceContainer::layout()
58 { 58 {
59 // FIXME: Investigate a way to detect and break resource layout dependency c ycles early. 59 // FIXME: Investigate a way to detect and break resource layout dependency c ycles early.
60 // Then we can remove this method altogether, and fall back onto RenderSVGHi ddenContainer::layout(). 60 // Then we can remove this method altogether, and fall back onto RenderSVGHi ddenContainer::layout().
61 ASSERT(needsLayout()); 61 ASSERT(needsLayout());
62 if (m_isInLayout) 62 if (m_isInLayout)
63 return; 63 return;
64 64
(...skipping 20 matching lines...) Expand all
85 registerResource(); 85 registerResource();
86 } 86 }
87 } 87 }
88 88
89 void RenderSVGResourceContainer::idChanged() 89 void RenderSVGResourceContainer::idChanged()
90 { 90 {
91 // Invalidate all our current clients. 91 // Invalidate all our current clients.
92 removeAllClientsFromCache(); 92 removeAllClientsFromCache();
93 93
94 // Remove old id, that is guaranteed to be present in cache. 94 // Remove old id, that is guaranteed to be present in cache.
95 SVGDocumentExtensions* extensions = svgExtensionsFromElement(element()); 95 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element());
96 extensions->removeResource(m_id); 96 extensions.removeResource(m_id);
97 m_id = element()->getIdAttribute(); 97 m_id = element()->getIdAttribute();
98 98
99 registerResource(); 99 registerResource();
100 } 100 }
101 101
102 void RenderSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode mode) 102 void RenderSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode mode)
103 { 103 {
104 if ((m_clients.isEmpty() && m_clientLayers.isEmpty()) || m_isInvalidating) 104 if ((m_clients.isEmpty() && m_clientLayers.isEmpty()) || m_isInvalidating)
105 return; 105 return;
106 106
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return; 203 return;
204 204
205 setNeedsLayout(MarkContainingBlockChain, layoutScope); 205 setNeedsLayout(MarkContainingBlockChain, layoutScope);
206 206
207 if (everHadLayout()) 207 if (everHadLayout())
208 removeAllClientsFromCache(); 208 removeAllClientsFromCache();
209 } 209 }
210 210
211 void RenderSVGResourceContainer::registerResource() 211 void RenderSVGResourceContainer::registerResource()
212 { 212 {
213 SVGDocumentExtensions* extensions = svgExtensionsFromElement(element()); 213 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element());
214 if (!extensions->hasPendingResource(m_id)) { 214 if (!extensions.hasPendingResource(m_id)) {
215 extensions->addResource(m_id, this); 215 extensions.addResource(m_id, this);
216 return; 216 return;
217 } 217 }
218 218
219 OwnPtr<SVGDocumentExtensions::SVGPendingElements> clients(extensions->remove PendingResource(m_id)); 219 OwnPtr<SVGDocumentExtensions::SVGPendingElements> clients(extensions.removeP endingResource(m_id));
220 220
221 // Cache us with the new id. 221 // Cache us with the new id.
222 extensions->addResource(m_id, this); 222 extensions.addResource(m_id, this);
223 223
224 // Update cached resources of pending clients. 224 // Update cached resources of pending clients.
225 const SVGDocumentExtensions::SVGPendingElements::const_iterator end = client s->end(); 225 const SVGDocumentExtensions::SVGPendingElements::const_iterator end = client s->end();
226 for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients- >begin(); it != end; ++it) { 226 for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients- >begin(); it != end; ++it) {
227 ASSERT((*it)->hasPendingResources()); 227 ASSERT((*it)->hasPendingResources());
228 extensions->clearHasPendingResourcesIfPossible(*it); 228 extensions.clearHasPendingResourcesIfPossible(*it);
229 RenderObject* renderer = (*it)->renderer(); 229 RenderObject* renderer = (*it)->renderer();
230 if (!renderer) 230 if (!renderer)
231 continue; 231 continue;
232 SVGResourcesCache::clientStyleChanged(renderer, StyleDifferenceLayout, r enderer->style()); 232 SVGResourcesCache::clientStyleChanged(renderer, StyleDifferenceLayout, r enderer->style());
233 renderer->setNeedsLayout(); 233 renderer->setNeedsLayout();
234 } 234 }
235 } 235 }
236 236
237 bool RenderSVGResourceContainer::shouldTransformOnTextPainting(RenderObject* obj ect, AffineTransform& resourceTransform) 237 bool RenderSVGResourceContainer::shouldTransformOnTextPainting(RenderObject* obj ect, AffineTransform& resourceTransform)
238 { 238 {
(...skipping 18 matching lines...) Expand all
257 if (!object->isSVGShape()) 257 if (!object->isSVGShape())
258 return resourceTransform; 258 return resourceTransform;
259 259
260 SVGGraphicsElement* element = toSVGGraphicsElement(object->node()); 260 SVGGraphicsElement* element = toSVGGraphicsElement(object->node());
261 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall owStyleUpdate); 261 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall owStyleUpdate);
262 transform *= resourceTransform; 262 transform *= resourceTransform;
263 return transform; 263 return transform;
264 } 264 }
265 265
266 } 266 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGResourceContainer.h ('k') | Source/core/rendering/svg/SVGResources.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698