1 /*
2  * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
3  * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
4  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
5  * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
6  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef CSSPrimitiveValueMappings_h
31 #define CSSPrimitiveValueMappings_h
32 
33 #include "ColorSpace.h"
34 #include "CSSPrimitiveValue.h"
35 #include "CSSValueKeywords.h"
36 #include "FontDescription.h"
37 #include "FontSmoothingMode.h"
38 #include "GraphicsTypes.h"
39 #include "Path.h"
40 #include "RenderStyleConstants.h"
41 #include "SVGRenderStyleDefs.h"
42 #include "TextDirection.h"
43 #include "TextOrientation.h"
44 #include "TextRenderingMode.h"
45 #include "ThemeTypes.h"
46 #include "UnicodeBidi.h"
47 
48 namespace WebCore {
49 
CSSPrimitiveValue(EBorderStyle e)50 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderStyle e)
51     : m_type(CSS_IDENT)
52     , m_hasCachedCSSText(false)
53 {
54     switch (e) {
55         case BNONE:
56             m_value.ident = CSSValueNone;
57             break;
58         case BHIDDEN:
59             m_value.ident = CSSValueHidden;
60             break;
61         case INSET:
62             m_value.ident = CSSValueInset;
63             break;
64         case GROOVE:
65             m_value.ident = CSSValueGroove;
66             break;
67         case RIDGE:
68             m_value.ident = CSSValueRidge;
69             break;
70         case OUTSET:
71             m_value.ident = CSSValueOutset;
72             break;
73         case DOTTED:
74             m_value.ident = CSSValueDotted;
75             break;
76         case DASHED:
77             m_value.ident = CSSValueDashed;
78             break;
79         case SOLID:
80             m_value.ident = CSSValueSolid;
81             break;
82         case DOUBLE:
83             m_value.ident = CSSValueDouble;
84             break;
85     }
86 }
87 
EBorderStyle()88 template<> inline CSSPrimitiveValue::operator EBorderStyle() const
89 {
90     return (EBorderStyle)(m_value.ident - CSSValueNone);
91 }
92 
CSSPrimitiveValue(CompositeOperator e)93 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e)
94     : m_type(CSS_IDENT)
95     , m_hasCachedCSSText(false)
96 {
97     switch (e) {
98         case CompositeClear:
99             m_value.ident = CSSValueClear;
100             break;
101         case CompositeCopy:
102             m_value.ident = CSSValueCopy;
103             break;
104         case CompositeSourceOver:
105             m_value.ident = CSSValueSourceOver;
106             break;
107         case CompositeSourceIn:
108             m_value.ident = CSSValueSourceIn;
109             break;
110         case CompositeSourceOut:
111             m_value.ident = CSSValueSourceOut;
112             break;
113         case CompositeSourceAtop:
114             m_value.ident = CSSValueSourceAtop;
115             break;
116         case CompositeDestinationOver:
117             m_value.ident = CSSValueDestinationOver;
118             break;
119         case CompositeDestinationIn:
120             m_value.ident = CSSValueDestinationIn;
121             break;
122         case CompositeDestinationOut:
123             m_value.ident = CSSValueDestinationOut;
124             break;
125         case CompositeDestinationAtop:
126             m_value.ident = CSSValueDestinationAtop;
127             break;
128         case CompositeXOR:
129             m_value.ident = CSSValueXor;
130             break;
131         case CompositePlusDarker:
132             m_value.ident = CSSValuePlusDarker;
133             break;
134         case CompositeHighlight:
135             m_value.ident = CSSValueHighlight;
136             break;
137         case CompositePlusLighter:
138             m_value.ident = CSSValuePlusLighter;
139             break;
140     }
141 }
142 
CompositeOperator()143 template<> inline CSSPrimitiveValue::operator CompositeOperator() const
144 {
145     switch (m_value.ident) {
146         case CSSValueClear:
147             return CompositeClear;
148         case CSSValueCopy:
149             return CompositeCopy;
150         case CSSValueSourceOver:
151             return CompositeSourceOver;
152         case CSSValueSourceIn:
153             return CompositeSourceIn;
154         case CSSValueSourceOut:
155             return CompositeSourceOut;
156         case CSSValueSourceAtop:
157             return CompositeSourceAtop;
158         case CSSValueDestinationOver:
159             return CompositeDestinationOver;
160         case CSSValueDestinationIn:
161             return CompositeDestinationIn;
162         case CSSValueDestinationOut:
163             return CompositeDestinationOut;
164         case CSSValueDestinationAtop:
165             return CompositeDestinationAtop;
166         case CSSValueXor:
167             return CompositeXOR;
168         case CSSValuePlusDarker:
169             return CompositePlusDarker;
170         case CSSValueHighlight:
171             return CompositeHighlight;
172         case CSSValuePlusLighter:
173             return CompositePlusLighter;
174         default:
175             ASSERT_NOT_REACHED();
176             return CompositeClear;
177     }
178 }
179 
CSSPrimitiveValue(ControlPart e)180 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
181     : m_type(CSS_IDENT)
182     , m_hasCachedCSSText(false)
183 {
184     switch (e) {
185         case NoControlPart:
186             m_value.ident = CSSValueNone;
187             break;
188         case CheckboxPart:
189             m_value.ident = CSSValueCheckbox;
190             break;
191         case RadioPart:
192             m_value.ident = CSSValueRadio;
193             break;
194         case PushButtonPart:
195             m_value.ident = CSSValuePushButton;
196             break;
197         case SquareButtonPart:
198             m_value.ident = CSSValueSquareButton;
199             break;
200         case ButtonPart:
201             m_value.ident = CSSValueButton;
202             break;
203         case ButtonBevelPart:
204             m_value.ident = CSSValueButtonBevel;
205             break;
206         case DefaultButtonPart:
207             m_value.ident = CSSValueDefaultButton;
208             break;
209         case InnerSpinButtonPart:
210             m_value.ident = CSSValueInnerSpinButton;
211             break;
212         case ListboxPart:
213             m_value.ident = CSSValueListbox;
214             break;
215         case ListButtonPart:
216 #if ENABLE(DATALIST)
217             m_value.ident = CSSValueListButton;
218 #endif
219             break;
220         case ListItemPart:
221             m_value.ident = CSSValueListitem;
222             break;
223         case MediaFullscreenButtonPart:
224             m_value.ident = CSSValueMediaFullscreenButton;
225             break;
226         case MediaPlayButtonPart:
227             m_value.ident = CSSValueMediaPlayButton;
228             break;
229         case MediaMuteButtonPart:
230             m_value.ident = CSSValueMediaMuteButton;
231             break;
232         case MediaSeekBackButtonPart:
233             m_value.ident = CSSValueMediaSeekBackButton;
234             break;
235         case MediaSeekForwardButtonPart:
236             m_value.ident = CSSValueMediaSeekForwardButton;
237             break;
238         case MediaRewindButtonPart:
239             m_value.ident = CSSValueMediaRewindButton;
240             break;
241         case MediaReturnToRealtimeButtonPart:
242             m_value.ident = CSSValueMediaReturnToRealtimeButton;
243             break;
244         case MediaToggleClosedCaptionsButtonPart:
245             m_value.ident = CSSValueMediaToggleClosedCaptionsButton;
246             break;
247         case MediaSliderPart:
248             m_value.ident = CSSValueMediaSlider;
249             break;
250         case MediaSliderThumbPart:
251             m_value.ident = CSSValueMediaSliderthumb;
252             break;
253         case MediaVolumeSliderContainerPart:
254             m_value.ident = CSSValueMediaVolumeSliderContainer;
255             break;
256         case MediaVolumeSliderPart:
257             m_value.ident = CSSValueMediaVolumeSlider;
258             break;
259         case MediaVolumeSliderMuteButtonPart:
260             m_value.ident = CSSValueMediaVolumeSliderMuteButton;
261             break;
262         case MediaVolumeSliderThumbPart:
263             m_value.ident = CSSValueMediaVolumeSliderthumb;
264             break;
265         case MediaControlsBackgroundPart:
266             m_value.ident = CSSValueMediaControlsBackground;
267             break;
268         case MediaControlsFullscreenBackgroundPart:
269             m_value.ident = CSSValueMediaControlsFullscreenBackground;
270             break;
271         case MediaCurrentTimePart:
272             m_value.ident = CSSValueMediaCurrentTimeDisplay;
273             break;
274         case MediaTimeRemainingPart:
275             m_value.ident = CSSValueMediaTimeRemainingDisplay;
276             break;
277         case MenulistPart:
278             m_value.ident = CSSValueMenulist;
279             break;
280         case MenulistButtonPart:
281             m_value.ident = CSSValueMenulistButton;
282             break;
283         case MenulistTextPart:
284             m_value.ident = CSSValueMenulistText;
285             break;
286         case MenulistTextFieldPart:
287             m_value.ident = CSSValueMenulistTextfield;
288             break;
289         case MeterPart:
290             m_value.ident = CSSValueMeter;
291             break;
292         case RelevancyLevelIndicatorPart:
293             m_value.ident = CSSValueRelevancyLevelIndicator;
294             break;
295         case ContinuousCapacityLevelIndicatorPart:
296             m_value.ident = CSSValueContinuousCapacityLevelIndicator;
297             break;
298         case DiscreteCapacityLevelIndicatorPart:
299             m_value.ident = CSSValueDiscreteCapacityLevelIndicator;
300             break;
301         case RatingLevelIndicatorPart:
302             m_value.ident = CSSValueRatingLevelIndicator;
303             break;
304         case OuterSpinButtonPart:
305             m_value.ident = CSSValueOuterSpinButton;
306             break;
307         case ProgressBarPart:
308 #if ENABLE(PROGRESS_TAG)
309             m_value.ident = CSSValueProgressBar;
310 #endif
311             break;
312         case ProgressBarValuePart:
313 #if ENABLE(PROGRESS_TAG)
314             m_value.ident = CSSValueProgressBarValue;
315 #endif
316             break;
317         case SliderHorizontalPart:
318             m_value.ident = CSSValueSliderHorizontal;
319             break;
320         case SliderVerticalPart:
321             m_value.ident = CSSValueSliderVertical;
322             break;
323         case SliderThumbHorizontalPart:
324             m_value.ident = CSSValueSliderthumbHorizontal;
325             break;
326         case SliderThumbVerticalPart:
327             m_value.ident = CSSValueSliderthumbVertical;
328             break;
329         case CaretPart:
330             m_value.ident = CSSValueCaret;
331             break;
332         case SearchFieldPart:
333             m_value.ident = CSSValueSearchfield;
334             break;
335         case SearchFieldDecorationPart:
336             m_value.ident = CSSValueSearchfieldDecoration;
337             break;
338         case SearchFieldResultsDecorationPart:
339             m_value.ident = CSSValueSearchfieldResultsDecoration;
340             break;
341         case SearchFieldResultsButtonPart:
342             m_value.ident = CSSValueSearchfieldResultsButton;
343             break;
344         case SearchFieldCancelButtonPart:
345             m_value.ident = CSSValueSearchfieldCancelButton;
346             break;
347         case TextFieldPart:
348             m_value.ident = CSSValueTextfield;
349             break;
350         case TextAreaPart:
351             m_value.ident = CSSValueTextarea;
352             break;
353         case CapsLockIndicatorPart:
354             m_value.ident = CSSValueCapsLockIndicator;
355             break;
356         case InputSpeechButtonPart:
357 #if ENABLE(INPUT_SPEECH)
358             m_value.ident = CSSValueWebkitInputSpeechButton;
359 #endif
360             break;
361     }
362 }
363 
ControlPart()364 template<> inline CSSPrimitiveValue::operator ControlPart() const
365 {
366     if (m_value.ident == CSSValueNone)
367         return NoControlPart;
368     else
369         return ControlPart(m_value.ident - CSSValueCheckbox + 1);
370 }
371 
CSSPrimitiveValue(EFillAttachment e)372 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillAttachment e)
373     : m_type(CSS_IDENT)
374     , m_hasCachedCSSText(false)
375 {
376     switch (e) {
377         case ScrollBackgroundAttachment:
378             m_value.ident = CSSValueScroll;
379             break;
380         case LocalBackgroundAttachment:
381             m_value.ident = CSSValueLocal;
382             break;
383         case FixedBackgroundAttachment:
384             m_value.ident = CSSValueFixed;
385             break;
386     }
387 }
388 
EFillAttachment()389 template<> inline CSSPrimitiveValue::operator EFillAttachment() const
390 {
391     switch (m_value.ident) {
392         case CSSValueScroll:
393             return ScrollBackgroundAttachment;
394         case CSSValueLocal:
395             return LocalBackgroundAttachment;
396         case CSSValueFixed:
397             return FixedBackgroundAttachment;
398         default:
399             ASSERT_NOT_REACHED();
400             return ScrollBackgroundAttachment;
401     }
402 }
403 
CSSPrimitiveValue(EFillBox e)404 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e)
405     : m_type(CSS_IDENT)
406     , m_hasCachedCSSText(false)
407 {
408     switch (e) {
409         case BorderFillBox:
410             m_value.ident = CSSValueBorderBox;
411             break;
412         case PaddingFillBox:
413             m_value.ident = CSSValuePaddingBox;
414             break;
415         case ContentFillBox:
416             m_value.ident = CSSValueContentBox;
417             break;
418         case TextFillBox:
419             m_value.ident = CSSValueText;
420             break;
421     }
422 }
423 
EFillBox()424 template<> inline CSSPrimitiveValue::operator EFillBox() const
425 {
426     switch (m_value.ident) {
427         case CSSValueBorder:
428         case CSSValueBorderBox:
429             return BorderFillBox;
430         case CSSValuePadding:
431         case CSSValuePaddingBox:
432             return PaddingFillBox;
433         case CSSValueContent:
434         case CSSValueContentBox:
435             return ContentFillBox;
436         case CSSValueText:
437         case CSSValueWebkitText:
438             return TextFillBox;
439         default:
440             ASSERT_NOT_REACHED();
441             return BorderFillBox;
442     }
443 }
444 
CSSPrimitiveValue(EFillRepeat e)445 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillRepeat e)
446     : m_type(CSS_IDENT)
447     , m_hasCachedCSSText(false)
448 {
449     switch (e) {
450         case RepeatFill:
451             m_value.ident = CSSValueRepeat;
452             break;
453         case NoRepeatFill:
454             m_value.ident = CSSValueNoRepeat;
455             break;
456         case RoundFill:
457             m_value.ident = CSSValueRound;
458             break;
459         case SpaceFill:
460             m_value.ident = CSSValueSpace;
461             break;
462     }
463 }
464 
EFillRepeat()465 template<> inline CSSPrimitiveValue::operator EFillRepeat() const
466 {
467     switch (m_value.ident) {
468         case CSSValueRepeat:
469             return RepeatFill;
470         case CSSValueNoRepeat:
471             return NoRepeatFill;
472         case CSSValueRound:
473             return RoundFill;
474         case CSSValueSpace:
475             return SpaceFill;
476         default:
477             ASSERT_NOT_REACHED();
478             return RepeatFill;
479     }
480 }
481 
CSSPrimitiveValue(EBoxAlignment e)482 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e)
483     : m_type(CSS_IDENT)
484     , m_hasCachedCSSText(false)
485 {
486     switch (e) {
487         case BSTRETCH:
488             m_value.ident = CSSValueStretch;
489             break;
490         case BSTART:
491             m_value.ident = CSSValueStart;
492             break;
493         case BCENTER:
494             m_value.ident = CSSValueCenter;
495             break;
496         case BEND:
497             m_value.ident = CSSValueEnd;
498             break;
499         case BBASELINE:
500             m_value.ident = CSSValueBaseline;
501             break;
502         case BJUSTIFY:
503             m_value.ident = CSSValueJustify;
504             break;
505     }
506 }
507 
EBoxAlignment()508 template<> inline CSSPrimitiveValue::operator EBoxAlignment() const
509 {
510     switch (m_value.ident) {
511         case CSSValueStretch:
512             return BSTRETCH;
513         case CSSValueStart:
514             return BSTART;
515         case CSSValueEnd:
516             return BEND;
517         case CSSValueCenter:
518             return BCENTER;
519         case CSSValueBaseline:
520             return BBASELINE;
521         case CSSValueJustify:
522             return BJUSTIFY;
523         default:
524             ASSERT_NOT_REACHED();
525             return BSTRETCH;
526     }
527 }
528 
CSSPrimitiveValue(EBoxDirection e)529 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDirection e)
530     : m_type(CSS_IDENT)
531     , m_hasCachedCSSText(false)
532 {
533     switch (e) {
534         case BNORMAL:
535             m_value.ident = CSSValueNormal;
536             break;
537         case BREVERSE:
538             m_value.ident = CSSValueReverse;
539             break;
540     }
541 }
542 
EBoxDirection()543 template<> inline CSSPrimitiveValue::operator EBoxDirection() const
544 {
545     switch (m_value.ident) {
546         case CSSValueNormal:
547             return BNORMAL;
548         case CSSValueReverse:
549             return BREVERSE;
550         default:
551             ASSERT_NOT_REACHED();
552             return BNORMAL;
553     }
554 }
555 
CSSPrimitiveValue(EBoxLines e)556 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxLines e)
557     : m_type(CSS_IDENT)
558     , m_hasCachedCSSText(false)
559 {
560     switch (e) {
561         case SINGLE:
562             m_value.ident = CSSValueSingle;
563             break;
564         case MULTIPLE:
565             m_value.ident = CSSValueMultiple;
566             break;
567     }
568 }
569 
EBoxLines()570 template<> inline CSSPrimitiveValue::operator EBoxLines() const
571 {
572     switch (m_value.ident) {
573         case CSSValueSingle:
574             return SINGLE;
575         case CSSValueMultiple:
576             return MULTIPLE;
577         default:
578             ASSERT_NOT_REACHED();
579             return SINGLE;
580     }
581 }
582 
CSSPrimitiveValue(EBoxOrient e)583 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxOrient e)
584     : m_type(CSS_IDENT)
585     , m_hasCachedCSSText(false)
586 {
587     switch (e) {
588         case HORIZONTAL:
589             m_value.ident = CSSValueHorizontal;
590             break;
591         case VERTICAL:
592             m_value.ident = CSSValueVertical;
593             break;
594     }
595 }
596 
EBoxOrient()597 template<> inline CSSPrimitiveValue::operator EBoxOrient() const
598 {
599     switch (m_value.ident) {
600         case CSSValueHorizontal:
601         case CSSValueInlineAxis:
602             return HORIZONTAL;
603         case CSSValueVertical:
604         case CSSValueBlockAxis:
605             return VERTICAL;
606         default:
607             ASSERT_NOT_REACHED();
608             return HORIZONTAL;
609     }
610 }
611 
CSSPrimitiveValue(ECaptionSide e)612 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECaptionSide e)
613     : m_type(CSS_IDENT)
614     , m_hasCachedCSSText(false)
615 {
616     switch (e) {
617         case CAPLEFT:
618             m_value.ident = CSSValueLeft;
619             break;
620         case CAPRIGHT:
621             m_value.ident = CSSValueRight;
622             break;
623         case CAPTOP:
624             m_value.ident = CSSValueTop;
625             break;
626         case CAPBOTTOM:
627             m_value.ident = CSSValueBottom;
628             break;
629     }
630 }
631 
ECaptionSide()632 template<> inline CSSPrimitiveValue::operator ECaptionSide() const
633 {
634     switch (m_value.ident) {
635         case CSSValueLeft:
636             return CAPLEFT;
637         case CSSValueRight:
638             return CAPRIGHT;
639         case CSSValueTop:
640             return CAPTOP;
641         case CSSValueBottom:
642             return CAPBOTTOM;
643         default:
644             ASSERT_NOT_REACHED();
645             return CAPTOP;
646     }
647 }
648 
CSSPrimitiveValue(EClear e)649 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EClear e)
650     : m_type(CSS_IDENT)
651     , m_hasCachedCSSText(false)
652 {
653     switch (e) {
654         case CNONE:
655             m_value.ident = CSSValueNone;
656             break;
657         case CLEFT:
658             m_value.ident = CSSValueLeft;
659             break;
660         case CRIGHT:
661             m_value.ident = CSSValueRight;
662             break;
663         case CBOTH:
664             m_value.ident = CSSValueBoth;
665             break;
666     }
667 }
668 
EClear()669 template<> inline CSSPrimitiveValue::operator EClear() const
670 {
671     switch (m_value.ident) {
672         case CSSValueNone:
673             return CNONE;
674         case CSSValueLeft:
675             return CLEFT;
676         case CSSValueRight:
677             return CRIGHT;
678         case CSSValueBoth:
679             return CBOTH;
680         default:
681             ASSERT_NOT_REACHED();
682             return CNONE;
683     }
684 }
685 
CSSPrimitiveValue(ECursor e)686 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e)
687     : m_type(CSS_IDENT)
688     , m_hasCachedCSSText(false)
689 {
690     switch (e) {
691         case CURSOR_AUTO:
692             m_value.ident = CSSValueAuto;
693             break;
694         case CURSOR_CROSS:
695             m_value.ident = CSSValueCrosshair;
696             break;
697         case CURSOR_DEFAULT:
698             m_value.ident = CSSValueDefault;
699             break;
700         case CURSOR_POINTER:
701             m_value.ident = CSSValuePointer;
702             break;
703         case CURSOR_MOVE:
704             m_value.ident = CSSValueMove;
705             break;
706         case CURSOR_CELL:
707             m_value.ident = CSSValueCell;
708             break;
709         case CURSOR_VERTICAL_TEXT:
710             m_value.ident = CSSValueVerticalText;
711             break;
712         case CURSOR_CONTEXT_MENU:
713             m_value.ident = CSSValueContextMenu;
714             break;
715         case CURSOR_ALIAS:
716             m_value.ident = CSSValueAlias;
717             break;
718         case CURSOR_COPY:
719             m_value.ident = CSSValueCopy;
720             break;
721         case CURSOR_NONE:
722             m_value.ident = CSSValueNone;
723             break;
724         case CURSOR_PROGRESS:
725             m_value.ident = CSSValueProgress;
726             break;
727         case CURSOR_NO_DROP:
728             m_value.ident = CSSValueNoDrop;
729             break;
730         case CURSOR_NOT_ALLOWED:
731             m_value.ident = CSSValueNotAllowed;
732             break;
733         case CURSOR_WEBKIT_ZOOM_IN:
734             m_value.ident = CSSValueWebkitZoomIn;
735             break;
736         case CURSOR_WEBKIT_ZOOM_OUT:
737             m_value.ident = CSSValueWebkitZoomOut;
738             break;
739         case CURSOR_E_RESIZE:
740             m_value.ident = CSSValueEResize;
741             break;
742         case CURSOR_NE_RESIZE:
743             m_value.ident = CSSValueNeResize;
744             break;
745         case CURSOR_NW_RESIZE:
746             m_value.ident = CSSValueNwResize;
747             break;
748         case CURSOR_N_RESIZE:
749             m_value.ident = CSSValueNResize;
750             break;
751         case CURSOR_SE_RESIZE:
752             m_value.ident = CSSValueSeResize;
753             break;
754         case CURSOR_SW_RESIZE:
755             m_value.ident = CSSValueSwResize;
756             break;
757         case CURSOR_S_RESIZE:
758             m_value.ident = CSSValueSResize;
759             break;
760         case CURSOR_W_RESIZE:
761             m_value.ident = CSSValueWResize;
762             break;
763         case CURSOR_EW_RESIZE:
764             m_value.ident = CSSValueEwResize;
765             break;
766         case CURSOR_NS_RESIZE:
767             m_value.ident = CSSValueNsResize;
768             break;
769         case CURSOR_NESW_RESIZE:
770             m_value.ident = CSSValueNeswResize;
771             break;
772         case CURSOR_NWSE_RESIZE:
773             m_value.ident = CSSValueNwseResize;
774             break;
775         case CURSOR_COL_RESIZE:
776             m_value.ident = CSSValueColResize;
777             break;
778         case CURSOR_ROW_RESIZE:
779             m_value.ident = CSSValueRowResize;
780             break;
781         case CURSOR_TEXT:
782             m_value.ident = CSSValueText;
783             break;
784         case CURSOR_WAIT:
785             m_value.ident = CSSValueWait;
786             break;
787         case CURSOR_HELP:
788             m_value.ident = CSSValueHelp;
789             break;
790         case CURSOR_ALL_SCROLL:
791             m_value.ident = CSSValueAllScroll;
792             break;
793         case CURSOR_WEBKIT_GRAB:
794             m_value.ident = CSSValueWebkitGrab;
795             break;
796         case CURSOR_WEBKIT_GRABBING:
797             m_value.ident = CSSValueWebkitGrabbing;
798             break;
799     }
800 }
801 
ECursor()802 template<> inline CSSPrimitiveValue::operator ECursor() const
803 {
804     if (m_value.ident == CSSValueCopy)
805         return CURSOR_COPY;
806     if (m_value.ident == CSSValueNone)
807         return CURSOR_NONE;
808     return static_cast<ECursor>(m_value.ident - CSSValueAuto);
809 }
810 
CSSPrimitiveValue(EDisplay e)811 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
812     : m_type(CSS_IDENT)
813     , m_hasCachedCSSText(false)
814 {
815     switch (e) {
816         case INLINE:
817             m_value.ident = CSSValueInline;
818             break;
819         case BLOCK:
820             m_value.ident = CSSValueBlock;
821             break;
822         case LIST_ITEM:
823             m_value.ident = CSSValueListItem;
824             break;
825         case RUN_IN:
826             m_value.ident = CSSValueRunIn;
827             break;
828         case COMPACT:
829             m_value.ident = CSSValueCompact;
830             break;
831         case INLINE_BLOCK:
832             m_value.ident = CSSValueInlineBlock;
833             break;
834         case TABLE:
835             m_value.ident = CSSValueTable;
836             break;
837         case INLINE_TABLE:
838             m_value.ident = CSSValueInlineTable;
839             break;
840         case TABLE_ROW_GROUP:
841             m_value.ident = CSSValueTableRowGroup;
842             break;
843         case TABLE_HEADER_GROUP:
844             m_value.ident = CSSValueTableHeaderGroup;
845             break;
846         case TABLE_FOOTER_GROUP:
847             m_value.ident = CSSValueTableFooterGroup;
848             break;
849         case TABLE_ROW:
850             m_value.ident = CSSValueTableRow;
851             break;
852         case TABLE_COLUMN_GROUP:
853             m_value.ident = CSSValueTableColumnGroup;
854             break;
855         case TABLE_COLUMN:
856             m_value.ident = CSSValueTableColumn;
857             break;
858         case TABLE_CELL:
859             m_value.ident = CSSValueTableCell;
860             break;
861         case TABLE_CAPTION:
862             m_value.ident = CSSValueTableCaption;
863             break;
864 #if ENABLE(WCSS)
865         case WAP_MARQUEE:
866             m_value.ident = CSSValueWapMarquee;
867             break;
868 #endif
869         case BOX:
870             m_value.ident = CSSValueWebkitBox;
871             break;
872         case INLINE_BOX:
873             m_value.ident = CSSValueWebkitInlineBox;
874             break;
875         case NONE:
876             m_value.ident = CSSValueNone;
877             break;
878     }
879 }
880 
EDisplay()881 template<> inline CSSPrimitiveValue::operator EDisplay() const
882 {
883     if (m_value.ident == CSSValueNone)
884         return NONE;
885     return static_cast<EDisplay>(m_value.ident - CSSValueInline);
886 }
887 
CSSPrimitiveValue(EEmptyCell e)888 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EEmptyCell e)
889     : m_type(CSS_IDENT)
890     , m_hasCachedCSSText(false)
891 {
892     switch (e) {
893         case SHOW:
894             m_value.ident = CSSValueShow;
895             break;
896         case HIDE:
897             m_value.ident = CSSValueHide;
898             break;
899     }
900 }
901 
EEmptyCell()902 template<> inline CSSPrimitiveValue::operator EEmptyCell() const
903 {
904     switch (m_value.ident) {
905         case CSSValueShow:
906             return SHOW;
907         case CSSValueHide:
908             return HIDE;
909         default:
910             ASSERT_NOT_REACHED();
911             return SHOW;
912     }
913 }
914 
CSSPrimitiveValue(EFloat e)915 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
916     : m_type(CSS_IDENT)
917     , m_hasCachedCSSText(false)
918 {
919     switch (e) {
920         case FNONE:
921             m_value.ident = CSSValueNone;
922             break;
923         case FLEFT:
924             m_value.ident = CSSValueLeft;
925             break;
926         case FRIGHT:
927             m_value.ident = CSSValueRight;
928             break;
929     }
930 }
931 
EFloat()932 template<> inline CSSPrimitiveValue::operator EFloat() const
933 {
934     switch (m_value.ident) {
935         case CSSValueLeft:
936             return FLEFT;
937         case CSSValueRight:
938             return FRIGHT;
939         case CSSValueNone:
940         case CSSValueCenter:  // Non-standard CSS value
941             return FNONE;
942         default:
943             ASSERT_NOT_REACHED();
944             return FNONE;
945     }
946 }
947 
CSSPrimitiveValue(EKHTMLLineBreak e)948 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EKHTMLLineBreak e)
949     : m_type(CSS_IDENT)
950     , m_hasCachedCSSText(false)
951 {
952     switch (e) {
953         case LBNORMAL:
954             m_value.ident = CSSValueNormal;
955             break;
956         case AFTER_WHITE_SPACE:
957             m_value.ident = CSSValueAfterWhiteSpace;
958             break;
959     }
960 }
961 
EKHTMLLineBreak()962 template<> inline CSSPrimitiveValue::operator EKHTMLLineBreak() const
963 {
964     switch (m_value.ident) {
965         case CSSValueAfterWhiteSpace:
966             return AFTER_WHITE_SPACE;
967         case CSSValueNormal:
968             return LBNORMAL;
969         default:
970             ASSERT_NOT_REACHED();
971             return LBNORMAL;
972     }
973 }
974 
CSSPrimitiveValue(EListStylePosition e)975 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStylePosition e)
976     : m_type(CSS_IDENT)
977     , m_hasCachedCSSText(false)
978 {
979     switch (e) {
980         case OUTSIDE:
981             m_value.ident = CSSValueOutside;
982             break;
983         case INSIDE:
984             m_value.ident = CSSValueInside;
985             break;
986     }
987 }
988 
EListStylePosition()989 template<> inline CSSPrimitiveValue::operator EListStylePosition() const
990 {
991     return (EListStylePosition)(m_value.ident - CSSValueOutside);
992 }
993 
CSSPrimitiveValue(EListStyleType e)994 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e)
995     : m_type(CSS_IDENT)
996     , m_hasCachedCSSText(false)
997 {
998     switch (e) {
999     case Afar:
1000         m_value.ident = CSSValueAfar;
1001         break;
1002     case Amharic:
1003         m_value.ident = CSSValueAmharic;
1004         break;
1005     case AmharicAbegede:
1006         m_value.ident = CSSValueAmharicAbegede;
1007         break;
1008     case ArabicIndic:
1009         m_value.ident = CSSValueArabicIndic;
1010         break;
1011     case Armenian:
1012         m_value.ident = CSSValueArmenian;
1013         break;
1014     case Asterisks:
1015         m_value.ident = CSSValueAsterisks;
1016         break;
1017     case BinaryListStyle:
1018         m_value.ident = CSSValueBinary;
1019         break;
1020     case Bengali:
1021         m_value.ident = CSSValueBengali;
1022         break;
1023     case Cambodian:
1024         m_value.ident = CSSValueCambodian;
1025         break;
1026     case Circle:
1027         m_value.ident = CSSValueCircle;
1028         break;
1029     case CjkEarthlyBranch:
1030         m_value.ident = CSSValueCjkEarthlyBranch;
1031         break;
1032     case CjkHeavenlyStem:
1033         m_value.ident = CSSValueCjkHeavenlyStem;
1034         break;
1035     case CJKIdeographic:
1036         m_value.ident = CSSValueCjkIdeographic;
1037         break;
1038     case DecimalLeadingZero:
1039         m_value.ident = CSSValueDecimalLeadingZero;
1040         break;
1041     case DecimalListStyle:
1042         m_value.ident = CSSValueDecimal;
1043         break;
1044     case Devanagari:
1045         m_value.ident = CSSValueDevanagari;
1046         break;
1047     case Disc:
1048         m_value.ident = CSSValueDisc;
1049         break;
1050     case Ethiopic:
1051         m_value.ident = CSSValueEthiopic;
1052         break;
1053     case EthiopicAbegede:
1054         m_value.ident = CSSValueEthiopicAbegede;
1055         break;
1056     case EthiopicAbegedeAmEt:
1057         m_value.ident = CSSValueEthiopicAbegedeAmEt;
1058         break;
1059     case EthiopicAbegedeGez:
1060         m_value.ident = CSSValueEthiopicAbegedeGez;
1061         break;
1062     case EthiopicAbegedeTiEr:
1063         m_value.ident = CSSValueEthiopicAbegedeTiEr;
1064         break;
1065     case EthiopicAbegedeTiEt:
1066         m_value.ident = CSSValueEthiopicAbegedeTiEt;
1067         break;
1068     case EthiopicHalehameAaEr:
1069         m_value.ident = CSSValueEthiopicHalehameAaEr;
1070         break;
1071     case EthiopicHalehameAaEt:
1072         m_value.ident = CSSValueEthiopicHalehameAaEt;
1073         break;
1074     case EthiopicHalehameAmEt:
1075         m_value.ident = CSSValueEthiopicHalehameAmEt;
1076         break;
1077     case EthiopicHalehameGez:
1078         m_value.ident = CSSValueEthiopicHalehameGez;
1079         break;
1080     case EthiopicHalehameOmEt:
1081         m_value.ident = CSSValueEthiopicHalehameOmEt;
1082         break;
1083     case EthiopicHalehameSidEt:
1084         m_value.ident = CSSValueEthiopicHalehameSidEt;
1085         break;
1086     case EthiopicHalehameSoEt:
1087         m_value.ident = CSSValueEthiopicHalehameSoEt;
1088         break;
1089     case EthiopicHalehameTiEr:
1090         m_value.ident = CSSValueEthiopicHalehameTiEr;
1091         break;
1092     case EthiopicHalehameTiEt:
1093         m_value.ident = CSSValueEthiopicHalehameTiEt;
1094         break;
1095     case EthiopicHalehameTig:
1096         m_value.ident = CSSValueEthiopicHalehameTig;
1097         break;
1098     case Footnotes:
1099         m_value.ident = CSSValueFootnotes;
1100         break;
1101     case Georgian:
1102         m_value.ident = CSSValueGeorgian;
1103         break;
1104     case Gujarati:
1105         m_value.ident = CSSValueGujarati;
1106         break;
1107     case Gurmukhi:
1108         m_value.ident = CSSValueGurmukhi;
1109         break;
1110     case Hangul:
1111         m_value.ident = CSSValueHangul;
1112         break;
1113     case HangulConsonant:
1114         m_value.ident = CSSValueHangulConsonant;
1115         break;
1116     case Hebrew:
1117         m_value.ident = CSSValueHebrew;
1118         break;
1119     case Hiragana:
1120         m_value.ident = CSSValueHiragana;
1121         break;
1122     case HiraganaIroha:
1123         m_value.ident = CSSValueHiraganaIroha;
1124         break;
1125     case Kannada:
1126         m_value.ident = CSSValueKannada;
1127         break;
1128     case Katakana:
1129         m_value.ident = CSSValueKatakana;
1130         break;
1131     case KatakanaIroha:
1132         m_value.ident = CSSValueKatakanaIroha;
1133         break;
1134     case Khmer:
1135         m_value.ident = CSSValueKhmer;
1136         break;
1137     case Lao:
1138         m_value.ident = CSSValueLao;
1139         break;
1140     case LowerAlpha:
1141         m_value.ident = CSSValueLowerAlpha;
1142         break;
1143     case LowerArmenian:
1144         m_value.ident = CSSValueLowerArmenian;
1145         break;
1146     case LowerGreek:
1147         m_value.ident = CSSValueLowerGreek;
1148         break;
1149     case LowerHexadecimal:
1150         m_value.ident = CSSValueLowerHexadecimal;
1151         break;
1152     case LowerLatin:
1153         m_value.ident = CSSValueLowerLatin;
1154         break;
1155     case LowerNorwegian:
1156         m_value.ident = CSSValueLowerNorwegian;
1157         break;
1158     case LowerRoman:
1159         m_value.ident = CSSValueLowerRoman;
1160         break;
1161     case Malayalam:
1162         m_value.ident = CSSValueMalayalam;
1163         break;
1164     case Mongolian:
1165         m_value.ident = CSSValueMongolian;
1166         break;
1167     case Myanmar:
1168         m_value.ident = CSSValueMyanmar;
1169         break;
1170     case NoneListStyle:
1171         m_value.ident = CSSValueNone;
1172         break;
1173     case Octal:
1174         m_value.ident = CSSValueOctal;
1175         break;
1176     case Oriya:
1177         m_value.ident = CSSValueOriya;
1178         break;
1179     case Oromo:
1180         m_value.ident = CSSValueOromo;
1181         break;
1182     case Persian:
1183         m_value.ident = CSSValuePersian;
1184         break;
1185     case Sidama:
1186         m_value.ident = CSSValueSidama;
1187         break;
1188     case Somali:
1189         m_value.ident = CSSValueSomali;
1190         break;
1191     case Square:
1192         m_value.ident = CSSValueSquare;
1193         break;
1194     case Telugu:
1195         m_value.ident = CSSValueTelugu;
1196         break;
1197     case Thai:
1198         m_value.ident = CSSValueThai;
1199         break;
1200     case Tibetan:
1201         m_value.ident = CSSValueTibetan;
1202         break;
1203     case Tigre:
1204         m_value.ident = CSSValueTigre;
1205         break;
1206     case TigrinyaEr:
1207         m_value.ident = CSSValueTigrinyaEr;
1208         break;
1209     case TigrinyaErAbegede:
1210         m_value.ident = CSSValueTigrinyaErAbegede;
1211         break;
1212     case TigrinyaEt:
1213         m_value.ident = CSSValueTigrinyaEt;
1214         break;
1215     case TigrinyaEtAbegede:
1216         m_value.ident = CSSValueTigrinyaEtAbegede;
1217         break;
1218     case UpperAlpha:
1219         m_value.ident = CSSValueUpperAlpha;
1220         break;
1221     case UpperArmenian:
1222         m_value.ident = CSSValueUpperArmenian;
1223         break;
1224     case UpperGreek:
1225         m_value.ident = CSSValueUpperGreek;
1226         break;
1227     case UpperHexadecimal:
1228         m_value.ident = CSSValueUpperHexadecimal;
1229         break;
1230     case UpperLatin:
1231         m_value.ident = CSSValueUpperLatin;
1232         break;
1233     case UpperNorwegian:
1234         m_value.ident = CSSValueUpperNorwegian;
1235         break;
1236     case UpperRoman:
1237         m_value.ident = CSSValueUpperRoman;
1238         break;
1239     case Urdu:
1240         m_value.ident = CSSValueUrdu;
1241         break;
1242     }
1243 }
1244 
EListStyleType()1245 template<> inline CSSPrimitiveValue::operator EListStyleType() const
1246 {
1247     switch (m_value.ident) {
1248         case CSSValueNone:
1249             return NoneListStyle;
1250         default:
1251             return static_cast<EListStyleType>(m_value.ident - CSSValueDisc);
1252     }
1253 }
1254 
CSSPrimitiveValue(EMarginCollapse e)1255 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarginCollapse e)
1256     : m_type(CSS_IDENT)
1257     , m_hasCachedCSSText(false)
1258 {
1259     switch (e) {
1260         case MCOLLAPSE:
1261             m_value.ident = CSSValueCollapse;
1262             break;
1263         case MSEPARATE:
1264             m_value.ident = CSSValueSeparate;
1265             break;
1266         case MDISCARD:
1267             m_value.ident = CSSValueDiscard;
1268             break;
1269     }
1270 }
1271 
EMarginCollapse()1272 template<> inline CSSPrimitiveValue::operator EMarginCollapse() const
1273 {
1274     switch (m_value.ident) {
1275         case CSSValueCollapse:
1276             return MCOLLAPSE;
1277         case CSSValueSeparate:
1278             return MSEPARATE;
1279         case CSSValueDiscard:
1280             return MDISCARD;
1281         default:
1282             ASSERT_NOT_REACHED();
1283             return MCOLLAPSE;
1284     }
1285 }
1286 
CSSPrimitiveValue(EMarqueeBehavior e)1287 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeBehavior e)
1288     : m_type(CSS_IDENT)
1289     , m_hasCachedCSSText(false)
1290 {
1291     switch (e) {
1292         case MNONE:
1293             m_value.ident = CSSValueNone;
1294             break;
1295         case MSCROLL:
1296             m_value.ident = CSSValueScroll;
1297             break;
1298         case MSLIDE:
1299             m_value.ident = CSSValueSlide;
1300             break;
1301         case MALTERNATE:
1302             m_value.ident = CSSValueAlternate;
1303             break;
1304     }
1305 }
1306 
EMarqueeBehavior()1307 template<> inline CSSPrimitiveValue::operator EMarqueeBehavior() const
1308 {
1309     switch (m_value.ident) {
1310         case CSSValueNone:
1311             return MNONE;
1312         case CSSValueScroll:
1313             return MSCROLL;
1314         case CSSValueSlide:
1315             return MSLIDE;
1316         case CSSValueAlternate:
1317             return MALTERNATE;
1318         default:
1319             ASSERT_NOT_REACHED();
1320             return MNONE;
1321     }
1322 }
1323 
CSSPrimitiveValue(EMarqueeDirection e)1324 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeDirection e)
1325     : m_type(CSS_IDENT)
1326     , m_hasCachedCSSText(false)
1327 {
1328     switch (e) {
1329         case MFORWARD:
1330             m_value.ident = CSSValueForwards;
1331             break;
1332         case MBACKWARD:
1333             m_value.ident = CSSValueBackwards;
1334             break;
1335         case MAUTO:
1336             m_value.ident = CSSValueAuto;
1337             break;
1338         case MUP:
1339             m_value.ident = CSSValueUp;
1340             break;
1341         case MDOWN:
1342             m_value.ident = CSSValueDown;
1343             break;
1344         case MLEFT:
1345             m_value.ident = CSSValueLeft;
1346             break;
1347         case MRIGHT:
1348             m_value.ident = CSSValueRight;
1349             break;
1350     }
1351 }
1352 
EMarqueeDirection()1353 template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const
1354 {
1355     switch (m_value.ident) {
1356         case CSSValueForwards:
1357             return MFORWARD;
1358         case CSSValueBackwards:
1359             return MBACKWARD;
1360         case CSSValueAuto:
1361             return MAUTO;
1362         case CSSValueAhead:
1363         case CSSValueUp: // We don't support vertical languages, so AHEAD just maps to UP.
1364             return MUP;
1365         case CSSValueReverse:
1366         case CSSValueDown: // REVERSE just maps to DOWN, since we don't do vertical text.
1367             return MDOWN;
1368         case CSSValueLeft:
1369             return MLEFT;
1370         case CSSValueRight:
1371             return MRIGHT;
1372         default:
1373             ASSERT_NOT_REACHED();
1374             return MAUTO;
1375     }
1376 }
1377 
CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e)1378 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e)
1379     : m_type(CSS_IDENT)
1380     , m_hasCachedCSSText(false)
1381 {
1382     switch (e) {
1383         case BCNORMAL:
1384             m_value.ident = CSSValueNormal;
1385             break;
1386         case MATCH:
1387             m_value.ident = CSSValueMatch;
1388             break;
1389     }
1390 }
1391 
EMatchNearestMailBlockquoteColor()1392 template<> inline CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor() const
1393 {
1394     switch (m_value.ident) {
1395         case CSSValueNormal:
1396             return BCNORMAL;
1397         case CSSValueMatch:
1398             return MATCH;
1399         default:
1400             ASSERT_NOT_REACHED();
1401             return BCNORMAL;
1402     }
1403 }
1404 
CSSPrimitiveValue(ENBSPMode e)1405 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e)
1406     : m_type(CSS_IDENT)
1407     , m_hasCachedCSSText(false)
1408 {
1409     switch (e) {
1410         case NBNORMAL:
1411             m_value.ident = CSSValueNormal;
1412             break;
1413         case SPACE:
1414             m_value.ident = CSSValueSpace;
1415             break;
1416     }
1417 }
1418 
ENBSPMode()1419 template<> inline CSSPrimitiveValue::operator ENBSPMode() const
1420 {
1421     switch (m_value.ident) {
1422         case CSSValueSpace:
1423             return SPACE;
1424         case CSSValueNormal:
1425             return NBNORMAL;
1426         default:
1427             ASSERT_NOT_REACHED();
1428             return NBNORMAL;
1429     }
1430 }
1431 
CSSPrimitiveValue(EOverflow e)1432 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e)
1433     : m_type(CSS_IDENT)
1434     , m_hasCachedCSSText(false)
1435 {
1436     switch (e) {
1437         case OVISIBLE:
1438             m_value.ident = CSSValueVisible;
1439             break;
1440         case OHIDDEN:
1441             m_value.ident = CSSValueHidden;
1442             break;
1443         case OSCROLL:
1444             m_value.ident = CSSValueScroll;
1445             break;
1446         case OAUTO:
1447             m_value.ident = CSSValueAuto;
1448             break;
1449         case OMARQUEE:
1450             m_value.ident = CSSValueWebkitMarquee;
1451             break;
1452         case OOVERLAY:
1453             m_value.ident = CSSValueOverlay;
1454             break;
1455     }
1456 }
1457 
EOverflow()1458 template<> inline CSSPrimitiveValue::operator EOverflow() const
1459 {
1460     switch (m_value.ident) {
1461         case CSSValueVisible:
1462             return OVISIBLE;
1463         case CSSValueHidden:
1464             return OHIDDEN;
1465         case CSSValueScroll:
1466             return OSCROLL;
1467         case CSSValueAuto:
1468             return OAUTO;
1469         case CSSValueWebkitMarquee:
1470             return OMARQUEE;
1471         case CSSValueOverlay:
1472             return OOVERLAY;
1473         default:
1474             ASSERT_NOT_REACHED();
1475             return OVISIBLE;
1476     }
1477 }
1478 
CSSPrimitiveValue(EPageBreak e)1479 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e)
1480     : m_type(CSS_IDENT)
1481     , m_hasCachedCSSText(false)
1482 {
1483     switch (e) {
1484         case PBAUTO:
1485             m_value.ident = CSSValueAuto;
1486             break;
1487         case PBALWAYS:
1488             m_value.ident = CSSValueAlways;
1489             break;
1490         case PBAVOID:
1491             m_value.ident = CSSValueAvoid;
1492             break;
1493     }
1494 }
1495 
EPageBreak()1496 template<> inline CSSPrimitiveValue::operator EPageBreak() const
1497 {
1498     switch (m_value.ident) {
1499         case CSSValueAuto:
1500             return PBAUTO;
1501         case CSSValueLeft:
1502         case CSSValueRight:
1503         case CSSValueAlways:
1504             return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always."
1505         case CSSValueAvoid:
1506             return PBAVOID;
1507         default:
1508             ASSERT_NOT_REACHED();
1509             return PBAUTO;
1510     }
1511 }
1512 
CSSPrimitiveValue(EPosition e)1513 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e)
1514     : m_type(CSS_IDENT)
1515     , m_hasCachedCSSText(false)
1516 {
1517     switch (e) {
1518         case StaticPosition:
1519             m_value.ident = CSSValueStatic;
1520             break;
1521         case RelativePosition:
1522             m_value.ident = CSSValueRelative;
1523             break;
1524         case AbsolutePosition:
1525             m_value.ident = CSSValueAbsolute;
1526             break;
1527         case FixedPosition:
1528             m_value.ident = CSSValueFixed;
1529             break;
1530     }
1531 }
1532 
EPosition()1533 template<> inline CSSPrimitiveValue::operator EPosition() const
1534 {
1535     switch (m_value.ident) {
1536         case CSSValueStatic:
1537             return StaticPosition;
1538         case CSSValueRelative:
1539             return RelativePosition;
1540         case CSSValueAbsolute:
1541             return AbsolutePosition;
1542         case CSSValueFixed:
1543             return FixedPosition;
1544         default:
1545             ASSERT_NOT_REACHED();
1546             return StaticPosition;
1547     }
1548 }
1549 
CSSPrimitiveValue(EResize e)1550 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EResize e)
1551     : m_type(CSS_IDENT)
1552     , m_hasCachedCSSText(false)
1553 {
1554     switch (e) {
1555         case RESIZE_BOTH:
1556             m_value.ident = CSSValueBoth;
1557             break;
1558         case RESIZE_HORIZONTAL:
1559             m_value.ident = CSSValueHorizontal;
1560             break;
1561         case RESIZE_VERTICAL:
1562             m_value.ident = CSSValueVertical;
1563             break;
1564         case RESIZE_NONE:
1565             m_value.ident = CSSValueNone;
1566             break;
1567     }
1568 }
1569 
EResize()1570 template<> inline CSSPrimitiveValue::operator EResize() const
1571 {
1572     switch (m_value.ident) {
1573         case CSSValueBoth:
1574             return RESIZE_BOTH;
1575         case CSSValueHorizontal:
1576             return RESIZE_HORIZONTAL;
1577         case CSSValueVertical:
1578             return RESIZE_VERTICAL;
1579         case CSSValueAuto:
1580             ASSERT_NOT_REACHED(); // Depends on settings, thus should be handled by the caller.
1581             return RESIZE_NONE;
1582         case CSSValueNone:
1583             return RESIZE_NONE;
1584         default:
1585             ASSERT_NOT_REACHED();
1586             return RESIZE_NONE;
1587     }
1588 }
1589 
CSSPrimitiveValue(ETableLayout e)1590 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETableLayout e)
1591     : m_type(CSS_IDENT)
1592     , m_hasCachedCSSText(false)
1593 {
1594     switch (e) {
1595         case TAUTO:
1596             m_value.ident = CSSValueAuto;
1597             break;
1598         case TFIXED:
1599             m_value.ident = CSSValueFixed;
1600             break;
1601     }
1602 }
1603 
ETableLayout()1604 template<> inline CSSPrimitiveValue::operator ETableLayout() const
1605 {
1606     switch (m_value.ident) {
1607         case CSSValueFixed:
1608             return TFIXED;
1609         case CSSValueAuto:
1610             return TAUTO;
1611         default:
1612             ASSERT_NOT_REACHED();
1613             return TAUTO;
1614     }
1615 }
1616 
CSSPrimitiveValue(ETextAlign e)1617 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e)
1618     : m_type(CSS_IDENT)
1619     , m_hasCachedCSSText(false)
1620 {
1621     switch (e) {
1622     case TAAUTO:
1623         m_value.ident = CSSValueWebkitAuto;
1624         break;
1625     case TASTART:
1626         m_value.ident = CSSValueStart;
1627         break;
1628     case TAEND:
1629         m_value.ident = CSSValueEnd;
1630         break;
1631     case LEFT:
1632         m_value.ident = CSSValueLeft;
1633         break;
1634     case RIGHT:
1635         m_value.ident = CSSValueRight;
1636         break;
1637     case CENTER:
1638         m_value.ident = CSSValueCenter;
1639         break;
1640     case JUSTIFY:
1641         m_value.ident = CSSValueJustify;
1642         break;
1643     case WEBKIT_LEFT:
1644         m_value.ident = CSSValueWebkitLeft;
1645         break;
1646     case WEBKIT_RIGHT:
1647         m_value.ident = CSSValueWebkitRight;
1648         break;
1649     case WEBKIT_CENTER:
1650         m_value.ident = CSSValueWebkitCenter;
1651         break;
1652     }
1653 }
1654 
ETextAlign()1655 template<> inline CSSPrimitiveValue::operator ETextAlign() const
1656 {
1657     switch (m_value.ident) {
1658         case CSSValueStart:
1659             return TASTART;
1660         case CSSValueEnd:
1661             return TAEND;
1662         default:
1663             return static_cast<ETextAlign>(m_value.ident - CSSValueWebkitAuto);
1664     }
1665 }
1666 
CSSPrimitiveValue(ETextSecurity e)1667 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e)
1668     : m_type(CSS_IDENT)
1669     , m_hasCachedCSSText(false)
1670 {
1671     switch (e) {
1672         case TSNONE:
1673             m_value.ident = CSSValueNone;
1674             break;
1675         case TSDISC:
1676             m_value.ident = CSSValueDisc;
1677             break;
1678         case TSCIRCLE:
1679             m_value.ident = CSSValueCircle;
1680             break;
1681         case TSSQUARE:
1682             m_value.ident = CSSValueSquare;
1683             break;
1684     }
1685 }
1686 
ETextSecurity()1687 template<> inline CSSPrimitiveValue::operator ETextSecurity() const
1688 {
1689     switch (m_value.ident) {
1690         case CSSValueNone:
1691             return TSNONE;
1692         case CSSValueDisc:
1693             return TSDISC;
1694         case CSSValueCircle:
1695             return TSCIRCLE;
1696         case CSSValueSquare:
1697             return TSSQUARE;
1698         default:
1699             ASSERT_NOT_REACHED();
1700             return TSNONE;
1701     }
1702 }
1703 
CSSPrimitiveValue(ETextTransform e)1704 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextTransform e)
1705     : m_type(CSS_IDENT)
1706     , m_hasCachedCSSText(false)
1707 {
1708     switch (e) {
1709         case CAPITALIZE:
1710             m_value.ident = CSSValueCapitalize;
1711             break;
1712         case UPPERCASE:
1713             m_value.ident = CSSValueUppercase;
1714             break;
1715         case LOWERCASE:
1716             m_value.ident = CSSValueLowercase;
1717             break;
1718         case TTNONE:
1719             m_value.ident = CSSValueNone;
1720             break;
1721     }
1722 }
1723 
ETextTransform()1724 template<> inline CSSPrimitiveValue::operator ETextTransform() const
1725 {
1726     switch (m_value.ident) {
1727         case CSSValueCapitalize:
1728             return CAPITALIZE;
1729         case CSSValueUppercase:
1730             return UPPERCASE;
1731         case CSSValueLowercase:
1732             return LOWERCASE;
1733         case CSSValueNone:
1734             return TTNONE;
1735         default:
1736             ASSERT_NOT_REACHED();
1737             return TTNONE;
1738     }
1739 }
1740 
CSSPrimitiveValue(EUnicodeBidi e)1741 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e)
1742     : m_type(CSS_IDENT)
1743     , m_hasCachedCSSText(false)
1744 {
1745     switch (e) {
1746     case UBNormal:
1747         m_value.ident = CSSValueNormal;
1748         break;
1749     case Embed:
1750         m_value.ident = CSSValueEmbed;
1751         break;
1752     case Override:
1753         m_value.ident = CSSValueBidiOverride;
1754         break;
1755     case Isolate:
1756         m_value.ident = CSSValueWebkitIsolate;
1757     }
1758 }
1759 
EUnicodeBidi()1760 template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const
1761 {
1762     switch (m_value.ident) {
1763     case CSSValueNormal:
1764         return UBNormal;
1765     case CSSValueEmbed:
1766         return Embed;
1767     case CSSValueBidiOverride:
1768         return Override;
1769     case CSSValueWebkitIsolate:
1770         return Isolate;
1771     default:
1772         ASSERT_NOT_REACHED();
1773         return UBNormal;
1774     }
1775 }
1776 
CSSPrimitiveValue(EUserDrag e)1777 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserDrag e)
1778     : m_type(CSS_IDENT)
1779     , m_hasCachedCSSText(false)
1780 {
1781     switch (e) {
1782         case DRAG_AUTO:
1783             m_value.ident = CSSValueAuto;
1784             break;
1785         case DRAG_NONE:
1786             m_value.ident = CSSValueNone;
1787             break;
1788         case DRAG_ELEMENT:
1789             m_value.ident = CSSValueElement;
1790             break;
1791     }
1792 }
1793 
EUserDrag()1794 template<> inline CSSPrimitiveValue::operator EUserDrag() const
1795 {
1796     switch (m_value.ident) {
1797         case CSSValueAuto:
1798             return DRAG_AUTO;
1799         case CSSValueNone:
1800             return DRAG_NONE;
1801         case CSSValueElement:
1802             return DRAG_ELEMENT;
1803         default:
1804             ASSERT_NOT_REACHED();
1805             return DRAG_AUTO;
1806     }
1807 }
1808 
CSSPrimitiveValue(EUserModify e)1809 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserModify e)
1810     : m_type(CSS_IDENT)
1811     , m_hasCachedCSSText(false)
1812 {
1813     switch (e) {
1814         case READ_ONLY:
1815             m_value.ident = CSSValueReadOnly;
1816             break;
1817         case READ_WRITE:
1818             m_value.ident = CSSValueReadWrite;
1819             break;
1820         case READ_WRITE_PLAINTEXT_ONLY:
1821             m_value.ident = CSSValueReadWritePlaintextOnly;
1822             break;
1823     }
1824 }
1825 
EUserModify()1826 template<> inline CSSPrimitiveValue::operator EUserModify() const
1827 {
1828     return static_cast<EUserModify>(m_value.ident - CSSValueReadOnly);
1829 }
1830 
CSSPrimitiveValue(EUserSelect e)1831 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e)
1832     : m_type(CSS_IDENT)
1833     , m_hasCachedCSSText(false)
1834 {
1835     switch (e) {
1836         case SELECT_NONE:
1837             m_value.ident = CSSValueNone;
1838             break;
1839         case SELECT_TEXT:
1840             m_value.ident = CSSValueText;
1841             break;
1842     }
1843 }
1844 
EUserSelect()1845 template<> inline CSSPrimitiveValue::operator EUserSelect() const
1846 {
1847     switch (m_value.ident) {
1848         case CSSValueAuto:
1849             return SELECT_TEXT;
1850         case CSSValueNone:
1851             return SELECT_NONE;
1852         case CSSValueText:
1853             return SELECT_TEXT;
1854         default:
1855             ASSERT_NOT_REACHED();
1856             return SELECT_TEXT;
1857     }
1858 }
1859 
CSSPrimitiveValue(EVisibility e)1860 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e)
1861     : m_type(CSS_IDENT)
1862     , m_hasCachedCSSText(false)
1863 {
1864     switch (e) {
1865         case VISIBLE:
1866             m_value.ident = CSSValueVisible;
1867             break;
1868         case HIDDEN:
1869             m_value.ident = CSSValueHidden;
1870             break;
1871         case COLLAPSE:
1872             m_value.ident = CSSValueCollapse;
1873             break;
1874     }
1875 }
1876 
EVisibility()1877 template<> inline CSSPrimitiveValue::operator EVisibility() const
1878 {
1879     switch (m_value.ident) {
1880         case CSSValueHidden:
1881             return HIDDEN;
1882         case CSSValueVisible:
1883             return VISIBLE;
1884         case CSSValueCollapse:
1885             return COLLAPSE;
1886         default:
1887             ASSERT_NOT_REACHED();
1888             return VISIBLE;
1889     }
1890 }
1891 
CSSPrimitiveValue(EWhiteSpace e)1892 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWhiteSpace e)
1893     : m_type(CSS_IDENT)
1894     , m_hasCachedCSSText(false)
1895 {
1896     switch (e) {
1897         case NORMAL:
1898             m_value.ident = CSSValueNormal;
1899             break;
1900         case PRE:
1901             m_value.ident = CSSValuePre;
1902             break;
1903         case PRE_WRAP:
1904             m_value.ident = CSSValuePreWrap;
1905             break;
1906         case PRE_LINE:
1907             m_value.ident = CSSValuePreLine;
1908             break;
1909         case NOWRAP:
1910             m_value.ident = CSSValueNowrap;
1911             break;
1912         case KHTML_NOWRAP:
1913             m_value.ident = CSSValueWebkitNowrap;
1914             break;
1915     }
1916 }
1917 
EWhiteSpace()1918 template<> inline CSSPrimitiveValue::operator EWhiteSpace() const
1919 {
1920     switch (m_value.ident) {
1921         case CSSValueWebkitNowrap:
1922             return KHTML_NOWRAP;
1923         case CSSValueNowrap:
1924             return NOWRAP;
1925         case CSSValuePre:
1926             return PRE;
1927         case CSSValuePreWrap:
1928             return PRE_WRAP;
1929         case CSSValuePreLine:
1930             return PRE_LINE;
1931         case CSSValueNormal:
1932             return NORMAL;
1933         default:
1934             ASSERT_NOT_REACHED();
1935             return NORMAL;
1936     }
1937 }
1938 
CSSPrimitiveValue(EWordBreak e)1939 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e)
1940     : m_type(CSS_IDENT)
1941     , m_hasCachedCSSText(false)
1942 {
1943     switch (e) {
1944         case NormalWordBreak:
1945             m_value.ident = CSSValueNormal;
1946             break;
1947         case BreakAllWordBreak:
1948             m_value.ident = CSSValueBreakAll;
1949             break;
1950         case BreakWordBreak:
1951             m_value.ident = CSSValueBreakWord;
1952             break;
1953     }
1954 }
1955 
EWordBreak()1956 template<> inline CSSPrimitiveValue::operator EWordBreak() const
1957 {
1958     switch (m_value.ident) {
1959         case CSSValueBreakAll:
1960             return BreakAllWordBreak;
1961         case CSSValueBreakWord:
1962             return BreakWordBreak;
1963         case CSSValueNormal:
1964             return NormalWordBreak;
1965         default:
1966         ASSERT_NOT_REACHED();
1967         return NormalWordBreak;
1968     }
1969 }
1970 
CSSPrimitiveValue(EWordWrap e)1971 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordWrap e)
1972     : m_type(CSS_IDENT)
1973     , m_hasCachedCSSText(false)
1974 {
1975     switch (e) {
1976         case NormalWordWrap:
1977             m_value.ident = CSSValueNormal;
1978             break;
1979         case BreakWordWrap:
1980             m_value.ident = CSSValueBreakWord;
1981             break;
1982     }
1983 }
1984 
EWordWrap()1985 template<> inline CSSPrimitiveValue::operator EWordWrap() const
1986 {
1987     switch (m_value.ident) {
1988         case CSSValueBreakWord:
1989             return BreakWordWrap;
1990         case CSSValueNormal:
1991             return NormalWordWrap;
1992         default:
1993             ASSERT_NOT_REACHED();
1994             return NormalWordWrap;
1995     }
1996 }
1997 
CSSPrimitiveValue(TextDirection e)1998 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e)
1999     : m_type(CSS_IDENT)
2000     , m_hasCachedCSSText(false)
2001 {
2002     switch (e) {
2003         case LTR:
2004             m_value.ident = CSSValueLtr;
2005             break;
2006         case RTL:
2007             m_value.ident = CSSValueRtl;
2008             break;
2009     }
2010 }
2011 
TextDirection()2012 template<> inline CSSPrimitiveValue::operator TextDirection() const
2013 {
2014     switch (m_value.ident) {
2015         case CSSValueLtr:
2016             return LTR;
2017         case CSSValueRtl:
2018             return RTL;
2019         default:
2020             ASSERT_NOT_REACHED();
2021             return LTR;
2022     }
2023 }
2024 
CSSPrimitiveValue(WritingMode e)2025 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WritingMode e)
2026     : m_type(CSS_IDENT)
2027     , m_hasCachedCSSText(false)
2028 {
2029     switch (e) {
2030     case TopToBottomWritingMode:
2031         m_value.ident = CSSValueHorizontalTb;
2032         break;
2033     case RightToLeftWritingMode:
2034         m_value.ident = CSSValueVerticalRl;
2035         break;
2036     case LeftToRightWritingMode:
2037         m_value.ident = CSSValueVerticalLr;
2038         break;
2039     case BottomToTopWritingMode:
2040         m_value.ident = CSSValueHorizontalBt;
2041         break;
2042     }
2043 }
2044 
WritingMode()2045 template<> inline CSSPrimitiveValue::operator WritingMode() const
2046 {
2047     switch (m_value.ident) {
2048     case CSSValueHorizontalTb:
2049         return TopToBottomWritingMode;
2050     case CSSValueVerticalRl:
2051         return RightToLeftWritingMode;
2052     case CSSValueVerticalLr:
2053         return LeftToRightWritingMode;
2054     case CSSValueHorizontalBt:
2055         return BottomToTopWritingMode;
2056     default:
2057         ASSERT_NOT_REACHED();
2058         return TopToBottomWritingMode;
2059     }
2060 }
2061 
CSSPrimitiveValue(TextCombine e)2062 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextCombine e)
2063     : m_type(CSS_IDENT)
2064     , m_hasCachedCSSText(false)
2065 {
2066     switch (e) {
2067     case TextCombineNone:
2068         m_value.ident = CSSValueNone;
2069         break;
2070     case TextCombineHorizontal:
2071         m_value.ident = CSSValueHorizontal;
2072         break;
2073     }
2074 }
2075 
TextCombine()2076 template<> inline CSSPrimitiveValue::operator TextCombine() const
2077 {
2078     switch (m_value.ident) {
2079     case CSSValueNone:
2080         return TextCombineNone;
2081     case CSSValueHorizontal:
2082         return TextCombineHorizontal;
2083     default:
2084         ASSERT_NOT_REACHED();
2085         return TextCombineNone;
2086     }
2087 }
2088 
CSSPrimitiveValue(TextEmphasisPosition position)2089 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisPosition position)
2090     : m_type(CSS_IDENT)
2091     , m_hasCachedCSSText(false)
2092 {
2093     switch (position) {
2094     case TextEmphasisPositionOver:
2095         m_value.ident = CSSValueOver;
2096         break;
2097     case TextEmphasisPositionUnder:
2098         m_value.ident = CSSValueUnder;
2099         break;
2100     }
2101 }
2102 
TextEmphasisPosition()2103 template<> inline CSSPrimitiveValue::operator TextEmphasisPosition() const
2104 {
2105     switch (m_value.ident) {
2106     case CSSValueOver:
2107         return TextEmphasisPositionOver;
2108     case CSSValueUnder:
2109         return TextEmphasisPositionUnder;
2110     default:
2111         ASSERT_NOT_REACHED();
2112         return TextEmphasisPositionOver;
2113     }
2114 }
2115 
CSSPrimitiveValue(TextEmphasisFill fill)2116 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisFill fill)
2117     : m_type(CSS_IDENT)
2118     , m_hasCachedCSSText(false)
2119 {
2120     switch (fill) {
2121     case TextEmphasisFillFilled:
2122         m_value.ident = CSSValueFilled;
2123         break;
2124     case TextEmphasisFillOpen:
2125         m_value.ident = CSSValueOpen;
2126         break;
2127     }
2128 }
2129 
TextEmphasisFill()2130 template<> inline CSSPrimitiveValue::operator TextEmphasisFill() const
2131 {
2132     switch (m_value.ident) {
2133     case CSSValueFilled:
2134         return TextEmphasisFillFilled;
2135     case CSSValueOpen:
2136         return TextEmphasisFillOpen;
2137     default:
2138         ASSERT_NOT_REACHED();
2139         return TextEmphasisFillFilled;
2140     }
2141 }
2142 
CSSPrimitiveValue(TextEmphasisMark mark)2143 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisMark mark)
2144     : m_type(CSS_IDENT)
2145     , m_hasCachedCSSText(false)
2146 {
2147     switch (mark) {
2148     case TextEmphasisMarkDot:
2149         m_value.ident = CSSValueDot;
2150         break;
2151     case TextEmphasisMarkCircle:
2152         m_value.ident = CSSValueCircle;
2153         break;
2154     case TextEmphasisMarkDoubleCircle:
2155         m_value.ident = CSSValueDoubleCircle;
2156         break;
2157     case TextEmphasisMarkTriangle:
2158         m_value.ident = CSSValueTriangle;
2159         break;
2160     case TextEmphasisMarkSesame:
2161         m_value.ident = CSSValueSesame;
2162         break;
2163     case TextEmphasisMarkNone:
2164     case TextEmphasisMarkAuto:
2165     case TextEmphasisMarkCustom:
2166         ASSERT_NOT_REACHED();
2167         m_value.ident = CSSValueNone;
2168         break;
2169     }
2170 }
2171 
TextEmphasisMark()2172 template<> inline CSSPrimitiveValue::operator TextEmphasisMark() const
2173 {
2174     switch (m_value.ident) {
2175     case CSSValueNone:
2176         return TextEmphasisMarkNone;
2177     case CSSValueDot:
2178         return TextEmphasisMarkDot;
2179     case CSSValueCircle:
2180         return TextEmphasisMarkCircle;
2181     case CSSValueDoubleCircle:
2182         return TextEmphasisMarkDoubleCircle;
2183     case CSSValueTriangle:
2184         return TextEmphasisMarkTriangle;
2185     case CSSValueSesame:
2186         return TextEmphasisMarkSesame;
2187     default:
2188         ASSERT_NOT_REACHED();
2189         return TextEmphasisMarkNone;
2190     }
2191 }
2192 
CSSPrimitiveValue(TextOrientation e)2193 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextOrientation e)
2194     : m_type(CSS_IDENT)
2195     , m_hasCachedCSSText(false)
2196 {
2197     switch (e) {
2198     case TextOrientationVerticalRight:
2199         m_value.ident = CSSValueVerticalRight;
2200         break;
2201     case TextOrientationUpright:
2202         m_value.ident = CSSValueUpright;
2203         break;
2204     }
2205 }
2206 
TextOrientation()2207 template<> inline CSSPrimitiveValue::operator TextOrientation() const
2208 {
2209     switch (m_value.ident) {
2210     case CSSValueVerticalRight:
2211         return TextOrientationVerticalRight;
2212     case CSSValueUpright:
2213         return TextOrientationUpright;
2214     default:
2215         ASSERT_NOT_REACHED();
2216         return TextOrientationVerticalRight;
2217     }
2218 }
2219 
CSSPrimitiveValue(EPointerEvents e)2220 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e)
2221     : m_type(CSS_IDENT)
2222     , m_hasCachedCSSText(false)
2223 {
2224     switch (e) {
2225         case PE_NONE:
2226             m_value.ident = CSSValueNone;
2227             break;
2228         case PE_STROKE:
2229             m_value.ident = CSSValueStroke;
2230             break;
2231         case PE_FILL:
2232             m_value.ident = CSSValueFill;
2233             break;
2234         case PE_PAINTED:
2235             m_value.ident = CSSValuePainted;
2236             break;
2237         case PE_VISIBLE:
2238             m_value.ident = CSSValueVisible;
2239             break;
2240         case PE_VISIBLE_STROKE:
2241             m_value.ident = CSSValueVisiblestroke;
2242             break;
2243         case PE_VISIBLE_FILL:
2244             m_value.ident = CSSValueVisiblefill;
2245             break;
2246         case PE_VISIBLE_PAINTED:
2247             m_value.ident = CSSValueVisiblepainted;
2248             break;
2249         case PE_AUTO:
2250             m_value.ident = CSSValueAuto;
2251             break;
2252         case PE_ALL:
2253             m_value.ident = CSSValueAll;
2254             break;
2255     }
2256 }
2257 
EPointerEvents()2258 template<> inline CSSPrimitiveValue::operator EPointerEvents() const
2259 {
2260     switch (m_value.ident) {
2261         case CSSValueAll:
2262             return PE_ALL;
2263         case CSSValueAuto:
2264             return PE_AUTO;
2265         case CSSValueNone:
2266             return PE_NONE;
2267         case CSSValueVisiblepainted:
2268             return PE_VISIBLE_PAINTED;
2269         case CSSValueVisiblefill:
2270             return PE_VISIBLE_FILL;
2271         case CSSValueVisiblestroke:
2272             return PE_VISIBLE_STROKE;
2273         case CSSValueVisible:
2274             return PE_VISIBLE;
2275         case CSSValuePainted:
2276             return PE_PAINTED;
2277         case CSSValueFill:
2278             return PE_FILL;
2279         case CSSValueStroke:
2280             return PE_STROKE;
2281         default:
2282             ASSERT_NOT_REACHED();
2283             return PE_ALL;
2284     }
2285 }
2286 
CSSPrimitiveValue(FontSmoothingMode smoothing)2287 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothingMode smoothing)
2288     : m_type(CSS_IDENT)
2289     , m_hasCachedCSSText(false)
2290 {
2291     switch (smoothing) {
2292     case AutoSmoothing:
2293         m_value.ident = CSSValueAuto;
2294         return;
2295     case NoSmoothing:
2296         m_value.ident = CSSValueNone;
2297         return;
2298     case Antialiased:
2299         m_value.ident = CSSValueAntialiased;
2300         return;
2301     case SubpixelAntialiased:
2302         m_value.ident = CSSValueSubpixelAntialiased;
2303         return;
2304     }
2305 
2306     ASSERT_NOT_REACHED();
2307     m_value.ident = CSSValueAuto;
2308 }
2309 
FontSmoothingMode()2310 template<> inline CSSPrimitiveValue::operator FontSmoothingMode() const
2311 {
2312     switch (m_value.ident) {
2313     case CSSValueAuto:
2314         return AutoSmoothing;
2315     case CSSValueNone:
2316         return NoSmoothing;
2317     case CSSValueAntialiased:
2318         return Antialiased;
2319     case CSSValueSubpixelAntialiased:
2320         return SubpixelAntialiased;
2321     }
2322 
2323     ASSERT_NOT_REACHED();
2324     return AutoSmoothing;
2325 }
2326 
CSSPrimitiveValue(FontItalic italic)2327 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontItalic italic)
2328     : m_type(CSS_IDENT)
2329     , m_hasCachedCSSText(false)
2330 {
2331     switch (italic) {
2332     case FontItalicOff:
2333         m_value.ident = CSSValueNormal;
2334         return;
2335     case FontItalicOn:
2336         m_value.ident = CSSValueItalic;
2337         return;
2338     }
2339 
2340     ASSERT_NOT_REACHED();
2341     m_value.ident = CSSValueNormal;
2342 }
2343 
FontItalic()2344 template<> inline CSSPrimitiveValue::operator FontItalic() const
2345 {
2346     switch (m_value.ident) {
2347     case CSSValueOblique:
2348     // FIXME: oblique is the same as italic for the moment...
2349     case CSSValueItalic:
2350         return FontItalicOn;
2351     case CSSValueNormal:
2352         return FontItalicOff;
2353     }
2354     ASSERT_NOT_REACHED();
2355     return FontItalicOff;
2356 }
2357 
CSSPrimitiveValue(FontSmallCaps smallCaps)2358 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps)
2359     : m_type(CSS_IDENT)
2360     , m_hasCachedCSSText(false)
2361 {
2362     switch (smallCaps) {
2363     case FontSmallCapsOff:
2364         m_value.ident = CSSValueNormal;
2365         return;
2366     case FontSmallCapsOn:
2367         m_value.ident = CSSValueSmallCaps;
2368         return;
2369     }
2370 
2371     ASSERT_NOT_REACHED();
2372     m_value.ident = CSSValueNormal;
2373 }
2374 
FontSmallCaps()2375 template<> inline CSSPrimitiveValue::operator FontSmallCaps() const
2376 {
2377     switch (m_value.ident) {
2378     case CSSValueSmallCaps:
2379         return FontSmallCapsOn;
2380     case CSSValueNormal:
2381         return FontSmallCapsOff;
2382     }
2383     ASSERT_NOT_REACHED();
2384     return FontSmallCapsOff;
2385 }
2386 
CSSPrimitiveValue(TextRenderingMode e)2387 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e)
2388     : m_type(CSS_IDENT)
2389     , m_hasCachedCSSText(false)
2390 {
2391     switch (e) {
2392         case AutoTextRendering:
2393             m_value.ident = CSSValueAuto;
2394             break;
2395         case OptimizeSpeed:
2396             m_value.ident = CSSValueOptimizespeed;
2397             break;
2398         case OptimizeLegibility:
2399             m_value.ident = CSSValueOptimizelegibility;
2400             break;
2401         case GeometricPrecision:
2402             m_value.ident = CSSValueGeometricprecision;
2403             break;
2404     }
2405 }
2406 
TextRenderingMode()2407 template<> inline CSSPrimitiveValue::operator TextRenderingMode() const
2408 {
2409     switch (m_value.ident) {
2410         case CSSValueAuto:
2411             return AutoTextRendering;
2412         case CSSValueOptimizespeed:
2413             return OptimizeSpeed;
2414         case CSSValueOptimizelegibility:
2415             return OptimizeLegibility;
2416         case CSSValueGeometricprecision:
2417             return GeometricPrecision;
2418         default:
2419             ASSERT_NOT_REACHED();
2420             return AutoTextRendering;
2421     }
2422 }
2423 
CSSPrimitiveValue(ColorSpace space)2424 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColorSpace space)
2425     : m_type(CSS_IDENT)
2426     , m_hasCachedCSSText(false)
2427 {
2428     switch (space) {
2429     case ColorSpaceDeviceRGB:
2430         m_value.ident = CSSValueDefault;
2431         break;
2432     case ColorSpaceSRGB:
2433         m_value.ident = CSSValueSrgb;
2434         break;
2435     case ColorSpaceLinearRGB:
2436         // CSS color correction does not support linearRGB yet.
2437         ASSERT_NOT_REACHED();
2438         m_value.ident = CSSValueDefault;
2439         break;
2440     }
2441 }
2442 
ColorSpace()2443 template<> inline CSSPrimitiveValue::operator ColorSpace() const
2444 {
2445     switch (m_value.ident) {
2446     case CSSValueDefault:
2447         return ColorSpaceDeviceRGB;
2448     case CSSValueSrgb:
2449         return ColorSpaceSRGB;
2450     default:
2451         ASSERT_NOT_REACHED();
2452         return ColorSpaceDeviceRGB;
2453     }
2454 }
2455 
CSSPrimitiveValue(Hyphens hyphens)2456 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens)
2457     : m_type(CSS_IDENT)
2458     , m_hasCachedCSSText(false)
2459 {
2460     switch (hyphens) {
2461     case HyphensNone:
2462         m_value.ident = CSSValueNone;
2463         break;
2464     case HyphensManual:
2465         m_value.ident = CSSValueManual;
2466         break;
2467     case HyphensAuto:
2468         m_value.ident = CSSValueAuto;
2469         break;
2470     }
2471 }
2472 
Hyphens()2473 template<> inline CSSPrimitiveValue::operator Hyphens() const
2474 {
2475     switch (m_value.ident) {
2476     case CSSValueNone:
2477         return HyphensNone;
2478     case CSSValueManual:
2479         return HyphensManual;
2480     case CSSValueAuto:
2481         return HyphensAuto;
2482     default:
2483         ASSERT_NOT_REACHED();
2484         return HyphensAuto;
2485     }
2486 }
2487 
CSSPrimitiveValue(ESpeak e)2488 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ESpeak e)
2489     : m_type(CSS_IDENT)
2490     , m_hasCachedCSSText(false)
2491 {
2492     switch (e) {
2493     case SpeakNone:
2494         m_value.ident = CSSValueNone;
2495         break;
2496     case SpeakNormal:
2497         m_value.ident = CSSValueNormal;
2498         break;
2499     case SpeakSpellOut:
2500         m_value.ident = CSSValueSpellOut;
2501         break;
2502     case SpeakDigits:
2503         m_value.ident = CSSValueDigits;
2504         break;
2505     case SpeakLiteralPunctuation:
2506         m_value.ident = CSSValueLiteralPunctuation;
2507         break;
2508     case SpeakNoPunctuation:
2509         m_value.ident = CSSValueNoPunctuation;
2510         break;
2511     }
2512 }
2513 
ESpeak()2514 template<> inline CSSPrimitiveValue::operator ESpeak() const
2515 {
2516     switch (m_value.ident) {
2517     case CSSValueNone:
2518         return SpeakNone;
2519     case CSSValueNormal:
2520         return SpeakNormal;
2521     case CSSValueSpellOut:
2522         return SpeakSpellOut;
2523     case CSSValueDigits:
2524         return SpeakDigits;
2525     case CSSValueLiteralPunctuation:
2526         return SpeakLiteralPunctuation;
2527     case CSSValueNoPunctuation:
2528         return SpeakNoPunctuation;
2529     default:
2530         ASSERT_NOT_REACHED();
2531         return SpeakNormal;
2532     }
2533 }
2534 
2535 #if ENABLE(SVG)
2536 
CSSPrimitiveValue(LineCap e)2537 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
2538     : m_type(CSS_IDENT)
2539     , m_hasCachedCSSText(false)
2540 {
2541     switch (e) {
2542         case ButtCap:
2543             m_value.ident = CSSValueButt;
2544             break;
2545         case RoundCap:
2546             m_value.ident = CSSValueRound;
2547             break;
2548         case SquareCap:
2549             m_value.ident = CSSValueSquare;
2550             break;
2551     }
2552 }
2553 
LineCap()2554 template<> inline CSSPrimitiveValue::operator LineCap() const
2555 {
2556     switch (m_value.ident) {
2557         case CSSValueButt:
2558             return ButtCap;
2559         case CSSValueRound:
2560             return RoundCap;
2561         case CSSValueSquare:
2562             return SquareCap;
2563         default:
2564             ASSERT_NOT_REACHED();
2565             return ButtCap;
2566     }
2567 }
2568 
CSSPrimitiveValue(LineJoin e)2569 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineJoin e)
2570     : m_type(CSS_IDENT)
2571     , m_hasCachedCSSText(false)
2572 {
2573     switch (e) {
2574         case MiterJoin:
2575             m_value.ident = CSSValueMiter;
2576             break;
2577         case RoundJoin:
2578             m_value.ident = CSSValueRound;
2579             break;
2580         case BevelJoin:
2581             m_value.ident = CSSValueBevel;
2582             break;
2583     }
2584 }
2585 
LineJoin()2586 template<> inline CSSPrimitiveValue::operator LineJoin() const
2587 {
2588     switch (m_value.ident) {
2589         case CSSValueMiter:
2590             return MiterJoin;
2591         case CSSValueRound:
2592             return RoundJoin;
2593         case CSSValueBevel:
2594             return BevelJoin;
2595         default:
2596             ASSERT_NOT_REACHED();
2597             return MiterJoin;
2598     }
2599 }
2600 
CSSPrimitiveValue(WindRule e)2601 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WindRule e)
2602     : m_type(CSS_IDENT)
2603     , m_hasCachedCSSText(false)
2604 {
2605     switch (e) {
2606         case RULE_NONZERO:
2607             m_value.ident = CSSValueNonzero;
2608             break;
2609         case RULE_EVENODD:
2610             m_value.ident = CSSValueEvenodd;
2611             break;
2612     }
2613 }
2614 
WindRule()2615 template<> inline CSSPrimitiveValue::operator WindRule() const
2616 {
2617     switch (m_value.ident) {
2618         case CSSValueNonzero:
2619             return RULE_NONZERO;
2620         case CSSValueEvenodd:
2621             return RULE_EVENODD;
2622         default:
2623             ASSERT_NOT_REACHED();
2624             return RULE_NONZERO;
2625     }
2626 }
2627 
2628 
CSSPrimitiveValue(EAlignmentBaseline e)2629 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignmentBaseline e)
2630     : m_type(CSS_IDENT)
2631     , m_hasCachedCSSText(false)
2632 {
2633     switch (e) {
2634         case AB_AUTO:
2635             m_value.ident = CSSValueAuto;
2636             break;
2637         case AB_BASELINE:
2638             m_value.ident = CSSValueBaseline;
2639             break;
2640         case AB_BEFORE_EDGE:
2641             m_value.ident = CSSValueBeforeEdge;
2642             break;
2643         case AB_TEXT_BEFORE_EDGE:
2644             m_value.ident = CSSValueTextBeforeEdge;
2645             break;
2646         case AB_MIDDLE:
2647             m_value.ident = CSSValueMiddle;
2648             break;
2649         case AB_CENTRAL:
2650             m_value.ident = CSSValueCentral;
2651             break;
2652         case AB_AFTER_EDGE:
2653             m_value.ident = CSSValueAfterEdge;
2654             break;
2655         case AB_TEXT_AFTER_EDGE:
2656             m_value.ident = CSSValueTextAfterEdge;
2657             break;
2658         case AB_IDEOGRAPHIC:
2659             m_value.ident = CSSValueIdeographic;
2660             break;
2661         case AB_ALPHABETIC:
2662             m_value.ident = CSSValueAlphabetic;
2663             break;
2664         case AB_HANGING:
2665             m_value.ident = CSSValueHanging;
2666             break;
2667         case AB_MATHEMATICAL:
2668             m_value.ident = CSSValueMathematical;
2669             break;
2670     }
2671 }
2672 
EAlignmentBaseline()2673 template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const
2674 {
2675     switch (m_value.ident) {
2676         case CSSValueAuto:
2677             return AB_AUTO;
2678         case CSSValueBaseline:
2679             return AB_BASELINE;
2680         case CSSValueBeforeEdge:
2681             return AB_BEFORE_EDGE;
2682         case CSSValueTextBeforeEdge:
2683             return AB_TEXT_BEFORE_EDGE;
2684         case CSSValueMiddle:
2685             return AB_MIDDLE;
2686         case CSSValueCentral:
2687             return AB_CENTRAL;
2688         case CSSValueAfterEdge:
2689             return AB_AFTER_EDGE;
2690         case CSSValueTextAfterEdge:
2691             return AB_TEXT_AFTER_EDGE;
2692         case CSSValueIdeographic:
2693             return AB_IDEOGRAPHIC;
2694         case CSSValueAlphabetic:
2695             return AB_ALPHABETIC;
2696         case CSSValueHanging:
2697             return AB_HANGING;
2698         case CSSValueMathematical:
2699             return AB_MATHEMATICAL;
2700         default:
2701             ASSERT_NOT_REACHED();
2702             return AB_AUTO;
2703     }
2704 }
2705 
2706 #endif
2707 
CSSPrimitiveValue(EBorderCollapse e)2708 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderCollapse e)
2709     : m_type(CSS_IDENT)
2710     , m_hasCachedCSSText(false)
2711 {
2712     switch (e) {
2713     case BSEPARATE:
2714         m_value.ident = CSSValueSeparate;
2715         break;
2716     case BCOLLAPSE:
2717         m_value.ident = CSSValueCollapse;
2718         break;
2719     }
2720 }
2721 
EBorderCollapse()2722 template<> inline CSSPrimitiveValue::operator EBorderCollapse() const
2723 {
2724     switch (m_value.ident) {
2725     case CSSValueSeparate:
2726         return BSEPARATE;
2727     case CSSValueCollapse:
2728         return BCOLLAPSE;
2729     default:
2730         ASSERT_NOT_REACHED();
2731         return BSEPARATE;
2732     }
2733 }
2734 
2735 #if ENABLE(SVG)
2736 
CSSPrimitiveValue(EColorInterpolation e)2737 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
2738     : m_type(CSS_IDENT)
2739     , m_hasCachedCSSText(false)
2740 {
2741     switch (e) {
2742         case CI_AUTO:
2743             m_value.ident = CSSValueAuto;
2744             break;
2745         case CI_SRGB:
2746             m_value.ident = CSSValueSrgb;
2747             break;
2748         case CI_LINEARRGB:
2749             m_value.ident = CSSValueLinearrgb;
2750             break;
2751     }
2752 }
2753 
EColorInterpolation()2754 template<> inline CSSPrimitiveValue::operator EColorInterpolation() const
2755 {
2756     switch (m_value.ident) {
2757         case CSSValueSrgb:
2758             return CI_SRGB;
2759         case CSSValueLinearrgb:
2760             return CI_LINEARRGB;
2761         case CSSValueAuto:
2762             return CI_AUTO;
2763         default:
2764             ASSERT_NOT_REACHED();
2765             return CI_AUTO;
2766     }
2767 }
2768 
CSSPrimitiveValue(EColorRendering e)2769 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e)
2770     : m_type(CSS_IDENT)
2771     , m_hasCachedCSSText(false)
2772 {
2773     switch (e) {
2774         case CR_AUTO:
2775             m_value.ident = CSSValueAuto;
2776             break;
2777         case CR_OPTIMIZESPEED:
2778             m_value.ident = CSSValueOptimizespeed;
2779             break;
2780         case CR_OPTIMIZEQUALITY:
2781             m_value.ident = CSSValueOptimizequality;
2782             break;
2783     }
2784 }
2785 
EColorRendering()2786 template<> inline CSSPrimitiveValue::operator EColorRendering() const
2787 {
2788     switch (m_value.ident) {
2789         case CSSValueOptimizespeed:
2790             return CR_OPTIMIZESPEED;
2791         case CSSValueOptimizequality:
2792             return CR_OPTIMIZEQUALITY;
2793         case CSSValueAuto:
2794             return CR_AUTO;
2795         default:
2796             ASSERT_NOT_REACHED();
2797             return CR_AUTO;
2798     }
2799 }
2800 
CSSPrimitiveValue(EDominantBaseline e)2801 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDominantBaseline e)
2802     : m_type(CSS_IDENT)
2803     , m_hasCachedCSSText(false)
2804 {
2805     switch (e) {
2806         case DB_AUTO:
2807             m_value.ident = CSSValueAuto;
2808             break;
2809         case DB_USE_SCRIPT:
2810             m_value.ident = CSSValueUseScript;
2811             break;
2812         case DB_NO_CHANGE:
2813             m_value.ident = CSSValueNoChange;
2814             break;
2815         case DB_RESET_SIZE:
2816             m_value.ident = CSSValueResetSize;
2817             break;
2818         case DB_CENTRAL:
2819             m_value.ident = CSSValueCentral;
2820             break;
2821         case DB_MIDDLE:
2822             m_value.ident = CSSValueMiddle;
2823             break;
2824         case DB_TEXT_BEFORE_EDGE:
2825             m_value.ident = CSSValueTextBeforeEdge;
2826             break;
2827         case DB_TEXT_AFTER_EDGE:
2828             m_value.ident = CSSValueTextAfterEdge;
2829             break;
2830         case DB_IDEOGRAPHIC:
2831             m_value.ident = CSSValueIdeographic;
2832             break;
2833         case DB_ALPHABETIC:
2834             m_value.ident = CSSValueAlphabetic;
2835             break;
2836         case DB_HANGING:
2837             m_value.ident = CSSValueHanging;
2838             break;
2839         case DB_MATHEMATICAL:
2840             m_value.ident = CSSValueMathematical;
2841             break;
2842     }
2843 }
2844 
EDominantBaseline()2845 template<> inline CSSPrimitiveValue::operator EDominantBaseline() const
2846 {
2847     switch (m_value.ident) {
2848         case CSSValueAuto:
2849             return DB_AUTO;
2850         case CSSValueUseScript:
2851             return DB_USE_SCRIPT;
2852         case CSSValueNoChange:
2853             return DB_NO_CHANGE;
2854         case CSSValueResetSize:
2855             return DB_RESET_SIZE;
2856         case CSSValueIdeographic:
2857             return DB_IDEOGRAPHIC;
2858         case CSSValueAlphabetic:
2859             return DB_ALPHABETIC;
2860         case CSSValueHanging:
2861             return DB_HANGING;
2862         case CSSValueMathematical:
2863             return DB_MATHEMATICAL;
2864         case CSSValueCentral:
2865             return DB_CENTRAL;
2866         case CSSValueMiddle:
2867             return DB_MIDDLE;
2868         case CSSValueTextAfterEdge:
2869             return DB_TEXT_AFTER_EDGE;
2870         case CSSValueTextBeforeEdge:
2871             return DB_TEXT_BEFORE_EDGE;
2872         default:
2873             ASSERT_NOT_REACHED();
2874             return DB_AUTO;
2875     }
2876 }
2877 
CSSPrimitiveValue(EImageRendering e)2878 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
2879     : m_type(CSS_IDENT)
2880     , m_hasCachedCSSText(false)
2881 {
2882     switch (e) {
2883         case IR_AUTO:
2884             m_value.ident = CSSValueAuto;
2885             break;
2886         case IR_OPTIMIZESPEED:
2887             m_value.ident = CSSValueOptimizespeed;
2888             break;
2889         case IR_OPTIMIZEQUALITY:
2890             m_value.ident = CSSValueOptimizequality;
2891             break;
2892     }
2893 }
2894 
EImageRendering()2895 template<> inline CSSPrimitiveValue::operator EImageRendering() const
2896 {
2897     switch (m_value.ident) {
2898         case CSSValueAuto:
2899             return IR_AUTO;
2900         case CSSValueOptimizespeed:
2901             return IR_OPTIMIZESPEED;
2902         case CSSValueOptimizequality:
2903             return IR_OPTIMIZEQUALITY;
2904         default:
2905             ASSERT_NOT_REACHED();
2906             return IR_AUTO;
2907     }
2908 }
2909 
CSSPrimitiveValue(EShapeRendering e)2910 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e)
2911     : m_type(CSS_IDENT)
2912     , m_hasCachedCSSText(false)
2913 {
2914     switch (e) {
2915     case SR_AUTO:
2916         m_value.ident = CSSValueAuto;
2917         break;
2918     case SR_OPTIMIZESPEED:
2919         m_value.ident = CSSValueOptimizespeed;
2920         break;
2921     case SR_CRISPEDGES:
2922         m_value.ident = CSSValueCrispedges;
2923         break;
2924     case SR_GEOMETRICPRECISION:
2925         m_value.ident = CSSValueGeometricprecision;
2926         break;
2927     }
2928 }
2929 
EShapeRendering()2930 template<> inline CSSPrimitiveValue::operator EShapeRendering() const
2931 {
2932     switch (m_value.ident) {
2933     case CSSValueAuto:
2934         return SR_AUTO;
2935     case CSSValueOptimizespeed:
2936         return SR_OPTIMIZESPEED;
2937     case CSSValueCrispedges:
2938         return SR_CRISPEDGES;
2939     case CSSValueGeometricprecision:
2940         return SR_GEOMETRICPRECISION;
2941     default:
2942         ASSERT_NOT_REACHED();
2943         return SR_AUTO;
2944     }
2945 }
2946 
CSSPrimitiveValue(ETextAnchor e)2947 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAnchor e)
2948     : m_type(CSS_IDENT)
2949     , m_hasCachedCSSText(false)
2950 {
2951     switch (e) {
2952         case TA_START:
2953             m_value.ident = CSSValueStart;
2954             break;
2955         case TA_MIDDLE:
2956             m_value.ident = CSSValueMiddle;
2957             break;
2958         case TA_END:
2959             m_value.ident = CSSValueEnd;
2960             break;
2961     }
2962 }
2963 
ETextAnchor()2964 template<> inline CSSPrimitiveValue::operator ETextAnchor() const
2965 {
2966     switch (m_value.ident) {
2967         case CSSValueStart:
2968             return TA_START;
2969         case CSSValueMiddle:
2970             return TA_MIDDLE;
2971         case CSSValueEnd:
2972             return TA_END;
2973         default:
2974             ASSERT_NOT_REACHED();
2975             return TA_START;
2976     }
2977 }
2978 
CSSPrimitiveValue(SVGWritingMode e)2979 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(SVGWritingMode e)
2980     : m_type(CSS_IDENT)
2981     , m_hasCachedCSSText(false)
2982 {
2983     switch (e) {
2984         case WM_LRTB:
2985             m_value.ident = CSSValueLrTb;
2986             break;
2987         case WM_LR:
2988             m_value.ident = CSSValueLr;
2989             break;
2990         case WM_RLTB:
2991             m_value.ident = CSSValueRlTb;
2992             break;
2993         case WM_RL:
2994             m_value.ident = CSSValueRl;
2995             break;
2996         case WM_TBRL:
2997             m_value.ident = CSSValueTbRl;
2998             break;
2999         case WM_TB:
3000             m_value.ident = CSSValueTb;
3001             break;
3002     }
3003 }
3004 
SVGWritingMode()3005 template<> inline CSSPrimitiveValue::operator SVGWritingMode() const
3006 {
3007     switch (m_value.ident) {
3008     case CSSValueLrTb:
3009         return WM_LRTB;
3010     case CSSValueLr:
3011         return WM_LR;
3012     case CSSValueRlTb:
3013         return WM_RLTB;
3014     case CSSValueRl:
3015         return WM_RL;
3016     case CSSValueTbRl:
3017         return WM_TBRL;
3018     case CSSValueTb:
3019         return WM_TB;
3020     default:
3021         ASSERT_NOT_REACHED();
3022         return WM_LRTB;
3023     }
3024 }
3025 
CSSPrimitiveValue(EVectorEffect e)3026 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVectorEffect e)
3027     : m_type(CSS_IDENT)
3028     , m_hasCachedCSSText(false)
3029 {
3030     switch (e) {
3031     case VE_NONE:
3032         m_value.ident = CSSValueNone;
3033         break;
3034     case VE_NON_SCALING_STROKE:
3035         m_value.ident = CSSValueNonScalingStroke;
3036         break;
3037     }
3038 }
3039 
EVectorEffect()3040 template<> inline CSSPrimitiveValue::operator EVectorEffect() const
3041 {
3042     switch (m_value.ident) {
3043     case CSSValueNone:
3044         return VE_NONE;
3045     case CSSValueNonScalingStroke:
3046         return VE_NON_SCALING_STROKE;
3047     default:
3048         ASSERT_NOT_REACHED();
3049         return VE_NONE;
3050     }
3051 }
3052 
3053 #endif
3054 
3055 }
3056 
3057 #endif
3058