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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "core/rendering/svg/SVGResources.h" | 21 #include "core/rendering/svg/SVGResources.h" |
22 | 22 |
23 #include "core/SVGNames.h" | 23 #include "core/SVGNames.h" |
24 #include "core/rendering/style/SVGRenderStyle.h" | 24 #include "core/rendering/style/SVGRenderStyle.h" |
25 #include "core/rendering/svg/RenderSVGResourceClipper.h" | 25 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
26 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 26 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
27 #include "core/rendering/svg/RenderSVGResourceMarker.h" | 27 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
28 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 28 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
| 29 #include "core/rendering/svg/RenderSVGResourcePaintServer.h" |
29 #include "core/svg/SVGFilterElement.h" | 30 #include "core/svg/SVGFilterElement.h" |
30 #include "core/svg/SVGGradientElement.h" | 31 #include "core/svg/SVGGradientElement.h" |
31 #include "core/svg/SVGPatternElement.h" | 32 #include "core/svg/SVGPatternElement.h" |
32 #include "core/svg/SVGURIReference.h" | 33 #include "core/svg/SVGURIReference.h" |
33 | 34 |
34 #ifndef NDEBUG | 35 #ifndef NDEBUG |
35 #include <stdio.h> | 36 #include <stdio.h> |
36 #endif | 37 #endif |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 case SVG_PAINTTYPE_URI_CURRENTCOLOR: | 169 case SVG_PAINTTYPE_URI_CURRENTCOLOR: |
169 case SVG_PAINTTYPE_URI_RGBCOLOR: | 170 case SVG_PAINTTYPE_URI_RGBCOLOR: |
170 case SVG_PAINTTYPE_URI: | 171 case SVG_PAINTTYPE_URI: |
171 return true; | 172 return true; |
172 default: | 173 default: |
173 break; | 174 break; |
174 } | 175 } |
175 return false; | 176 return false; |
176 } | 177 } |
177 | 178 |
178 static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(TreeScope
& treeScope, const SVGPaintType& paintType, const String& paintUri, AtomicString
& id, bool& hasPendingResource) | 179 static inline RenderSVGResourcePaintServer* paintingResourceFromSVGPaint(TreeSco
pe& treeScope, const SVGPaintType& paintType, const String& paintUri, AtomicStri
ng& id, bool& hasPendingResource) |
179 { | 180 { |
180 if (!svgPaintTypeHasURL(paintType)) | 181 if (!svgPaintTypeHasURL(paintType)) |
181 return 0; | 182 return 0; |
182 | 183 |
183 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); | 184 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); |
184 RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(tr
eeScope, id); | 185 RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(tr
eeScope, id); |
185 if (!container) { | 186 if (!container) { |
186 hasPendingResource = true; | 187 hasPendingResource = true; |
187 return 0; | 188 return 0; |
188 } | 189 } |
189 | 190 |
190 RenderSVGResourceType resourceType = container->resourceType(); | 191 if (!container->isSVGPaintServer()) |
191 if (resourceType != PatternResourceType && resourceType != LinearGradientRes
ourceType && resourceType != RadialGradientResourceType) | |
192 return 0; | 192 return 0; |
193 | 193 |
194 return container; | 194 return toRenderSVGResourcePaintServer(container); |
195 } | 195 } |
196 | 196 |
197 static inline void registerPendingResource(SVGDocumentExtensions& extensions, co
nst AtomicString& id, SVGElement* element) | 197 static inline void registerPendingResource(SVGDocumentExtensions& extensions, co
nst AtomicString& id, SVGElement* element) |
198 { | 198 { |
199 ASSERT(element); | 199 ASSERT(element); |
200 extensions.addPendingResource(id, element); | 200 extensions.addPendingResource(id, element); |
201 } | 201 } |
202 | 202 |
203 bool SVGResources::hasResourceData() const | 203 bool SVGResources::hasResourceData() const |
204 { | 204 { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 const AtomicString& markerEndId = style.markerEndResource(); | 269 const AtomicString& markerEndId = style.markerEndResource(); |
270 if (!ensureResources(resources)->setMarkerEnd(getRenderSVGResourceById<R
enderSVGResourceMarker>(treeScope, style.markerEndResource()))) | 270 if (!ensureResources(resources)->setMarkerEnd(getRenderSVGResourceById<R
enderSVGResourceMarker>(treeScope, style.markerEndResource()))) |
271 registerPendingResource(extensions, markerEndId, element); | 271 registerPendingResource(extensions, markerEndId, element); |
272 } | 272 } |
273 | 273 |
274 if (fillAndStrokeTags().contains(tagName)) { | 274 if (fillAndStrokeTags().contains(tagName)) { |
275 if (style.hasFill()) { | 275 if (style.hasFill()) { |
276 bool hasPendingResource = false; | 276 bool hasPendingResource = false; |
277 AtomicString id; | 277 AtomicString id; |
278 RenderSVGResourceContainer* resource = paintingResourceFromSVGPaint(
treeScope, style.fillPaintType(), style.fillPaintUri(), id, hasPendingResource); | 278 RenderSVGResourcePaintServer* resource = paintingResourceFromSVGPain
t(treeScope, style.fillPaintType(), style.fillPaintUri(), id, hasPendingResource
); |
279 if (!ensureResources(resources)->setFill(resource) && hasPendingReso
urce) { | 279 if (!ensureResources(resources)->setFill(resource) && hasPendingReso
urce) { |
280 registerPendingResource(extensions, id, element); | 280 registerPendingResource(extensions, id, element); |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 if (style.hasStroke()) { | 284 if (style.hasStroke()) { |
285 bool hasPendingResource = false; | 285 bool hasPendingResource = false; |
286 AtomicString id; | 286 AtomicString id; |
287 RenderSVGResourceContainer* resource = paintingResourceFromSVGPaint(
treeScope, style.strokePaintType(), style.strokePaintUri(), id, hasPendingResour
ce); | 287 RenderSVGResourcePaintServer* resource = paintingResourceFromSVGPain
t(treeScope, style.strokePaintType(), style.strokePaintUri(), id, hasPendingReso
urce); |
288 if (!ensureResources(resources)->setStroke(resource) && hasPendingRe
source) { | 288 if (!ensureResources(resources)->setStroke(resource) && hasPendingRe
source) { |
289 registerPendingResource(extensions, id, element); | 289 registerPendingResource(extensions, id, element); |
290 } | 290 } |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 if (chainableResourceTags().contains(tagName)) { | 294 if (chainableResourceTags().contains(tagName)) { |
295 AtomicString id = targetReferenceFromResource(*element); | 295 AtomicString id = targetReferenceFromResource(*element); |
296 if (!ensureResources(resources)->setLinkedResource(getRenderSVGResourceC
ontainerById(treeScope, id))) | 296 if (!ensureResources(resources)->setLinkedResource(getRenderSVGResourceC
ontainerById(treeScope, id))) |
297 registerPendingResource(extensions, id, element); | 297 registerPendingResource(extensions, id, element); |
(...skipping 16 matching lines...) Expand all Loading... |
314 if (m_markerData) { | 314 if (m_markerData) { |
315 if (RenderSVGResourceMarker* marker = m_markerData->markerStart) | 315 if (RenderSVGResourceMarker* marker = m_markerData->markerStart) |
316 marker->layoutIfNeeded(); | 316 marker->layoutIfNeeded(); |
317 if (RenderSVGResourceMarker* marker = m_markerData->markerMid) | 317 if (RenderSVGResourceMarker* marker = m_markerData->markerMid) |
318 marker->layoutIfNeeded(); | 318 marker->layoutIfNeeded(); |
319 if (RenderSVGResourceMarker* marker = m_markerData->markerEnd) | 319 if (RenderSVGResourceMarker* marker = m_markerData->markerEnd) |
320 marker->layoutIfNeeded(); | 320 marker->layoutIfNeeded(); |
321 } | 321 } |
322 | 322 |
323 if (m_fillStrokeData) { | 323 if (m_fillStrokeData) { |
324 if (RenderSVGResourceContainer* fill = m_fillStrokeData->fill) | 324 if (RenderSVGResourcePaintServer* fill = m_fillStrokeData->fill) |
325 fill->layoutIfNeeded(); | 325 fill->layoutIfNeeded(); |
326 if (RenderSVGResourceContainer* stroke = m_fillStrokeData->stroke) | 326 if (RenderSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) |
327 stroke->layoutIfNeeded(); | 327 stroke->layoutIfNeeded(); |
328 } | 328 } |
329 | 329 |
330 if (m_linkedResource) | 330 if (m_linkedResource) |
331 m_linkedResource->layoutIfNeeded(); | 331 m_linkedResource->layoutIfNeeded(); |
332 } | 332 } |
333 | 333 |
334 void SVGResources::removeClientFromCache(RenderObject* object, bool markForInval
idation) const | 334 void SVGResources::removeClientFromCache(RenderObject* object, bool markForInval
idation) const |
335 { | 335 { |
336 if (!hasResourceData()) | 336 if (!hasResourceData()) |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 return true; | 603 return true; |
604 } | 604 } |
605 | 605 |
606 void SVGResources::resetMasker() | 606 void SVGResources::resetMasker() |
607 { | 607 { |
608 ASSERT(m_clipperFilterMaskerData); | 608 ASSERT(m_clipperFilterMaskerData); |
609 ASSERT(m_clipperFilterMaskerData->masker); | 609 ASSERT(m_clipperFilterMaskerData->masker); |
610 m_clipperFilterMaskerData->masker = 0; | 610 m_clipperFilterMaskerData->masker = 0; |
611 } | 611 } |
612 | 612 |
613 bool SVGResources::setFill(RenderSVGResourceContainer* fill) | 613 bool SVGResources::setFill(RenderSVGResourcePaintServer* fill) |
614 { | 614 { |
615 if (!fill) | 615 if (!fill) |
616 return false; | 616 return false; |
617 | 617 |
618 ASSERT(fill->resourceType() == PatternResourceType | |
619 || fill->resourceType() == LinearGradientResourceType | |
620 || fill->resourceType() == RadialGradientResourceType); | |
621 | |
622 if (!m_fillStrokeData) | 618 if (!m_fillStrokeData) |
623 m_fillStrokeData = FillStrokeData::create(); | 619 m_fillStrokeData = FillStrokeData::create(); |
624 | 620 |
625 m_fillStrokeData->fill = fill; | 621 m_fillStrokeData->fill = fill; |
626 return true; | 622 return true; |
627 } | 623 } |
628 | 624 |
629 void SVGResources::resetFill() | 625 void SVGResources::resetFill() |
630 { | 626 { |
631 ASSERT(m_fillStrokeData); | 627 ASSERT(m_fillStrokeData); |
632 ASSERT(m_fillStrokeData->fill); | 628 ASSERT(m_fillStrokeData->fill); |
633 m_fillStrokeData->fill = 0; | 629 m_fillStrokeData->fill = 0; |
634 } | 630 } |
635 | 631 |
636 bool SVGResources::setStroke(RenderSVGResourceContainer* stroke) | 632 bool SVGResources::setStroke(RenderSVGResourcePaintServer* stroke) |
637 { | 633 { |
638 if (!stroke) | 634 if (!stroke) |
639 return false; | 635 return false; |
640 | 636 |
641 ASSERT(stroke->resourceType() == PatternResourceType | |
642 || stroke->resourceType() == LinearGradientResourceType | |
643 || stroke->resourceType() == RadialGradientResourceType); | |
644 | |
645 if (!m_fillStrokeData) | 637 if (!m_fillStrokeData) |
646 m_fillStrokeData = FillStrokeData::create(); | 638 m_fillStrokeData = FillStrokeData::create(); |
647 | 639 |
648 m_fillStrokeData->stroke = stroke; | 640 m_fillStrokeData->stroke = stroke; |
649 return true; | 641 return true; |
650 } | 642 } |
651 | 643 |
652 void SVGResources::resetStroke() | 644 void SVGResources::resetStroke() |
653 { | 645 { |
654 ASSERT(m_fillStrokeData); | 646 ASSERT(m_fillStrokeData); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 if (m_markerData) { | 686 if (m_markerData) { |
695 if (RenderSVGResourceMarker* markerStart = m_markerData->markerStart) | 687 if (RenderSVGResourceMarker* markerStart = m_markerData->markerStart) |
696 fprintf(stderr, " |-> MarkerStart: %p (node=%p)\n", markerStart, mar
kerStart->element()); | 688 fprintf(stderr, " |-> MarkerStart: %p (node=%p)\n", markerStart, mar
kerStart->element()); |
697 if (RenderSVGResourceMarker* markerMid = m_markerData->markerMid) | 689 if (RenderSVGResourceMarker* markerMid = m_markerData->markerMid) |
698 fprintf(stderr, " |-> MarkerMid : %p (node=%p)\n", markerMid, marke
rMid->element()); | 690 fprintf(stderr, " |-> MarkerMid : %p (node=%p)\n", markerMid, marke
rMid->element()); |
699 if (RenderSVGResourceMarker* markerEnd = m_markerData->markerEnd) | 691 if (RenderSVGResourceMarker* markerEnd = m_markerData->markerEnd) |
700 fprintf(stderr, " |-> MarkerEnd : %p (node=%p)\n", markerEnd, marke
rEnd->element()); | 692 fprintf(stderr, " |-> MarkerEnd : %p (node=%p)\n", markerEnd, marke
rEnd->element()); |
701 } | 693 } |
702 | 694 |
703 if (m_fillStrokeData) { | 695 if (m_fillStrokeData) { |
704 if (RenderSVGResourceContainer* fill = m_fillStrokeData->fill) | 696 if (RenderSVGResourcePaintServer* fill = m_fillStrokeData->fill) |
705 fprintf(stderr, " |-> Fill : %p (node=%p)\n", fill, fill->elem
ent()); | 697 fprintf(stderr, " |-> Fill : %p (node=%p)\n", fill, fill->elem
ent()); |
706 if (RenderSVGResourceContainer* stroke = m_fillStrokeData->stroke) | 698 if (RenderSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) |
707 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); | 699 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); |
708 } | 700 } |
709 | 701 |
710 if (m_linkedResource) | 702 if (m_linkedResource) |
711 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); | 703 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); |
712 } | 704 } |
713 #endif | 705 #endif |
714 | 706 |
715 } | 707 } |
OLD | NEW |