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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 String target; 144 String target;
145 if (element->hasTagName(SVGNames::patternTag)) 145 if (element->hasTagName(SVGNames::patternTag))
146 target = toSVGPatternElement(element)->hrefCurrentValue(); 146 target = toSVGPatternElement(element)->hrefCurrentValue();
147 else if (element->hasTagName(SVGNames::linearGradientTag) || element->hasTag Name(SVGNames::radialGradientTag)) 147 else if (element->hasTagName(SVGNames::linearGradientTag) || element->hasTag Name(SVGNames::radialGradientTag))
148 target = toSVGGradientElement(element)->hrefCurrentValue(); 148 target = toSVGGradientElement(element)->hrefCurrentValue();
149 else if (element->hasTagName(SVGNames::filterTag)) 149 else if (element->hasTagName(SVGNames::filterTag))
150 target = toSVGFilterElement(element)->hrefCurrentValue(); 150 target = toSVGFilterElement(element)->hrefCurrentValue();
151 else 151 else
152 ASSERT_NOT_REACHED(); 152 ASSERT_NOT_REACHED();
153 153
154 return SVGURIReference::fragmentIdentifierFromIRIString(target, element->doc ument()); 154 return SVGURIReference::fragmentIdentifierFromIRIString(target, &element->do cument());
155 } 155 }
156 156
157 static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, Atom icString& id, bool& hasPendingResource) 157 static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, Atom icString& id, bool& hasPendingResource)
158 { 158 {
159 if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_P AINTTYPE_URI_RGBCOLOR) 159 if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_P AINTTYPE_URI_RGBCOLOR)
160 return 0; 160 return 0;
161 161
162 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, document); 162 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, document);
163 RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(do cument, id); 163 RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(do cument, id);
164 if (!container) { 164 if (!container) {
(...skipping 20 matching lines...) Expand all
185 ASSERT(style); 185 ASSERT(style);
186 186
187 Node* node = object->node(); 187 Node* node = object->node();
188 ASSERT(node); 188 ASSERT(node);
189 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); 189 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement());
190 190
191 SVGElement* element = toSVGElement(node); 191 SVGElement* element = toSVGElement(node);
192 if (!element) 192 if (!element)
193 return false; 193 return false;
194 194
195 Document* document = object->document(); 195 Document& document = object->document();
196 ASSERT(document);
197 196
198 SVGDocumentExtensions* extensions = document->accessSVGExtensions(); 197 SVGDocumentExtensions* extensions = document.accessSVGExtensions();
199 ASSERT(extensions); 198 ASSERT(extensions);
200 199
201 const AtomicString& tagName = element->localName(); 200 const AtomicString& tagName = element->localName();
202 if (tagName.isNull()) 201 if (tagName.isNull())
203 return false; 202 return false;
204 203
205 bool foundResources = false; 204 bool foundResources = false;
206 if (clipperFilterMaskerTags().contains(tagName)) { 205 if (clipperFilterMaskerTags().contains(tagName)) {
207 if (style->hasClipper()) { 206 if (style->hasClipper()) {
208 AtomicString id(style->clipperResource()); 207 AtomicString id(style->clipperResource());
209 if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(do cument, id))) 208 if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(&d ocument, id)))
210 foundResources = true; 209 foundResources = true;
211 else 210 else
212 registerPendingResource(extensions, id, element); 211 registerPendingResource(extensions, id, element);
213 } 212 }
214 213
215 if (style->hasFilter()) { 214 if (style->hasFilter()) {
216 AtomicString id(style->filterResource()); 215 AtomicString id(style->filterResource());
217 if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(docu ment, id))) 216 if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(&doc ument, id)))
218 foundResources = true; 217 foundResources = true;
219 else 218 else
220 registerPendingResource(extensions, id, element); 219 registerPendingResource(extensions, id, element);
221 } 220 }
222 221
223 if (style->hasMasker()) { 222 if (style->hasMasker()) {
224 AtomicString id(style->maskerResource()); 223 AtomicString id(style->maskerResource());
225 if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(docu ment, id))) 224 if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(&doc ument, id)))
226 foundResources = true; 225 foundResources = true;
227 else 226 else
228 registerPendingResource(extensions, id, element); 227 registerPendingResource(extensions, id, element);
229 } 228 }
230 } 229 }
231 230
232 if (markerTags().contains(tagName) && style->hasMarkers()) { 231 if (markerTags().contains(tagName) && style->hasMarkers()) {
233 AtomicString markerStartId(style->markerStartResource()); 232 AtomicString markerStartId(style->markerStartResource());
234 if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(doc ument, markerStartId))) 233 if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(&do cument, markerStartId)))
235 foundResources = true; 234 foundResources = true;
236 else 235 else
237 registerPendingResource(extensions, markerStartId, element); 236 registerPendingResource(extensions, markerStartId, element);
238 237
239 AtomicString markerMidId(style->markerMidResource()); 238 AtomicString markerMidId(style->markerMidResource());
240 if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(docum ent, markerMidId))) 239 if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(&docu ment, markerMidId)))
241 foundResources = true; 240 foundResources = true;
242 else 241 else
243 registerPendingResource(extensions, markerMidId, element); 242 registerPendingResource(extensions, markerMidId, element);
244 243
245 AtomicString markerEndId(style->markerEndResource()); 244 AtomicString markerEndId(style->markerEndResource());
246 if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(docum ent, markerEndId))) 245 if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(&docu ment, markerEndId)))
247 foundResources = true; 246 foundResources = true;
248 else 247 else
249 registerPendingResource(extensions, markerEndId, element); 248 registerPendingResource(extensions, markerEndId, element);
250 } 249 }
251 250
252 if (fillAndStrokeTags().contains(tagName)) { 251 if (fillAndStrokeTags().contains(tagName)) {
253 if (style->hasFill()) { 252 if (style->hasFill()) {
254 bool hasPendingResource = false; 253 bool hasPendingResource = false;
255 AtomicString id; 254 AtomicString id;
256 if (setFill(paintingResourceFromSVGPaint(document, style->fillPaintT ype(), style->fillPaintUri(), id, hasPendingResource))) 255 if (setFill(paintingResourceFromSVGPaint(&document, style->fillPaint Type(), style->fillPaintUri(), id, hasPendingResource)))
257 foundResources = true; 256 foundResources = true;
258 else if (hasPendingResource) 257 else if (hasPendingResource)
259 registerPendingResource(extensions, id, element); 258 registerPendingResource(extensions, id, element);
260 } 259 }
261 260
262 if (style->hasStroke()) { 261 if (style->hasStroke()) {
263 bool hasPendingResource = false; 262 bool hasPendingResource = false;
264 AtomicString id; 263 AtomicString id;
265 if (setStroke(paintingResourceFromSVGPaint(document, style->strokePa intType(), style->strokePaintUri(), id, hasPendingResource))) 264 if (setStroke(paintingResourceFromSVGPaint(&document, style->strokeP aintType(), style->strokePaintUri(), id, hasPendingResource)))
266 foundResources = true; 265 foundResources = true;
267 else if (hasPendingResource) 266 else if (hasPendingResource)
268 registerPendingResource(extensions, id, element); 267 registerPendingResource(extensions, id, element);
269 } 268 }
270 } 269 }
271 270
272 if (chainableResourceTags().contains(tagName)) { 271 if (chainableResourceTags().contains(tagName)) {
273 AtomicString id(targetReferenceFromResource(element)); 272 AtomicString id(targetReferenceFromResource(element));
274 if (setLinkedResource(getRenderSVGResourceContainerById(document, id))) 273 if (setLinkedResource(getRenderSVGResourceContainerById(&document, id)))
275 foundResources = true; 274 foundResources = true;
276 else 275 else
277 registerPendingResource(extensions, id, element); 276 registerPendingResource(extensions, id, element);
278 } 277 }
279 278
280 return foundResources; 279 return foundResources;
281 } 280 }
282 281
283 void SVGResources::removeClientFromCache(RenderObject* object, bool markForInval idation) const 282 void SVGResources::removeClientFromCache(RenderObject* object, bool markForInval idation) const
284 { 283 {
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (RenderSVGResourceContainer* stroke = m_fillStrokeData->stroke) 654 if (RenderSVGResourceContainer* stroke = m_fillStrokeData->stroke)
656 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke-> node()); 655 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke-> node());
657 } 656 }
658 657
659 if (m_linkedResource) 658 if (m_linkedResource)
660 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_ linkedResource->node()); 659 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_ linkedResource->node());
661 } 660 }
662 #endif 661 #endif
663 662
664 } 663 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGRenderingContext.cpp ('k') | Source/core/rendering/svg/SVGResourcesCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698