| 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) 2008 Eric Seidel <eric@webkit.org> | 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.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/rendering/svg/RenderSVGResourceGradient.h" | 24 #include "core/layout/svg/LayoutSVGResourceGradient.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 RenderSVGResourceGradient::RenderSVGResourceGradient(SVGGradientElement* node) | 28 LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) |
| 29 : RenderSVGResourcePaintServer(node) | 29 : LayoutSVGResourcePaintServer(node) |
| 30 , m_shouldCollectGradientAttributes(true) | 30 , m_shouldCollectGradientAttributes(true) |
| 31 { | 31 { |
| 32 } | 32 } |
| 33 | 33 |
| 34 void RenderSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) | 34 void LayoutSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) |
| 35 { | 35 { |
| 36 m_gradientMap.clear(); | 36 m_gradientMap.clear(); |
| 37 m_shouldCollectGradientAttributes = true; | 37 m_shouldCollectGradientAttributes = true; |
| 38 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare
ntOnlyInvalidation); | 38 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare
ntOnlyInvalidation); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void RenderSVGResourceGradient::removeClientFromCache(LayoutObject* client, bool
markForInvalidation) | 41 void LayoutSVGResourceGradient::removeClientFromCache(LayoutObject* client, bool
markForInvalidation) |
| 42 { | 42 { |
| 43 ASSERT(client); | 43 ASSERT(client); |
| 44 m_gradientMap.remove(client); | 44 m_gradientMap.remove(client); |
| 45 markClientForInvalidation(client, markForInvalidation ? PaintInvalidation :
ParentOnlyInvalidation); | 45 markClientForInvalidation(client, markForInvalidation ? PaintInvalidation :
ParentOnlyInvalidation); |
| 46 } | 46 } |
| 47 | 47 |
| 48 SVGPaintServer RenderSVGResourceGradient::preparePaintServer(const LayoutObject&
object) | 48 SVGPaintServer LayoutSVGResourceGradient::preparePaintServer(const LayoutObject&
object) |
| 49 { | 49 { |
| 50 clearInvalidationMask(); | 50 clearInvalidationMask(); |
| 51 | 51 |
| 52 // Be sure to synchronize all SVG properties on the gradientElement _before_
processing any further. | 52 // Be sure to synchronize all SVG properties on the gradientElement _before_
processing any further. |
| 53 // Otherwhise the call to collectGradientAttributes() in createTileImage(),
may cause the SVG DOM property | 53 // Otherwhise the call to collectGradientAttributes() in createTileImage(),
may cause the SVG DOM property |
| 54 // synchronization to kick in, which causes removeAllClientsFromCache() to b
e called, which in turn deletes our | 54 // synchronization to kick in, which causes removeAllClientsFromCache() to b
e called, which in turn deletes our |
| 55 // GradientData object! Leaving out the line below will cause svg/dynamic-up
dates/SVG*GradientElement-svgdom* to crash. | 55 // GradientData object! Leaving out the line below will cause svg/dynamic-up
dates/SVG*GradientElement-svgdom* to crash. |
| 56 SVGGradientElement* gradientElement = toSVGGradientElement(element()); | 56 SVGGradientElement* gradientElement = toSVGGradientElement(element()); |
| 57 if (!gradientElement) | 57 if (!gradientElement) |
| 58 return SVGPaintServer::invalid(); | 58 return SVGPaintServer::invalid(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 if (!gradientData->gradient) | 94 if (!gradientData->gradient) |
| 95 return SVGPaintServer::invalid(); | 95 return SVGPaintServer::invalid(); |
| 96 | 96 |
| 97 gradientData->gradient->setGradientSpaceTransform(gradientData->userspaceTra
nsform); | 97 gradientData->gradient->setGradientSpaceTransform(gradientData->userspaceTra
nsform); |
| 98 | 98 |
| 99 return SVGPaintServer(gradientData->gradient); | 99 return SVGPaintServer(gradientData->gradient); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool RenderSVGResourceGradient::isChildAllowed(LayoutObject* child, const Layout
Style&) const | 102 bool LayoutSVGResourceGradient::isChildAllowed(LayoutObject* child, const Layout
Style&) const |
| 103 { | 103 { |
| 104 if (child->isSVGGradientStop()) | 104 if (child->isSVGGradientStop()) |
| 105 return true; | 105 return true; |
| 106 | 106 |
| 107 if (!child->isSVGResourceContainer()) | 107 if (!child->isSVGResourceContainer()) |
| 108 return false; | 108 return false; |
| 109 | 109 |
| 110 return toRenderSVGResourceContainer(child)->isSVGPaintServer(); | 110 return toLayoutSVGResourceContainer(child)->isSVGPaintServer(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void RenderSVGResourceGradient::addStops(GradientData* gradientData, const Vecto
r<Gradient::ColorStop>& stops) const | 113 void LayoutSVGResourceGradient::addStops(GradientData* gradientData, const Vecto
r<Gradient::ColorStop>& stops) const |
| 114 { | 114 { |
| 115 ASSERT(gradientData->gradient); | 115 ASSERT(gradientData->gradient); |
| 116 | 116 |
| 117 const Vector<Gradient::ColorStop>::const_iterator end = stops.end(); | 117 const Vector<Gradient::ColorStop>::const_iterator end = stops.end(); |
| 118 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e
nd; ++it) | 118 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e
nd; ++it) |
| 119 gradientData->gradient->addColorStop(*it); | 119 gradientData->gradient->addColorStop(*it); |
| 120 } | 120 } |
| 121 | 121 |
| 122 GradientSpreadMethod RenderSVGResourceGradient::platformSpreadMethodFromSVGType(
SVGSpreadMethodType method) const | 122 GradientSpreadMethod LayoutSVGResourceGradient::platformSpreadMethodFromSVGType(
SVGSpreadMethodType method) const |
| 123 { | 123 { |
| 124 switch (method) { | 124 switch (method) { |
| 125 case SVGSpreadMethodUnknown: | 125 case SVGSpreadMethodUnknown: |
| 126 case SVGSpreadMethodPad: | 126 case SVGSpreadMethodPad: |
| 127 return SpreadMethodPad; | 127 return SpreadMethodPad; |
| 128 case SVGSpreadMethodReflect: | 128 case SVGSpreadMethodReflect: |
| 129 return SpreadMethodReflect; | 129 return SpreadMethodReflect; |
| 130 case SVGSpreadMethodRepeat: | 130 case SVGSpreadMethodRepeat: |
| 131 return SpreadMethodRepeat; | 131 return SpreadMethodRepeat; |
| 132 } | 132 } |
| 133 | 133 |
| 134 ASSERT_NOT_REACHED(); | 134 ASSERT_NOT_REACHED(); |
| 135 return SpreadMethodPad; | 135 return SpreadMethodPad; |
| 136 } | 136 } |
| 137 | 137 |
| 138 } | 138 } |
| OLD | NEW |