OLD | NEW |
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 case SVG_PAINTTYPE_URI: | 131 case SVG_PAINTTYPE_URI: |
132 return true; | 132 return true; |
133 default: | 133 default: |
134 break; | 134 break; |
135 } | 135 } |
136 return false; | 136 return false; |
137 } | 137 } |
138 | 138 |
139 static inline LayoutSVGResourcePaintServer* paintingResourceFromSVGPaint( | 139 static inline LayoutSVGResourcePaintServer* paintingResourceFromSVGPaint( |
140 TreeScope& treeScope, | 140 TreeScope& treeScope, |
141 const SVGPaintType& paintType, | |
142 const String& paintUri, | 141 const String& paintUri, |
143 AtomicString& id, | 142 AtomicString& id) { |
144 bool& hasPendingResource) { | |
145 if (!svgPaintTypeHasURL(paintType)) | |
146 return nullptr; | |
147 | |
148 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); | 143 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); |
149 LayoutSVGResourceContainer* container = | 144 LayoutSVGResourceContainer* container = |
150 treeScope.ensureSVGTreeScopedResources().resourceById(id); | 145 treeScope.ensureSVGTreeScopedResources().resourceById(id); |
151 if (!container) { | 146 if (!container || !container->isSVGPaintServer()) |
152 hasPendingResource = true; | |
153 return nullptr; | 147 return nullptr; |
154 } | |
155 | |
156 if (!container->isSVGPaintServer()) | |
157 return nullptr; | |
158 | |
159 return toLayoutSVGResourcePaintServer(container); | 148 return toLayoutSVGResourcePaintServer(container); |
160 } | 149 } |
161 | 150 |
162 bool SVGResources::hasResourceData() const { | 151 bool SVGResources::hasResourceData() const { |
163 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || | 152 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || |
164 m_linkedResource; | 153 m_linkedResource; |
165 } | 154 } |
166 | 155 |
167 static inline SVGResources& ensureResources( | 156 static inline SVGResources& ensureResources( |
168 std::unique_ptr<SVGResources>& resources) { | 157 std::unique_ptr<SVGResources>& resources) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 treeScopeResources.addPendingResource(markerMidId, element); | 237 treeScopeResources.addPendingResource(markerMidId, element); |
249 | 238 |
250 const AtomicString& markerEndId = style.markerEndResource(); | 239 const AtomicString& markerEndId = style.markerEndResource(); |
251 if (!ensureResources(resources).setMarkerEnd( | 240 if (!ensureResources(resources).setMarkerEnd( |
252 getLayoutSVGResourceById<LayoutSVGResourceMarker>( | 241 getLayoutSVGResourceById<LayoutSVGResourceMarker>( |
253 treeScopeResources, markerEndId))) | 242 treeScopeResources, markerEndId))) |
254 treeScopeResources.addPendingResource(markerEndId, element); | 243 treeScopeResources.addPendingResource(markerEndId, element); |
255 } | 244 } |
256 | 245 |
257 if (fillAndStrokeTags().contains(tagName)) { | 246 if (fillAndStrokeTags().contains(tagName)) { |
258 if (style.hasFill()) { | 247 if (style.hasFill() && svgPaintTypeHasURL(style.fillPaintType())) { |
259 bool hasPendingResource = false; | |
260 AtomicString id; | 248 AtomicString id; |
261 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( | 249 LayoutSVGResourcePaintServer* resource = |
262 treeScope, style.fillPaintType(), style.fillPaintUri(), id, | 250 paintingResourceFromSVGPaint(treeScope, style.fillPaintUri(), id); |
263 hasPendingResource); | 251 if (!ensureResources(resources).setFill(resource)) |
264 if (!ensureResources(resources).setFill(resource) && hasPendingResource) | |
265 treeScopeResources.addPendingResource(id, element); | 252 treeScopeResources.addPendingResource(id, element); |
266 } | 253 } |
267 | 254 |
268 if (style.hasStroke()) { | 255 if (style.hasStroke() && svgPaintTypeHasURL(style.strokePaintType())) { |
269 bool hasPendingResource = false; | |
270 AtomicString id; | 256 AtomicString id; |
271 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( | 257 LayoutSVGResourcePaintServer* resource = |
272 treeScope, style.strokePaintType(), style.strokePaintUri(), id, | 258 paintingResourceFromSVGPaint(treeScope, style.strokePaintUri(), id); |
273 hasPendingResource); | 259 if (!ensureResources(resources).setStroke(resource)) |
274 if (!ensureResources(resources).setStroke(resource) && hasPendingResource) | |
275 treeScopeResources.addPendingResource(id, element); | 260 treeScopeResources.addPendingResource(id, element); |
276 } | 261 } |
277 } | 262 } |
278 | 263 |
279 if (chainableResourceTags().contains(tagName)) { | 264 if (chainableResourceTags().contains(tagName)) { |
280 AtomicString id = targetReferenceFromResource(element); | 265 AtomicString id = targetReferenceFromResource(element); |
281 if (!ensureResources(resources).setLinkedResource( | 266 if (!ensureResources(resources).setLinkedResource( |
282 treeScopeResources.resourceById(id))) | 267 treeScopeResources.resourceById(id))) |
283 treeScopeResources.addPendingResource(id, element); | 268 treeScopeResources.addPendingResource(id, element); |
284 } | 269 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 stroke->element()); | 655 stroke->element()); |
671 } | 656 } |
672 | 657 |
673 if (m_linkedResource) | 658 if (m_linkedResource) |
674 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, | 659 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, |
675 m_linkedResource->element()); | 660 m_linkedResource->element()); |
676 } | 661 } |
677 #endif | 662 #endif |
678 | 663 |
679 } // namespace blink | 664 } // namespace blink |
OLD | NEW |