2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebCore / css / CSSPrimitiveValueMappings.h
blob2cf4a1e3ab388f1e848ee8800d3d16fb2ea5b809
1 /*
2 * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
3 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef CSSPrimitiveValueMappings_h
28 #define CSSPrimitiveValueMappings_h
30 #include "CSSPrimitiveValue.h"
31 #include "CSSValueKeywords.h"
32 #include "RenderStyle.h"
34 namespace WebCore {
36 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderStyle e)
37 : m_type(CSS_IDENT)
39 switch (e) {
40 case BNONE:
41 m_value.ident = CSSValueNone;
42 break;
43 case BHIDDEN:
44 m_value.ident = CSSValueHidden;
45 break;
46 case INSET:
47 m_value.ident = CSSValueInset;
48 break;
49 case GROOVE:
50 m_value.ident = CSSValueGroove;
51 break;
52 case RIDGE:
53 m_value.ident = CSSValueRidge;
54 break;
55 case OUTSET:
56 m_value.ident = CSSValueOutset;
57 break;
58 case DOTTED:
59 m_value.ident = CSSValueDotted;
60 break;
61 case DASHED:
62 m_value.ident = CSSValueDashed;
63 break;
64 case SOLID:
65 m_value.ident = CSSValueSolid;
66 break;
67 case DOUBLE:
68 m_value.ident = CSSValueDouble;
69 break;
73 template<> inline CSSPrimitiveValue::operator EBorderStyle() const
75 return (EBorderStyle)(m_value.ident - CSSValueNone);
78 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e)
79 : m_type(CSS_IDENT)
81 switch (e) {
82 case CompositeClear:
83 m_value.ident = CSSValueClear;
84 break;
85 case CompositeCopy:
86 m_value.ident = CSSValueCopy;
87 break;
88 case CompositeSourceOver:
89 m_value.ident = CSSValueSourceOver;
90 break;
91 case CompositeSourceIn:
92 m_value.ident = CSSValueSourceIn;
93 break;
94 case CompositeSourceOut:
95 m_value.ident = CSSValueSourceOut;
96 break;
97 case CompositeSourceAtop:
98 m_value.ident = CSSValueSourceAtop;
99 break;
100 case CompositeDestinationOver:
101 m_value.ident = CSSValueDestinationOver;
102 break;
103 case CompositeDestinationIn:
104 m_value.ident = CSSValueDestinationIn;
105 break;
106 case CompositeDestinationOut:
107 m_value.ident = CSSValueDestinationOut;
108 break;
109 case CompositeDestinationAtop:
110 m_value.ident = CSSValueDestinationAtop;
111 break;
112 case CompositeXOR:
113 m_value.ident = CSSValueXor;
114 break;
115 case CompositePlusDarker:
116 m_value.ident = CSSValuePlusDarker;
117 break;
118 case CompositeHighlight:
119 m_value.ident = CSSValueHighlight;
120 break;
121 case CompositePlusLighter:
122 m_value.ident = CSSValuePlusLighter;
123 break;
127 template<> inline CSSPrimitiveValue::operator CompositeOperator() const
129 switch (m_value.ident) {
130 case CSSValueClear:
131 return CompositeClear;
132 case CSSValueCopy:
133 return CompositeCopy;
134 case CSSValueSourceOver:
135 return CompositeSourceOver;
136 case CSSValueSourceIn:
137 return CompositeSourceIn;
138 case CSSValueSourceOut:
139 return CompositeSourceOut;
140 case CSSValueSourceAtop:
141 return CompositeSourceAtop;
142 case CSSValueDestinationOver:
143 return CompositeDestinationOver;
144 case CSSValueDestinationIn:
145 return CompositeDestinationIn;
146 case CSSValueDestinationOut:
147 return CompositeDestinationOut;
148 case CSSValueDestinationAtop:
149 return CompositeDestinationAtop;
150 case CSSValueXor:
151 return CompositeXOR;
152 case CSSValuePlusDarker:
153 return CompositePlusDarker;
154 case CSSValueHighlight:
155 return CompositeHighlight;
156 case CSSValuePlusLighter:
157 return CompositePlusLighter;
158 default:
159 ASSERT_NOT_REACHED();
160 return CompositeClear;
164 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
165 : m_type(CSS_IDENT)
167 switch (e) {
168 case NoControlPart:
169 m_value.ident = CSSValueNone;
170 break;
171 case CheckboxPart:
172 m_value.ident = CSSValueCheckbox;
173 break;
174 case RadioPart:
175 m_value.ident = CSSValueRadio;
176 break;
177 case PushButtonPart:
178 m_value.ident = CSSValuePushButton;
179 break;
180 case SquareButtonPart:
181 m_value.ident = CSSValueSquareButton;
182 break;
183 case ButtonPart:
184 m_value.ident = CSSValueButton;
185 break;
186 case ButtonBevelPart:
187 m_value.ident = CSSValueButtonBevel;
188 break;
189 case DefaultButtonPart:
190 m_value.ident = CSSValueDefaultButton;
191 break;
192 case ListboxPart:
193 m_value.ident = CSSValueListbox;
194 break;
195 case ListItemPart:
196 m_value.ident = CSSValueListitem;
197 break;
198 case MediaFullscreenButtonPart:
199 m_value.ident = CSSValueMediaFullscreenButton;
200 break;
201 case MediaPlayButtonPart:
202 m_value.ident = CSSValueMediaPlayButton;
203 break;
204 case MediaMuteButtonPart:
205 m_value.ident = CSSValueMediaMuteButton;
206 break;
207 case MediaSeekBackButtonPart:
208 m_value.ident = CSSValueMediaSeekBackButton;
209 break;
210 case MediaSeekForwardButtonPart:
211 m_value.ident = CSSValueMediaSeekForwardButton;
212 break;
213 case MediaSliderPart:
214 m_value.ident = CSSValueMediaSlider;
215 break;
216 case MediaSliderThumbPart:
217 m_value.ident = CSSValueMediaSliderthumb;
218 break;
219 case MenulistPart:
220 m_value.ident = CSSValueMenulist;
221 break;
222 case MenulistButtonPart:
223 m_value.ident = CSSValueMenulistButton;
224 break;
225 case MenulistTextPart:
226 m_value.ident = CSSValueMenulistText;
227 break;
228 case MenulistTextFieldPart:
229 m_value.ident = CSSValueMenulistTextfield;
230 break;
231 case SliderHorizontalPart:
232 m_value.ident = CSSValueSliderHorizontal;
233 break;
234 case SliderVerticalPart:
235 m_value.ident = CSSValueSliderVertical;
236 break;
237 case SliderThumbHorizontalPart:
238 m_value.ident = CSSValueSliderthumbHorizontal;
239 break;
240 case SliderThumbVerticalPart:
241 m_value.ident = CSSValueSliderthumbVertical;
242 break;
243 case CaretPart:
244 m_value.ident = CSSValueCaret;
245 break;
246 case SearchFieldPart:
247 m_value.ident = CSSValueSearchfield;
248 break;
249 case SearchFieldDecorationPart:
250 m_value.ident = CSSValueSearchfieldDecoration;
251 break;
252 case SearchFieldResultsDecorationPart:
253 m_value.ident = CSSValueSearchfieldResultsDecoration;
254 break;
255 case SearchFieldResultsButtonPart:
256 m_value.ident = CSSValueSearchfieldResultsButton;
257 break;
258 case SearchFieldCancelButtonPart:
259 m_value.ident = CSSValueSearchfieldCancelButton;
260 break;
261 case TextFieldPart:
262 m_value.ident = CSSValueTextfield;
263 break;
264 case TextAreaPart:
265 m_value.ident = CSSValueTextarea;
266 break;
267 case CapsLockIndicatorPart:
268 m_value.ident = CSSValueCapsLockIndicator;
269 break;
273 template<> inline CSSPrimitiveValue::operator ControlPart() const
275 if (m_value.ident == CSSValueNone)
276 return NoControlPart;
277 else
278 return ControlPart(m_value.ident - CSSValueCheckbox + 1);
281 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e)
282 : m_type(CSS_IDENT)
284 switch (e) {
285 case BorderFillBox:
286 m_value.ident = CSSValueBorder;
287 break;
288 case PaddingFillBox:
289 m_value.ident = CSSValuePadding;
290 break;
291 case ContentFillBox:
292 m_value.ident = CSSValueContent;
293 break;
294 case TextFillBox:
295 m_value.ident = CSSValueText;
296 break;
300 template<> inline CSSPrimitiveValue::operator EFillBox() const
302 switch (m_value.ident) {
303 case CSSValueBorder:
304 return BorderFillBox;
305 case CSSValuePadding:
306 return PaddingFillBox;
307 case CSSValueContent:
308 return ContentFillBox;
309 case CSSValueText:
310 return TextFillBox;
311 default:
312 ASSERT_NOT_REACHED();
313 return BorderFillBox;
317 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillRepeat e)
318 : m_type(CSS_IDENT)
320 switch (e) {
321 case RepeatFill:
322 m_value.ident = CSSValueRepeat;
323 break;
324 case RepeatXFill:
325 m_value.ident = CSSValueRepeatX;
326 break;
327 case RepeatYFill:
328 m_value.ident = CSSValueRepeatY;
329 break;
330 case NoRepeatFill:
331 m_value.ident = CSSValueNoRepeat;
332 break;
336 template<> inline CSSPrimitiveValue::operator EFillRepeat() const
338 switch (m_value.ident) {
339 case CSSValueRepeat:
340 return RepeatFill;
341 case CSSValueRepeatX:
342 return RepeatXFill;
343 case CSSValueRepeatY:
344 return RepeatYFill;
345 case CSSValueNoRepeat:
346 return NoRepeatFill;
347 default:
348 ASSERT_NOT_REACHED();
349 return RepeatFill;
353 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e)
354 : m_type(CSS_IDENT)
356 switch (e) {
357 case BSTRETCH:
358 m_value.ident = CSSValueStretch;
359 break;
360 case BSTART:
361 m_value.ident = CSSValueStart;
362 break;
363 case BCENTER:
364 m_value.ident = CSSValueCenter;
365 break;
366 case BEND:
367 m_value.ident = CSSValueEnd;
368 break;
369 case BBASELINE:
370 m_value.ident = CSSValueBaseline;
371 break;
372 case BJUSTIFY:
373 m_value.ident = CSSValueJustify;
374 break;
378 template<> inline CSSPrimitiveValue::operator EBoxAlignment() const
380 switch (m_value.ident) {
381 case CSSValueStretch:
382 return BSTRETCH;
383 case CSSValueStart:
384 return BSTART;
385 case CSSValueEnd:
386 return BEND;
387 case CSSValueCenter:
388 return BCENTER;
389 case CSSValueBaseline:
390 return BBASELINE;
391 case CSSValueJustify:
392 return BJUSTIFY;
393 default:
394 ASSERT_NOT_REACHED();
395 return BSTRETCH;
399 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDirection e)
400 : m_type(CSS_IDENT)
402 switch (e) {
403 case BNORMAL:
404 m_value.ident = CSSValueNormal;
405 break;
406 case BREVERSE:
407 m_value.ident = CSSValueReverse;
408 break;
412 template<> inline CSSPrimitiveValue::operator EBoxDirection() const
414 switch (m_value.ident) {
415 case CSSValueNormal:
416 return BNORMAL;
417 case CSSValueReverse:
418 return BREVERSE;
419 default:
420 ASSERT_NOT_REACHED();
421 return BNORMAL;
425 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxLines e)
426 : m_type(CSS_IDENT)
428 switch (e) {
429 case SINGLE:
430 m_value.ident = CSSValueSingle;
431 break;
432 case MULTIPLE:
433 m_value.ident = CSSValueMultiple;
434 break;
438 template<> inline CSSPrimitiveValue::operator EBoxLines() const
440 switch (m_value.ident) {
441 case CSSValueSingle:
442 return SINGLE;
443 case CSSValueMultiple:
444 return MULTIPLE;
445 default:
446 ASSERT_NOT_REACHED();
447 return SINGLE;
451 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxOrient e)
452 : m_type(CSS_IDENT)
454 switch (e) {
455 case HORIZONTAL:
456 m_value.ident = CSSValueHorizontal;
457 break;
458 case VERTICAL:
459 m_value.ident = CSSValueVertical;
460 break;
464 template<> inline CSSPrimitiveValue::operator EBoxOrient() const
466 switch (m_value.ident) {
467 case CSSValueHorizontal:
468 case CSSValueInlineAxis:
469 return HORIZONTAL;
470 case CSSValueVertical:
471 return VERTICAL;
472 default:
473 ASSERT_NOT_REACHED();
474 return HORIZONTAL;
478 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECaptionSide e)
479 : m_type(CSS_IDENT)
481 switch (e) {
482 case CAPLEFT:
483 m_value.ident = CSSValueLeft;
484 break;
485 case CAPRIGHT:
486 m_value.ident = CSSValueRight;
487 break;
488 case CAPTOP:
489 m_value.ident = CSSValueTop;
490 break;
491 case CAPBOTTOM:
492 m_value.ident = CSSValueBottom;
493 break;
497 template<> inline CSSPrimitiveValue::operator ECaptionSide() const
499 switch (m_value.ident) {
500 case CSSValueLeft:
501 return CAPLEFT;
502 case CSSValueRight:
503 return CAPRIGHT;
504 case CSSValueTop:
505 return CAPTOP;
506 case CSSValueBottom:
507 return CAPBOTTOM;
508 default:
509 ASSERT_NOT_REACHED();
510 return CAPTOP;
514 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EClear e)
515 : m_type(CSS_IDENT)
517 switch (e) {
518 case CNONE:
519 m_value.ident = CSSValueNone;
520 break;
521 case CLEFT:
522 m_value.ident = CSSValueLeft;
523 break;
524 case CRIGHT:
525 m_value.ident = CSSValueRight;
526 break;
527 case CBOTH:
528 m_value.ident = CSSValueBoth;
529 break;
533 template<> inline CSSPrimitiveValue::operator EClear() const
535 switch (m_value.ident) {
536 case CSSValueNone:
537 return CNONE;
538 case CSSValueLeft:
539 return CLEFT;
540 case CSSValueRight:
541 return CRIGHT;
542 case CSSValueBoth:
543 return CBOTH;
544 default:
545 ASSERT_NOT_REACHED();
546 return CNONE;
550 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e)
551 : m_type(CSS_IDENT)
553 switch (e) {
554 case CURSOR_AUTO:
555 m_value.ident = CSSValueAuto;
556 break;
557 case CURSOR_CROSS:
558 m_value.ident = CSSValueCrosshair;
559 break;
560 case CURSOR_DEFAULT:
561 m_value.ident = CSSValueDefault;
562 break;
563 case CURSOR_POINTER:
564 m_value.ident = CSSValuePointer;
565 break;
566 case CURSOR_MOVE:
567 m_value.ident = CSSValueMove;
568 break;
569 case CURSOR_CELL:
570 m_value.ident = CSSValueCell;
571 break;
572 case CURSOR_VERTICAL_TEXT:
573 m_value.ident = CSSValueVerticalText;
574 break;
575 case CURSOR_CONTEXT_MENU:
576 m_value.ident = CSSValueContextMenu;
577 break;
578 case CURSOR_ALIAS:
579 m_value.ident = CSSValueAlias;
580 break;
581 case CURSOR_COPY:
582 m_value.ident = CSSValueCopy;
583 break;
584 case CURSOR_NONE:
585 m_value.ident = CSSValueNone;
586 break;
587 case CURSOR_PROGRESS:
588 m_value.ident = CSSValueProgress;
589 break;
590 case CURSOR_NO_DROP:
591 m_value.ident = CSSValueNoDrop;
592 break;
593 case CURSOR_NOT_ALLOWED:
594 m_value.ident = CSSValueNotAllowed;
595 break;
596 case CURSOR_WEBKIT_ZOOM_IN:
597 m_value.ident = CSSValueWebkitZoomIn;
598 break;
599 case CURSOR_WEBKIT_ZOOM_OUT:
600 m_value.ident = CSSValueWebkitZoomOut;
601 break;
602 case CURSOR_E_RESIZE:
603 m_value.ident = CSSValueEResize;
604 break;
605 case CURSOR_NE_RESIZE:
606 m_value.ident = CSSValueNeResize;
607 break;
608 case CURSOR_NW_RESIZE:
609 m_value.ident = CSSValueNwResize;
610 break;
611 case CURSOR_N_RESIZE:
612 m_value.ident = CSSValueNResize;
613 break;
614 case CURSOR_SE_RESIZE:
615 m_value.ident = CSSValueSeResize;
616 break;
617 case CURSOR_SW_RESIZE:
618 m_value.ident = CSSValueSwResize;
619 break;
620 case CURSOR_S_RESIZE:
621 m_value.ident = CSSValueSResize;
622 break;
623 case CURSOR_W_RESIZE:
624 m_value.ident = CSSValueWResize;
625 break;
626 case CURSOR_EW_RESIZE:
627 m_value.ident = CSSValueEwResize;
628 break;
629 case CURSOR_NS_RESIZE:
630 m_value.ident = CSSValueNsResize;
631 break;
632 case CURSOR_NESW_RESIZE:
633 m_value.ident = CSSValueNeswResize;
634 break;
635 case CURSOR_NWSE_RESIZE:
636 m_value.ident = CSSValueNwseResize;
637 break;
638 case CURSOR_COL_RESIZE:
639 m_value.ident = CSSValueColResize;
640 break;
641 case CURSOR_ROW_RESIZE:
642 m_value.ident = CSSValueRowResize;
643 break;
644 case CURSOR_TEXT:
645 m_value.ident = CSSValueText;
646 break;
647 case CURSOR_WAIT:
648 m_value.ident = CSSValueWait;
649 break;
650 case CURSOR_HELP:
651 m_value.ident = CSSValueHelp;
652 break;
653 case CURSOR_ALL_SCROLL:
654 m_value.ident = CSSValueAllScroll;
655 break;
656 case CURSOR_WEBKIT_GRAB:
657 m_value.ident = CSSValueWebkitGrab;
658 break;
659 case CURSOR_WEBKIT_GRABBING:
660 m_value.ident = CSSValueWebkitGrabbing;
661 break;
665 template<> inline CSSPrimitiveValue::operator ECursor() const
667 if (m_value.ident == CSSValueCopy)
668 return CURSOR_COPY;
669 if (m_value.ident == CSSValueNone)
670 return CURSOR_NONE;
671 return static_cast<ECursor>(m_value.ident - CSSValueAuto);
674 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
675 : m_type(CSS_IDENT)
677 switch (e) {
678 case INLINE:
679 m_value.ident = CSSValueInline;
680 break;
681 case BLOCK:
682 m_value.ident = CSSValueBlock;
683 break;
684 case LIST_ITEM:
685 m_value.ident = CSSValueListItem;
686 break;
687 case RUN_IN:
688 m_value.ident = CSSValueRunIn;
689 break;
690 case COMPACT:
691 m_value.ident = CSSValueCompact;
692 break;
693 case INLINE_BLOCK:
694 m_value.ident = CSSValueInlineBlock;
695 break;
696 case TABLE:
697 m_value.ident = CSSValueTable;
698 break;
699 case INLINE_TABLE:
700 m_value.ident = CSSValueInlineTable;
701 break;
702 case TABLE_ROW_GROUP:
703 m_value.ident = CSSValueTableRowGroup;
704 break;
705 case TABLE_HEADER_GROUP:
706 m_value.ident = CSSValueTableHeaderGroup;
707 break;
708 case TABLE_FOOTER_GROUP:
709 m_value.ident = CSSValueTableFooterGroup;
710 break;
711 case TABLE_ROW:
712 m_value.ident = CSSValueTableRow;
713 break;
714 case TABLE_COLUMN_GROUP:
715 m_value.ident = CSSValueTableColumnGroup;
716 break;
717 case TABLE_COLUMN:
718 m_value.ident = CSSValueTableColumn;
719 break;
720 case TABLE_CELL:
721 m_value.ident = CSSValueTableCell;
722 break;
723 case TABLE_CAPTION:
724 m_value.ident = CSSValueTableCaption;
725 break;
726 case BOX:
727 m_value.ident = CSSValueWebkitBox;
728 break;
729 case INLINE_BOX:
730 m_value.ident = CSSValueWebkitInlineBox;
731 break;
732 case NONE:
733 m_value.ident = CSSValueNone;
734 break;
738 template<> inline CSSPrimitiveValue::operator EDisplay() const
740 if (m_value.ident == CSSValueNone)
741 return NONE;
742 return static_cast<EDisplay>(m_value.ident - CSSValueInline);
745 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EEmptyCell e)
746 : m_type(CSS_IDENT)
748 switch (e) {
749 case SHOW:
750 m_value.ident = CSSValueShow;
751 break;
752 case HIDE:
753 m_value.ident = CSSValueHide;
754 break;
758 template<> inline CSSPrimitiveValue::operator EEmptyCell() const
760 switch (m_value.ident) {
761 case CSSValueShow:
762 return SHOW;
763 case CSSValueHide:
764 return HIDE;
765 default:
766 ASSERT_NOT_REACHED();
767 return SHOW;
771 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
772 : m_type(CSS_IDENT)
774 switch (e) {
775 case FNONE:
776 m_value.ident = CSSValueNone;
777 break;
778 case FLEFT:
779 m_value.ident = CSSValueLeft;
780 break;
781 case FRIGHT:
782 m_value.ident = CSSValueRight;
783 break;
787 template<> inline CSSPrimitiveValue::operator EFloat() const
789 switch (m_value.ident) {
790 case CSSValueLeft:
791 return FLEFT;
792 case CSSValueRight:
793 return FRIGHT;
794 case CSSValueNone:
795 case CSSValueCenter: // Non-standard CSS value
796 return FNONE;
797 default:
798 ASSERT_NOT_REACHED();
799 return FNONE;
803 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EKHTMLLineBreak e)
804 : m_type(CSS_IDENT)
806 switch (e) {
807 case LBNORMAL:
808 m_value.ident = CSSValueNormal;
809 break;
810 case AFTER_WHITE_SPACE:
811 m_value.ident = CSSValueAfterWhiteSpace;
812 break;
816 template<> inline CSSPrimitiveValue::operator EKHTMLLineBreak() const
818 switch (m_value.ident) {
819 case CSSValueAfterWhiteSpace:
820 return AFTER_WHITE_SPACE;
821 case CSSValueNormal:
822 return LBNORMAL;
823 default:
824 ASSERT_NOT_REACHED();
825 return LBNORMAL;
829 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStylePosition e)
830 : m_type(CSS_IDENT)
832 switch (e) {
833 case OUTSIDE:
834 m_value.ident = CSSValueOutside;
835 break;
836 case INSIDE:
837 m_value.ident = CSSValueInside;
838 break;
842 template<> inline CSSPrimitiveValue::operator EListStylePosition() const
844 return (EListStylePosition)(m_value.ident - CSSValueOutside);
847 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e)
848 : m_type(CSS_IDENT)
850 switch (e) {
851 case LNONE:
852 m_value.ident = CSSValueNone;
853 break;
854 case DISC:
855 m_value.ident = CSSValueDisc;
856 break;
857 case CIRCLE:
858 m_value.ident = CSSValueCircle;
859 break;
860 case SQUARE:
861 m_value.ident = CSSValueSquare;
862 break;
863 case LDECIMAL:
864 m_value.ident = CSSValueDecimal;
865 break;
866 case DECIMAL_LEADING_ZERO:
867 m_value.ident = CSSValueDecimalLeadingZero;
868 break;
869 case LOWER_ROMAN:
870 m_value.ident = CSSValueLowerRoman;
871 break;
872 case UPPER_ROMAN:
873 m_value.ident = CSSValueUpperRoman;
874 break;
875 case LOWER_GREEK:
876 m_value.ident = CSSValueLowerGreek;
877 break;
878 case LOWER_ALPHA:
879 m_value.ident = CSSValueLowerAlpha;
880 break;
881 case LOWER_LATIN:
882 m_value.ident = CSSValueLowerLatin;
883 break;
884 case UPPER_ALPHA:
885 m_value.ident = CSSValueUpperAlpha;
886 break;
887 case UPPER_LATIN:
888 m_value.ident = CSSValueUpperLatin;
889 break;
890 case HEBREW:
891 m_value.ident = CSSValueHebrew;
892 break;
893 case ARMENIAN:
894 m_value.ident = CSSValueArmenian;
895 break;
896 case GEORGIAN:
897 m_value.ident = CSSValueGeorgian;
898 break;
899 case CJK_IDEOGRAPHIC:
900 m_value.ident = CSSValueCjkIdeographic;
901 break;
902 case HIRAGANA:
903 m_value.ident = CSSValueHiragana;
904 break;
905 case KATAKANA:
906 m_value.ident = CSSValueKatakana;
907 break;
908 case HIRAGANA_IROHA:
909 m_value.ident = CSSValueHiraganaIroha;
910 break;
911 case KATAKANA_IROHA:
912 m_value.ident = CSSValueKatakanaIroha;
913 break;
917 template<> inline CSSPrimitiveValue::operator EListStyleType() const
919 switch (m_value.ident) {
920 case CSSValueNone:
921 return LNONE;
922 default:
923 return static_cast<EListStyleType>(m_value.ident - CSSValueDisc);
927 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarginCollapse e)
928 : m_type(CSS_IDENT)
930 switch (e) {
931 case MCOLLAPSE:
932 m_value.ident = CSSValueCollapse;
933 break;
934 case MSEPARATE:
935 m_value.ident = CSSValueSeparate;
936 break;
937 case MDISCARD:
938 m_value.ident = CSSValueDiscard;
939 break;
943 template<> inline CSSPrimitiveValue::operator EMarginCollapse() const
945 switch (m_value.ident) {
946 case CSSValueCollapse:
947 return MCOLLAPSE;
948 case CSSValueSeparate:
949 return MSEPARATE;
950 case CSSValueDiscard:
951 return MDISCARD;
952 default:
953 ASSERT_NOT_REACHED();
954 return MCOLLAPSE;
958 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeBehavior e)
959 : m_type(CSS_IDENT)
961 switch (e) {
962 case MNONE:
963 m_value.ident = CSSValueNone;
964 break;
965 case MSCROLL:
966 m_value.ident = CSSValueScroll;
967 break;
968 case MSLIDE:
969 m_value.ident = CSSValueSlide;
970 break;
971 case MALTERNATE:
972 m_value.ident = CSSValueAlternate;
973 break;
977 template<> inline CSSPrimitiveValue::operator EMarqueeBehavior() const
979 switch (m_value.ident) {
980 case CSSValueNone:
981 return MNONE;
982 case CSSValueScroll:
983 return MSCROLL;
984 case CSSValueSlide:
985 return MSLIDE;
986 case CSSValueAlternate:
987 return MALTERNATE;
988 default:
989 ASSERT_NOT_REACHED();
990 return MNONE;
994 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeDirection e)
995 : m_type(CSS_IDENT)
997 switch (e) {
998 case MFORWARD:
999 m_value.ident = CSSValueForwards;
1000 break;
1001 case MBACKWARD:
1002 m_value.ident = CSSValueBackwards;
1003 break;
1004 case MAUTO:
1005 m_value.ident = CSSValueAuto;
1006 break;
1007 case MUP:
1008 m_value.ident = CSSValueUp;
1009 break;
1010 case MDOWN:
1011 m_value.ident = CSSValueDown;
1012 break;
1013 case MLEFT:
1014 m_value.ident = CSSValueLeft;
1015 break;
1016 case MRIGHT:
1017 m_value.ident = CSSValueRight;
1018 break;
1022 template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const
1024 switch (m_value.ident) {
1025 case CSSValueForwards:
1026 return MFORWARD;
1027 case CSSValueBackwards:
1028 return MBACKWARD;
1029 case CSSValueAuto:
1030 return MAUTO;
1031 case CSSValueAhead:
1032 case CSSValueUp: // We don't support vertical languages, so AHEAD just maps to UP.
1033 return MUP;
1034 case CSSValueReverse:
1035 case CSSValueDown: // REVERSE just maps to DOWN, since we don't do vertical text.
1036 return MDOWN;
1037 case CSSValueLeft:
1038 return MLEFT;
1039 case CSSValueRight:
1040 return MRIGHT;
1041 default:
1042 ASSERT_NOT_REACHED();
1043 return MAUTO;
1047 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e)
1048 : m_type(CSS_IDENT)
1050 switch (e) {
1051 case BCNORMAL:
1052 m_value.ident = CSSValueNormal;
1053 break;
1054 case MATCH:
1055 m_value.ident = CSSValueMatch;
1056 break;
1060 template<> inline CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor() const
1062 switch (m_value.ident) {
1063 case CSSValueNormal:
1064 return BCNORMAL;
1065 case CSSValueMatch:
1066 return MATCH;
1067 default:
1068 ASSERT_NOT_REACHED();
1069 return BCNORMAL;
1073 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e)
1074 : m_type(CSS_IDENT)
1076 switch (e) {
1077 case NBNORMAL:
1078 m_value.ident = CSSValueNormal;
1079 break;
1080 case SPACE:
1081 m_value.ident = CSSValueSpace;
1082 break;
1086 template<> inline CSSPrimitiveValue::operator ENBSPMode() const
1088 switch (m_value.ident) {
1089 case CSSValueSpace:
1090 return SPACE;
1091 case CSSValueNormal:
1092 return NBNORMAL;
1093 default:
1094 ASSERT_NOT_REACHED();
1095 return NBNORMAL;
1099 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e)
1100 : m_type(CSS_IDENT)
1102 switch (e) {
1103 case OVISIBLE:
1104 m_value.ident = CSSValueVisible;
1105 break;
1106 case OHIDDEN:
1107 m_value.ident = CSSValueHidden;
1108 break;
1109 case OSCROLL:
1110 m_value.ident = CSSValueScroll;
1111 break;
1112 case OAUTO:
1113 m_value.ident = CSSValueAuto;
1114 break;
1115 case OMARQUEE:
1116 m_value.ident = CSSValueWebkitMarquee;
1117 break;
1118 case OOVERLAY:
1119 m_value.ident = CSSValueOverlay;
1120 break;
1124 template<> inline CSSPrimitiveValue::operator EOverflow() const
1126 switch (m_value.ident) {
1127 case CSSValueVisible:
1128 return OVISIBLE;
1129 case CSSValueHidden:
1130 return OHIDDEN;
1131 case CSSValueScroll:
1132 return OSCROLL;
1133 case CSSValueAuto:
1134 return OAUTO;
1135 case CSSValueWebkitMarquee:
1136 return OMARQUEE;
1137 case CSSValueOverlay:
1138 return OOVERLAY;
1139 default:
1140 ASSERT_NOT_REACHED();
1141 return OVISIBLE;
1145 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e)
1146 : m_type(CSS_IDENT)
1148 switch (e) {
1149 case PBAUTO:
1150 m_value.ident = CSSValueAuto;
1151 break;
1152 case PBALWAYS:
1153 m_value.ident = CSSValueAlways;
1154 break;
1155 case PBAVOID:
1156 m_value.ident = CSSValueAvoid;
1157 break;
1161 template<> inline CSSPrimitiveValue::operator EPageBreak() const
1163 switch (m_value.ident) {
1164 case CSSValueAuto:
1165 return PBAUTO;
1166 case CSSValueLeft:
1167 case CSSValueRight:
1168 case CSSValueAlways:
1169 return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always."
1170 case CSSValueAvoid:
1171 return PBAVOID;
1172 default:
1173 ASSERT_NOT_REACHED();
1174 return PBAUTO;
1178 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e)
1179 : m_type(CSS_IDENT)
1181 switch (e) {
1182 case StaticPosition:
1183 m_value.ident = CSSValueStatic;
1184 break;
1185 case RelativePosition:
1186 m_value.ident = CSSValueRelative;
1187 break;
1188 case AbsolutePosition:
1189 m_value.ident = CSSValueAbsolute;
1190 break;
1191 case FixedPosition:
1192 m_value.ident = CSSValueFixed;
1193 break;
1197 template<> inline CSSPrimitiveValue::operator EPosition() const
1199 switch (m_value.ident) {
1200 case CSSValueStatic:
1201 return StaticPosition;
1202 case CSSValueRelative:
1203 return RelativePosition;
1204 case CSSValueAbsolute:
1205 return AbsolutePosition;
1206 case CSSValueFixed:
1207 return FixedPosition;
1208 default:
1209 ASSERT_NOT_REACHED();
1210 return StaticPosition;
1214 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EResize e)
1215 : m_type(CSS_IDENT)
1217 switch (e) {
1218 case RESIZE_BOTH:
1219 m_value.ident = CSSValueBoth;
1220 break;
1221 case RESIZE_HORIZONTAL:
1222 m_value.ident = CSSValueHorizontal;
1223 break;
1224 case RESIZE_VERTICAL:
1225 m_value.ident = CSSValueVertical;
1226 break;
1227 case RESIZE_NONE:
1228 m_value.ident = CSSValueNone;
1229 break;
1233 template<> inline CSSPrimitiveValue::operator EResize() const
1235 switch (m_value.ident) {
1236 case CSSValueBoth:
1237 return RESIZE_BOTH;
1238 case CSSValueHorizontal:
1239 return RESIZE_HORIZONTAL;
1240 case CSSValueVertical:
1241 return RESIZE_VERTICAL;
1242 case CSSValueAuto:
1243 ASSERT_NOT_REACHED(); // Depends on settings, thus should be handled by the caller.
1244 return RESIZE_NONE;
1245 case CSSValueNone:
1246 return RESIZE_NONE;
1247 default:
1248 ASSERT_NOT_REACHED();
1249 return RESIZE_NONE;
1253 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETableLayout e)
1254 : m_type(CSS_IDENT)
1256 switch (e) {
1257 case TAUTO:
1258 m_value.ident = CSSValueAuto;
1259 break;
1260 case TFIXED:
1261 m_value.ident = CSSValueFixed;
1262 break;
1266 template<> inline CSSPrimitiveValue::operator ETableLayout() const
1268 switch (m_value.ident) {
1269 case CSSValueFixed:
1270 return TFIXED;
1271 case CSSValueAuto:
1272 return TAUTO;
1273 default:
1274 ASSERT_NOT_REACHED();
1275 return TAUTO;
1279 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e)
1280 : m_type(CSS_IDENT)
1282 switch (e) {
1283 case TAAUTO:
1284 m_value.ident = CSSValueAuto;
1285 break;
1286 case LEFT:
1287 m_value.ident = CSSValueLeft;
1288 break;
1289 case RIGHT:
1290 m_value.ident = CSSValueRight;
1291 break;
1292 case CENTER:
1293 m_value.ident = CSSValueCenter;
1294 break;
1295 case JUSTIFY:
1296 m_value.ident = CSSValueJustify;
1297 break;
1298 case WEBKIT_LEFT:
1299 m_value.ident = CSSValueWebkitLeft;
1300 break;
1301 case WEBKIT_RIGHT:
1302 m_value.ident = CSSValueWebkitRight;
1303 break;
1304 case WEBKIT_CENTER:
1305 m_value.ident = CSSValueWebkitCenter;
1306 break;
1310 template<> inline CSSPrimitiveValue::operator ETextAlign() const
1312 switch (m_value.ident) {
1313 case CSSValueStart:
1314 case CSSValueEnd:
1315 ASSERT_NOT_REACHED(); // Depends on direction, thus should be handled by the caller.
1316 return LEFT;
1317 default:
1318 return static_cast<ETextAlign>(m_value.ident - CSSValueWebkitAuto);
1322 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e)
1323 : m_type(CSS_IDENT)
1325 switch (e) {
1326 case TSNONE:
1327 m_value.ident = CSSValueNone;
1328 break;
1329 case TSDISC:
1330 m_value.ident = CSSValueDisc;
1331 break;
1332 case TSCIRCLE:
1333 m_value.ident = CSSValueCircle;
1334 break;
1335 case TSSQUARE:
1336 m_value.ident = CSSValueSquare;
1337 break;
1341 template<> inline CSSPrimitiveValue::operator ETextSecurity() const
1343 switch (m_value.ident) {
1344 case CSSValueNone:
1345 return TSNONE;
1346 case CSSValueDisc:
1347 return TSDISC;
1348 case CSSValueCircle:
1349 return TSCIRCLE;
1350 case CSSValueSquare:
1351 return TSSQUARE;
1352 default:
1353 ASSERT_NOT_REACHED();
1354 return TSNONE;
1358 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextTransform e)
1359 : m_type(CSS_IDENT)
1361 switch (e) {
1362 case CAPITALIZE:
1363 m_value.ident = CSSValueCapitalize;
1364 break;
1365 case UPPERCASE:
1366 m_value.ident = CSSValueUppercase;
1367 break;
1368 case LOWERCASE:
1369 m_value.ident = CSSValueLowercase;
1370 break;
1371 case TTNONE:
1372 m_value.ident = CSSValueNone;
1373 break;
1377 template<> inline CSSPrimitiveValue::operator ETextTransform() const
1379 switch (m_value.ident) {
1380 case CSSValueCapitalize:
1381 return CAPITALIZE;
1382 case CSSValueUppercase:
1383 return UPPERCASE;
1384 case CSSValueLowercase:
1385 return LOWERCASE;
1386 case CSSValueNone:
1387 return TTNONE;
1388 default:
1389 ASSERT_NOT_REACHED();
1390 return TTNONE;
1394 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e)
1395 : m_type(CSS_IDENT)
1397 switch (e) {
1398 case UBNormal:
1399 m_value.ident = CSSValueNormal;
1400 break;
1401 case Embed:
1402 m_value.ident = CSSValueEmbed;
1403 break;
1404 case Override:
1405 m_value.ident = CSSValueBidiOverride;
1406 break;
1410 template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const
1412 switch (m_value.ident) {
1413 case CSSValueNormal:
1414 return UBNormal;
1415 case CSSValueEmbed:
1416 return Embed;
1417 case CSSValueBidiOverride:
1418 return Override;
1419 default:
1420 ASSERT_NOT_REACHED();
1421 return UBNormal;
1425 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserDrag e)
1426 : m_type(CSS_IDENT)
1428 switch (e) {
1429 case DRAG_AUTO:
1430 m_value.ident = CSSValueAuto;
1431 break;
1432 case DRAG_NONE:
1433 m_value.ident = CSSValueNone;
1434 break;
1435 case DRAG_ELEMENT:
1436 m_value.ident = CSSValueElement;
1437 break;
1441 template<> inline CSSPrimitiveValue::operator EUserDrag() const
1443 switch (m_value.ident) {
1444 case CSSValueAuto:
1445 return DRAG_AUTO;
1446 case CSSValueNone:
1447 return DRAG_NONE;
1448 case CSSValueElement:
1449 return DRAG_ELEMENT;
1450 default:
1451 ASSERT_NOT_REACHED();
1452 return DRAG_AUTO;
1456 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserModify e)
1457 : m_type(CSS_IDENT)
1459 switch (e) {
1460 case READ_ONLY:
1461 m_value.ident = CSSValueReadOnly;
1462 break;
1463 case READ_WRITE:
1464 m_value.ident = CSSValueReadWrite;
1465 break;
1466 case READ_WRITE_PLAINTEXT_ONLY:
1467 m_value.ident = CSSValueReadWritePlaintextOnly;
1468 break;
1472 template<> inline CSSPrimitiveValue::operator EUserModify() const
1474 return static_cast<EUserModify>(m_value.ident - CSSValueReadOnly);
1477 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e)
1478 : m_type(CSS_IDENT)
1480 switch (e) {
1481 case SELECT_NONE:
1482 m_value.ident = CSSValueNone;
1483 break;
1484 case SELECT_TEXT:
1485 m_value.ident = CSSValueText;
1486 break;
1490 template<> inline CSSPrimitiveValue::operator EUserSelect() const
1492 switch (m_value.ident) {
1493 case CSSValueAuto:
1494 return SELECT_TEXT;
1495 case CSSValueNone:
1496 return SELECT_NONE;
1497 case CSSValueText:
1498 return SELECT_TEXT;
1499 default:
1500 ASSERT_NOT_REACHED();
1501 return SELECT_TEXT;
1505 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e)
1506 : m_type(CSS_IDENT)
1508 switch (e) {
1509 case VISIBLE:
1510 m_value.ident = CSSValueVisible;
1511 break;
1512 case HIDDEN:
1513 m_value.ident = CSSValueHidden;
1514 break;
1515 case COLLAPSE:
1516 m_value.ident = CSSValueCollapse;
1517 break;
1521 template<> inline CSSPrimitiveValue::operator EVisibility() const
1523 switch (m_value.ident) {
1524 case CSSValueHidden:
1525 return HIDDEN;
1526 case CSSValueVisible:
1527 return VISIBLE;
1528 case CSSValueCollapse:
1529 return COLLAPSE;
1530 default:
1531 ASSERT_NOT_REACHED();
1532 return VISIBLE;
1536 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWhiteSpace e)
1537 : m_type(CSS_IDENT)
1539 switch (e) {
1540 case NORMAL:
1541 m_value.ident = CSSValueNormal;
1542 break;
1543 case PRE:
1544 m_value.ident = CSSValuePre;
1545 break;
1546 case PRE_WRAP:
1547 m_value.ident = CSSValuePreWrap;
1548 break;
1549 case PRE_LINE:
1550 m_value.ident = CSSValuePreLine;
1551 break;
1552 case NOWRAP:
1553 m_value.ident = CSSValueNowrap;
1554 break;
1555 case KHTML_NOWRAP:
1556 m_value.ident = CSSValueWebkitNowrap;
1557 break;
1561 template<> inline CSSPrimitiveValue::operator EWhiteSpace() const
1563 switch (m_value.ident) {
1564 case CSSValueWebkitNowrap:
1565 return KHTML_NOWRAP;
1566 case CSSValueNowrap:
1567 return NOWRAP;
1568 case CSSValuePre:
1569 return PRE;
1570 case CSSValuePreWrap:
1571 return PRE_WRAP;
1572 case CSSValuePreLine:
1573 return PRE_LINE;
1574 case CSSValueNormal:
1575 return NORMAL;
1576 default:
1577 ASSERT_NOT_REACHED();
1578 return NORMAL;
1582 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e)
1583 : m_type(CSS_IDENT)
1585 switch (e) {
1586 case NormalWordBreak:
1587 m_value.ident = CSSValueNormal;
1588 break;
1589 case BreakAllWordBreak:
1590 m_value.ident = CSSValueBreakAll;
1591 break;
1592 case BreakWordBreak:
1593 m_value.ident = CSSValueBreakWord;
1594 break;
1598 template<> inline CSSPrimitiveValue::operator EWordBreak() const
1600 switch (m_value.ident) {
1601 case CSSValueBreakAll:
1602 return BreakAllWordBreak;
1603 case CSSValueBreakWord:
1604 return BreakWordBreak;
1605 case CSSValueNormal:
1606 return NormalWordBreak;
1607 default:
1608 ASSERT_NOT_REACHED();
1609 return NormalWordBreak;
1613 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordWrap e)
1614 : m_type(CSS_IDENT)
1616 switch (e) {
1617 case NormalWordWrap:
1618 m_value.ident = CSSValueNormal;
1619 break;
1620 case BreakWordWrap:
1621 m_value.ident = CSSValueBreakWord;
1622 break;
1626 template<> inline CSSPrimitiveValue::operator EWordWrap() const
1628 switch (m_value.ident) {
1629 case CSSValueBreakWord:
1630 return BreakWordWrap;
1631 case CSSValueNormal:
1632 return NormalWordWrap;
1633 default:
1634 ASSERT_NOT_REACHED();
1635 return NormalWordWrap;
1639 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e)
1640 : m_type(CSS_IDENT)
1642 switch (e) {
1643 case LTR:
1644 m_value.ident = CSSValueLtr;
1645 break;
1646 case RTL:
1647 m_value.ident = CSSValueRtl;
1648 break;
1652 template<> inline CSSPrimitiveValue::operator TextDirection() const
1654 switch (m_value.ident) {
1655 case CSSValueLtr:
1656 return LTR;
1657 case CSSValueRtl:
1658 return RTL;
1659 default:
1660 ASSERT_NOT_REACHED();
1661 return LTR;
1665 #if ENABLE(SVG)
1667 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
1668 : m_type(CSS_IDENT)
1670 switch (e) {
1671 case ButtCap:
1672 m_value.ident = CSSValueButt;
1673 break;
1674 case RoundCap:
1675 m_value.ident = CSSValueRound;
1676 break;
1677 case SquareCap:
1678 m_value.ident = CSSValueSquare;
1679 break;
1683 template<> inline CSSPrimitiveValue::operator LineCap() const
1685 switch (m_value.ident) {
1686 case CSSValueButt:
1687 return ButtCap;
1688 case CSSValueRound:
1689 return RoundCap;
1690 case CSSValueSquare:
1691 return SquareCap;
1692 default:
1693 ASSERT_NOT_REACHED();
1694 return ButtCap;
1698 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineJoin e)
1699 : m_type(CSS_IDENT)
1701 switch (e) {
1702 case MiterJoin:
1703 m_value.ident = CSSValueMiter;
1704 break;
1705 case RoundJoin:
1706 m_value.ident = CSSValueRound;
1707 break;
1708 case BevelJoin:
1709 m_value.ident = CSSValueBevel;
1710 break;
1714 template<> inline CSSPrimitiveValue::operator LineJoin() const
1716 switch (m_value.ident) {
1717 case CSSValueMiter:
1718 return MiterJoin;
1719 case CSSValueRound:
1720 return RoundJoin;
1721 case CSSValueBevel:
1722 return BevelJoin;
1723 default:
1724 ASSERT_NOT_REACHED();
1725 return MiterJoin;
1729 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WindRule e)
1730 : m_type(CSS_IDENT)
1732 switch (e) {
1733 case RULE_NONZERO:
1734 m_value.ident = CSSValueNonzero;
1735 break;
1736 case RULE_EVENODD:
1737 m_value.ident = CSSValueEvenodd;
1738 break;
1742 template<> inline CSSPrimitiveValue::operator WindRule() const
1744 switch (m_value.ident) {
1745 case CSSValueNonzero:
1746 return RULE_NONZERO;
1747 case CSSValueEvenodd:
1748 return RULE_EVENODD;
1749 default:
1750 ASSERT_NOT_REACHED();
1751 return RULE_NONZERO;
1756 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignmentBaseline e)
1757 : m_type(CSS_IDENT)
1759 switch (e) {
1760 case AB_AUTO:
1761 m_value.ident = CSSValueAuto;
1762 break;
1763 case AB_BASELINE:
1764 m_value.ident = CSSValueBaseline;
1765 break;
1766 case AB_BEFORE_EDGE:
1767 m_value.ident = CSSValueBeforeEdge;
1768 break;
1769 case AB_TEXT_BEFORE_EDGE:
1770 m_value.ident = CSSValueTextBeforeEdge;
1771 break;
1772 case AB_MIDDLE:
1773 m_value.ident = CSSValueMiddle;
1774 break;
1775 case AB_CENTRAL:
1776 m_value.ident = CSSValueCentral;
1777 break;
1778 case AB_AFTER_EDGE:
1779 m_value.ident = CSSValueAfterEdge;
1780 break;
1781 case AB_TEXT_AFTER_EDGE:
1782 m_value.ident = CSSValueTextAfterEdge;
1783 break;
1784 case AB_IDEOGRAPHIC:
1785 m_value.ident = CSSValueIdeographic;
1786 break;
1787 case AB_ALPHABETIC:
1788 m_value.ident = CSSValueAlphabetic;
1789 break;
1790 case AB_HANGING:
1791 m_value.ident = CSSValueHanging;
1792 break;
1793 case AB_MATHEMATICAL:
1794 m_value.ident = CSSValueMathematical;
1795 break;
1799 template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const
1801 switch (m_value.ident) {
1802 case CSSValueAuto:
1803 return AB_AUTO;
1804 case CSSValueBaseline:
1805 return AB_BASELINE;
1806 case CSSValueBeforeEdge:
1807 return AB_BEFORE_EDGE;
1808 case CSSValueTextBeforeEdge:
1809 return AB_TEXT_BEFORE_EDGE;
1810 case CSSValueMiddle:
1811 return AB_MIDDLE;
1812 case CSSValueCentral:
1813 return AB_CENTRAL;
1814 case CSSValueAfterEdge:
1815 return AB_AFTER_EDGE;
1816 case CSSValueTextAfterEdge:
1817 return AB_TEXT_AFTER_EDGE;
1818 case CSSValueIdeographic:
1819 return AB_IDEOGRAPHIC;
1820 case CSSValueAlphabetic:
1821 return AB_ALPHABETIC;
1822 case CSSValueHanging:
1823 return AB_HANGING;
1824 case CSSValueMathematical:
1825 return AB_MATHEMATICAL;
1826 default:
1827 ASSERT_NOT_REACHED();
1828 return AB_AUTO;
1832 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
1833 : m_type(CSS_IDENT)
1835 switch (e) {
1836 case CI_AUTO:
1837 m_value.ident = CSSValueAuto;
1838 break;
1839 case CI_SRGB:
1840 m_value.ident = CSSValueSrgb;
1841 break;
1842 case CI_LINEARRGB:
1843 m_value.ident = CSSValueLinearrgb;
1844 break;
1848 template<> inline CSSPrimitiveValue::operator EColorInterpolation() const
1850 switch (m_value.ident) {
1851 case CSSValueSrgb:
1852 return CI_SRGB;
1853 case CSSValueLinearrgb:
1854 return CI_LINEARRGB;
1855 case CSSValueAuto:
1856 return CI_AUTO;
1857 default:
1858 ASSERT_NOT_REACHED();
1859 return CI_AUTO;
1863 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e)
1864 : m_type(CSS_IDENT)
1866 switch (e) {
1867 case CR_AUTO:
1868 m_value.ident = CSSValueAuto;
1869 break;
1870 case CR_OPTIMIZESPEED:
1871 m_value.ident = CSSValueOptimizespeed;
1872 break;
1873 case CR_OPTIMIZEQUALITY:
1874 m_value.ident = CSSValueOptimizequality;
1875 break;
1879 template<> inline CSSPrimitiveValue::operator EColorRendering() const
1881 switch (m_value.ident) {
1882 case CSSValueOptimizespeed:
1883 return CR_OPTIMIZESPEED;
1884 case CSSValueOptimizequality:
1885 return CR_OPTIMIZEQUALITY;
1886 case CSSValueAuto:
1887 return CR_AUTO;
1888 default:
1889 ASSERT_NOT_REACHED();
1890 return CR_AUTO;
1894 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDominantBaseline e)
1895 : m_type(CSS_IDENT)
1897 switch (e) {
1898 case DB_AUTO:
1899 m_value.ident = CSSValueAuto;
1900 break;
1901 case DB_USE_SCRIPT:
1902 m_value.ident = CSSValueUseScript;
1903 break;
1904 case DB_NO_CHANGE:
1905 m_value.ident = CSSValueNoChange;
1906 break;
1907 case DB_RESET_SIZE:
1908 m_value.ident = CSSValueResetSize;
1909 break;
1910 case DB_CENTRAL:
1911 m_value.ident = CSSValueCentral;
1912 break;
1913 case DB_MIDDLE:
1914 m_value.ident = CSSValueMiddle;
1915 break;
1916 case DB_TEXT_BEFORE_EDGE:
1917 m_value.ident = CSSValueTextBeforeEdge;
1918 break;
1919 case DB_TEXT_AFTER_EDGE:
1920 m_value.ident = CSSValueTextAfterEdge;
1921 break;
1922 case DB_IDEOGRAPHIC:
1923 m_value.ident = CSSValueIdeographic;
1924 break;
1925 case DB_ALPHABETIC:
1926 m_value.ident = CSSValueAlphabetic;
1927 break;
1928 case DB_HANGING:
1929 m_value.ident = CSSValueHanging;
1930 break;
1931 case DB_MATHEMATICAL:
1932 m_value.ident = CSSValueMathematical;
1933 break;
1937 template<> inline CSSPrimitiveValue::operator EDominantBaseline() const
1939 switch (m_value.ident) {
1940 case CSSValueAuto:
1941 return DB_AUTO;
1942 case CSSValueUseScript:
1943 return DB_USE_SCRIPT;
1944 case CSSValueNoChange:
1945 return DB_NO_CHANGE;
1946 case CSSValueResetSize:
1947 return DB_RESET_SIZE;
1948 case CSSValueIdeographic:
1949 return DB_IDEOGRAPHIC;
1950 case CSSValueAlphabetic:
1951 return DB_ALPHABETIC;
1952 case CSSValueHanging:
1953 return DB_HANGING;
1954 case CSSValueMathematical:
1955 return DB_MATHEMATICAL;
1956 case CSSValueCentral:
1957 return DB_CENTRAL;
1958 case CSSValueMiddle:
1959 return DB_MIDDLE;
1960 case CSSValueTextAfterEdge:
1961 return DB_TEXT_AFTER_EDGE;
1962 case CSSValueTextBeforeEdge:
1963 return DB_TEXT_BEFORE_EDGE;
1964 default:
1965 ASSERT_NOT_REACHED();
1966 return DB_AUTO;
1970 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
1971 : m_type(CSS_IDENT)
1973 switch (e) {
1974 case IR_AUTO:
1975 m_value.ident = CSSValueAuto;
1976 break;
1977 case IR_OPTIMIZESPEED:
1978 m_value.ident = CSSValueOptimizespeed;
1979 break;
1980 case IR_OPTIMIZEQUALITY:
1981 m_value.ident = CSSValueOptimizequality;
1982 break;
1986 template<> inline CSSPrimitiveValue::operator EImageRendering() const
1988 switch (m_value.ident) {
1989 case CSSValueAuto:
1990 return IR_AUTO;
1991 case CSSValueOptimizespeed:
1992 return IR_OPTIMIZESPEED;
1993 case CSSValueOptimizequality:
1994 return IR_OPTIMIZEQUALITY;
1995 default:
1996 ASSERT_NOT_REACHED();
1997 return IR_AUTO;
2001 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e)
2002 : m_type(CSS_IDENT)
2004 switch (e) {
2005 case PE_NONE:
2006 m_value.ident = CSSValueNone;
2007 break;
2008 case PE_STROKE:
2009 m_value.ident = CSSValueStroke;
2010 break;
2011 case PE_FILL:
2012 m_value.ident = CSSValueFill;
2013 break;
2014 case PE_PAINTED:
2015 m_value.ident = CSSValuePainted;
2016 break;
2017 case PE_VISIBLE:
2018 m_value.ident = CSSValueVisible;
2019 break;
2020 case PE_VISIBLE_STROKE:
2021 m_value.ident = CSSValueVisiblestroke;
2022 break;
2023 case PE_VISIBLE_FILL:
2024 m_value.ident = CSSValueVisiblefill;
2025 break;
2026 case PE_VISIBLE_PAINTED:
2027 m_value.ident = CSSValueVisiblepainted;
2028 break;
2029 case PE_ALL:
2030 m_value.ident = CSSValueAll;
2031 break;
2035 template<> inline CSSPrimitiveValue::operator EPointerEvents() const
2037 switch (m_value.ident) {
2038 case CSSValueAll:
2039 return PE_ALL;
2040 case CSSValueNone:
2041 return PE_NONE;
2042 case CSSValueVisiblepainted:
2043 return PE_VISIBLE_PAINTED;
2044 case CSSValueVisiblefill:
2045 return PE_VISIBLE_FILL;
2046 case CSSValueVisiblestroke:
2047 return PE_VISIBLE_STROKE;
2048 case CSSValueVisible:
2049 return PE_VISIBLE;
2050 case CSSValuePainted:
2051 return PE_PAINTED;
2052 case CSSValueFill:
2053 return PE_FILL;
2054 case CSSValueStroke:
2055 return PE_STROKE;
2056 default:
2057 ASSERT_NOT_REACHED();
2058 return PE_ALL;
2062 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e)
2063 : m_type(CSS_IDENT)
2065 switch (e) {
2066 case IR_AUTO:
2067 m_value.ident = CSSValueAuto;
2068 break;
2069 case IR_OPTIMIZESPEED:
2070 m_value.ident = CSSValueOptimizespeed;
2071 break;
2072 case SR_CRISPEDGES:
2073 m_value.ident = CSSValueCrispedges;
2074 break;
2075 case SR_GEOMETRICPRECISION:
2076 m_value.ident = CSSValueGeometricprecision;
2077 break;
2081 template<> inline CSSPrimitiveValue::operator EShapeRendering() const
2083 switch (m_value.ident) {
2084 case CSSValueAuto:
2085 return SR_AUTO;
2086 case CSSValueOptimizespeed:
2087 return SR_OPTIMIZESPEED;
2088 case CSSValueCrispedges:
2089 return SR_CRISPEDGES;
2090 case CSSValueGeometricprecision:
2091 return SR_GEOMETRICPRECISION;
2092 default:
2093 ASSERT_NOT_REACHED();
2094 return SR_AUTO;
2098 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAnchor e)
2099 : m_type(CSS_IDENT)
2101 switch (e) {
2102 case TA_START:
2103 m_value.ident = CSSValueStart;
2104 break;
2105 case TA_MIDDLE:
2106 m_value.ident = CSSValueMiddle;
2107 break;
2108 case TA_END:
2109 m_value.ident = CSSValueEnd;
2110 break;
2114 template<> inline CSSPrimitiveValue::operator ETextAnchor() const
2116 switch (m_value.ident) {
2117 case CSSValueStart:
2118 return TA_START;
2119 case CSSValueMiddle:
2120 return TA_MIDDLE;
2121 case CSSValueEnd:
2122 return TA_END;
2123 default:
2124 ASSERT_NOT_REACHED();
2125 return TA_START;
2129 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextRendering e)
2130 : m_type(CSS_IDENT)
2132 switch (e) {
2133 case TR_AUTO:
2134 m_value.ident = CSSValueAuto;
2135 break;
2136 case TR_OPTIMIZESPEED:
2137 m_value.ident = CSSValueOptimizespeed;
2138 break;
2139 case TR_OPTIMIZELEGIBILITY:
2140 m_value.ident = CSSValueOptimizelegibility;
2141 break;
2142 case TR_GEOMETRICPRECISION:
2143 m_value.ident = CSSValueGeometricprecision;
2144 break;
2148 template<> inline CSSPrimitiveValue::operator ETextRendering() const
2150 switch (m_value.ident) {
2151 case CSSValueAuto:
2152 return TR_AUTO;
2153 case CSSValueOptimizespeed:
2154 return TR_OPTIMIZESPEED;
2155 case CSSValueOptimizelegibility:
2156 return TR_OPTIMIZELEGIBILITY;
2157 case CSSValueGeometricprecision:
2158 return TR_GEOMETRICPRECISION;
2159 default:
2160 ASSERT_NOT_REACHED();
2161 return TR_AUTO;
2165 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWritingMode e)
2166 : m_type(CSS_IDENT)
2168 switch (e) {
2169 case WM_LRTB:
2170 m_value.ident = CSSValueLrTb;
2171 break;
2172 case WM_LR:
2173 m_value.ident = CSSValueLr;
2174 break;
2175 case WM_RLTB:
2176 m_value.ident = CSSValueRlTb;
2177 break;
2178 case WM_RL:
2179 m_value.ident = CSSValueRl;
2180 break;
2181 case WM_TBRL:
2182 m_value.ident = CSSValueTbRl;
2183 break;
2184 case WM_TB:
2185 m_value.ident = CSSValueTb;
2186 break;
2190 template<> inline CSSPrimitiveValue::operator EWritingMode() const
2192 return static_cast<EWritingMode>(m_value.ident - CSSValueLrTb);
2195 #endif
2199 #endif