OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 2 Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
3 Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 3 Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
4 | 4 |
5 This library is free software; you can redistribute it and/or | 5 This library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Library General Public | 6 modify it under the terms of the GNU Library General Public |
7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
8 version 2 of the License, or (at your option) any later version. | 8 version 2 of the License, or (at your option) any later version. |
9 | 9 |
10 This library is distributed in the hope that it will be useful, | 10 This library is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 Library General Public License for more details. | 13 Library General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU Library General Public License | 15 You should have received a copy of the GNU Library General Public License |
16 along with this library; see the file COPYING.LIB. If not, write to | 16 along with this library; see the file COPYING.LIB. If not, write to |
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 Boston, MA 02110-1301, USA. | 18 Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 | 22 |
23 #if ENABLE(SVG) | 23 #if ENABLE(SVG) |
24 #include "CSSComputedStyleDeclaration.h" | 24 #include "CSSComputedStyleDeclaration.h" |
25 | 25 |
26 #include "CSSPrimitiveValueMappings.h" | 26 #include "CSSPrimitiveValueMappings.h" |
27 #include "CSSPropertyNames.h" | 27 #include "CSSPropertyNames.h" |
28 #include "Document.h" | 28 #include "Document.h" |
29 #include "RenderStyle.h" | 29 #include "RenderStyle.h" |
30 #include "SVGPaint.h" | |
31 | 30 |
32 namespace WebCore { | 31 namespace WebCore { |
33 | 32 |
34 static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphO
rientation orientation) | 33 static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphO
rientation orientation) |
35 { | 34 { |
36 switch (orientation) { | 35 switch (orientation) { |
37 case GO_0DEG: | 36 case GO_0DEG: |
38 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); | 37 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); |
39 case GO_90DEG: | 38 case GO_90DEG: |
40 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); | 39 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); |
(...skipping 12 matching lines...) Expand all Loading... |
53 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 52 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
54 | 53 |
55 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 54 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
56 const Vector<SVGLength>::const_iterator end = dashes.end(); | 55 const Vector<SVGLength>::const_iterator end = dashes.end(); |
57 for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it) | 56 for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it) |
58 list->append(SVGLength::toCSSPrimitiveValue(*it)); | 57 list->append(SVGLength::toCSSPrimitiveValue(*it)); |
59 | 58 |
60 return list.release(); | 59 return list.release(); |
61 } | 60 } |
62 | 61 |
63 PassRefPtr<SVGPaint> CSSComputedStyleDeclaration::adjustSVGPaintForCurrentColor(
PassRefPtr<SVGPaint> newPaint, RenderStyle* style) const | |
64 { | |
65 RefPtr<SVGPaint> paint = newPaint; | |
66 if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->pai
ntType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) | |
67 paint->setColor(style->color()); | |
68 return paint.release(); | |
69 } | |
70 | |
71 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
pertyID, EUpdateLayout updateLayout) const | 62 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
pertyID, EUpdateLayout updateLayout) const |
72 { | 63 { |
73 Node* node = m_node.get(); | 64 Node* node = m_node.get(); |
74 if (!node) | 65 if (!node) |
75 return 0; | 66 return 0; |
76 | 67 |
77 // Make sure our layout is up to date before we allow a query on these attri
butes. | 68 // Make sure our layout is up to date before we allow a query on these attri
butes. |
78 if (updateLayout) | 69 if (updateLayout) |
79 node->document()->updateLayout(); | 70 node->document()->updateLayout(); |
80 | 71 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 120 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
130 case CSSPropertyMask: | 121 case CSSPropertyMask: |
131 if (!svgStyle->maskerResource().isEmpty()) | 122 if (!svgStyle->maskerResource().isEmpty()) |
132 return CSSPrimitiveValue::create(svgStyle->maskerResource(), CSS
PrimitiveValue::CSS_URI); | 123 return CSSPrimitiveValue::create(svgStyle->maskerResource(), CSS
PrimitiveValue::CSS_URI); |
133 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 124 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
134 case CSSPropertyFilter: | 125 case CSSPropertyFilter: |
135 if (!svgStyle->filterResource().isEmpty()) | 126 if (!svgStyle->filterResource().isEmpty()) |
136 return CSSPrimitiveValue::create(svgStyle->filterResource(), CSS
PrimitiveValue::CSS_URI); | 127 return CSSPrimitiveValue::create(svgStyle->filterResource(), CSS
PrimitiveValue::CSS_URI); |
137 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 128 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
138 case CSSPropertyFloodColor: | 129 case CSSPropertyFloodColor: |
139 return currentColorOrValidColor(style, svgStyle->floodColor()); | 130 return CSSPrimitiveValue::createColor(svgStyle->floodColor().rgb()); |
140 case CSSPropertyLightingColor: | 131 case CSSPropertyLightingColor: |
141 return currentColorOrValidColor(style, svgStyle->lightingColor()); | 132 return CSSPrimitiveValue::createColor(svgStyle->lightingColor().rgb(
)); |
142 case CSSPropertyStopColor: | 133 case CSSPropertyStopColor: |
143 return currentColorOrValidColor(style, svgStyle->stopColor()); | 134 return CSSPrimitiveValue::createColor(svgStyle->stopColor().rgb()); |
144 case CSSPropertyFill: | 135 case CSSPropertyFill: |
145 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->fill
PaintType(), svgStyle->fillPaintUri(), svgStyle->fillPaintColor()), style); | 136 return svgStyle->fillPaint(); |
146 case CSSPropertyKerning: | 137 case CSSPropertyKerning: |
147 return SVGLength::toCSSPrimitiveValue(svgStyle->kerning()); | 138 return SVGLength::toCSSPrimitiveValue(svgStyle->kerning()); |
148 case CSSPropertyMarkerEnd: | 139 case CSSPropertyMarkerEnd: |
149 if (!svgStyle->markerEndResource().isEmpty()) | 140 if (!svgStyle->markerEndResource().isEmpty()) |
150 return CSSPrimitiveValue::create(svgStyle->markerEndResource(),
CSSPrimitiveValue::CSS_URI); | 141 return CSSPrimitiveValue::create(svgStyle->markerEndResource(),
CSSPrimitiveValue::CSS_URI); |
151 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 142 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
152 case CSSPropertyMarkerMid: | 143 case CSSPropertyMarkerMid: |
153 if (!svgStyle->markerMidResource().isEmpty()) | 144 if (!svgStyle->markerMidResource().isEmpty()) |
154 return CSSPrimitiveValue::create(svgStyle->markerMidResource(),
CSSPrimitiveValue::CSS_URI); | 145 return CSSPrimitiveValue::create(svgStyle->markerMidResource(),
CSSPrimitiveValue::CSS_URI); |
155 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 146 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
156 case CSSPropertyMarkerStart: | 147 case CSSPropertyMarkerStart: |
157 if (!svgStyle->markerStartResource().isEmpty()) | 148 if (!svgStyle->markerStartResource().isEmpty()) |
158 return CSSPrimitiveValue::create(svgStyle->markerStartResource()
, CSSPrimitiveValue::CSS_URI); | 149 return CSSPrimitiveValue::create(svgStyle->markerStartResource()
, CSSPrimitiveValue::CSS_URI); |
159 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 150 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
160 case CSSPropertyStroke: | 151 case CSSPropertyStroke: |
161 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->stro
kePaintType(), svgStyle->strokePaintUri(), svgStyle->strokePaintColor()), style)
; | 152 return svgStyle->strokePaint(); |
162 case CSSPropertyStrokeDasharray: | 153 case CSSPropertyStrokeDasharray: |
163 return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); | 154 return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); |
164 case CSSPropertyStrokeDashoffset: | 155 case CSSPropertyStrokeDashoffset: |
165 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset()); | 156 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset()); |
166 case CSSPropertyStrokeWidth: | 157 case CSSPropertyStrokeWidth: |
167 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth()); | 158 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth()); |
168 case CSSPropertyBaselineShift: { | 159 case CSSPropertyBaselineShift: { |
169 switch (svgStyle->baselineShift()) { | 160 switch (svgStyle->baselineShift()) { |
170 case BS_BASELINE: | 161 case BS_BASELINE: |
171 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline)
; | 162 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline)
; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 195 } |
205 LOG_ERROR("unimplemented propertyID: %d", propertyID); | 196 LOG_ERROR("unimplemented propertyID: %d", propertyID); |
206 return 0; | 197 return 0; |
207 } | 198 } |
208 | 199 |
209 } | 200 } |
210 | 201 |
211 #endif // ENABLE(SVG) | 202 #endif // ENABLE(SVG) |
212 | 203 |
213 // vim:ts=4:noet | 204 // vim:ts=4:noet |
OLD | NEW |