JavaScriptCore:
[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., 59 Temple Place - Suite 330,
27     Boston, MA 02111-1307, USA.
28 */
29
30 #include "config.h"
31 #if ENABLE(SVG)
32 #include "cssstyleselector.h"
33
34 #include "SVGColor.h"
35 #include "SVGNames.h"
36 #include "SVGPaint.h"
37 #include "SVGRenderStyle.h"
38 #include "SVGRenderStyleDefs.h"
39 #include "SVGStyledElement.h"
40 #include "CSSValueKeywords.h"
41 #include "CSSValueList.h"
42 #include "ksvgcssvalues.h"
43 #include "ksvgcssproperties.h"
44 #include <stdlib.h>
45 #include <math.h>
46 #include <wtf/MathExtras.h>
47
48 #define HANDLE_INHERIT(prop, Prop) \
49 if (isInherit) \
50 {\
51     svgstyle->set##Prop(parentStyle->svgStyle()->prop());\
52     return;\
53 }
54
55 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
56 HANDLE_INHERIT(prop, Prop) \
57 else if (isInitial) \
58     svgstyle->set##Prop(SVGRenderStyle::initial##Prop());
59
60 #define HANDLE_INHERIT_COND(propID, prop, Prop) \
61 if (id == propID) \
62 {\
63     svgstyle->set##Prop(parentStyle->svgStyle()->prop());\
64     return;\
65 }
66
67 #define HANDLE_INITIAL_COND(propID, Prop) \
68 if (id == propID) \
69 {\
70     svgstyle->set##Prop(SVGRenderStyle::initial##Prop());\
71     return;\
72 }
73
74 #define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \
75 if (id == propID) { \
76     svgstyle->set##Prop(SVGRenderStyle::initial##Value()); \
77     return; \
78 }
79
80 namespace WebCore {
81
82 void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
83 {
84     CSSPrimitiveValue* primitiveValue = 0;
85     if (value->isPrimitiveValue())
86         primitiveValue = static_cast<CSSPrimitiveValue*>(value);
87
88     SVGRenderStyle* svgstyle = style->accessSVGStyle();
89     unsigned short valueType = value->cssValueType();
90     
91     bool isInherit = parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
92     bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);
93
94     // What follows is a list that maps the CSS properties into their
95     // corresponding front-end RenderStyle values. Shorthands(e.g. border,
96     // background) occur in this list as well and are only hit when mapping
97     // "inherit" or "initial" into front-end values.
98     switch (id)
99     {
100         // ident only properties
101         case SVGCSS_PROP_ALIGNMENT_BASELINE:
102         {
103             HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
104             if (!primitiveValue)
105                 break;
106
107             switch (primitiveValue->getIdent())
108             {
109                 case CSS_VAL_AUTO:
110                     svgstyle->setAlignmentBaseline(AB_AUTO);
111                     break;
112                 case CSS_VAL_BASELINE:
113                     svgstyle->setAlignmentBaseline(AB_BASELINE);
114                     break;
115                 case SVGCSS_VAL_BEFORE_EDGE:
116                     svgstyle->setAlignmentBaseline(AB_BEFORE_EDGE);
117                     break;
118                 case SVGCSS_VAL_TEXT_BEFORE_EDGE:
119                     svgstyle->setAlignmentBaseline(AB_TEXT_BEFORE_EDGE);
120                     break;
121                 case CSS_VAL_MIDDLE:
122                     svgstyle->setAlignmentBaseline(AB_MIDDLE);
123                     break;
124                 case SVGCSS_VAL_CENTRAL:
125                     svgstyle->setAlignmentBaseline(AB_CENTRAL);
126                     break;
127                 case SVGCSS_VAL_AFTER_EDGE:
128                     svgstyle->setAlignmentBaseline(AB_AFTER_EDGE);
129                     break;
130                 case SVGCSS_VAL_TEXT_AFTER_EDGE:
131                     svgstyle->setAlignmentBaseline(AB_TEXT_AFTER_EDGE);
132                     break;
133                 case SVGCSS_VAL_IDEOGRAPHIC:
134                     svgstyle->setAlignmentBaseline(AB_IDEOGRAPHIC);
135                     break;
136                 case SVGCSS_VAL_ALPHABETIC:
137                     svgstyle->setAlignmentBaseline(AB_ALPHABETIC);
138                     break;
139                 case SVGCSS_VAL_HANGING:
140                     svgstyle->setAlignmentBaseline(AB_HANGING);
141                     break;
142                 case SVGCSS_VAL_MATHEMATICAL:
143                     svgstyle->setAlignmentBaseline(AB_MATHEMATICAL);
144                     break;
145                 default:
146                     return;
147             }
148
149             break;
150         }
151         case SVGCSS_PROP_BASELINE_SHIFT:
152         {
153             HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
154             if (!primitiveValue)
155                 break;
156
157             if (primitiveValue->getIdent()) {
158                 switch (primitiveValue->getIdent()) {
159                 case CSS_VAL_BASELINE:
160                     svgstyle->setBaselineShift(BS_BASELINE);
161                     break;
162                 case CSS_VAL_SUB:
163                     svgstyle->setBaselineShift(BS_SUB);
164                     break;
165                 case CSS_VAL_SUPER:
166                     svgstyle->setBaselineShift(BS_SUPER);
167                     break;
168                 default:
169                     break;
170                 }
171             } else {
172                 svgstyle->setBaselineShift(BS_LENGTH);
173                 svgstyle->setBaselineShiftValue(primitiveValue);
174             }
175
176             break;
177         }
178         case SVGCSS_PROP_KERNING:
179         {
180             if (isInherit) {
181                 HANDLE_INHERIT_COND(SVGCSS_PROP_KERNING, kerning, Kerning)
182                 return;
183             }
184             else if (isInitial) {
185                 HANDLE_INITIAL_COND_WITH_VALUE(SVGCSS_PROP_KERNING, Kerning, Kerning)
186                 return;
187             }
188
189             svgstyle->setKerning(primitiveValue);
190             break;
191         }
192         case SVGCSS_PROP_POINTER_EVENTS:
193         {
194             HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
195             if (!primitiveValue)
196                 break;
197                 
198             switch (primitiveValue->getIdent())
199             {
200                 case SVGCSS_VAL_ALL:
201                     svgstyle->setPointerEvents(PE_ALL);
202                     break;
203                 case CSS_VAL_NONE:
204                     svgstyle->setPointerEvents(PE_NONE);
205                     break;
206                 case SVGCSS_VAL_VISIBLEPAINTED:
207                     svgstyle->setPointerEvents(PE_VISIBLE_PAINTED);
208                     break;
209                 case SVGCSS_VAL_VISIBLEFILL:
210                     svgstyle->setPointerEvents(PE_VISIBLE_FILL);
211                     break;
212                 case SVGCSS_VAL_VISIBLESTROKE:
213                     svgstyle->setPointerEvents(PE_VISIBLE_STROKE);
214                     break;
215                 case CSS_VAL_VISIBLE:
216                     svgstyle->setPointerEvents(PE_VISIBLE);
217                     break;
218                 case SVGCSS_VAL_PAINTED:
219                     svgstyle->setPointerEvents(PE_PAINTED);
220                     break;
221                 case SVGCSS_VAL_FILL:
222                     svgstyle->setPointerEvents(PE_FILL);
223                     break;
224                 case SVGCSS_VAL_STROKE:
225                     svgstyle->setPointerEvents(PE_STROKE);
226                 default:
227                     return;
228             }
229
230             break;
231         }
232         case SVGCSS_PROP_DOMINANT_BASELINE:
233         {
234             HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
235             if (!primitiveValue)
236                 break;
237     
238             switch (primitiveValue->getIdent())
239             {
240                 case CSS_VAL_AUTO:
241                     svgstyle->setDominantBaseline(DB_AUTO);
242                     break;
243                 case SVGCSS_VAL_USE_SCRIPT:
244                     svgstyle->setDominantBaseline(DB_USE_SCRIPT);
245                     break;
246                 case SVGCSS_VAL_NO_CHANGE:
247                     svgstyle->setDominantBaseline(DB_NO_CHANGE);
248                     break;
249                 case SVGCSS_VAL_RESET_SIZE:
250                     svgstyle->setDominantBaseline(DB_RESET_SIZE);
251                     break;
252                 case SVGCSS_VAL_IDEOGRAPHIC:
253                     svgstyle->setDominantBaseline(DB_IDEOGRAPHIC);
254                     break;
255                 case SVGCSS_VAL_ALPHABETIC:
256                     svgstyle->setDominantBaseline(DB_ALPHABETIC);
257                     break;
258                 case SVGCSS_VAL_HANGING:
259                     svgstyle->setDominantBaseline(DB_HANGING);
260                     break;
261                 case SVGCSS_VAL_MATHEMATICAL:
262                     svgstyle->setDominantBaseline(DB_MATHEMATICAL);
263                     break;
264                 case SVGCSS_VAL_CENTRAL:
265                     svgstyle->setDominantBaseline(DB_CENTRAL);
266                     break;
267                 case CSS_VAL_MIDDLE:
268                     svgstyle->setDominantBaseline(DB_MIDDLE);
269                     break;
270                 case SVGCSS_VAL_TEXT_AFTER_EDGE:
271                     svgstyle->setDominantBaseline(DB_TEXT_AFTER_EDGE);
272                     break;
273                 case SVGCSS_VAL_TEXT_BEFORE_EDGE:
274                     svgstyle->setDominantBaseline(DB_TEXT_BEFORE_EDGE);
275                     break;
276                 default:
277                     return;
278             }
279     
280             break;
281         }
282         case SVGCSS_PROP_COLOR_INTERPOLATION:
283         {
284             HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
285             if (!primitiveValue)
286                 return;
287                 
288             switch (primitiveValue->getIdent())
289             {
290                 case SVGCSS_VAL_SRGB:
291                     svgstyle->setColorInterpolation(CI_SRGB);
292                     break;
293                 case SVGCSS_VAL_LINEARRGB:
294                     svgstyle->setColorInterpolation(CI_LINEARRGB);
295                     break;
296                 case CSS_VAL_AUTO:
297                     svgstyle->setColorInterpolation(CI_AUTO);
298                 default:
299                     return;
300             }
301     
302             break;
303         }
304         case SVGCSS_PROP_COLOR_INTERPOLATION_FILTERS:
305         {
306             HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
307             if (!primitiveValue)
308                 return;
309                 
310             switch (primitiveValue->getIdent())
311             {
312                 case SVGCSS_VAL_SRGB:
313                     svgstyle->setColorInterpolationFilters(CI_SRGB);
314                     break;
315                 case SVGCSS_VAL_LINEARRGB:
316                     svgstyle->setColorInterpolationFilters(CI_LINEARRGB);
317                     break;
318                 case CSS_VAL_AUTO:
319                     svgstyle->setColorInterpolationFilters(CI_AUTO);
320                 default:
321                     return;
322             }
323             
324             break;
325         }
326         case SVGCSS_PROP_CLIP_RULE:
327         {
328             HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
329             if (!primitiveValue)
330                 break;
331                 
332             switch (primitiveValue->getIdent())
333             {
334                 case SVGCSS_VAL_NONZERO:
335                     svgstyle->setClipRule(RULE_NONZERO);
336                     break;
337                 case SVGCSS_VAL_EVENODD:
338                     svgstyle->setClipRule(RULE_EVENODD);
339                     break;
340                 default:
341                     break;
342             }
343         
344             break;
345         }
346         case SVGCSS_PROP_FILL_RULE:
347         {
348             HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
349             if (!primitiveValue)
350                 break;
351             
352             switch (primitiveValue->getIdent())
353             {
354                 case SVGCSS_VAL_NONZERO:
355                     svgstyle->setFillRule(RULE_NONZERO);
356                     break;
357                 case SVGCSS_VAL_EVENODD:
358                     svgstyle->setFillRule(RULE_EVENODD);
359                 default:
360                     return;
361             }
362         
363             break;
364         }
365         case SVGCSS_PROP_STROKE_LINEJOIN:
366         {
367             HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
368
369             if (!primitiveValue)
370                 break;
371                 
372             switch (primitiveValue->getIdent())
373             {
374                 case SVGCSS_VAL_MITER:
375                     svgstyle->setJoinStyle(MiterJoin);
376                     break;
377                 case CSS_VAL_ROUND:
378                     svgstyle->setJoinStyle(RoundJoin);
379                     break;
380                 case SVGCSS_VAL_BEVEL:
381                     svgstyle->setJoinStyle(BevelJoin);
382                 default:
383                     return;
384             }
385             
386             break;
387         }
388         case SVGCSS_PROP_IMAGE_RENDERING:
389         {
390             HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
391             if (!primitiveValue)
392                 return;
393             
394             switch (primitiveValue->getIdent())
395             {
396                 case SVGCSS_VAL_OPTIMIZESPEED:
397                     svgstyle->setImageRendering(IR_OPTIMIZESPEED);
398                 default:
399                     return;
400             }
401     
402             break;
403         }
404         // end of ident only properties
405         case SVGCSS_PROP_FILL:
406         {
407             HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint)
408             if (!primitiveValue && value) {
409                 SVGPaint *paint = static_cast<SVGPaint*>(value);
410                 if (paint)
411                     svgstyle->setFillPaint(paint);
412             }
413             
414             break;
415         }
416         case SVGCSS_PROP_STROKE:
417         {
418             HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint)
419             if (!primitiveValue && value) {
420                 SVGPaint *paint = static_cast<SVGPaint*>(value);
421                 if (paint)
422                     svgstyle->setStrokePaint(paint);
423             }
424             
425             break;
426         }
427         case SVGCSS_PROP_STROKE_WIDTH:
428         {
429             HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
430             if (!primitiveValue)
431                 return;
432         
433             svgstyle->setStrokeWidth(primitiveValue);
434             break;
435         }
436         case SVGCSS_PROP_STROKE_DASHARRAY:
437         {
438             HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
439             if (!primitiveValue && value) {
440                 CSSValueList* dashes = static_cast<CSSValueList*>(value);
441                 if (dashes)
442                     svgstyle->setStrokeDashArray(dashes);
443             }
444         
445             break;
446         }
447         case SVGCSS_PROP_STROKE_DASHOFFSET:
448         {
449             HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
450             if (!primitiveValue)
451                 return;
452
453             svgstyle->setStrokeDashOffset(primitiveValue);
454             break;
455         }
456         case SVGCSS_PROP_FILL_OPACITY:
457         {
458             HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
459             if (!primitiveValue)
460                 return;
461         
462             float f = 0.0f;    
463             int type = primitiveValue->primitiveType();
464             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
465                 f = primitiveValue->getFloatValue() / 100.;
466             else if (type == CSSPrimitiveValue::CSS_NUMBER)
467                 f = primitiveValue->getFloatValue();
468             else
469                 return;
470
471             svgstyle->setFillOpacity(f);
472             break;
473         }
474         case SVGCSS_PROP_STROKE_OPACITY:
475         {
476             HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
477             if (!primitiveValue)
478                 return;
479         
480             float f = 0.0f;    
481             int type = primitiveValue->primitiveType();
482             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
483                 f = primitiveValue->getFloatValue() / 100.;
484             else if (type == CSSPrimitiveValue::CSS_NUMBER)
485                 f = primitiveValue->getFloatValue();
486             else
487                 return;
488
489             svgstyle->setStrokeOpacity(f);
490             break;
491         }
492         case SVGCSS_PROP_STOP_OPACITY:
493         {
494             HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
495             if (!primitiveValue)
496                 return;
497         
498             float f = 0.0f;    
499             int type = primitiveValue->primitiveType();
500             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
501                 f = primitiveValue->getFloatValue() / 100.;
502             else if (type == CSSPrimitiveValue::CSS_NUMBER)
503                 f = primitiveValue->getFloatValue();
504             else
505                 return;
506
507             svgstyle->setStopOpacity(f);
508             break;
509         }
510         case SVGCSS_PROP_MARKER_START:
511         {
512             HANDLE_INHERIT_AND_INITIAL(startMarker, StartMarker)
513             if (!primitiveValue)
514                 return;
515
516             String s;
517             int type = primitiveValue->primitiveType();
518             if (type == CSSPrimitiveValue::CSS_URI)
519                 s = primitiveValue->getStringValue();
520             else
521                 return;
522
523             svgstyle->setStartMarker(s);
524             break;
525         }
526         case SVGCSS_PROP_MARKER_MID:
527         {
528             HANDLE_INHERIT_AND_INITIAL(midMarker, MidMarker)
529             if (!primitiveValue)
530                 return;
531
532             String s;
533             int type = primitiveValue->primitiveType();
534             if (type == CSSPrimitiveValue::CSS_URI)
535                 s = primitiveValue->getStringValue();
536             else
537                 return;
538
539             svgstyle->setMidMarker(s);
540             break;
541         }
542         case SVGCSS_PROP_MARKER_END:
543         {
544             HANDLE_INHERIT_AND_INITIAL(endMarker, EndMarker)
545             if (!primitiveValue)
546                 return;
547
548             String s;
549             int type = primitiveValue->primitiveType();
550             if (type == CSSPrimitiveValue::CSS_URI)
551                 s = primitiveValue->getStringValue();
552             else
553                 return;
554
555             svgstyle->setEndMarker(s);
556             break;
557         }
558         case SVGCSS_PROP_STROKE_LINECAP:
559         {
560             HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
561             if (!primitiveValue)
562                 break;
563             
564             switch (primitiveValue->getIdent())
565             {
566                 case SVGCSS_VAL_BUTT:
567                     svgstyle->setCapStyle(ButtCap);
568                     break;
569                 case CSS_VAL_ROUND:
570                     svgstyle->setCapStyle(RoundCap);
571                     break;
572                 case CSS_VAL_SQUARE:
573                     svgstyle->setCapStyle(SquareCap);
574                 default:
575                     return;
576             }
577
578             break;
579         }
580         case SVGCSS_PROP_STROKE_MITERLIMIT:
581         {
582             HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
583             if (!primitiveValue)
584                 return;
585
586             float f = 0.0f;
587             int type = primitiveValue->primitiveType();
588             if (type == CSSPrimitiveValue::CSS_NUMBER)
589                 f = primitiveValue->getFloatValue();
590             else
591                 return;
592
593             svgstyle->setStrokeMiterLimit(f);
594             break;
595         }
596         case SVGCSS_PROP_FILTER:
597         {
598             HANDLE_INHERIT_AND_INITIAL(filter, Filter)
599             if (!primitiveValue)
600                 return;
601
602             String s;
603             int type = primitiveValue->primitiveType();
604             if (type == CSSPrimitiveValue::CSS_URI)
605                 s = primitiveValue->getStringValue();
606             else
607                 return;
608             svgstyle->setFilter(s);
609             break;
610         }
611         case SVGCSS_PROP_MASK:
612         {
613             HANDLE_INHERIT_AND_INITIAL(maskElement, MaskElement)
614             if (!primitiveValue)
615                 return;
616
617             String s;
618             int type = primitiveValue->primitiveType();
619             if (type == CSSPrimitiveValue::CSS_URI)
620                 s = primitiveValue->getStringValue();
621             else
622                 return;
623
624             svgstyle->setMaskElement(s);
625             break;
626         }
627         case SVGCSS_PROP_CLIP_PATH:
628         {
629             HANDLE_INHERIT_AND_INITIAL(clipPath, ClipPath)
630             if (!primitiveValue)
631                 return;
632
633             String s;
634             int type = primitiveValue->primitiveType();
635             if (type == CSSPrimitiveValue::CSS_URI)
636                 s = primitiveValue->getStringValue();
637             else
638                 return;
639
640             svgstyle->setClipPath(s);
641             break;
642         }
643         case SVGCSS_PROP_TEXT_ANCHOR:
644         {
645             HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
646             if (!primitiveValue)
647                 break;
648             
649             switch (primitiveValue->getIdent())
650             {
651                 case CSS_VAL_START:
652                     svgstyle->setTextAnchor(TA_START);
653                     break;
654                 case CSS_VAL_MIDDLE:
655                     svgstyle->setTextAnchor(TA_MIDDLE);
656                     break;
657                 case CSS_VAL_END:
658                     svgstyle->setTextAnchor(TA_END);
659                 default:
660                     return;
661             }
662             
663             break;
664         }
665         case SVGCSS_PROP_WRITING_MODE:
666         {
667             HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
668             if (primitiveValue)
669                 svgstyle->setWritingMode((EWritingMode)(primitiveValue->getIdent() - SVGCSS_VAL_LR_TB));
670             break;
671         }       
672 #if 0
673         case CSS_PROP_COLOR: // colors || inherit
674         {
675             Color col;
676             if (isInherit) {
677                 HANDLE_INHERIT_COND(CSS_PROP_COLOR, color, Color)
678                 return;
679             } else if (isInitial)
680                 col = RenderStyle::initialColor();
681             else {
682                 SVGColor *c = static_cast<SVGColor*>(value);
683                 if (!c)
684                     return CSSStyleSelector::applyProperty(id, value);
685                 
686                 col = c->color();
687             }
688         
689             svgstyle->setColor(col);
690             break;
691         }
692 #endif
693         case SVGCSS_PROP_STOP_COLOR:
694         {
695             HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
696
697             SVGColor* c = static_cast<SVGColor*>(value);
698             if (!c)
699                 return CSSStyleSelector::applyProperty(id, value);
700
701             Color col;
702             if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
703                 col = style->color();
704             else
705                 col = c->color();
706             svgstyle->setStopColor(col);
707             break;
708         }
709         case SVGCSS_PROP_FLOOD_OPACITY:
710         {
711             HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
712             if (!primitiveValue)
713                 return;
714
715             float f = 0.0f;
716             int type = primitiveValue->primitiveType();
717             if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
718                 f = primitiveValue->getFloatValue() / 100.;
719             else if (type == CSSPrimitiveValue::CSS_NUMBER)
720                 f = primitiveValue->getFloatValue();
721             else
722                 return;
723
724             svgstyle->setFloodOpacity(f);
725             break;
726         }
727         case SVGCSS_PROP_FLOOD_COLOR:
728         {
729             Color col;
730             if (isInitial)
731                 col = SVGRenderStyle::initialStopColor();
732             else {
733                 SVGColor *c = static_cast<SVGColor*>(value);
734                 if (!c)
735                     return CSSStyleSelector::applyProperty(id, value);
736
737                 if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
738                     col = style->color();
739                 else
740                     col = c->color();
741             }
742
743             svgstyle->setFloodColor(col);
744             break;
745         }
746         default:
747             return;
748     }
749 }
750
751 }
752
753 // vim:ts=4:noet
754 #endif // ENABLE(SVG)