Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / layout / svg / LayoutSVGResourceRadialGradient.cpp
blob3725146ee9a768f77afca6a20eca65f438c8fe2f
1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "config.h"
24 #include "core/layout/svg/LayoutSVGResourceRadialGradient.h"
26 #include "core/svg/SVGRadialGradientElement.h"
28 namespace blink {
30 LayoutSVGResourceRadialGradient::LayoutSVGResourceRadialGradient(SVGRadialGradientElement* node)
31 : LayoutSVGResourceGradient(node)
32 #if ENABLE(OILPAN)
33 , m_attributesWrapper(RadialGradientAttributesWrapper::create())
34 #endif
38 LayoutSVGResourceRadialGradient::~LayoutSVGResourceRadialGradient()
42 bool LayoutSVGResourceRadialGradient::collectGradientAttributes(SVGGradientElement* gradientElement)
44 #if ENABLE(OILPAN)
45 m_attributesWrapper->set(RadialGradientAttributes());
46 #else
47 m_attributes = RadialGradientAttributes();
48 #endif
49 return toSVGRadialGradientElement(gradientElement)->collectGradientAttributes(mutableAttributes());
52 FloatPoint LayoutSVGResourceRadialGradient::centerPoint(const RadialGradientAttributes& attributes) const
54 return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), *attributes.cx(), *attributes.cy());
57 FloatPoint LayoutSVGResourceRadialGradient::focalPoint(const RadialGradientAttributes& attributes) const
59 return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), *attributes.fx(), *attributes.fy());
62 float LayoutSVGResourceRadialGradient::radius(const RadialGradientAttributes& attributes) const
64 return SVGLengthContext::resolveLength(element(), attributes.gradientUnits(), *attributes.r());
67 float LayoutSVGResourceRadialGradient::focalRadius(const RadialGradientAttributes& attributes) const
69 return SVGLengthContext::resolveLength(element(), attributes.gradientUnits(), *attributes.fr());
72 void LayoutSVGResourceRadialGradient::buildGradient(GradientData* gradientData) const
74 const RadialGradientAttributes& attributes = this->attributes();
75 gradientData->gradient = Gradient::create(this->focalPoint(attributes),
76 this->focalRadius(attributes),
77 this->centerPoint(attributes),
78 this->radius(attributes));
80 gradientData->gradient->setSpreadMethod(platformSpreadMethodFromSVGType(attributes.spreadMethod()));
82 addStops(gradientData, attributes.stops());