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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 void SVGPaintServer::prependTransform(const AffineTransform& transform) | 75 void SVGPaintServer::prependTransform(const AffineTransform& transform) |
76 { | 76 { |
77 ASSERT(m_gradient || m_pattern); | 77 ASSERT(m_gradient || m_pattern); |
78 if (m_pattern) | 78 if (m_pattern) |
79 m_pattern->setPatternSpaceTransform(transform * m_pattern->patternSpaceT
ransform()); | 79 m_pattern->setPatternSpaceTransform(transform * m_pattern->patternSpaceT
ransform()); |
80 else | 80 else |
81 m_gradient->setGradientSpaceTransform(transform * m_gradient->gradientSp
aceTransform()); | 81 m_gradient->setGradientSpaceTransform(transform * m_gradient->gradientSp
aceTransform()); |
82 } | 82 } |
83 | 83 |
84 static SVGPaintDescription requestPaint(const RenderObject& object, const Render
Style& style, RenderSVGResourceMode mode) | 84 static SVGPaintDescription requestPaint(const LayoutObject& object, const Render
Style& style, RenderSVGResourceMode mode) |
85 { | 85 { |
86 // If we have no style at all, ignore it. | 86 // If we have no style at all, ignore it. |
87 const SVGRenderStyle& svgStyle = style.svgStyle(); | 87 const SVGRenderStyle& svgStyle = style.svgStyle(); |
88 | 88 |
89 // If we have no fill/stroke, return 0. | 89 // If we have no fill/stroke, return 0. |
90 if (mode == ApplyToFillMode) { | 90 if (mode == ApplyToFillMode) { |
91 if (!svgStyle.hasFill()) | 91 if (!svgStyle.hasFill()) |
92 return SVGPaintDescription(); | 92 return SVGPaintDescription(); |
93 } else { | 93 } else { |
94 if (!svgStyle.hasStroke()) | 94 if (!svgStyle.hasStroke()) |
(...skipping 30 matching lines...) Expand all Loading... |
125 } | 125 } |
126 | 126 |
127 // If the primary resource is just a color, return immediately. | 127 // If the primary resource is just a color, return immediately. |
128 if (paintType < SVG_PAINTTYPE_URI_NONE) { | 128 if (paintType < SVG_PAINTTYPE_URI_NONE) { |
129 // |paintType| will be either <current-color> or <rgb-color> here - both
of which will have a color. | 129 // |paintType| will be either <current-color> or <rgb-color> here - both
of which will have a color. |
130 ASSERT(hasColor); | 130 ASSERT(hasColor); |
131 return SVGPaintDescription(color); | 131 return SVGPaintDescription(color); |
132 } | 132 } |
133 | 133 |
134 RenderSVGResourcePaintServer* uriResource = 0; | 134 RenderSVGResourcePaintServer* uriResource = 0; |
135 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj
ect(&object)) | 135 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&object)) |
136 uriResource = applyToFill ? resources->fill() : resources->stroke(); | 136 uriResource = applyToFill ? resources->fill() : resources->stroke(); |
137 | 137 |
138 // If the requested resource is not available, return the color resource or
'none'. | 138 // If the requested resource is not available, return the color resource or
'none'. |
139 if (!uriResource) { | 139 if (!uriResource) { |
140 // The fallback is 'none'. (SVG2 say 'none' is implied when no fallback
is specified.) | 140 // The fallback is 'none'. (SVG2 say 'none' is implied when no fallback
is specified.) |
141 if (paintType == SVG_PAINTTYPE_URI_NONE || !hasColor) | 141 if (paintType == SVG_PAINTTYPE_URI_NONE || !hasColor) |
142 return SVGPaintDescription(); | 142 return SVGPaintDescription(); |
143 | 143 |
144 return SVGPaintDescription(color); | 144 return SVGPaintDescription(color); |
145 } | 145 } |
146 | 146 |
147 // The paint server resource exists, though it may be invalid (pattern with
width/height=0). | 147 // The paint server resource exists, though it may be invalid (pattern with
width/height=0). |
148 // Return the fallback color to our caller so it can use it, if | 148 // Return the fallback color to our caller so it can use it, if |
149 // preparePaintServer() on the resource container failed. | 149 // preparePaintServer() on the resource container failed. |
150 if (hasColor) | 150 if (hasColor) |
151 return SVGPaintDescription(uriResource, color); | 151 return SVGPaintDescription(uriResource, color); |
152 | 152 |
153 return SVGPaintDescription(uriResource); | 153 return SVGPaintDescription(uriResource); |
154 } | 154 } |
155 | 155 |
156 SVGPaintServer SVGPaintServer::requestForRenderer(const RenderObject& renderer,
const RenderStyle& style, RenderSVGResourceMode resourceMode) | 156 SVGPaintServer SVGPaintServer::requestForRenderer(const LayoutObject& renderer,
const RenderStyle& style, RenderSVGResourceMode resourceMode) |
157 { | 157 { |
158 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; | 158 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; |
159 | 159 |
160 SVGPaintDescription paintDescription = requestPaint(renderer, style, resourc
eMode); | 160 SVGPaintDescription paintDescription = requestPaint(renderer, style, resourc
eMode); |
161 if (!paintDescription.isValid) | 161 if (!paintDescription.isValid) |
162 return invalid(); | 162 return invalid(); |
163 if (!paintDescription.resource) | 163 if (!paintDescription.resource) |
164 return SVGPaintServer(paintDescription.color); | 164 return SVGPaintServer(paintDescription.color); |
165 SVGPaintServer paintServer = paintDescription.resource->preparePaintServer(r
enderer); | 165 SVGPaintServer paintServer = paintDescription.resource->preparePaintServer(r
enderer); |
166 if (paintServer.isValid()) | 166 if (paintServer.isValid()) |
167 return paintServer; | 167 return paintServer; |
168 if (paintDescription.hasFallback) | 168 if (paintDescription.hasFallback) |
169 return SVGPaintServer(paintDescription.color); | 169 return SVGPaintServer(paintDescription.color); |
170 return invalid(); | 170 return invalid(); |
171 } | 171 } |
172 | 172 |
173 bool SVGPaintServer::existsForRenderer(const RenderObject& renderer, const Rende
rStyle& style, RenderSVGResourceMode resourceMode) | 173 bool SVGPaintServer::existsForRenderer(const LayoutObject& renderer, const Rende
rStyle& style, RenderSVGResourceMode resourceMode) |
174 { | 174 { |
175 return requestPaint(renderer, style, resourceMode).isValid; | 175 return requestPaint(renderer, style, resourceMode).isValid; |
176 } | 176 } |
177 | 177 |
178 RenderSVGResourcePaintServer::RenderSVGResourcePaintServer(SVGElement* element) | 178 RenderSVGResourcePaintServer::RenderSVGResourcePaintServer(SVGElement* element) |
179 : RenderSVGResourceContainer(element) | 179 : RenderSVGResourceContainer(element) |
180 { | 180 { |
181 } | 181 } |
182 | 182 |
183 RenderSVGResourcePaintServer::~RenderSVGResourcePaintServer() | 183 RenderSVGResourcePaintServer::~RenderSVGResourcePaintServer() |
184 { | 184 { |
185 } | 185 } |
186 | 186 |
187 SVGPaintDescription RenderSVGResourcePaintServer::requestPaintDescription(const
RenderObject& renderer, const RenderStyle& style, RenderSVGResourceMode resource
Mode) | 187 SVGPaintDescription RenderSVGResourcePaintServer::requestPaintDescription(const
LayoutObject& renderer, const RenderStyle& style, RenderSVGResourceMode resource
Mode) |
188 { | 188 { |
189 return requestPaint(renderer, style, resourceMode); | 189 return requestPaint(renderer, style, resourceMode); |
190 } | 190 } |
191 | 191 |
192 } | 192 } |
OLD | NEW |