| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 24 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
| 25 | 25 |
| 26 #include "core/layout/style/LayoutStyle.h" | 26 #include "core/layout/style/ComputedStyle.h" |
| 27 #include "core/layout/svg/SVGResources.h" | 27 #include "core/layout/svg/SVGResources.h" |
| 28 #include "core/layout/svg/SVGResourcesCache.h" | 28 #include "core/layout/svg/SVGResourcesCache.h" |
| 29 #include "platform/graphics/GraphicsContext.h" | 29 #include "platform/graphics/GraphicsContext.h" |
| 30 #include "platform/graphics/GraphicsContextStateSaver.h" | 30 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 SVGPaintServer::SVGPaintServer(Color color) | 34 SVGPaintServer::SVGPaintServer(Color color) |
| 35 : m_color(color) | 35 : m_color(color) |
| 36 { | 36 { |
| (...skipping 37 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 LayoutObject& object, const Layout
Style& style, LayoutSVGResourceMode mode) | 84 static SVGPaintDescription requestPaint(const LayoutObject& object, const Comput
edStyle& style, LayoutSVGResourceMode 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 SVGLayoutStyle& svgStyle = style.svgStyle(); | 87 const SVGComputedStyle& 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()) |
| 95 return SVGPaintDescription(); | 95 return SVGPaintDescription(); |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::requestForLayoutObject(const LayoutObject& layout
Object, const LayoutStyle& style, LayoutSVGResourceMode resourceMode) | 156 SVGPaintServer SVGPaintServer::requestForLayoutObject(const LayoutObject& layout
Object, const ComputedStyle& style, LayoutSVGResourceMode resourceMode) |
| 157 { | 157 { |
| 158 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; | 158 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; |
| 159 | 159 |
| 160 SVGPaintDescription paintDescription = requestPaint(layoutObject, style, res
ourceMode); | 160 SVGPaintDescription paintDescription = requestPaint(layoutObject, style, res
ourceMode); |
| 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(l
ayoutObject); | 165 SVGPaintServer paintServer = paintDescription.resource->preparePaintServer(l
ayoutObject); |
| 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::existsForLayoutObject(const LayoutObject& layoutObject, con
st LayoutStyle& style, LayoutSVGResourceMode resourceMode) | 173 bool SVGPaintServer::existsForLayoutObject(const LayoutObject& layoutObject, con
st ComputedStyle& style, LayoutSVGResourceMode resourceMode) |
| 174 { | 174 { |
| 175 return requestPaint(layoutObject, style, resourceMode).isValid; | 175 return requestPaint(layoutObject, style, resourceMode).isValid; |
| 176 } | 176 } |
| 177 | 177 |
| 178 LayoutSVGResourcePaintServer::LayoutSVGResourcePaintServer(SVGElement* element) | 178 LayoutSVGResourcePaintServer::LayoutSVGResourcePaintServer(SVGElement* element) |
| 179 : LayoutSVGResourceContainer(element) | 179 : LayoutSVGResourceContainer(element) |
| 180 { | 180 { |
| 181 } | 181 } |
| 182 | 182 |
| 183 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() | 183 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() |
| 184 { | 184 { |
| 185 } | 185 } |
| 186 | 186 |
| 187 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const
LayoutObject& layoutObject, const LayoutStyle& style, LayoutSVGResourceMode reso
urceMode) | 187 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const
LayoutObject& layoutObject, const ComputedStyle& style, LayoutSVGResourceMode re
sourceMode) |
| 188 { | 188 { |
| 189 return requestPaint(layoutObject, style, resourceMode); | 189 return requestPaint(layoutObject, style, resourceMode); |
| 190 } | 190 } |
| 191 | 191 |
| 192 } | 192 } |
| OLD | NEW |