OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "core/svg/SVGGradientElement.h" | 22 #include "core/svg/SVGGradientElement.h" |
23 | 23 |
24 #include "core/dom/Attribute.h" | 24 #include "core/dom/Attribute.h" |
25 #include "core/dom/ElementTraversal.h" | 25 #include "core/dom/ElementTraversal.h" |
| 26 #include "core/dom/StyleChangeReason.h" |
26 #include "core/layout/svg/LayoutSVGResourceContainer.h" | 27 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
27 #include "core/svg/SVGStopElement.h" | 28 #include "core/svg/SVGStopElement.h" |
28 #include "core/svg/SVGTransformList.h" | 29 #include "core/svg/SVGTransformList.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 template <> | 33 template <> |
33 const SVGEnumerationStringEntries& | 34 const SVGEnumerationStringEntries& |
34 getStaticStringEntries<SVGSpreadMethodType>() { | 35 getStaticStringEntries<SVGSpreadMethodType>() { |
35 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 36 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
36 if (entries.isEmpty()) { | 37 if (entries.isEmpty()) { |
37 entries.append(std::make_pair(SVGSpreadMethodPad, "pad")); | 38 entries.append(std::make_pair(SVGSpreadMethodPad, "pad")); |
38 entries.append(std::make_pair(SVGSpreadMethodReflect, "reflect")); | 39 entries.append(std::make_pair(SVGSpreadMethodReflect, "reflect")); |
39 entries.append(std::make_pair(SVGSpreadMethodRepeat, "repeat")); | 40 entries.append(std::make_pair(SVGSpreadMethodRepeat, "repeat")); |
40 } | 41 } |
41 return entries; | 42 return entries; |
42 } | 43 } |
43 | 44 |
44 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, | 45 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, |
45 Document& document) | 46 Document& document) |
46 : SVGElement(tagName, document), | 47 : SVGElement(tagName, document), |
47 SVGURIReference(this), | 48 SVGURIReference(this), |
48 m_gradientTransform( | 49 m_gradientTransform( |
49 SVGAnimatedTransformList::create(this, | 50 SVGAnimatedTransformList::create(this, |
50 SVGNames::gradientTransformAttr)), | 51 SVGNames::gradientTransformAttr, |
| 52 CSSPropertyTransform)), |
51 m_spreadMethod(SVGAnimatedEnumeration<SVGSpreadMethodType>::create( | 53 m_spreadMethod(SVGAnimatedEnumeration<SVGSpreadMethodType>::create( |
52 this, | 54 this, |
53 SVGNames::spreadMethodAttr, | 55 SVGNames::spreadMethodAttr, |
54 SVGSpreadMethodPad)), | 56 SVGSpreadMethodPad)), |
55 m_gradientUnits(SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create( | 57 m_gradientUnits(SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create( |
56 this, | 58 this, |
57 SVGNames::gradientUnitsAttr, | 59 SVGNames::gradientUnitsAttr, |
58 SVGUnitTypes::kSvgUnitTypeObjectboundingbox)) { | 60 SVGUnitTypes::kSvgUnitTypeObjectboundingbox)) { |
59 addToPropertyMap(m_gradientTransform); | 61 addToPropertyMap(m_gradientTransform); |
60 addToPropertyMap(m_spreadMethod); | 62 addToPropertyMap(m_spreadMethod); |
61 addToPropertyMap(m_gradientUnits); | 63 addToPropertyMap(m_gradientUnits); |
62 } | 64 } |
63 | 65 |
64 DEFINE_TRACE(SVGGradientElement) { | 66 DEFINE_TRACE(SVGGradientElement) { |
65 visitor->trace(m_gradientTransform); | 67 visitor->trace(m_gradientTransform); |
66 visitor->trace(m_spreadMethod); | 68 visitor->trace(m_spreadMethod); |
67 visitor->trace(m_gradientUnits); | 69 visitor->trace(m_gradientUnits); |
68 SVGElement::trace(visitor); | 70 SVGElement::trace(visitor); |
69 SVGURIReference::trace(visitor); | 71 SVGURIReference::trace(visitor); |
70 } | 72 } |
71 | 73 |
| 74 void SVGGradientElement::collectStyleForPresentationAttribute( |
| 75 const QualifiedName& name, |
| 76 const AtomicString& value, |
| 77 MutableStylePropertySet* style) { |
| 78 if (name == SVGNames::gradientTransformAttr) { |
| 79 addPropertyToPresentationAttributeStyle( |
| 80 style, CSSPropertyTransform, |
| 81 m_gradientTransform->currentValue()->cssValue()); |
| 82 return; |
| 83 } |
| 84 SVGElement::collectStyleForPresentationAttribute(name, value, style); |
| 85 } |
| 86 |
72 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) { | 87 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) { |
| 88 if (attrName == SVGNames::gradientTransformAttr) { |
| 89 invalidateSVGPresentationAttributeStyle(); |
| 90 setNeedsStyleRecalc(LocalStyleChange, |
| 91 StyleChangeReasonForTracing::fromAttribute(attrName)); |
| 92 } |
| 93 |
73 if (attrName == SVGNames::gradientUnitsAttr || | 94 if (attrName == SVGNames::gradientUnitsAttr || |
74 attrName == SVGNames::gradientTransformAttr || | 95 attrName == SVGNames::gradientTransformAttr || |
75 attrName == SVGNames::spreadMethodAttr || | 96 attrName == SVGNames::spreadMethodAttr || |
76 SVGURIReference::isKnownAttribute(attrName)) { | 97 SVGURIReference::isKnownAttribute(attrName)) { |
77 SVGElement::InvalidationGuard invalidationGuard(this); | 98 SVGElement::InvalidationGuard invalidationGuard(this); |
78 | 99 |
79 LayoutSVGResourceContainer* layoutObject = | 100 LayoutSVGResourceContainer* layoutObject = |
80 toLayoutSVGResourceContainer(this->layoutObject()); | 101 toLayoutSVGResourceContainer(this->layoutObject()); |
81 if (layoutObject) | 102 if (layoutObject) |
82 layoutObject->invalidateCacheAndMarkForLayout(); | 103 layoutObject->invalidateCacheAndMarkForLayout(); |
(...skipping 25 matching lines...) Expand all Loading... |
108 float offset = stop.offset()->currentValue()->value(); | 129 float offset = stop.offset()->currentValue()->value(); |
109 offset = std::min(std::max(previousOffset, offset), 1.0f); | 130 offset = std::min(std::max(previousOffset, offset), 1.0f); |
110 previousOffset = offset; | 131 previousOffset = offset; |
111 | 132 |
112 stops.append(Gradient::ColorStop(offset, stop.stopColorIncludingOpacity())); | 133 stops.append(Gradient::ColorStop(offset, stop.stopColorIncludingOpacity())); |
113 } | 134 } |
114 return stops; | 135 return stops; |
115 } | 136 } |
116 | 137 |
117 } // namespace blink | 138 } // namespace blink |
OLD | NEW |