]> git.saurik.com Git - iphone-api.git/blob - WebCore/CSSPrimitiveValueMappings.h
Adding the WebCore headers (for Cydget).
[iphone-api.git] / WebCore / CSSPrimitiveValueMappings.h
1 /*
2 * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
3 * Copyright (C) 2008 Apple Inc. All rights reserved.
4 *
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.
14 *
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.
25 */
26
27 #ifndef CSSPrimitiveValueMappings_h
28 #define CSSPrimitiveValueMappings_h
29
30 #include "CSSPrimitiveValue.h"
31 #include "CSSValueKeywords.h"
32 #include "RenderStyle.h"
33
34 namespace WebCore {
35
36 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderStyle e)
37 : m_type(CSS_IDENT)
38 {
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;
70 }
71 }
72
73 template<> inline CSSPrimitiveValue::operator EBorderStyle() const
74 {
75 return (EBorderStyle)(m_value.ident - CSSValueNone);
76 }
77
78 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e)
79 : m_type(CSS_IDENT)
80 {
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;
124 }
125 }
126
127 template<> inline CSSPrimitiveValue::operator CompositeOperator() const
128 {
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;
161 }
162 }
163
164 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
165 : m_type(CSS_IDENT)
166 {
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 MediaTimelineContainerPart:
220 m_value.ident = CSSValueMediaTimelineContainer;
221 break;
222 case MediaCurrentTimePart:
223 m_value.ident = CSSValueMediaCurrentTimeDisplay;
224 break;
225 case MediaTimeRemainingPart:
226 m_value.ident = CSSValueMediaTimeRemainingDisplay;
227 break;
228 case MenulistPart:
229 m_value.ident = CSSValueMenulist;
230 break;
231 case MenulistButtonPart:
232 m_value.ident = CSSValueMenulistButton;
233 break;
234 case MenulistTextPart:
235 m_value.ident = CSSValueMenulistText;
236 break;
237 case MenulistTextFieldPart:
238 m_value.ident = CSSValueMenulistTextfield;
239 break;
240 case SliderHorizontalPart:
241 m_value.ident = CSSValueSliderHorizontal;
242 break;
243 case SliderVerticalPart:
244 m_value.ident = CSSValueSliderVertical;
245 break;
246 case SliderThumbHorizontalPart:
247 m_value.ident = CSSValueSliderthumbHorizontal;
248 break;
249 case SliderThumbVerticalPart:
250 m_value.ident = CSSValueSliderthumbVertical;
251 break;
252 case CaretPart:
253 m_value.ident = CSSValueCaret;
254 break;
255 case SearchFieldPart:
256 m_value.ident = CSSValueSearchfield;
257 break;
258 case SearchFieldDecorationPart:
259 m_value.ident = CSSValueSearchfieldDecoration;
260 break;
261 case SearchFieldResultsDecorationPart:
262 m_value.ident = CSSValueSearchfieldResultsDecoration;
263 break;
264 case SearchFieldResultsButtonPart:
265 m_value.ident = CSSValueSearchfieldResultsButton;
266 break;
267 case SearchFieldCancelButtonPart:
268 m_value.ident = CSSValueSearchfieldCancelButton;
269 break;
270 case TextFieldPart:
271 m_value.ident = CSSValueTextfield;
272 break;
273 case TextAreaPart:
274 m_value.ident = CSSValueTextarea;
275 break;
276 case CapsLockIndicatorPart:
277 m_value.ident = CSSValueCapsLockIndicator;
278 break;
279 }
280 }
281
282 template<> inline CSSPrimitiveValue::operator ControlPart() const
283 {
284 if (m_value.ident == CSSValueNone)
285 return NoControlPart;
286 else
287 return ControlPart(m_value.ident - CSSValueCheckbox + 1);
288 }
289
290 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e)
291 : m_type(CSS_IDENT)
292 {
293 switch (e) {
294 case BorderFillBox:
295 m_value.ident = CSSValueBorder;
296 break;
297 case PaddingFillBox:
298 m_value.ident = CSSValuePadding;
299 break;
300 case ContentFillBox:
301 m_value.ident = CSSValueContent;
302 break;
303 case TextFillBox:
304 m_value.ident = CSSValueText;
305 break;
306 }
307 }
308
309 template<> inline CSSPrimitiveValue::operator EFillBox() const
310 {
311 switch (m_value.ident) {
312 case CSSValueBorder:
313 return BorderFillBox;
314 case CSSValuePadding:
315 return PaddingFillBox;
316 case CSSValueContent:
317 return ContentFillBox;
318 case CSSValueText:
319 return TextFillBox;
320 default:
321 ASSERT_NOT_REACHED();
322 return BorderFillBox;
323 }
324 }
325
326 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillRepeat e)
327 : m_type(CSS_IDENT)
328 {
329 switch (e) {
330 case RepeatFill:
331 m_value.ident = CSSValueRepeat;
332 break;
333 case RepeatXFill:
334 m_value.ident = CSSValueRepeatX;
335 break;
336 case RepeatYFill:
337 m_value.ident = CSSValueRepeatY;
338 break;
339 case NoRepeatFill:
340 m_value.ident = CSSValueNoRepeat;
341 break;
342 }
343 }
344
345 template<> inline CSSPrimitiveValue::operator EFillRepeat() const
346 {
347 switch (m_value.ident) {
348 case CSSValueRepeat:
349 return RepeatFill;
350 case CSSValueRepeatX:
351 return RepeatXFill;
352 case CSSValueRepeatY:
353 return RepeatYFill;
354 case CSSValueNoRepeat:
355 return NoRepeatFill;
356 default:
357 ASSERT_NOT_REACHED();
358 return RepeatFill;
359 }
360 }
361
362 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e)
363 : m_type(CSS_IDENT)
364 {
365 switch (e) {
366 case BSTRETCH:
367 m_value.ident = CSSValueStretch;
368 break;
369 case BSTART:
370 m_value.ident = CSSValueStart;
371 break;
372 case BCENTER:
373 m_value.ident = CSSValueCenter;
374 break;
375 case BEND:
376 m_value.ident = CSSValueEnd;
377 break;
378 case BBASELINE:
379 m_value.ident = CSSValueBaseline;
380 break;
381 case BJUSTIFY:
382 m_value.ident = CSSValueJustify;
383 break;
384 }
385 }
386
387 template<> inline CSSPrimitiveValue::operator EBoxAlignment() const
388 {
389 switch (m_value.ident) {
390 case CSSValueStretch:
391 return BSTRETCH;
392 case CSSValueStart:
393 return BSTART;
394 case CSSValueEnd:
395 return BEND;
396 case CSSValueCenter:
397 return BCENTER;
398 case CSSValueBaseline:
399 return BBASELINE;
400 case CSSValueJustify:
401 return BJUSTIFY;
402 default:
403 ASSERT_NOT_REACHED();
404 return BSTRETCH;
405 }
406 }
407
408 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDirection e)
409 : m_type(CSS_IDENT)
410 {
411 switch (e) {
412 case BNORMAL:
413 m_value.ident = CSSValueNormal;
414 break;
415 case BREVERSE:
416 m_value.ident = CSSValueReverse;
417 break;
418 }
419 }
420
421 template<> inline CSSPrimitiveValue::operator EBoxDirection() const
422 {
423 switch (m_value.ident) {
424 case CSSValueNormal:
425 return BNORMAL;
426 case CSSValueReverse:
427 return BREVERSE;
428 default:
429 ASSERT_NOT_REACHED();
430 return BNORMAL;
431 }
432 }
433
434 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxLines e)
435 : m_type(CSS_IDENT)
436 {
437 switch (e) {
438 case SINGLE:
439 m_value.ident = CSSValueSingle;
440 break;
441 case MULTIPLE:
442 m_value.ident = CSSValueMultiple;
443 break;
444 }
445 }
446
447 template<> inline CSSPrimitiveValue::operator EBoxLines() const
448 {
449 switch (m_value.ident) {
450 case CSSValueSingle:
451 return SINGLE;
452 case CSSValueMultiple:
453 return MULTIPLE;
454 default:
455 ASSERT_NOT_REACHED();
456 return SINGLE;
457 }
458 }
459
460 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxOrient e)
461 : m_type(CSS_IDENT)
462 {
463 switch (e) {
464 case HORIZONTAL:
465 m_value.ident = CSSValueHorizontal;
466 break;
467 case VERTICAL:
468 m_value.ident = CSSValueVertical;
469 break;
470 }
471 }
472
473 template<> inline CSSPrimitiveValue::operator EBoxOrient() const
474 {
475 switch (m_value.ident) {
476 case CSSValueHorizontal:
477 case CSSValueInlineAxis:
478 return HORIZONTAL;
479 case CSSValueVertical:
480 return VERTICAL;
481 default:
482 ASSERT_NOT_REACHED();
483 return HORIZONTAL;
484 }
485 }
486
487 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECaptionSide e)
488 : m_type(CSS_IDENT)
489 {
490 switch (e) {
491 case CAPLEFT:
492 m_value.ident = CSSValueLeft;
493 break;
494 case CAPRIGHT:
495 m_value.ident = CSSValueRight;
496 break;
497 case CAPTOP:
498 m_value.ident = CSSValueTop;
499 break;
500 case CAPBOTTOM:
501 m_value.ident = CSSValueBottom;
502 break;
503 }
504 }
505
506 template<> inline CSSPrimitiveValue::operator ECaptionSide() const
507 {
508 switch (m_value.ident) {
509 case CSSValueLeft:
510 return CAPLEFT;
511 case CSSValueRight:
512 return CAPRIGHT;
513 case CSSValueTop:
514 return CAPTOP;
515 case CSSValueBottom:
516 return CAPBOTTOM;
517 default:
518 ASSERT_NOT_REACHED();
519 return CAPTOP;
520 }
521 }
522
523 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EClear e)
524 : m_type(CSS_IDENT)
525 {
526 switch (e) {
527 case CNONE:
528 m_value.ident = CSSValueNone;
529 break;
530 case CLEFT:
531 m_value.ident = CSSValueLeft;
532 break;
533 case CRIGHT:
534 m_value.ident = CSSValueRight;
535 break;
536 case CBOTH:
537 m_value.ident = CSSValueBoth;
538 break;
539 }
540 }
541
542 template<> inline CSSPrimitiveValue::operator EClear() const
543 {
544 switch (m_value.ident) {
545 case CSSValueNone:
546 return CNONE;
547 case CSSValueLeft:
548 return CLEFT;
549 case CSSValueRight:
550 return CRIGHT;
551 case CSSValueBoth:
552 return CBOTH;
553 default:
554 ASSERT_NOT_REACHED();
555 return CNONE;
556 }
557 }
558
559 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e)
560 : m_type(CSS_IDENT)
561 {
562 switch (e) {
563 case CURSOR_AUTO:
564 m_value.ident = CSSValueAuto;
565 break;
566 case CURSOR_CROSS:
567 m_value.ident = CSSValueCrosshair;
568 break;
569 case CURSOR_DEFAULT:
570 m_value.ident = CSSValueDefault;
571 break;
572 case CURSOR_POINTER:
573 m_value.ident = CSSValuePointer;
574 break;
575 case CURSOR_MOVE:
576 m_value.ident = CSSValueMove;
577 break;
578 case CURSOR_CELL:
579 m_value.ident = CSSValueCell;
580 break;
581 case CURSOR_VERTICAL_TEXT:
582 m_value.ident = CSSValueVerticalText;
583 break;
584 case CURSOR_CONTEXT_MENU:
585 m_value.ident = CSSValueContextMenu;
586 break;
587 case CURSOR_ALIAS:
588 m_value.ident = CSSValueAlias;
589 break;
590 case CURSOR_COPY:
591 m_value.ident = CSSValueCopy;
592 break;
593 case CURSOR_NONE:
594 m_value.ident = CSSValueNone;
595 break;
596 case CURSOR_PROGRESS:
597 m_value.ident = CSSValueProgress;
598 break;
599 case CURSOR_NO_DROP:
600 m_value.ident = CSSValueNoDrop;
601 break;
602 case CURSOR_NOT_ALLOWED:
603 m_value.ident = CSSValueNotAllowed;
604 break;
605 case CURSOR_WEBKIT_ZOOM_IN:
606 m_value.ident = CSSValueWebkitZoomIn;
607 break;
608 case CURSOR_WEBKIT_ZOOM_OUT:
609 m_value.ident = CSSValueWebkitZoomOut;
610 break;
611 case CURSOR_E_RESIZE:
612 m_value.ident = CSSValueEResize;
613 break;
614 case CURSOR_NE_RESIZE:
615 m_value.ident = CSSValueNeResize;
616 break;
617 case CURSOR_NW_RESIZE:
618 m_value.ident = CSSValueNwResize;
619 break;
620 case CURSOR_N_RESIZE:
621 m_value.ident = CSSValueNResize;
622 break;
623 case CURSOR_SE_RESIZE:
624 m_value.ident = CSSValueSeResize;
625 break;
626 case CURSOR_SW_RESIZE:
627 m_value.ident = CSSValueSwResize;
628 break;
629 case CURSOR_S_RESIZE:
630 m_value.ident = CSSValueSResize;
631 break;
632 case CURSOR_W_RESIZE:
633 m_value.ident = CSSValueWResize;
634 break;
635 case CURSOR_EW_RESIZE:
636 m_value.ident = CSSValueEwResize;
637 break;
638 case CURSOR_NS_RESIZE:
639 m_value.ident = CSSValueNsResize;
640 break;
641 case CURSOR_NESW_RESIZE:
642 m_value.ident = CSSValueNeswResize;
643 break;
644 case CURSOR_NWSE_RESIZE:
645 m_value.ident = CSSValueNwseResize;
646 break;
647 case CURSOR_COL_RESIZE:
648 m_value.ident = CSSValueColResize;
649 break;
650 case CURSOR_ROW_RESIZE:
651 m_value.ident = CSSValueRowResize;
652 break;
653 case CURSOR_TEXT:
654 m_value.ident = CSSValueText;
655 break;
656 case CURSOR_WAIT:
657 m_value.ident = CSSValueWait;
658 break;
659 case CURSOR_HELP:
660 m_value.ident = CSSValueHelp;
661 break;
662 case CURSOR_ALL_SCROLL:
663 m_value.ident = CSSValueAllScroll;
664 break;
665 case CURSOR_WEBKIT_GRAB:
666 m_value.ident = CSSValueWebkitGrab;
667 break;
668 case CURSOR_WEBKIT_GRABBING:
669 m_value.ident = CSSValueWebkitGrabbing;
670 break;
671 }
672 }
673
674 template<> inline CSSPrimitiveValue::operator ECursor() const
675 {
676 if (m_value.ident == CSSValueCopy)
677 return CURSOR_COPY;
678 if (m_value.ident == CSSValueNone)
679 return CURSOR_NONE;
680 return static_cast<ECursor>(m_value.ident - CSSValueAuto);
681 }
682
683 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
684 : m_type(CSS_IDENT)
685 {
686 switch (e) {
687 case INLINE:
688 m_value.ident = CSSValueInline;
689 break;
690 case BLOCK:
691 m_value.ident = CSSValueBlock;
692 break;
693 case LIST_ITEM:
694 m_value.ident = CSSValueListItem;
695 break;
696 case RUN_IN:
697 m_value.ident = CSSValueRunIn;
698 break;
699 case COMPACT:
700 m_value.ident = CSSValueCompact;
701 break;
702 case INLINE_BLOCK:
703 m_value.ident = CSSValueInlineBlock;
704 break;
705 case TABLE:
706 m_value.ident = CSSValueTable;
707 break;
708 case INLINE_TABLE:
709 m_value.ident = CSSValueInlineTable;
710 break;
711 case TABLE_ROW_GROUP:
712 m_value.ident = CSSValueTableRowGroup;
713 break;
714 case TABLE_HEADER_GROUP:
715 m_value.ident = CSSValueTableHeaderGroup;
716 break;
717 case TABLE_FOOTER_GROUP:
718 m_value.ident = CSSValueTableFooterGroup;
719 break;
720 case TABLE_ROW:
721 m_value.ident = CSSValueTableRow;
722 break;
723 case TABLE_COLUMN_GROUP:
724 m_value.ident = CSSValueTableColumnGroup;
725 break;
726 case TABLE_COLUMN:
727 m_value.ident = CSSValueTableColumn;
728 break;
729 case TABLE_CELL:
730 m_value.ident = CSSValueTableCell;
731 break;
732 case TABLE_CAPTION:
733 m_value.ident = CSSValueTableCaption;
734 break;
735 case BOX:
736 m_value.ident = CSSValueWebkitBox;
737 break;
738 case INLINE_BOX:
739 m_value.ident = CSSValueWebkitInlineBox;
740 break;
741 case NONE:
742 m_value.ident = CSSValueNone;
743 break;
744 }
745 }
746
747 template<> inline CSSPrimitiveValue::operator EDisplay() const
748 {
749 if (m_value.ident == CSSValueNone)
750 return NONE;
751 return static_cast<EDisplay>(m_value.ident - CSSValueInline);
752 }
753
754 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EEmptyCell e)
755 : m_type(CSS_IDENT)
756 {
757 switch (e) {
758 case SHOW:
759 m_value.ident = CSSValueShow;
760 break;
761 case HIDE:
762 m_value.ident = CSSValueHide;
763 break;
764 }
765 }
766
767 template<> inline CSSPrimitiveValue::operator EEmptyCell() const
768 {
769 switch (m_value.ident) {
770 case CSSValueShow:
771 return SHOW;
772 case CSSValueHide:
773 return HIDE;
774 default:
775 ASSERT_NOT_REACHED();
776 return SHOW;
777 }
778 }
779
780 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
781 : m_type(CSS_IDENT)
782 {
783 switch (e) {
784 case FNONE:
785 m_value.ident = CSSValueNone;
786 break;
787 case FLEFT:
788 m_value.ident = CSSValueLeft;
789 break;
790 case FRIGHT:
791 m_value.ident = CSSValueRight;
792 break;
793 }
794 }
795
796 template<> inline CSSPrimitiveValue::operator EFloat() const
797 {
798 switch (m_value.ident) {
799 case CSSValueLeft:
800 return FLEFT;
801 case CSSValueRight:
802 return FRIGHT;
803 case CSSValueNone:
804 case CSSValueCenter: // Non-standard CSS value
805 return FNONE;
806 default:
807 ASSERT_NOT_REACHED();
808 return FNONE;
809 }
810 }
811
812 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EKHTMLLineBreak e)
813 : m_type(CSS_IDENT)
814 {
815 switch (e) {
816 case LBNORMAL:
817 m_value.ident = CSSValueNormal;
818 break;
819 case AFTER_WHITE_SPACE:
820 m_value.ident = CSSValueAfterWhiteSpace;
821 break;
822 }
823 }
824
825 template<> inline CSSPrimitiveValue::operator EKHTMLLineBreak() const
826 {
827 switch (m_value.ident) {
828 case CSSValueAfterWhiteSpace:
829 return AFTER_WHITE_SPACE;
830 case CSSValueNormal:
831 return LBNORMAL;
832 default:
833 ASSERT_NOT_REACHED();
834 return LBNORMAL;
835 }
836 }
837
838 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStylePosition e)
839 : m_type(CSS_IDENT)
840 {
841 switch (e) {
842 case OUTSIDE:
843 m_value.ident = CSSValueOutside;
844 break;
845 case INSIDE:
846 m_value.ident = CSSValueInside;
847 break;
848 }
849 }
850
851 template<> inline CSSPrimitiveValue::operator EListStylePosition() const
852 {
853 return (EListStylePosition)(m_value.ident - CSSValueOutside);
854 }
855
856 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e)
857 : m_type(CSS_IDENT)
858 {
859 switch (e) {
860 case LNONE:
861 m_value.ident = CSSValueNone;
862 break;
863 case DISC:
864 m_value.ident = CSSValueDisc;
865 break;
866 case CIRCLE:
867 m_value.ident = CSSValueCircle;
868 break;
869 case SQUARE:
870 m_value.ident = CSSValueSquare;
871 break;
872 case LDECIMAL:
873 m_value.ident = CSSValueDecimal;
874 break;
875 case DECIMAL_LEADING_ZERO:
876 m_value.ident = CSSValueDecimalLeadingZero;
877 break;
878 case LOWER_ROMAN:
879 m_value.ident = CSSValueLowerRoman;
880 break;
881 case UPPER_ROMAN:
882 m_value.ident = CSSValueUpperRoman;
883 break;
884 case LOWER_GREEK:
885 m_value.ident = CSSValueLowerGreek;
886 break;
887 case LOWER_ALPHA:
888 m_value.ident = CSSValueLowerAlpha;
889 break;
890 case LOWER_LATIN:
891 m_value.ident = CSSValueLowerLatin;
892 break;
893 case UPPER_ALPHA:
894 m_value.ident = CSSValueUpperAlpha;
895 break;
896 case UPPER_LATIN:
897 m_value.ident = CSSValueUpperLatin;
898 break;
899 case HEBREW:
900 m_value.ident = CSSValueHebrew;
901 break;
902 case ARMENIAN:
903 m_value.ident = CSSValueArmenian;
904 break;
905 case GEORGIAN:
906 m_value.ident = CSSValueGeorgian;
907 break;
908 case CJK_IDEOGRAPHIC:
909 m_value.ident = CSSValueCjkIdeographic;
910 break;
911 case HIRAGANA:
912 m_value.ident = CSSValueHiragana;
913 break;
914 case KATAKANA:
915 m_value.ident = CSSValueKatakana;
916 break;
917 case HIRAGANA_IROHA:
918 m_value.ident = CSSValueHiraganaIroha;
919 break;
920 case KATAKANA_IROHA:
921 m_value.ident = CSSValueKatakanaIroha;
922 break;
923 }
924 }
925
926 template<> inline CSSPrimitiveValue::operator EListStyleType() const
927 {
928 switch (m_value.ident) {
929 case CSSValueNone:
930 return LNONE;
931 default:
932 return static_cast<EListStyleType>(m_value.ident - CSSValueDisc);
933 }
934 }
935
936 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarginCollapse e)
937 : m_type(CSS_IDENT)
938 {
939 switch (e) {
940 case MCOLLAPSE:
941 m_value.ident = CSSValueCollapse;
942 break;
943 case MSEPARATE:
944 m_value.ident = CSSValueSeparate;
945 break;
946 case MDISCARD:
947 m_value.ident = CSSValueDiscard;
948 break;
949 }
950 }
951
952 template<> inline CSSPrimitiveValue::operator EMarginCollapse() const
953 {
954 switch (m_value.ident) {
955 case CSSValueCollapse:
956 return MCOLLAPSE;
957 case CSSValueSeparate:
958 return MSEPARATE;
959 case CSSValueDiscard:
960 return MDISCARD;
961 default:
962 ASSERT_NOT_REACHED();
963 return MCOLLAPSE;
964 }
965 }
966
967 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeBehavior e)
968 : m_type(CSS_IDENT)
969 {
970 switch (e) {
971 case MNONE:
972 m_value.ident = CSSValueNone;
973 break;
974 case MSCROLL:
975 m_value.ident = CSSValueScroll;
976 break;
977 case MSLIDE:
978 m_value.ident = CSSValueSlide;
979 break;
980 case MALTERNATE:
981 m_value.ident = CSSValueAlternate;
982 break;
983 }
984 }
985
986 template<> inline CSSPrimitiveValue::operator EMarqueeBehavior() const
987 {
988 switch (m_value.ident) {
989 case CSSValueNone:
990 return MNONE;
991 case CSSValueScroll:
992 return MSCROLL;
993 case CSSValueSlide:
994 return MSLIDE;
995 case CSSValueAlternate:
996 return MALTERNATE;
997 default:
998 ASSERT_NOT_REACHED();
999 return MNONE;
1000 }
1001 }
1002
1003 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeDirection e)
1004 : m_type(CSS_IDENT)
1005 {
1006 switch (e) {
1007 case MFORWARD:
1008 m_value.ident = CSSValueForwards;
1009 break;
1010 case MBACKWARD:
1011 m_value.ident = CSSValueBackwards;
1012 break;
1013 case MAUTO:
1014 m_value.ident = CSSValueAuto;
1015 break;
1016 case MUP:
1017 m_value.ident = CSSValueUp;
1018 break;
1019 case MDOWN:
1020 m_value.ident = CSSValueDown;
1021 break;
1022 case MLEFT:
1023 m_value.ident = CSSValueLeft;
1024 break;
1025 case MRIGHT:
1026 m_value.ident = CSSValueRight;
1027 break;
1028 }
1029 }
1030
1031 template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const
1032 {
1033 switch (m_value.ident) {
1034 case CSSValueForwards:
1035 return MFORWARD;
1036 case CSSValueBackwards:
1037 return MBACKWARD;
1038 case CSSValueAuto:
1039 return MAUTO;
1040 case CSSValueAhead:
1041 case CSSValueUp: // We don't support vertical languages, so AHEAD just maps to UP.
1042 return MUP;
1043 case CSSValueReverse:
1044 case CSSValueDown: // REVERSE just maps to DOWN, since we don't do vertical text.
1045 return MDOWN;
1046 case CSSValueLeft:
1047 return MLEFT;
1048 case CSSValueRight:
1049 return MRIGHT;
1050 default:
1051 ASSERT_NOT_REACHED();
1052 return MAUTO;
1053 }
1054 }
1055
1056 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e)
1057 : m_type(CSS_IDENT)
1058 {
1059 switch (e) {
1060 case BCNORMAL:
1061 m_value.ident = CSSValueNormal;
1062 break;
1063 case MATCH:
1064 m_value.ident = CSSValueMatch;
1065 break;
1066 }
1067 }
1068
1069 template<> inline CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor() const
1070 {
1071 switch (m_value.ident) {
1072 case CSSValueNormal:
1073 return BCNORMAL;
1074 case CSSValueMatch:
1075 return MATCH;
1076 default:
1077 ASSERT_NOT_REACHED();
1078 return BCNORMAL;
1079 }
1080 }
1081
1082 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e)
1083 : m_type(CSS_IDENT)
1084 {
1085 switch (e) {
1086 case NBNORMAL:
1087 m_value.ident = CSSValueNormal;
1088 break;
1089 case SPACE:
1090 m_value.ident = CSSValueSpace;
1091 break;
1092 }
1093 }
1094
1095 template<> inline CSSPrimitiveValue::operator ENBSPMode() const
1096 {
1097 switch (m_value.ident) {
1098 case CSSValueSpace:
1099 return SPACE;
1100 case CSSValueNormal:
1101 return NBNORMAL;
1102 default:
1103 ASSERT_NOT_REACHED();
1104 return NBNORMAL;
1105 }
1106 }
1107
1108 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e)
1109 : m_type(CSS_IDENT)
1110 {
1111 switch (e) {
1112 case OVISIBLE:
1113 m_value.ident = CSSValueVisible;
1114 break;
1115 case OHIDDEN:
1116 m_value.ident = CSSValueHidden;
1117 break;
1118 case OSCROLL:
1119 m_value.ident = CSSValueScroll;
1120 break;
1121 case OAUTO:
1122 m_value.ident = CSSValueAuto;
1123 break;
1124 case OMARQUEE:
1125 m_value.ident = CSSValueWebkitMarquee;
1126 break;
1127 case OOVERLAY:
1128 m_value.ident = CSSValueOverlay;
1129 break;
1130 }
1131 }
1132
1133 template<> inline CSSPrimitiveValue::operator EOverflow() const
1134 {
1135 switch (m_value.ident) {
1136 case CSSValueVisible:
1137 return OVISIBLE;
1138 case CSSValueHidden:
1139 return OHIDDEN;
1140 case CSSValueScroll:
1141 return OSCROLL;
1142 case CSSValueAuto:
1143 return OAUTO;
1144 case CSSValueWebkitMarquee:
1145 return OMARQUEE;
1146 case CSSValueOverlay:
1147 return OOVERLAY;
1148 default:
1149 ASSERT_NOT_REACHED();
1150 return OVISIBLE;
1151 }
1152 }
1153
1154 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e)
1155 : m_type(CSS_IDENT)
1156 {
1157 switch (e) {
1158 case PBAUTO:
1159 m_value.ident = CSSValueAuto;
1160 break;
1161 case PBALWAYS:
1162 m_value.ident = CSSValueAlways;
1163 break;
1164 case PBAVOID:
1165 m_value.ident = CSSValueAvoid;
1166 break;
1167 }
1168 }
1169
1170 template<> inline CSSPrimitiveValue::operator EPageBreak() const
1171 {
1172 switch (m_value.ident) {
1173 case CSSValueAuto:
1174 return PBAUTO;
1175 case CSSValueLeft:
1176 case CSSValueRight:
1177 case CSSValueAlways:
1178 return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always."
1179 case CSSValueAvoid:
1180 return PBAVOID;
1181 default:
1182 ASSERT_NOT_REACHED();
1183 return PBAUTO;
1184 }
1185 }
1186
1187 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e)
1188 : m_type(CSS_IDENT)
1189 {
1190 switch (e) {
1191 case StaticPosition:
1192 m_value.ident = CSSValueStatic;
1193 break;
1194 case RelativePosition:
1195 m_value.ident = CSSValueRelative;
1196 break;
1197 case AbsolutePosition:
1198 m_value.ident = CSSValueAbsolute;
1199 break;
1200 case FixedPosition:
1201 m_value.ident = CSSValueFixed;
1202 break;
1203 }
1204 }
1205
1206 template<> inline CSSPrimitiveValue::operator EPosition() const
1207 {
1208 switch (m_value.ident) {
1209 case CSSValueStatic:
1210 return StaticPosition;
1211 case CSSValueRelative:
1212 return RelativePosition;
1213 case CSSValueAbsolute:
1214 return AbsolutePosition;
1215 case CSSValueFixed:
1216 return FixedPosition;
1217 default:
1218 ASSERT_NOT_REACHED();
1219 return StaticPosition;
1220 }
1221 }
1222
1223 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EResize e)
1224 : m_type(CSS_IDENT)
1225 {
1226 switch (e) {
1227 case RESIZE_BOTH:
1228 m_value.ident = CSSValueBoth;
1229 break;
1230 case RESIZE_HORIZONTAL:
1231 m_value.ident = CSSValueHorizontal;
1232 break;
1233 case RESIZE_VERTICAL:
1234 m_value.ident = CSSValueVertical;
1235 break;
1236 case RESIZE_NONE:
1237 m_value.ident = CSSValueNone;
1238 break;
1239 }
1240 }
1241
1242 template<> inline CSSPrimitiveValue::operator EResize() const
1243 {
1244 switch (m_value.ident) {
1245 case CSSValueBoth:
1246 return RESIZE_BOTH;
1247 case CSSValueHorizontal:
1248 return RESIZE_HORIZONTAL;
1249 case CSSValueVertical:
1250 return RESIZE_VERTICAL;
1251 case CSSValueAuto:
1252 ASSERT_NOT_REACHED(); // Depends on settings, thus should be handled by the caller.
1253 return RESIZE_NONE;
1254 case CSSValueNone:
1255 return RESIZE_NONE;
1256 default:
1257 ASSERT_NOT_REACHED();
1258 return RESIZE_NONE;
1259 }
1260 }
1261
1262 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETableLayout e)
1263 : m_type(CSS_IDENT)
1264 {
1265 switch (e) {
1266 case TAUTO:
1267 m_value.ident = CSSValueAuto;
1268 break;
1269 case TFIXED:
1270 m_value.ident = CSSValueFixed;
1271 break;
1272 }
1273 }
1274
1275 template<> inline CSSPrimitiveValue::operator ETableLayout() const
1276 {
1277 switch (m_value.ident) {
1278 case CSSValueFixed:
1279 return TFIXED;
1280 case CSSValueAuto:
1281 return TAUTO;
1282 default:
1283 ASSERT_NOT_REACHED();
1284 return TAUTO;
1285 }
1286 }
1287
1288 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e)
1289 : m_type(CSS_IDENT)
1290 {
1291 switch (e) {
1292 case TAAUTO:
1293 m_value.ident = CSSValueAuto;
1294 break;
1295 case LEFT:
1296 m_value.ident = CSSValueLeft;
1297 break;
1298 case RIGHT:
1299 m_value.ident = CSSValueRight;
1300 break;
1301 case CENTER:
1302 m_value.ident = CSSValueCenter;
1303 break;
1304 case JUSTIFY:
1305 m_value.ident = CSSValueJustify;
1306 break;
1307 case WEBKIT_LEFT:
1308 m_value.ident = CSSValueWebkitLeft;
1309 break;
1310 case WEBKIT_RIGHT:
1311 m_value.ident = CSSValueWebkitRight;
1312 break;
1313 case WEBKIT_CENTER:
1314 m_value.ident = CSSValueWebkitCenter;
1315 break;
1316 }
1317 }
1318
1319 template<> inline CSSPrimitiveValue::operator ETextAlign() const
1320 {
1321 switch (m_value.ident) {
1322 case CSSValueStart:
1323 case CSSValueEnd:
1324 ASSERT_NOT_REACHED(); // Depends on direction, thus should be handled by the caller.
1325 return LEFT;
1326 default:
1327 return static_cast<ETextAlign>(m_value.ident - CSSValueWebkitAuto);
1328 }
1329 }
1330
1331 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e)
1332 : m_type(CSS_IDENT)
1333 {
1334 switch (e) {
1335 case TSNONE:
1336 m_value.ident = CSSValueNone;
1337 break;
1338 case TSDISC:
1339 m_value.ident = CSSValueDisc;
1340 break;
1341 case TSCIRCLE:
1342 m_value.ident = CSSValueCircle;
1343 break;
1344 case TSSQUARE:
1345 m_value.ident = CSSValueSquare;
1346 break;
1347 }
1348 }
1349
1350 template<> inline CSSPrimitiveValue::operator ETextSecurity() const
1351 {
1352 switch (m_value.ident) {
1353 case CSSValueNone:
1354 return TSNONE;
1355 case CSSValueDisc:
1356 return TSDISC;
1357 case CSSValueCircle:
1358 return TSCIRCLE;
1359 case CSSValueSquare:
1360 return TSSQUARE;
1361 default:
1362 ASSERT_NOT_REACHED();
1363 return TSNONE;
1364 }
1365 }
1366
1367 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextTransform e)
1368 : m_type(CSS_IDENT)
1369 {
1370 switch (e) {
1371 case CAPITALIZE:
1372 m_value.ident = CSSValueCapitalize;
1373 break;
1374 case UPPERCASE:
1375 m_value.ident = CSSValueUppercase;
1376 break;
1377 case LOWERCASE:
1378 m_value.ident = CSSValueLowercase;
1379 break;
1380 case TTNONE:
1381 m_value.ident = CSSValueNone;
1382 break;
1383 }
1384 }
1385
1386 template<> inline CSSPrimitiveValue::operator ETextTransform() const
1387 {
1388 switch (m_value.ident) {
1389 case CSSValueCapitalize:
1390 return CAPITALIZE;
1391 case CSSValueUppercase:
1392 return UPPERCASE;
1393 case CSSValueLowercase:
1394 return LOWERCASE;
1395 case CSSValueNone:
1396 return TTNONE;
1397 default:
1398 ASSERT_NOT_REACHED();
1399 return TTNONE;
1400 }
1401 }
1402
1403 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e)
1404 : m_type(CSS_IDENT)
1405 {
1406 switch (e) {
1407 case UBNormal:
1408 m_value.ident = CSSValueNormal;
1409 break;
1410 case Embed:
1411 m_value.ident = CSSValueEmbed;
1412 break;
1413 case Override:
1414 m_value.ident = CSSValueBidiOverride;
1415 break;
1416 }
1417 }
1418
1419 template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const
1420 {
1421 switch (m_value.ident) {
1422 case CSSValueNormal:
1423 return UBNormal;
1424 case CSSValueEmbed:
1425 return Embed;
1426 case CSSValueBidiOverride:
1427 return Override;
1428 default:
1429 ASSERT_NOT_REACHED();
1430 return UBNormal;
1431 }
1432 }
1433
1434 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserDrag e)
1435 : m_type(CSS_IDENT)
1436 {
1437 switch (e) {
1438 case DRAG_AUTO:
1439 m_value.ident = CSSValueAuto;
1440 break;
1441 case DRAG_NONE:
1442 m_value.ident = CSSValueNone;
1443 break;
1444 case DRAG_ELEMENT:
1445 m_value.ident = CSSValueElement;
1446 break;
1447 }
1448 }
1449
1450 template<> inline CSSPrimitiveValue::operator EUserDrag() const
1451 {
1452 switch (m_value.ident) {
1453 case CSSValueAuto:
1454 return DRAG_AUTO;
1455 case CSSValueNone:
1456 return DRAG_NONE;
1457 case CSSValueElement:
1458 return DRAG_ELEMENT;
1459 default:
1460 ASSERT_NOT_REACHED();
1461 return DRAG_AUTO;
1462 }
1463 }
1464
1465 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserModify e)
1466 : m_type(CSS_IDENT)
1467 {
1468 switch (e) {
1469 case READ_ONLY:
1470 m_value.ident = CSSValueReadOnly;
1471 break;
1472 case READ_WRITE:
1473 m_value.ident = CSSValueReadWrite;
1474 break;
1475 case READ_WRITE_PLAINTEXT_ONLY:
1476 m_value.ident = CSSValueReadWritePlaintextOnly;
1477 break;
1478 }
1479 }
1480
1481 template<> inline CSSPrimitiveValue::operator EUserModify() const
1482 {
1483 return static_cast<EUserModify>(m_value.ident - CSSValueReadOnly);
1484 }
1485
1486 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e)
1487 : m_type(CSS_IDENT)
1488 {
1489 switch (e) {
1490 case SELECT_NONE:
1491 m_value.ident = CSSValueNone;
1492 break;
1493 case SELECT_TEXT:
1494 m_value.ident = CSSValueText;
1495 break;
1496 }
1497 }
1498
1499 template<> inline CSSPrimitiveValue::operator EUserSelect() const
1500 {
1501 switch (m_value.ident) {
1502 case CSSValueAuto:
1503 return SELECT_TEXT;
1504 case CSSValueNone:
1505 return SELECT_NONE;
1506 case CSSValueText:
1507 return SELECT_TEXT;
1508 default:
1509 ASSERT_NOT_REACHED();
1510 return SELECT_TEXT;
1511 }
1512 }
1513
1514 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e)
1515 : m_type(CSS_IDENT)
1516 {
1517 switch (e) {
1518 case VISIBLE:
1519 m_value.ident = CSSValueVisible;
1520 break;
1521 case HIDDEN:
1522 m_value.ident = CSSValueHidden;
1523 break;
1524 case COLLAPSE:
1525 m_value.ident = CSSValueCollapse;
1526 break;
1527 }
1528 }
1529
1530 template<> inline CSSPrimitiveValue::operator EVisibility() const
1531 {
1532 switch (m_value.ident) {
1533 case CSSValueHidden:
1534 return HIDDEN;
1535 case CSSValueVisible:
1536 return VISIBLE;
1537 case CSSValueCollapse:
1538 return COLLAPSE;
1539 default:
1540 ASSERT_NOT_REACHED();
1541 return VISIBLE;
1542 }
1543 }
1544
1545 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWhiteSpace e)
1546 : m_type(CSS_IDENT)
1547 {
1548 switch (e) {
1549 case NORMAL:
1550 m_value.ident = CSSValueNormal;
1551 break;
1552 case PRE:
1553 m_value.ident = CSSValuePre;
1554 break;
1555 case PRE_WRAP:
1556 m_value.ident = CSSValuePreWrap;
1557 break;
1558 case PRE_LINE:
1559 m_value.ident = CSSValuePreLine;
1560 break;
1561 case NOWRAP:
1562 m_value.ident = CSSValueNowrap;
1563 break;
1564 case KHTML_NOWRAP:
1565 m_value.ident = CSSValueWebkitNowrap;
1566 break;
1567 }
1568 }
1569
1570 template<> inline CSSPrimitiveValue::operator EWhiteSpace() const
1571 {
1572 switch (m_value.ident) {
1573 case CSSValueWebkitNowrap:
1574 return KHTML_NOWRAP;
1575 case CSSValueNowrap:
1576 return NOWRAP;
1577 case CSSValuePre:
1578 return PRE;
1579 case CSSValuePreWrap:
1580 return PRE_WRAP;
1581 case CSSValuePreLine:
1582 return PRE_LINE;
1583 case CSSValueNormal:
1584 return NORMAL;
1585 default:
1586 ASSERT_NOT_REACHED();
1587 return NORMAL;
1588 }
1589 }
1590
1591 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e)
1592 : m_type(CSS_IDENT)
1593 {
1594 switch (e) {
1595 case NormalWordBreak:
1596 m_value.ident = CSSValueNormal;
1597 break;
1598 case BreakAllWordBreak:
1599 m_value.ident = CSSValueBreakAll;
1600 break;
1601 case BreakWordBreak:
1602 m_value.ident = CSSValueBreakWord;
1603 break;
1604 }
1605 }
1606
1607 template<> inline CSSPrimitiveValue::operator EWordBreak() const
1608 {
1609 switch (m_value.ident) {
1610 case CSSValueBreakAll:
1611 return BreakAllWordBreak;
1612 case CSSValueBreakWord:
1613 return BreakWordBreak;
1614 case CSSValueNormal:
1615 return NormalWordBreak;
1616 default:
1617 ASSERT_NOT_REACHED();
1618 return NormalWordBreak;
1619 }
1620 }
1621
1622 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordWrap e)
1623 : m_type(CSS_IDENT)
1624 {
1625 switch (e) {
1626 case NormalWordWrap:
1627 m_value.ident = CSSValueNormal;
1628 break;
1629 case BreakWordWrap:
1630 m_value.ident = CSSValueBreakWord;
1631 break;
1632 }
1633 }
1634
1635 template<> inline CSSPrimitiveValue::operator EWordWrap() const
1636 {
1637 switch (m_value.ident) {
1638 case CSSValueBreakWord:
1639 return BreakWordWrap;
1640 case CSSValueNormal:
1641 return NormalWordWrap;
1642 default:
1643 ASSERT_NOT_REACHED();
1644 return NormalWordWrap;
1645 }
1646 }
1647
1648 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e)
1649 : m_type(CSS_IDENT)
1650 {
1651 switch (e) {
1652 case LTR:
1653 m_value.ident = CSSValueLtr;
1654 break;
1655 case RTL:
1656 m_value.ident = CSSValueRtl;
1657 break;
1658 }
1659 }
1660
1661 template<> inline CSSPrimitiveValue::operator TextDirection() const
1662 {
1663 switch (m_value.ident) {
1664 case CSSValueLtr:
1665 return LTR;
1666 case CSSValueRtl:
1667 return RTL;
1668 default:
1669 ASSERT_NOT_REACHED();
1670 return LTR;
1671 }
1672 }
1673
1674 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e)
1675 : m_type(CSS_IDENT)
1676 {
1677 switch (e) {
1678 case PE_NONE:
1679 m_value.ident = CSSValueNone;
1680 break;
1681 case PE_STROKE:
1682 m_value.ident = CSSValueStroke;
1683 break;
1684 case PE_FILL:
1685 m_value.ident = CSSValueFill;
1686 break;
1687 case PE_PAINTED:
1688 m_value.ident = CSSValuePainted;
1689 break;
1690 case PE_VISIBLE:
1691 m_value.ident = CSSValueVisible;
1692 break;
1693 case PE_VISIBLE_STROKE:
1694 m_value.ident = CSSValueVisiblestroke;
1695 break;
1696 case PE_VISIBLE_FILL:
1697 m_value.ident = CSSValueVisiblefill;
1698 break;
1699 case PE_VISIBLE_PAINTED:
1700 m_value.ident = CSSValueVisiblepainted;
1701 break;
1702 case PE_AUTO:
1703 m_value.ident = CSSValueAuto;
1704 break;
1705 case PE_ALL:
1706 m_value.ident = CSSValueAll;
1707 break;
1708 }
1709 }
1710
1711 template<> inline CSSPrimitiveValue::operator EPointerEvents() const
1712 {
1713 switch (m_value.ident) {
1714 case CSSValueAll:
1715 return PE_ALL;
1716 case CSSValueAuto:
1717 return PE_AUTO;
1718 case CSSValueNone:
1719 return PE_NONE;
1720 case CSSValueVisiblepainted:
1721 return PE_VISIBLE_PAINTED;
1722 case CSSValueVisiblefill:
1723 return PE_VISIBLE_FILL;
1724 case CSSValueVisiblestroke:
1725 return PE_VISIBLE_STROKE;
1726 case CSSValueVisible:
1727 return PE_VISIBLE;
1728 case CSSValuePainted:
1729 return PE_PAINTED;
1730 case CSSValueFill:
1731 return PE_FILL;
1732 case CSSValueStroke:
1733 return PE_STROKE;
1734 default:
1735 ASSERT_NOT_REACHED();
1736 return PE_ALL;
1737 }
1738 }
1739
1740 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageLoadingBorder e)
1741 : m_type(CSS_IDENT)
1742 {
1743 switch (e) {
1744 case IMAGE_LOADING_BORDER_NONE:
1745 m_value.ident = CSSValueNone;
1746 break;
1747 case IMAGE_LOADING_BORDER_OUTLINE:
1748 m_value.ident = CSSValueWebkitLoadingOutline;
1749 break;
1750 }
1751 }
1752
1753 template<> inline CSSPrimitiveValue::operator EImageLoadingBorder() const
1754 {
1755 switch (m_value.ident) {
1756 case CSSValueNone:
1757 return IMAGE_LOADING_BORDER_NONE;
1758 case CSSValueWebkitLoadingOutline:
1759 return IMAGE_LOADING_BORDER_OUTLINE;
1760 default:
1761 ASSERT_NOT_REACHED();
1762 return IMAGE_LOADING_BORDER_NONE;
1763 }
1764 }
1765
1766 #if ENABLE(SVG)
1767
1768 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
1769 : m_type(CSS_IDENT)
1770 {
1771 switch (e) {
1772 case ButtCap:
1773 m_value.ident = CSSValueButt;
1774 break;
1775 case RoundCap:
1776 m_value.ident = CSSValueRound;
1777 break;
1778 case SquareCap:
1779 m_value.ident = CSSValueSquare;
1780 break;
1781 }
1782 }
1783
1784 template<> inline CSSPrimitiveValue::operator LineCap() const
1785 {
1786 switch (m_value.ident) {
1787 case CSSValueButt:
1788 return ButtCap;
1789 case CSSValueRound:
1790 return RoundCap;
1791 case CSSValueSquare:
1792 return SquareCap;
1793 default:
1794 ASSERT_NOT_REACHED();
1795 return ButtCap;
1796 }
1797 }
1798
1799 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineJoin e)
1800 : m_type(CSS_IDENT)
1801 {
1802 switch (e) {
1803 case MiterJoin:
1804 m_value.ident = CSSValueMiter;
1805 break;
1806 case RoundJoin:
1807 m_value.ident = CSSValueRound;
1808 break;
1809 case BevelJoin:
1810 m_value.ident = CSSValueBevel;
1811 break;
1812 }
1813 }
1814
1815 template<> inline CSSPrimitiveValue::operator LineJoin() const
1816 {
1817 switch (m_value.ident) {
1818 case CSSValueMiter:
1819 return MiterJoin;
1820 case CSSValueRound:
1821 return RoundJoin;
1822 case CSSValueBevel:
1823 return BevelJoin;
1824 default:
1825 ASSERT_NOT_REACHED();
1826 return MiterJoin;
1827 }
1828 }
1829
1830 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WindRule e)
1831 : m_type(CSS_IDENT)
1832 {
1833 switch (e) {
1834 case RULE_NONZERO:
1835 m_value.ident = CSSValueNonzero;
1836 break;
1837 case RULE_EVENODD:
1838 m_value.ident = CSSValueEvenodd;
1839 break;
1840 }
1841 }
1842
1843 template<> inline CSSPrimitiveValue::operator WindRule() const
1844 {
1845 switch (m_value.ident) {
1846 case CSSValueNonzero:
1847 return RULE_NONZERO;
1848 case CSSValueEvenodd:
1849 return RULE_EVENODD;
1850 default:
1851 ASSERT_NOT_REACHED();
1852 return RULE_NONZERO;
1853 }
1854 }
1855
1856
1857 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignmentBaseline e)
1858 : m_type(CSS_IDENT)
1859 {
1860 switch (e) {
1861 case AB_AUTO:
1862 m_value.ident = CSSValueAuto;
1863 break;
1864 case AB_BASELINE:
1865 m_value.ident = CSSValueBaseline;
1866 break;
1867 case AB_BEFORE_EDGE:
1868 m_value.ident = CSSValueBeforeEdge;
1869 break;
1870 case AB_TEXT_BEFORE_EDGE:
1871 m_value.ident = CSSValueTextBeforeEdge;
1872 break;
1873 case AB_MIDDLE:
1874 m_value.ident = CSSValueMiddle;
1875 break;
1876 case AB_CENTRAL:
1877 m_value.ident = CSSValueCentral;
1878 break;
1879 case AB_AFTER_EDGE:
1880 m_value.ident = CSSValueAfterEdge;
1881 break;
1882 case AB_TEXT_AFTER_EDGE:
1883 m_value.ident = CSSValueTextAfterEdge;
1884 break;
1885 case AB_IDEOGRAPHIC:
1886 m_value.ident = CSSValueIdeographic;
1887 break;
1888 case AB_ALPHABETIC:
1889 m_value.ident = CSSValueAlphabetic;
1890 break;
1891 case AB_HANGING:
1892 m_value.ident = CSSValueHanging;
1893 break;
1894 case AB_MATHEMATICAL:
1895 m_value.ident = CSSValueMathematical;
1896 break;
1897 }
1898 }
1899
1900 template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const
1901 {
1902 switch (m_value.ident) {
1903 case CSSValueAuto:
1904 return AB_AUTO;
1905 case CSSValueBaseline:
1906 return AB_BASELINE;
1907 case CSSValueBeforeEdge:
1908 return AB_BEFORE_EDGE;
1909 case CSSValueTextBeforeEdge:
1910 return AB_TEXT_BEFORE_EDGE;
1911 case CSSValueMiddle:
1912 return AB_MIDDLE;
1913 case CSSValueCentral:
1914 return AB_CENTRAL;
1915 case CSSValueAfterEdge:
1916 return AB_AFTER_EDGE;
1917 case CSSValueTextAfterEdge:
1918 return AB_TEXT_AFTER_EDGE;
1919 case CSSValueIdeographic:
1920 return AB_IDEOGRAPHIC;
1921 case CSSValueAlphabetic:
1922 return AB_ALPHABETIC;
1923 case CSSValueHanging:
1924 return AB_HANGING;
1925 case CSSValueMathematical:
1926 return AB_MATHEMATICAL;
1927 default:
1928 ASSERT_NOT_REACHED();
1929 return AB_AUTO;
1930 }
1931 }
1932
1933 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
1934 : m_type(CSS_IDENT)
1935 {
1936 switch (e) {
1937 case CI_AUTO:
1938 m_value.ident = CSSValueAuto;
1939 break;
1940 case CI_SRGB:
1941 m_value.ident = CSSValueSrgb;
1942 break;
1943 case CI_LINEARRGB:
1944 m_value.ident = CSSValueLinearrgb;
1945 break;
1946 }
1947 }
1948
1949 template<> inline CSSPrimitiveValue::operator EColorInterpolation() const
1950 {
1951 switch (m_value.ident) {
1952 case CSSValueSrgb:
1953 return CI_SRGB;
1954 case CSSValueLinearrgb:
1955 return CI_LINEARRGB;
1956 case CSSValueAuto:
1957 return CI_AUTO;
1958 default:
1959 ASSERT_NOT_REACHED();
1960 return CI_AUTO;
1961 }
1962 }
1963
1964 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e)
1965 : m_type(CSS_IDENT)
1966 {
1967 switch (e) {
1968 case CR_AUTO:
1969 m_value.ident = CSSValueAuto;
1970 break;
1971 case CR_OPTIMIZESPEED:
1972 m_value.ident = CSSValueOptimizespeed;
1973 break;
1974 case CR_OPTIMIZEQUALITY:
1975 m_value.ident = CSSValueOptimizequality;
1976 break;
1977 }
1978 }
1979
1980 template<> inline CSSPrimitiveValue::operator EColorRendering() const
1981 {
1982 switch (m_value.ident) {
1983 case CSSValueOptimizespeed:
1984 return CR_OPTIMIZESPEED;
1985 case CSSValueOptimizequality:
1986 return CR_OPTIMIZEQUALITY;
1987 case CSSValueAuto:
1988 return CR_AUTO;
1989 default:
1990 ASSERT_NOT_REACHED();
1991 return CR_AUTO;
1992 }
1993 }
1994
1995 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDominantBaseline e)
1996 : m_type(CSS_IDENT)
1997 {
1998 switch (e) {
1999 case DB_AUTO:
2000 m_value.ident = CSSValueAuto;
2001 break;
2002 case DB_USE_SCRIPT:
2003 m_value.ident = CSSValueUseScript;
2004 break;
2005 case DB_NO_CHANGE:
2006 m_value.ident = CSSValueNoChange;
2007 break;
2008 case DB_RESET_SIZE:
2009 m_value.ident = CSSValueResetSize;
2010 break;
2011 case DB_CENTRAL:
2012 m_value.ident = CSSValueCentral;
2013 break;
2014 case DB_MIDDLE:
2015 m_value.ident = CSSValueMiddle;
2016 break;
2017 case DB_TEXT_BEFORE_EDGE:
2018 m_value.ident = CSSValueTextBeforeEdge;
2019 break;
2020 case DB_TEXT_AFTER_EDGE:
2021 m_value.ident = CSSValueTextAfterEdge;
2022 break;
2023 case DB_IDEOGRAPHIC:
2024 m_value.ident = CSSValueIdeographic;
2025 break;
2026 case DB_ALPHABETIC:
2027 m_value.ident = CSSValueAlphabetic;
2028 break;
2029 case DB_HANGING:
2030 m_value.ident = CSSValueHanging;
2031 break;
2032 case DB_MATHEMATICAL:
2033 m_value.ident = CSSValueMathematical;
2034 break;
2035 }
2036 }
2037
2038 template<> inline CSSPrimitiveValue::operator EDominantBaseline() const
2039 {
2040 switch (m_value.ident) {
2041 case CSSValueAuto:
2042 return DB_AUTO;
2043 case CSSValueUseScript:
2044 return DB_USE_SCRIPT;
2045 case CSSValueNoChange:
2046 return DB_NO_CHANGE;
2047 case CSSValueResetSize:
2048 return DB_RESET_SIZE;
2049 case CSSValueIdeographic:
2050 return DB_IDEOGRAPHIC;
2051 case CSSValueAlphabetic:
2052 return DB_ALPHABETIC;
2053 case CSSValueHanging:
2054 return DB_HANGING;
2055 case CSSValueMathematical:
2056 return DB_MATHEMATICAL;
2057 case CSSValueCentral:
2058 return DB_CENTRAL;
2059 case CSSValueMiddle:
2060 return DB_MIDDLE;
2061 case CSSValueTextAfterEdge:
2062 return DB_TEXT_AFTER_EDGE;
2063 case CSSValueTextBeforeEdge:
2064 return DB_TEXT_BEFORE_EDGE;
2065 default:
2066 ASSERT_NOT_REACHED();
2067 return DB_AUTO;
2068 }
2069 }
2070
2071 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
2072 : m_type(CSS_IDENT)
2073 {
2074 switch (e) {
2075 case IR_AUTO:
2076 m_value.ident = CSSValueAuto;
2077 break;
2078 case IR_OPTIMIZESPEED:
2079 m_value.ident = CSSValueOptimizespeed;
2080 break;
2081 case IR_OPTIMIZEQUALITY:
2082 m_value.ident = CSSValueOptimizequality;
2083 break;
2084 }
2085 }
2086
2087 template<> inline CSSPrimitiveValue::operator EImageRendering() const
2088 {
2089 switch (m_value.ident) {
2090 case CSSValueAuto:
2091 return IR_AUTO;
2092 case CSSValueOptimizespeed:
2093 return IR_OPTIMIZESPEED;
2094 case CSSValueOptimizequality:
2095 return IR_OPTIMIZEQUALITY;
2096 default:
2097 ASSERT_NOT_REACHED();
2098 return IR_AUTO;
2099 }
2100 }
2101
2102 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e)
2103 : m_type(CSS_IDENT)
2104 {
2105 switch (e) {
2106 case IR_AUTO:
2107 m_value.ident = CSSValueAuto;
2108 break;
2109 case IR_OPTIMIZESPEED:
2110 m_value.ident = CSSValueOptimizespeed;
2111 break;
2112 case SR_CRISPEDGES:
2113 m_value.ident = CSSValueCrispedges;
2114 break;
2115 case SR_GEOMETRICPRECISION:
2116 m_value.ident = CSSValueGeometricprecision;
2117 break;
2118 }
2119 }
2120
2121 template<> inline CSSPrimitiveValue::operator EShapeRendering() const
2122 {
2123 switch (m_value.ident) {
2124 case CSSValueAuto:
2125 return SR_AUTO;
2126 case CSSValueOptimizespeed:
2127 return SR_OPTIMIZESPEED;
2128 case CSSValueCrispedges:
2129 return SR_CRISPEDGES;
2130 case CSSValueGeometricprecision:
2131 return SR_GEOMETRICPRECISION;
2132 default:
2133 ASSERT_NOT_REACHED();
2134 return SR_AUTO;
2135 }
2136 }
2137
2138 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAnchor e)
2139 : m_type(CSS_IDENT)
2140 {
2141 switch (e) {
2142 case TA_START:
2143 m_value.ident = CSSValueStart;
2144 break;
2145 case TA_MIDDLE:
2146 m_value.ident = CSSValueMiddle;
2147 break;
2148 case TA_END:
2149 m_value.ident = CSSValueEnd;
2150 break;
2151 }
2152 }
2153
2154 template<> inline CSSPrimitiveValue::operator ETextAnchor() const
2155 {
2156 switch (m_value.ident) {
2157 case CSSValueStart:
2158 return TA_START;
2159 case CSSValueMiddle:
2160 return TA_MIDDLE;
2161 case CSSValueEnd:
2162 return TA_END;
2163 default:
2164 ASSERT_NOT_REACHED();
2165 return TA_START;
2166 }
2167 }
2168
2169 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextRendering e)
2170 : m_type(CSS_IDENT)
2171 {
2172 switch (e) {
2173 case TR_AUTO:
2174 m_value.ident = CSSValueAuto;
2175 break;
2176 case TR_OPTIMIZESPEED:
2177 m_value.ident = CSSValueOptimizespeed;
2178 break;
2179 case TR_OPTIMIZELEGIBILITY:
2180 m_value.ident = CSSValueOptimizelegibility;
2181 break;
2182 case TR_GEOMETRICPRECISION:
2183 m_value.ident = CSSValueGeometricprecision;
2184 break;
2185 }
2186 }
2187
2188 template<> inline CSSPrimitiveValue::operator ETextRendering() const
2189 {
2190 switch (m_value.ident) {
2191 case CSSValueAuto:
2192 return TR_AUTO;
2193 case CSSValueOptimizespeed:
2194 return TR_OPTIMIZESPEED;
2195 case CSSValueOptimizelegibility:
2196 return TR_OPTIMIZELEGIBILITY;
2197 case CSSValueGeometricprecision:
2198 return TR_GEOMETRICPRECISION;
2199 default:
2200 ASSERT_NOT_REACHED();
2201 return TR_AUTO;
2202 }
2203 }
2204
2205 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWritingMode e)
2206 : m_type(CSS_IDENT)
2207 {
2208 switch (e) {
2209 case WM_LRTB:
2210 m_value.ident = CSSValueLrTb;
2211 break;
2212 case WM_LR:
2213 m_value.ident = CSSValueLr;
2214 break;
2215 case WM_RLTB:
2216 m_value.ident = CSSValueRlTb;
2217 break;
2218 case WM_RL:
2219 m_value.ident = CSSValueRl;
2220 break;
2221 case WM_TBRL:
2222 m_value.ident = CSSValueTbRl;
2223 break;
2224 case WM_TB:
2225 m_value.ident = CSSValueTb;
2226 break;
2227 }
2228 }
2229
2230 template<> inline CSSPrimitiveValue::operator EWritingMode() const
2231 {
2232 return static_cast<EWritingMode>(m_value.ident - CSSValueLrTb);
2233 }
2234
2235 #endif
2236
2237 }
2238
2239 #endif