OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // If we have no fill/stroke, return 0. | 45 // If we have no fill/stroke, return 0. |
46 if (mode == ApplyToFillMode) { | 46 if (mode == ApplyToFillMode) { |
47 if (!svgStyle->hasFill()) | 47 if (!svgStyle->hasFill()) |
48 return 0; | 48 return 0; |
49 } else { | 49 } else { |
50 if (!svgStyle->hasStroke()) | 50 if (!svgStyle->hasStroke()) |
51 return 0; | 51 return 0; |
52 } | 52 } |
53 | 53 |
54 bool applyToFill = mode == ApplyToFillMode; | 54 SVGPaint* paint = mode == ApplyToFillMode ? svgStyle->fillPaint() : svgStyle
->strokePaint(); |
55 SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() :
svgStyle->strokePaintType(); | 55 ASSERT(paint); |
| 56 |
| 57 SVGPaint::SVGPaintType paintType = paint->paintType(); |
56 if (paintType == SVGPaint::SVG_PAINTTYPE_NONE) | 58 if (paintType == SVGPaint::SVG_PAINTTYPE_NONE) |
57 return 0; | 59 return 0; |
58 | 60 |
59 Color color; | 61 Color color; |
60 switch (paintType) { | 62 if (paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR |
61 case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR: | 63 || paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR |
62 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR: | 64 || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR |
63 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: | 65 || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR) |
64 case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR: | 66 color = paint->color(); |
65 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR: | 67 else if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paintType == S
VGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) |
66 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: | 68 color = style->visitedDependentColor(CSSPropertyColor); |
67 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaint
Color(); | |
68 default: | |
69 break; | |
70 } | |
71 | 69 |
72 if (style->insideLink() == InsideVisitedLink) { | 70 if (style->insideLink() == InsideVisitedLink) { |
73 RenderStyle* visitedStyle = style->getCachedPseudoStyle(VISITED_LINK); | 71 RenderStyle* visitedStyle = style->getCachedPseudoStyle(VISITED_LINK); |
74 ASSERT(visitedStyle); | 72 ASSERT(visitedStyle); |
75 | 73 |
76 const SVGRenderStyle* svgVisitedStyle = visitedStyle->svgStyle(); | 74 if (SVGPaint* visitedPaint = mode == ApplyToFillMode ? visitedStyle->svg
Style()->fillPaint() : visitedStyle->svgStyle()->strokePaint()) { |
77 SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgVisitedStyle-
>fillPaintType() : svgVisitedStyle->strokePaintType(); | 75 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'vis
itedColor'. |
78 | 76 if (visitedPaint->paintType() < SVGPaint::SVG_PAINTTYPE_URI_NONE &&
visitedPaint->paintType() != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { |
79 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visited
Color'. | 77 const Color& visitedColor = visitedPaint->color(); |
80 if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintT
ype != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { | 78 if (visitedColor.isValid()) |
81 const Color& visitedColor = applyToFill ? svgVisitedStyle->fillPaint
Color() : svgVisitedStyle->strokePaintColor(); | 79 color = Color(visitedColor.red(), visitedColor.green(), visi
tedColor.blue(), color.alpha()); |
82 if (visitedColor.isValid()) | 80 } |
83 color = Color(visitedColor.red(), visitedColor.green(), visitedC
olor.blue(), color.alpha()); | |
84 } | 81 } |
85 } | 82 } |
86 | 83 |
87 // If the primary resource is just a color, return immediately. | 84 // If the primary resource is just a color, return immediately. |
88 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP
aintingResource(); | 85 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP
aintingResource(); |
89 if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) { | 86 if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) { |
90 // If an invalid fill color is specified, fallback to fill/stroke="none"
. | 87 // If an invalid fill color is specified, fallback to fill/stroke="none"
. |
91 if (!color.isValid()) | 88 if (!color.isValid()) |
92 return 0; | 89 return 0; |
93 | 90 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 break; | 152 break; |
156 } | 153 } |
157 | 154 |
158 current = current->parent(); | 155 current = current->parent(); |
159 } | 156 } |
160 } | 157 } |
161 | 158 |
162 } | 159 } |
163 | 160 |
164 #endif | 161 #endif |
OLD | NEW |