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 #include "core/css/CSSComputedStyleDeclaration.h" | 23 #include "core/css/CSSComputedStyleDeclaration.h" |
24 | 24 |
25 #include "core/CSSPropertyNames.h" | 25 #include "core/CSSPropertyNames.h" |
26 #include "core/css/CSSPrimitiveValueMappings.h" | 26 #include "core/css/CSSPrimitiveValueMappings.h" |
27 #include "core/dom/Document.h" | 27 #include "core/dom/Document.h" |
28 #include "core/rendering/style/RenderStyle.h" | 28 #include "core/rendering/style/RenderStyle.h" |
29 #include "core/svg/SVGPaint.h" | |
30 | 29 |
31 namespace WebCore { | 30 namespace WebCore { |
32 | 31 |
33 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveV
alue(EGlyphOrientation orientation) | 32 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveV
alue(EGlyphOrientation orientation) |
34 { | 33 { |
35 switch (orientation) { | 34 switch (orientation) { |
36 case GO_0DEG: | 35 case GO_0DEG: |
37 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); | 36 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); |
38 case GO_90DEG: | 37 case GO_90DEG: |
39 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); | 38 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 case PT_NONE: | 75 case PT_NONE: |
77 default: | 76 default: |
78 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
79 break; | 78 break; |
80 } | 79 } |
81 } while (paintorder >>= kPaintOrderBitwidth); | 80 } while (paintorder >>= kPaintOrderBitwidth); |
82 | 81 |
83 return list.release(); | 82 return list.release(); |
84 } | 83 } |
85 | 84 |
86 PassRefPtrWillBeRawPtr<SVGPaint> CSSComputedStyleDeclaration::adjustSVGPaintForC
urrentColor(PassRefPtrWillBeRawPtr<SVGPaint> newPaint, RenderStyle& style) const | 85 static PassRefPtrWillBeRawPtr<CSSValue> adjustSVGPaintForCurrentColor(SVGPaintTy
pe paintType, const String& url, const Color& color, const Color& currentColor) |
87 { | 86 { |
88 RefPtrWillBeRawPtr<SVGPaint> paint = newPaint; | 87 if (paintType >= SVG_PAINTTYPE_URI_NONE) { |
89 if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->pai
ntType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) | 88 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSepar
ated(); |
90 paint->setColor(style.color()); | 89 values->append(CSSPrimitiveValue::create(url, CSSPrimitiveValue::CSS_URI
)); |
91 return paint.release(); | 90 if (paintType == SVG_PAINTTYPE_URI_NONE) |
| 91 values->append(CSSPrimitiveValue::create(CSSValueNone)); |
| 92 else if (paintType == SVG_PAINTTYPE_URI_CURRENTCOLOR) |
| 93 values->append(CSSPrimitiveValue::createColor(currentColor.rgb())); |
| 94 else if (paintType == SVG_PAINTTYPE_URI_RGBCOLOR) |
| 95 values->append(CSSPrimitiveValue::createColor(color.rgb())); |
| 96 return values.release(); |
| 97 } |
| 98 if (paintType == SVG_PAINTTYPE_NONE) |
| 99 return CSSPrimitiveValue::create(CSSValueNone); |
| 100 if (paintType == SVG_PAINTTYPE_CURRENTCOLOR) |
| 101 return CSSPrimitiveValue::createColor(currentColor.rgb()); |
| 102 |
| 103 return CSSPrimitiveValue::createColor(color.rgb()); |
92 } | 104 } |
93 | 105 |
94 static inline String serializeAsFragmentIdentifier(const AtomicString& resource) | 106 static inline String serializeAsFragmentIdentifier(const AtomicString& resource) |
95 { | 107 { |
96 return "#" + resource; | 108 return "#" + resource; |
97 } | 109 } |
98 | 110 |
99 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSV
alue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const | 111 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSV
alue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
100 { | 112 { |
101 Node* node = m_node.get(); | 113 Node* node = m_node.get(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (!svgStyle->filterResource().isEmpty()) | 173 if (!svgStyle->filterResource().isEmpty()) |
162 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->filterResource()), CSSPrimitiveValue::CSS_URI); | 174 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->filterResource()), CSSPrimitiveValue::CSS_URI); |
163 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 175 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
164 case CSSPropertyFloodColor: | 176 case CSSPropertyFloodColor: |
165 return currentColorOrValidColor(*style, svgStyle->floodColor()); | 177 return currentColorOrValidColor(*style, svgStyle->floodColor()); |
166 case CSSPropertyLightingColor: | 178 case CSSPropertyLightingColor: |
167 return currentColorOrValidColor(*style, svgStyle->lightingColor()); | 179 return currentColorOrValidColor(*style, svgStyle->lightingColor()); |
168 case CSSPropertyStopColor: | 180 case CSSPropertyStopColor: |
169 return currentColorOrValidColor(*style, svgStyle->stopColor()); | 181 return currentColorOrValidColor(*style, svgStyle->stopColor()); |
170 case CSSPropertyFill: | 182 case CSSPropertyFill: |
171 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->fill
PaintType(), svgStyle->fillPaintUri(), svgStyle->fillPaintColor()), *style); | 183 return adjustSVGPaintForCurrentColor(svgStyle->fillPaintType(), svgS
tyle->fillPaintUri(), svgStyle->fillPaintColor(), style->color()); |
172 case CSSPropertyMarkerEnd: | 184 case CSSPropertyMarkerEnd: |
173 if (!svgStyle->markerEndResource().isEmpty()) | 185 if (!svgStyle->markerEndResource().isEmpty()) |
174 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerEndResource()), CSSPrimitiveValue::CSS_URI); | 186 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerEndResource()), CSSPrimitiveValue::CSS_URI); |
175 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 187 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
176 case CSSPropertyMarkerMid: | 188 case CSSPropertyMarkerMid: |
177 if (!svgStyle->markerMidResource().isEmpty()) | 189 if (!svgStyle->markerMidResource().isEmpty()) |
178 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerMidResource()), CSSPrimitiveValue::CSS_URI); | 190 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerMidResource()), CSSPrimitiveValue::CSS_URI); |
179 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 191 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
180 case CSSPropertyMarkerStart: | 192 case CSSPropertyMarkerStart: |
181 if (!svgStyle->markerStartResource().isEmpty()) | 193 if (!svgStyle->markerStartResource().isEmpty()) |
182 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerStartResource()), CSSPrimitiveValue::CSS_URI); | 194 return CSSPrimitiveValue::create(serializeAsFragmentIdentifier(s
vgStyle->markerStartResource()), CSSPrimitiveValue::CSS_URI); |
183 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 195 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
184 case CSSPropertyStroke: | 196 case CSSPropertyStroke: |
185 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->stro
kePaintType(), svgStyle->strokePaintUri(), svgStyle->strokePaintColor()), *style
); | 197 return adjustSVGPaintForCurrentColor(svgStyle->strokePaintType(), sv
gStyle->strokePaintUri(), svgStyle->strokePaintColor(), style->color()); |
186 case CSSPropertyStrokeDasharray: | 198 case CSSPropertyStrokeDasharray: |
187 return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); | 199 return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); |
188 case CSSPropertyStrokeDashoffset: | 200 case CSSPropertyStrokeDashoffset: |
189 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset()); | 201 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset()); |
190 case CSSPropertyStrokeWidth: | 202 case CSSPropertyStrokeWidth: |
191 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth()); | 203 return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth()); |
192 case CSSPropertyBaselineShift: { | 204 case CSSPropertyBaselineShift: { |
193 switch (svgStyle->baselineShift()) { | 205 switch (svgStyle->baselineShift()) { |
194 case BS_BASELINE: | 206 case BS_BASELINE: |
195 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline)
; | 207 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline)
; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 default: | 241 default: |
230 // If you crash here, it's because you added a css property and are not
handling it | 242 // If you crash here, it's because you added a css property and are not
handling it |
231 // in either this switch statement or the one in CSSComputedStyleDelcara
tion::getPropertyCSSValue | 243 // in either this switch statement or the one in CSSComputedStyleDelcara
tion::getPropertyCSSValue |
232 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propertyID); | 244 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propertyID); |
233 } | 245 } |
234 WTF_LOG_ERROR("unimplemented propertyID: %d", propertyID); | 246 WTF_LOG_ERROR("unimplemented propertyID: %d", propertyID); |
235 return nullptr; | 247 return nullptr; |
236 } | 248 } |
237 | 249 |
238 } | 250 } |
OLD | NEW |