2007-10-08 Eric Seidel <eric@webkit.org>
[WebKit-https.git] / WebCore / ksvg2 / css / SVGCSSStyleSelector.cpp
1 /*
2     Copyright (C) 2005 Apple Computer, Inc.
3     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
4                   2004, 2005 Rob Buis <buis@kde.org>
5
6     Based on khtml css code by:
7     Copyright(C) 1999-2003 Lars Knoll(knoll@kde.org)
8              (C) 2003 Apple Computer, Inc.
9              (C) 2004 Allan Sandfeld Jensen(kde@carewolf.com)
10              (C) 2004 Germain Garand(germain@ebooksfrance.org)
11
12     This file is part of the KDE project
13
14     This library is free software; you can redistribute it and/or
15     modify it under the terms of the GNU Library General Public
16     License as published by the Free Software Foundation; either
17     version 2 of the License, or (at your option) any later version.
18
19     This library is distributed in the hope that it will be useful,
20     but WITHOUT ANY WARRANTY; without even the implied warranty of
21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22     Library General Public License for more details.
23
24     You should have received a copy of the GNU Library General Public License
25     along with this library; see the file COPYING.LIB.  If not, write to
26     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27     Boston, MA 02110-1301, USA.
28 */
29
30 #include "config.h"
31 #if ENABLE(SVG)
32 #include "CSSStyleSelector.h"
33
34 #include "CSSPropertyNames.h"
35 #include "CSSValueKeywords.h"
36 #include "CSSValueList.h"
37 #include "SVGColor.h"
38 #include "SVGNames.h"
39 #include "SVGPaint.h"
40 #include "SVGRenderStyle.h"
41 #include "SVGRenderStyleDefs.h"
42 #include "SVGStyledElement.h"
43 #include <math.h>
44 #include <stdlib.h>
45 #include <wtf/MathExtras.h>
46
47 #define HANDLE_INHERIT(prop, Prop) \
48 if (isInherit) \
49 {\
50     svgstyle->set##Prop(parentStyle->svgStyle()->prop());\
51     return;\
52 }
53
54 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
55 HANDLE_INHERIT(prop, Prop) \
56 else if (isInitial) \
57     svgstyle->set##Prop(SVGRenderStyle::initial##Prop());
58
59 #define HANDLE_INHERIT_COND(propID, prop, Prop) \
60 if (id == propID) \
61 {\
62     svgstyle->set##Prop(parentStyle->svgStyle()->prop());\
63     return;\
64 }
65
66 #define HANDLE_INITIAL_COND(propID, Prop) \
67 if (id == propID) \
68 {\
69     svgstyle->set##Prop(SVGRenderStyle::initial##Prop());\
70     return;\
71 }
72
73 #define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \
74 if (id == propID) { \
75     svgstyle->set##Prop(SVGRenderStyle::initial##Value()); \
76     return; \
77 }
78
79 namespace WebCore {
80
81 void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
82 {
83     CSSPrimitiveValue* primitiveValue = 0;
84     if (value->isPrimitiveValue())
85         primitiveValue = static_cast<CSSPrimitiveValue*>(value);
86
87     SVGRenderStyle* svgstyle = style->accessSVGStyle();
88     unsigned short valueType = value->cssValueType();
89     
90     bool isInherit = parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
91     bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);
92
93     // What follows is a list that maps the CSS properties into their
94     // corresponding front-end RenderStyle values. Shorthands(e.g. border,
95     // background) occur in this list as well and are only hit when mapping
96     // "inherit" or "initial" into front-end values.
97     switch (id)
98     {
99         // ident only properties
100         case CSS_PROP_ALIGNMENT_BASELINE:
101         {
102             HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
103             if (!primitiveValue)
104                 break;
105
106             switch (primitiveValue->getIdent()) {
107                 case CSS_VAL_AUTO:
108                     svgstyle->setAlignmentBaseline(AB_AUTO);
109                     break;
110                 case CSS_VAL_BASELINE:
111                     svgstyle->setAlignmentBaseline(AB_BASELINE);
112                     break;
113                 case CSS_VAL_BEFORE_EDGE:
114                     svgstyle->setAlignmentBaseline(AB_BEFORE_EDGE);
115                     break;
116                 case CSS_VAL_TEXT_BEFORE_EDGE:
117                     svgstyle->setAlignmentBaseline(AB_TEXT_BEFORE_EDGE);
118                     break;
119                 case CSS_VAL_MIDDLE:
120                     svgstyle->setAlignmentBaseline(AB_MIDDLE);
121                     break;
122                 case CSS_VAL_CENTRAL:
123                     svgstyle->setAlignmentBaseline(AB_CENTRAL);
124                     break;
125                 case CSS_VAL_AFTER_EDGE:
126                     svgstyle->setAlignmentBaseline(AB_AFTER_EDGE);
127                     break;
128                 case CSS_VAL_TEXT_AFTER_EDGE:
129                     svgstyle->setAlignmentBaseline(AB_TEXT_AFTER_EDGE);
130                     break;
131                 case CSS_VAL_IDEOGRAPHIC:
132                     svgstyle->setAlignmentBaseline(AB_IDEOGRAPHIC);
133                     break;
134                 case CSS_VAL_ALPHABETIC:
135                     svgstyle->setAlignmentBaseline(AB_ALPHABETIC);
136                     break;
137                 case CSS_VAL_HANGING:
138                     svgstyle->setAlignmentBaseline(AB_HANGING);
139                     break;
140                 case CSS_VAL_MATHEMATICAL:
141                     svgstyle->setAlignmentBaseline(AB_MATHEMATICAL);
142                     break;
143                 default:
144                     return;
145             }
146
147             break;
148         }
149         case CSS_PROP_BASELINE_SHIFT:
150         {
151             HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
152             if (!primitiveValue)
153                 break;
154
155             if (primitiveValue->getIdent()) {
156                 switch (primitiveValue->getIdent()) {
157                 case CSS_VAL_BASELINE:
158                     svgstyle->setBaselineShift(BS_BASELINE);
159                     break;
160                 case CSS_VAL_SUB:
161                     svgstyle->setBaselineShift(BS_SUB);
162                     break;
163                 case CSS_VAL_SUPER:
164                     svgstyle->setBaselineShift(BS_SUPER);
165                     break;
166                 default:
167                     break;
168                 }
169             } else {
170                 svgstyle->setBaselineShift(BS_LENGTH);
171                 svgstyle->setBaselineShiftValue(primitiveValue);
172             }
173
174             break;
175         }
176         case CSS_PROP_KERNING:
177         {
178             if (isInherit) {
179                 HANDLE_INHERIT_COND(CSS_PROP_KERNING, kerning, Kerning)
180                 return;
181             }
182             else if (isInitial) {
183                 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_KERNING, Kerning, Kerning)
184                 return;
185             }
186
187             svgstyle->setKerning(primitiveValue);
188             break;
189         }
190         case CSS_PROP_POINTER_EVENTS:
191         {
192             HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
193             if (!primitiveValue)
194                 break;
195                 
196             switch (primitiveValue->getIdent()) {
197                 case CSS_VAL_ALL:
198                     svgstyle->setPointerEvents(PE_ALL);
199                     break;
200                 case CSS_VAL_NONE:
201                     svgstyle->setPointerEvents(PE_NONE);
202                     break;
203                 case CSS_VAL_VISIBLEPAINTED:
204                     svgstyle->setPointerEvents(PE_VISIBLE_PAINTED);
205                     break;
206                 case CSS_VAL_VISIBLEFILL:
207                     svgstyle->setPointerEvents(PE_VISIBLE_FILL);
208                     break;
209                 case CSS_VAL_VISIBLESTROKE:
210                     svgstyle->setPointerEvents(PE_VISIBLE_STROKE);
211                     break;
212                 case CSS_VAL_VISIBLE:
213                     svgstyle->setPointerEvents(PE_VISIBLE);
214                     break;
215                 case CSS_VAL_PAINTED:
216                     svgstyle->setPointerEvents(PE_PAINTED);
217                     break;
218                 case CSS_VAL_FILL:
219                     svgstyle->setPointerEvents(PE_FILL);
220                     break;
221                 case CSS_VAL_STROKE:
222                     svgstyle->setPointerEvents(PE_STROKE);
223                 default:
224                     return;
225             }
226
227             break;
228         }
229         case CSS_PROP_DOMINANT_BASELINE:
230         {
231             HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
232             if (!primitiveValue)
233                 break;
234     
235             switch (primitiveValue->getIdent()) {
236                 case CSS_VAL_AUTO:
237                     svgstyle->setDominantBaseline(DB_AUTO);
238                     break;
239                 case CSS_VAL_USE_SCRIPT:
240                     svgstyle->setDominantBaseline(DB_USE_SCRIPT);
241                     break;
242                 case CSS_VAL_NO_CHANGE:
243                     svgstyle->setDominantBaseline(DB_NO_CHANGE);
244                     break;
245                 case CSS_VAL_RESET_SIZE:
246                     svgstyle->setDominantBaseline(DB_RESET_SIZE);
247                     break;
248                 case CSS_VAL_IDEOGRAPHIC:
249                     svgstyle->setDominantBaseline(DB_IDEOGRAPHIC);
250                     break;
251                 case CSS_VAL_ALPHABETIC:
252                     svgstyle->setDominantBaseline(DB_ALPHABETIC);
253                     break;
254                 case CSS_VAL_HANGING:
255                     svgstyle->setDominantBaseline(DB_HANGING);
256                     break;
257                 case CSS_VAL_MATHEMATICAL:
258                     svgstyle->setDominantBaseline(DB_MATHEMATICAL);
259                     break;
260                 case CSS_VAL_CENTRAL:
261                     svgstyle->setDominantBaseline(DB_CENTRAL);
262                     break;
263                 case CSS_VAL_MIDDLE:
264                     svgstyle->setDominantBaseline(DB_MIDDLE);
265                     break;
266                 case CSS_VAL_TEXT_AFTER_EDGE:
267                     svgstyle->setDominantBaseline(DB_TEXT_AFTER_EDGE);
268                     break;
269                 case CSS_VAL_TEXT_BEFORE_EDGE:
270                     svgstyle->setDominantBaseline(DB_TEXT_BEFORE_EDGE);
271                     break;
272                 default:
273                     return;
274             }
275     
276             break;
277         }
278         case CSS_PROP_COLOR_INTERPOLATION:
279         {
280             HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
281             if (!primitiveValue)
282                 return;
283                 
284             switch (primitiveValue->getIdent()) {
285                 case CSS_VAL_SRGB:
286                     svgstyle->setColorInterpolation(CI_SRGB);
287                     break;
288                 case CSS_VAL_LINEARRGB:
289                     svgstyle->setColorInterpolation(CI_LINEARRGB);
290                     break;
291                 case CSS_VAL_AUTO:
292                     svgstyle->setColorInterpolation(CI_AUTO);
293                 default:
294                     return;
295             }
296     
297             break;
298         }
299         case CSS_PROP_COLOR_INTERPOLATION_FILTERS:
300         {
301             HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
302             if (!primitiveValue)
303                 return;
304                 
305             switch (primitiveValue->getIdent()) {
306                 case CSS_VAL_SRGB:
307                     svgstyle->setColorInterpolationFilters(CI_SRGB);
308                     break;
309                 case CSS_VAL_LINEARRGB:
310                     svgstyle->setColorInterpolationFilters(CI_LINEARRGB);
311                     break;
312                 case CSS_VAL_AUTO:
313                     svgstyle->setColorInterpolationFilters(CI_AUTO);
314                 default:
315                     return;
316             }
317             
318             break;
319         }
320         case CSS_PROP_CLIP_RULE:
321         {
322             HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
323             if (!primitiveValue)
324                 break;
325                 
326             switch (primitiveValue->getIdent()) {
327                 case CSS_VAL_NONZERO:
328                     svgstyle->setClipRule(RULE_NONZERO);
329                     break;
330                 case CSS_VAL_EVENODD:
331                     svgstyle->setClipRule(RULE_EVENODD);
332                     break;
333                 default:
334                     break;
335             }
336         
337             break;
338         }
339         case CSS_PROP_FILL_RULE:
340         {
341             HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
342             if (!primitiveValue)
343                 break;
344             
345             switch (primitiveValue->getIdent()) {
346                 case CSS_VAL_NONZERO:
347                     svgstyle->setFillRule(RULE_NONZERO);
348                     break;
349                 case CSS_VAL_EVENODD:
350                     svgstyle->setFillRule(RULE_EVENODD);
351                 default:
352                     return;
353             }
354         
355             break;
356         }
357         case CSS_PROP_STROKE_LINEJOIN:
358         {
359             HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
360
361             if (!primitiveValue)
362                 break;
363                 
364             switch (primitiveValue->getIdent()) {
365                 case CSS_VAL_MITER:
366                     svgstyle->setJoinStyle(MiterJoin);
367                     break;
368                 case CSS_VAL_ROUND:
369                     svgstyle->setJoinStyle(RoundJoin);
370                     break;
371                 case CSS_VAL_BEVEL:
372                     svgstyle->setJoinStyle(BevelJoin);
373                 default:
374                     return;
375             }
376             
377             break;
378         }
379         case CSS_PROP_IMAGE_RENDERING:
380         {
381             HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
382             if (!primitiveValue)
383                 return;
384             
385             switch (primitiveValue->getIdent()) {
386                 case CSS_VAL_AUTO:
387                     svgstyle->setImageRendering(IR_AUTO);
388                 case CSS_VAL_OPTIMIZESPEED:
389                     svgstyle->setImageRendering(IR_OPTIMIZESPEED);
390                 case CSS_VAL_OPTIMIZEQUALITY:
391                     svgstyle->setImageRendering(IR_OPTIMIZEQUALITY);
392             }
393             break;
394         }
395         case CSS_PROP_SHAPE_RENDERING:
396         {
397             HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
398             if (!primitiveValue)
399                 return;
400             
401             switch (primitiveValue->getIdent()) {
402                 case CSS_VAL_AUTO:
403                     svgstyle->setShapeRendering(SR_AUTO);
404                 case CSS_VAL_OPTIMIZESPEED:
405                     svgstyle->setShapeRendering(SR_OPTIMIZESPEED);
406                 case CSS_VAL_CRISPEDGES:
407                     svgstyle->setShapeRendering(SR_CRISPEDGES);
408                 case CSS_VAL_GEOMETRICPRECISION:
409                     svgstyle->setShapeRendering(SR_GEOMETRICPRECISION);
410             }
411             break;
412         }
413         case CSS_PROP_TEXT_RENDERING:
414         {
415             HANDLE_INHERIT_AND_INITIAL(textRendering, TextRendering)
416             if (!primitiveValue)
417                 return;
418             
419             switch (primitiveValue->getIdent()) {
420                 case CSS_VAL_AUTO:
421                     svgstyle->setTextRendering(TR_AUTO);
422                 case CSS_VAL_OPTIMIZESPEED:
423                     svgstyle->setTextRendering(TR_OPTIMIZESPEED);
424                 case CSS_VAL_OPTIMIZELEGIBILITY:
425                     svgstyle->setTextRendering(TR_OPTIMIZELEGIBILITY);
426                 case CSS_VAL_GEOMETRICPRECISION:
427                     svgstyle->setTextRendering(TR_GEOMETRICPRECISION);
428             }
429             break;
430         }
431         // end of ident only properties
432         case CSS_PROP_FILL:
433         {
434             HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint)
435             if (!primitiveValue && value) {
436                 SVGPaint *paint = static_cast<SVGPaint*>(value);
437                 if (paint)
438                     svgstyle->setFillPaint(paint);
439             }
440             
441             break;
442         }
443         case CSS_PROP_STROKE:
444         {
445             HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint)
446             if (!primitiveValue && value) {
447                 SVGPaint *paint = static_cast<SVGPaint*>(value);
448                 if (paint)
449                     svgstyle->setStrokePaint(paint);
450             }
451             
452             break;
453         }
454         case CSS_PROP_STROKE_WIDTH:
455         {
456             HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
457             if (!primitiveValue)
458                 return;
459         
460             svgstyle->setStrokeWidth(primitiveValue);
461             break;
462         }
463         case CSS_PROP_STROKE_DASHARRAY:
464         {
465             HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
466             if (!primitiveValue && value) {
467                 CSSValueList* dashes = static_cast<CSSValueList*>(value);
468                 if (dashes)
469                     svgstyle->setStrokeDashArray(dashes);
470             }
471         
472             break;
473         }
474         case CSS_PROP_STROKE_DASHOFFSET:
475         {
476             HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
477             if (!primitiveValue)
478                 return;
479
480             svgstyle->setStrokeDashOffset(primitiveValue);
481             break;
482         }
483         case CSS_PROP_FILL_OPACITY:
484         {
485             HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
486             if (!primitiveValue)
487                 return;
488         
489             float f = 0.0f;    
490             int type = primitiveValue->primitiveType();
491             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
492                 f = primitiveValue->getFloatValue() / 100.0f;
493             else if (type == CSSPrimitiveValue::CSS_NUMBER)
494                 f = primitiveValue->getFloatValue();
495             else
496                 return;
497
498             svgstyle->setFillOpacity(f);
499             break;
500         }
501         case CSS_PROP_STROKE_OPACITY:
502         {
503             HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
504             if (!primitiveValue)
505                 return;
506         
507             float f = 0.0f;    
508             int type = primitiveValue->primitiveType();
509             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
510                 f = primitiveValue->getFloatValue() / 100.0f;
511             else if (type == CSSPrimitiveValue::CSS_NUMBER)
512                 f = primitiveValue->getFloatValue();
513             else
514                 return;
515
516             svgstyle->setStrokeOpacity(f);
517             break;
518         }
519         case CSS_PROP_STOP_OPACITY:
520         {
521             HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
522             if (!primitiveValue)
523                 return;
524         
525             float f = 0.0f;    
526             int type = primitiveValue->primitiveType();
527             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
528                 f = primitiveValue->getFloatValue() / 100.0f;
529             else if (type == CSSPrimitiveValue::CSS_NUMBER)
530                 f = primitiveValue->getFloatValue();
531             else
532                 return;
533
534             svgstyle->setStopOpacity(f);
535             break;
536         }
537         case CSS_PROP_MARKER_START:
538         {
539             HANDLE_INHERIT_AND_INITIAL(startMarker, StartMarker)
540             if (!primitiveValue)
541                 return;
542
543             String s;
544             int type = primitiveValue->primitiveType();
545             if (type == CSSPrimitiveValue::CSS_URI)
546                 s = primitiveValue->getStringValue();
547             else
548                 return;
549
550             svgstyle->setStartMarker(s);
551             break;
552         }
553         case CSS_PROP_MARKER_MID:
554         {
555             HANDLE_INHERIT_AND_INITIAL(midMarker, MidMarker)
556             if (!primitiveValue)
557                 return;
558
559             String s;
560             int type = primitiveValue->primitiveType();
561             if (type == CSSPrimitiveValue::CSS_URI)
562                 s = primitiveValue->getStringValue();
563             else
564                 return;
565
566             svgstyle->setMidMarker(s);
567             break;
568         }
569         case CSS_PROP_MARKER_END:
570         {
571             HANDLE_INHERIT_AND_INITIAL(endMarker, EndMarker)
572             if (!primitiveValue)
573                 return;
574
575             String s;
576             int type = primitiveValue->primitiveType();
577             if (type == CSSPrimitiveValue::CSS_URI)
578                 s = primitiveValue->getStringValue();
579             else
580                 return;
581
582             svgstyle->setEndMarker(s);
583             break;
584         }
585         case CSS_PROP_STROKE_LINECAP:
586         {
587             HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
588             if (!primitiveValue)
589                 break;
590             
591             switch (primitiveValue->getIdent()) {
592                 case CSS_VAL_BUTT:
593                     svgstyle->setCapStyle(ButtCap);
594                     break;
595                 case CSS_VAL_ROUND:
596                     svgstyle->setCapStyle(RoundCap);
597                     break;
598                 case CSS_VAL_SQUARE:
599                     svgstyle->setCapStyle(SquareCap);
600                 default:
601                     return;
602             }
603
604             break;
605         }
606         case CSS_PROP_STROKE_MITERLIMIT:
607         {
608             HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
609             if (!primitiveValue)
610                 return;
611
612             float f = 0.0f;
613             int type = primitiveValue->primitiveType();
614             if (type == CSSPrimitiveValue::CSS_NUMBER)
615                 f = primitiveValue->getFloatValue();
616             else
617                 return;
618
619             svgstyle->setStrokeMiterLimit(f);
620             break;
621         }
622         case CSS_PROP_FILTER:
623         {
624             HANDLE_INHERIT_AND_INITIAL(filter, Filter)
625             if (!primitiveValue)
626                 return;
627
628             String s;
629             int type = primitiveValue->primitiveType();
630             if (type == CSSPrimitiveValue::CSS_URI)
631                 s = primitiveValue->getStringValue();
632             else
633                 return;
634             svgstyle->setFilter(s);
635             break;
636         }
637         case CSS_PROP_MASK:
638         {
639             HANDLE_INHERIT_AND_INITIAL(maskElement, MaskElement)
640             if (!primitiveValue)
641                 return;
642
643             String s;
644             int type = primitiveValue->primitiveType();
645             if (type == CSSPrimitiveValue::CSS_URI)
646                 s = primitiveValue->getStringValue();
647             else
648                 return;
649
650             svgstyle->setMaskElement(s);
651             break;
652         }
653         case CSS_PROP_CLIP_PATH:
654         {
655             HANDLE_INHERIT_AND_INITIAL(clipPath, ClipPath)
656             if (!primitiveValue)
657                 return;
658
659             String s;
660             int type = primitiveValue->primitiveType();
661             if (type == CSSPrimitiveValue::CSS_URI)
662                 s = primitiveValue->getStringValue();
663             else
664                 return;
665
666             svgstyle->setClipPath(s);
667             break;
668         }
669         case CSS_PROP_TEXT_ANCHOR:
670         {
671             HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
672             if (!primitiveValue)
673                 break;
674             
675             switch (primitiveValue->getIdent()) {
676                 case CSS_VAL_START:
677                     svgstyle->setTextAnchor(TA_START);
678                     break;
679                 case CSS_VAL_MIDDLE:
680                     svgstyle->setTextAnchor(TA_MIDDLE);
681                     break;
682                 case CSS_VAL_END:
683                     svgstyle->setTextAnchor(TA_END);
684                 default:
685                     return;
686             }
687             
688             break;
689         }
690         case CSS_PROP_WRITING_MODE:
691         {
692             HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
693             if (primitiveValue)
694                 svgstyle->setWritingMode((EWritingMode)(primitiveValue->getIdent() - CSS_VAL_LR_TB));
695             break;
696         }
697         case CSS_PROP_STOP_COLOR:
698         {
699             HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
700
701             SVGColor* c = static_cast<SVGColor*>(value);
702             if (!c)
703                 return CSSStyleSelector::applyProperty(id, value);
704
705             Color col;
706             if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
707                 col = style->color();
708             else
709                 col = c->color();
710
711             svgstyle->setStopColor(col);
712             break;
713         }
714        case CSS_PROP_LIGHTING_COLOR:
715         {
716             HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
717
718             SVGColor* c = static_cast<SVGColor*>(value);
719             if (!c)
720                 return CSSStyleSelector::applyProperty(id, value);
721
722             Color col;
723             if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
724                 col = style->color();
725             else
726                 col = c->color();
727
728             svgstyle->setLightingColor(col);
729             break;
730         }
731         case CSS_PROP_FLOOD_OPACITY:
732         {
733             HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
734             if (!primitiveValue)
735                 return;
736
737             float f = 0.0f;
738             int type = primitiveValue->primitiveType();
739             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
740                 f = primitiveValue->getFloatValue() / 100.0f;
741             else if (type == CSSPrimitiveValue::CSS_NUMBER)
742                 f = primitiveValue->getFloatValue();
743             else
744                 return;
745
746             svgstyle->setFloodOpacity(f);
747             break;
748         }
749         case CSS_PROP_FLOOD_COLOR:
750         {
751             Color col;
752             if (isInitial)
753                 col = SVGRenderStyle::initialFloodColor();
754             else {
755                 SVGColor *c = static_cast<SVGColor*>(value);
756                 if (!c)
757                     return CSSStyleSelector::applyProperty(id, value);
758
759                 if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
760                     col = style->color();
761                 else
762                     col = c->color();
763             }
764
765             svgstyle->setFloodColor(col);
766             break;
767         }
768         case CSS_PROP_GLYPH_ORIENTATION_VERTICAL:
769         case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL:
770             // support for above properties has not been implemented in the engine yet
771             break;
772         default:
773             // If you crash here, it's because you added a css property and are not handling it
774             // in either this switch statement or the one in CSSStyleSelector::applyProperty
775             ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
776             return;
777     }
778 }
779
780 }
781
782 // vim:ts=4:noet
783 #endif // ENABLE(SVG)