1/* 2 * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>. 3 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 4 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 5 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#ifndef CSSPrimitiveValueMappings_h 31#define CSSPrimitiveValueMappings_h 32 33#include "CSSCalculationValue.h" 34#include "CSSPrimitiveValue.h" 35#include "CSSReflectionDirection.h" 36#include "ColorSpace.h" 37#include "CSSValueKeywords.h" 38#include "FontDescription.h" 39#include "FontSmoothingMode.h" 40#include "GraphicsTypes.h" 41#if ENABLE(CSS_IMAGE_ORIENTATION) 42#include "ImageOrientation.h" 43#endif 44#include "Length.h" 45#include "LineClampValue.h" 46#include "Path.h" 47#include "RenderStyleConstants.h" 48#include "SVGRenderStyleDefs.h" 49#include "TextDirection.h" 50#include "TextRenderingMode.h" 51#include "ThemeTypes.h" 52#include "UnicodeBidi.h" 53#include "WritingMode.h" 54 55#include <wtf/MathExtras.h> 56 57namespace WebCore { 58 59template<> inline CSSPrimitiveValue::CSSPrimitiveValue(short i) 60 : CSSValue(PrimitiveClass) 61{ 62 m_primitiveUnitType = CSS_NUMBER; 63 m_value.num = static_cast<double>(i); 64} 65 66template<> inline CSSPrimitiveValue::operator short() const 67{ 68 if (m_primitiveUnitType == CSS_NUMBER) 69 return clampTo<short>(m_value.num); 70 71 ASSERT_NOT_REACHED(); 72 return 0; 73} 74 75template<> inline CSSPrimitiveValue::CSSPrimitiveValue(unsigned short i) 76 : CSSValue(PrimitiveClass) 77{ 78 m_primitiveUnitType = CSS_NUMBER; 79 m_value.num = static_cast<double>(i); 80} 81 82template<> inline CSSPrimitiveValue::operator unsigned short() const 83{ 84 if (m_primitiveUnitType == CSS_NUMBER) 85 return clampTo<unsigned short>(m_value.num); 86 87 ASSERT_NOT_REACHED(); 88 return 0; 89} 90 91template<> inline CSSPrimitiveValue::operator int() const 92{ 93 if (m_primitiveUnitType == CSS_NUMBER) 94 return clampTo<int>(m_value.num); 95 96 ASSERT_NOT_REACHED(); 97 return 0; 98} 99 100template<> inline CSSPrimitiveValue::operator unsigned() const 101{ 102 if (m_primitiveUnitType == CSS_NUMBER) 103 return clampTo<unsigned>(m_value.num); 104 105 ASSERT_NOT_REACHED(); 106 return 0; 107} 108 109 110template<> inline CSSPrimitiveValue::CSSPrimitiveValue(float i) 111 : CSSValue(PrimitiveClass) 112{ 113 m_primitiveUnitType = CSS_NUMBER; 114 m_value.num = static_cast<double>(i); 115} 116 117template<> inline CSSPrimitiveValue::operator float() const 118{ 119 if (m_primitiveUnitType == CSS_NUMBER) 120 return clampTo<float>(m_value.num); 121 122 ASSERT_NOT_REACHED(); 123 return 0.0f; 124} 125 126template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineClampValue i) 127 : CSSValue(PrimitiveClass) 128{ 129 m_primitiveUnitType = i.isPercentage() ? CSS_PERCENTAGE : CSS_NUMBER; 130 m_value.num = static_cast<double>(i.value()); 131} 132 133template<> inline CSSPrimitiveValue::operator LineClampValue() const 134{ 135 if (m_primitiveUnitType == CSS_NUMBER) 136 return LineClampValue(clampTo<int>(m_value.num), LineClampLineCount); 137 138 if (m_primitiveUnitType == CSS_PERCENTAGE) 139 return LineClampValue(clampTo<int>(m_value.num), LineClampPercentage); 140 141 ASSERT_NOT_REACHED(); 142 return LineClampValue(); 143} 144 145template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSReflectionDirection e) 146 : CSSValue(PrimitiveClass) 147{ 148 m_primitiveUnitType = CSS_IDENT; 149 switch (e) { 150 case ReflectionAbove: 151 m_value.ident = CSSValueAbove; 152 break; 153 case ReflectionBelow: 154 m_value.ident = CSSValueBelow; 155 break; 156 case ReflectionLeft: 157 m_value.ident = CSSValueLeft; 158 break; 159 case ReflectionRight: 160 m_value.ident = CSSValueRight; 161 } 162} 163 164template<> inline CSSPrimitiveValue::operator CSSReflectionDirection() const 165{ 166 switch (m_value.ident) { 167 case CSSValueAbove: 168 return ReflectionAbove; 169 case CSSValueBelow: 170 return ReflectionBelow; 171 case CSSValueLeft: 172 return ReflectionLeft; 173 case CSSValueRight: 174 return ReflectionRight; 175 } 176 177 ASSERT_NOT_REACHED(); 178 return ReflectionBelow; 179} 180 181template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColumnSpan columnSpan) 182 : CSSValue(PrimitiveClass) 183{ 184 m_primitiveUnitType = CSS_IDENT; 185 switch (columnSpan) { 186 case ColumnSpanAll: 187 m_value.ident = CSSValueAll; 188 break; 189 case ColumnSpanNone: 190 m_value.ident = CSSValueNone; 191 break; 192 } 193} 194 195template<> inline CSSPrimitiveValue::operator ColumnSpan() const 196{ 197 // Map 1 to none for compatibility reasons. 198 if (m_primitiveUnitType == CSS_NUMBER && m_value.num == 1) 199 return ColumnSpanNone; 200 201 switch (m_value.ident) { 202 case CSSValueAll: 203 return ColumnSpanAll; 204 case CSSValueNone: 205 return ColumnSpanNone; 206 } 207 208 ASSERT_NOT_REACHED(); 209 return ColumnSpanNone; 210} 211 212 213template<> inline CSSPrimitiveValue::CSSPrimitiveValue(PrintColorAdjust value) 214 : CSSValue(PrimitiveClass) 215{ 216 m_primitiveUnitType = CSS_IDENT; 217 switch (value) { 218 case PrintColorAdjustExact: 219 m_value.ident = CSSValueExact; 220 break; 221 case PrintColorAdjustEconomy: 222 m_value.ident = CSSValueEconomy; 223 break; 224 } 225} 226 227template<> inline CSSPrimitiveValue::operator PrintColorAdjust() const 228{ 229 switch (m_value.ident) { 230 case CSSValueEconomy: 231 return PrintColorAdjustEconomy; 232 case CSSValueExact: 233 return PrintColorAdjustExact; 234 } 235 236 ASSERT_NOT_REACHED(); 237 return PrintColorAdjustEconomy; 238} 239 240 241template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderStyle e) 242 : CSSValue(PrimitiveClass) 243{ 244 m_primitiveUnitType = CSS_IDENT; 245 switch (e) { 246 case BNONE: 247 m_value.ident = CSSValueNone; 248 break; 249 case BHIDDEN: 250 m_value.ident = CSSValueHidden; 251 break; 252 case INSET: 253 m_value.ident = CSSValueInset; 254 break; 255 case GROOVE: 256 m_value.ident = CSSValueGroove; 257 break; 258 case RIDGE: 259 m_value.ident = CSSValueRidge; 260 break; 261 case OUTSET: 262 m_value.ident = CSSValueOutset; 263 break; 264 case DOTTED: 265 m_value.ident = CSSValueDotted; 266 break; 267 case DASHED: 268 m_value.ident = CSSValueDashed; 269 break; 270 case SOLID: 271 m_value.ident = CSSValueSolid; 272 break; 273 case DOUBLE: 274 m_value.ident = CSSValueDouble; 275 break; 276 } 277} 278 279template<> inline CSSPrimitiveValue::operator EBorderStyle() const 280{ 281 if (m_value.ident == CSSValueAuto) // Valid for CSS outline-style 282 return DOTTED; 283 return (EBorderStyle)(m_value.ident - CSSValueNone); 284} 285 286template<> inline CSSPrimitiveValue::operator OutlineIsAuto() const 287{ 288 if (m_value.ident == CSSValueAuto) 289 return AUTO_ON; 290 return AUTO_OFF; 291} 292 293template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e) 294 : CSSValue(PrimitiveClass) 295{ 296 m_primitiveUnitType = CSS_IDENT; 297 switch (e) { 298 case CompositeClear: 299 m_value.ident = CSSValueClear; 300 break; 301 case CompositeCopy: 302 m_value.ident = CSSValueCopy; 303 break; 304 case CompositeSourceOver: 305 m_value.ident = CSSValueSourceOver; 306 break; 307 case CompositeSourceIn: 308 m_value.ident = CSSValueSourceIn; 309 break; 310 case CompositeSourceOut: 311 m_value.ident = CSSValueSourceOut; 312 break; 313 case CompositeSourceAtop: 314 m_value.ident = CSSValueSourceAtop; 315 break; 316 case CompositeDestinationOver: 317 m_value.ident = CSSValueDestinationOver; 318 break; 319 case CompositeDestinationIn: 320 m_value.ident = CSSValueDestinationIn; 321 break; 322 case CompositeDestinationOut: 323 m_value.ident = CSSValueDestinationOut; 324 break; 325 case CompositeDestinationAtop: 326 m_value.ident = CSSValueDestinationAtop; 327 break; 328 case CompositeXOR: 329 m_value.ident = CSSValueXor; 330 break; 331 case CompositePlusDarker: 332 m_value.ident = CSSValuePlusDarker; 333 break; 334 case CompositePlusLighter: 335 m_value.ident = CSSValuePlusLighter; 336 break; 337 case CompositeDifference: 338 ASSERT_NOT_REACHED(); 339 break; 340 } 341} 342 343template<> inline CSSPrimitiveValue::operator CompositeOperator() const 344{ 345 switch (m_value.ident) { 346 case CSSValueClear: 347 return CompositeClear; 348 case CSSValueCopy: 349 return CompositeCopy; 350 case CSSValueSourceOver: 351 return CompositeSourceOver; 352 case CSSValueSourceIn: 353 return CompositeSourceIn; 354 case CSSValueSourceOut: 355 return CompositeSourceOut; 356 case CSSValueSourceAtop: 357 return CompositeSourceAtop; 358 case CSSValueDestinationOver: 359 return CompositeDestinationOver; 360 case CSSValueDestinationIn: 361 return CompositeDestinationIn; 362 case CSSValueDestinationOut: 363 return CompositeDestinationOut; 364 case CSSValueDestinationAtop: 365 return CompositeDestinationAtop; 366 case CSSValueXor: 367 return CompositeXOR; 368 case CSSValuePlusDarker: 369 return CompositePlusDarker; 370 case CSSValuePlusLighter: 371 return CompositePlusLighter; 372 } 373 374 ASSERT_NOT_REACHED(); 375 return CompositeClear; 376} 377 378template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) 379 : CSSValue(PrimitiveClass) 380{ 381 m_primitiveUnitType = CSS_IDENT; 382 switch (e) { 383 case NoControlPart: 384 m_value.ident = CSSValueNone; 385 break; 386 case CheckboxPart: 387 m_value.ident = CSSValueCheckbox; 388 break; 389 case RadioPart: 390 m_value.ident = CSSValueRadio; 391 break; 392 case PushButtonPart: 393 m_value.ident = CSSValuePushButton; 394 break; 395 case SquareButtonPart: 396 m_value.ident = CSSValueSquareButton; 397 break; 398 case ButtonPart: 399 m_value.ident = CSSValueButton; 400 break; 401 case ButtonBevelPart: 402 m_value.ident = CSSValueButtonBevel; 403 break; 404 case DefaultButtonPart: 405 m_value.ident = CSSValueDefaultButton; 406 break; 407 case InnerSpinButtonPart: 408 m_value.ident = CSSValueInnerSpinButton; 409 break; 410 case ListboxPart: 411 m_value.ident = CSSValueListbox; 412 break; 413 case ListItemPart: 414 m_value.ident = CSSValueListitem; 415 break; 416 case MediaEnterFullscreenButtonPart: 417 m_value.ident = CSSValueMediaEnterFullscreenButton; 418 break; 419 case MediaExitFullscreenButtonPart: 420 m_value.ident = CSSValueMediaExitFullscreenButton; 421 break; 422 case MediaPlayButtonPart: 423 m_value.ident = CSSValueMediaPlayButton; 424 break; 425 case MediaOverlayPlayButtonPart: 426 m_value.ident = CSSValueMediaOverlayPlayButton; 427 break; 428 case MediaMuteButtonPart: 429 m_value.ident = CSSValueMediaMuteButton; 430 break; 431 case MediaSeekBackButtonPart: 432 m_value.ident = CSSValueMediaSeekBackButton; 433 break; 434 case MediaSeekForwardButtonPart: 435 m_value.ident = CSSValueMediaSeekForwardButton; 436 break; 437 case MediaRewindButtonPart: 438 m_value.ident = CSSValueMediaRewindButton; 439 break; 440 case MediaReturnToRealtimeButtonPart: 441 m_value.ident = CSSValueMediaReturnToRealtimeButton; 442 break; 443 case MediaToggleClosedCaptionsButtonPart: 444 m_value.ident = CSSValueMediaToggleClosedCaptionsButton; 445 break; 446 case MediaSliderPart: 447 m_value.ident = CSSValueMediaSlider; 448 break; 449 case MediaSliderThumbPart: 450 m_value.ident = CSSValueMediaSliderthumb; 451 break; 452 case MediaVolumeSliderContainerPart: 453 m_value.ident = CSSValueMediaVolumeSliderContainer; 454 break; 455 case MediaVolumeSliderPart: 456 m_value.ident = CSSValueMediaVolumeSlider; 457 break; 458 case MediaVolumeSliderMuteButtonPart: 459 m_value.ident = CSSValueMediaVolumeSliderMuteButton; 460 break; 461 case MediaVolumeSliderThumbPart: 462 m_value.ident = CSSValueMediaVolumeSliderthumb; 463 break; 464 case MediaControlsBackgroundPart: 465 m_value.ident = CSSValueMediaControlsBackground; 466 break; 467 case MediaControlsFullscreenBackgroundPart: 468 m_value.ident = CSSValueMediaControlsFullscreenBackground; 469 break; 470 case MediaFullScreenVolumeSliderPart: 471 m_value.ident = CSSValueMediaFullscreenVolumeSlider; 472 break; 473 case MediaFullScreenVolumeSliderThumbPart: 474 m_value.ident = CSSValueMediaFullscreenVolumeSliderThumb; 475 break; 476 case MediaCurrentTimePart: 477 m_value.ident = CSSValueMediaCurrentTimeDisplay; 478 break; 479 case MediaTimeRemainingPart: 480 m_value.ident = CSSValueMediaTimeRemainingDisplay; 481 break; 482 case MenulistPart: 483 m_value.ident = CSSValueMenulist; 484 break; 485 case MenulistButtonPart: 486 m_value.ident = CSSValueMenulistButton; 487 break; 488 case MenulistTextPart: 489 m_value.ident = CSSValueMenulistText; 490 break; 491 case MenulistTextFieldPart: 492 m_value.ident = CSSValueMenulistTextfield; 493 break; 494 case MeterPart: 495 m_value.ident = CSSValueMeter; 496 break; 497 case RelevancyLevelIndicatorPart: 498 m_value.ident = CSSValueRelevancyLevelIndicator; 499 break; 500 case ContinuousCapacityLevelIndicatorPart: 501 m_value.ident = CSSValueContinuousCapacityLevelIndicator; 502 break; 503 case DiscreteCapacityLevelIndicatorPart: 504 m_value.ident = CSSValueDiscreteCapacityLevelIndicator; 505 break; 506 case RatingLevelIndicatorPart: 507 m_value.ident = CSSValueRatingLevelIndicator; 508 break; 509 case ProgressBarPart: 510#if ENABLE(PROGRESS_ELEMENT) 511 m_value.ident = CSSValueProgressBar; 512#endif 513 break; 514 case ProgressBarValuePart: 515#if ENABLE(PROGRESS_ELEMENT) 516 m_value.ident = CSSValueProgressBarValue; 517#endif 518 break; 519 case SliderHorizontalPart: 520 m_value.ident = CSSValueSliderHorizontal; 521 break; 522 case SliderVerticalPart: 523 m_value.ident = CSSValueSliderVertical; 524 break; 525 case SliderThumbHorizontalPart: 526 m_value.ident = CSSValueSliderthumbHorizontal; 527 break; 528 case SliderThumbVerticalPart: 529 m_value.ident = CSSValueSliderthumbVertical; 530 break; 531 case CaretPart: 532 m_value.ident = CSSValueCaret; 533 break; 534 case SearchFieldPart: 535 m_value.ident = CSSValueSearchfield; 536 break; 537 case SearchFieldDecorationPart: 538 m_value.ident = CSSValueSearchfieldDecoration; 539 break; 540 case SearchFieldResultsDecorationPart: 541 m_value.ident = CSSValueSearchfieldResultsDecoration; 542 break; 543 case SearchFieldResultsButtonPart: 544 m_value.ident = CSSValueSearchfieldResultsButton; 545 break; 546 case SearchFieldCancelButtonPart: 547 m_value.ident = CSSValueSearchfieldCancelButton; 548 break; 549 case SnapshottedPluginOverlayPart: 550 m_value.ident = CSSValueSnapshottedPluginOverlay; 551 break; 552 case TextFieldPart: 553 m_value.ident = CSSValueTextfield; 554 break; 555 case TextAreaPart: 556 m_value.ident = CSSValueTextarea; 557 break; 558 case CapsLockIndicatorPart: 559 m_value.ident = CSSValueCapsLockIndicator; 560 break; 561 case InputSpeechButtonPart: 562#if ENABLE(INPUT_SPEECH) 563 m_value.ident = CSSValueWebkitInputSpeechButton; 564#endif 565 break; 566 } 567} 568 569template<> inline CSSPrimitiveValue::operator ControlPart() const 570{ 571 if (m_value.ident == CSSValueNone) 572 return NoControlPart; 573 else 574 return ControlPart(m_value.ident - CSSValueCheckbox + 1); 575} 576 577template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBackfaceVisibility e) 578 : CSSValue(PrimitiveClass) 579{ 580 m_primitiveUnitType = CSS_IDENT; 581 switch (e) { 582 case BackfaceVisibilityVisible: 583 m_value.ident = CSSValueVisible; 584 break; 585 case BackfaceVisibilityHidden: 586 m_value.ident = CSSValueHidden; 587 break; 588 } 589} 590 591template<> inline CSSPrimitiveValue::operator EBackfaceVisibility() const 592{ 593 switch (m_value.ident) { 594 case CSSValueVisible: 595 return BackfaceVisibilityVisible; 596 case CSSValueHidden: 597 return BackfaceVisibilityHidden; 598 } 599 600 ASSERT_NOT_REACHED(); 601 return BackfaceVisibilityHidden; 602} 603 604 605template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillAttachment e) 606 : CSSValue(PrimitiveClass) 607{ 608 m_primitiveUnitType = CSS_IDENT; 609 switch (e) { 610 case ScrollBackgroundAttachment: 611 m_value.ident = CSSValueScroll; 612 break; 613 case LocalBackgroundAttachment: 614 m_value.ident = CSSValueLocal; 615 break; 616 case FixedBackgroundAttachment: 617 m_value.ident = CSSValueFixed; 618 break; 619 } 620} 621 622template<> inline CSSPrimitiveValue::operator EFillAttachment() const 623{ 624 switch (m_value.ident) { 625 case CSSValueScroll: 626 return ScrollBackgroundAttachment; 627 case CSSValueLocal: 628 return LocalBackgroundAttachment; 629 case CSSValueFixed: 630 return FixedBackgroundAttachment; 631 } 632 633 ASSERT_NOT_REACHED(); 634 return ScrollBackgroundAttachment; 635} 636 637template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e) 638 : CSSValue(PrimitiveClass) 639{ 640 m_primitiveUnitType = CSS_IDENT; 641 switch (e) { 642 case BorderFillBox: 643 m_value.ident = CSSValueBorderBox; 644 break; 645 case PaddingFillBox: 646 m_value.ident = CSSValuePaddingBox; 647 break; 648 case ContentFillBox: 649 m_value.ident = CSSValueContentBox; 650 break; 651 case TextFillBox: 652 m_value.ident = CSSValueText; 653 break; 654 } 655} 656 657template<> inline CSSPrimitiveValue::operator EFillBox() const 658{ 659 switch (m_value.ident) { 660 case CSSValueBorder: 661 case CSSValueBorderBox: 662 return BorderFillBox; 663 case CSSValuePadding: 664 case CSSValuePaddingBox: 665 return PaddingFillBox; 666 case CSSValueContent: 667 case CSSValueContentBox: 668 return ContentFillBox; 669 case CSSValueText: 670 case CSSValueWebkitText: 671 return TextFillBox; 672 } 673 674 ASSERT_NOT_REACHED(); 675 return BorderFillBox; 676} 677 678template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillRepeat e) 679 : CSSValue(PrimitiveClass) 680{ 681 m_primitiveUnitType = CSS_IDENT; 682 switch (e) { 683 case RepeatFill: 684 m_value.ident = CSSValueRepeat; 685 break; 686 case NoRepeatFill: 687 m_value.ident = CSSValueNoRepeat; 688 break; 689 case RoundFill: 690 m_value.ident = CSSValueRound; 691 break; 692 case SpaceFill: 693 m_value.ident = CSSValueSpace; 694 break; 695 } 696} 697 698template<> inline CSSPrimitiveValue::operator EFillRepeat() const 699{ 700 switch (m_value.ident) { 701 case CSSValueRepeat: 702 return RepeatFill; 703 case CSSValueNoRepeat: 704 return NoRepeatFill; 705 case CSSValueRound: 706 return RoundFill; 707 case CSSValueSpace: 708 return SpaceFill; 709 } 710 711 ASSERT_NOT_REACHED(); 712 return RepeatFill; 713} 714 715template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxPack e) 716 : CSSValue(PrimitiveClass) 717{ 718 m_primitiveUnitType = CSS_IDENT; 719 switch (e) { 720 case Start: 721 m_value.ident = CSSValueStart; 722 break; 723 case Center: 724 m_value.ident = CSSValueCenter; 725 break; 726 case End: 727 m_value.ident = CSSValueEnd; 728 break; 729 case Justify: 730 m_value.ident = CSSValueJustify; 731 break; 732 } 733} 734 735template<> inline CSSPrimitiveValue::operator EBoxPack() const 736{ 737 switch (m_value.ident) { 738 case CSSValueStart: 739 return Start; 740 case CSSValueEnd: 741 return End; 742 case CSSValueCenter: 743 return Center; 744 case CSSValueJustify: 745 return Justify; 746 } 747 748 ASSERT_NOT_REACHED(); 749 return Justify; 750} 751 752template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e) 753 : CSSValue(PrimitiveClass) 754{ 755 m_primitiveUnitType = CSS_IDENT; 756 switch (e) { 757 case BSTRETCH: 758 m_value.ident = CSSValueStretch; 759 break; 760 case BSTART: 761 m_value.ident = CSSValueStart; 762 break; 763 case BCENTER: 764 m_value.ident = CSSValueCenter; 765 break; 766 case BEND: 767 m_value.ident = CSSValueEnd; 768 break; 769 case BBASELINE: 770 m_value.ident = CSSValueBaseline; 771 break; 772 } 773} 774 775template<> inline CSSPrimitiveValue::operator EBoxAlignment() const 776{ 777 switch (m_value.ident) { 778 case CSSValueStretch: 779 return BSTRETCH; 780 case CSSValueStart: 781 return BSTART; 782 case CSSValueEnd: 783 return BEND; 784 case CSSValueCenter: 785 return BCENTER; 786 case CSSValueBaseline: 787 return BBASELINE; 788 } 789 790 ASSERT_NOT_REACHED(); 791 return BSTRETCH; 792} 793 794#if ENABLE(CSS_BOX_DECORATION_BREAK) 795template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDecorationBreak e) 796 : CSSValue(PrimitiveClass) 797{ 798 m_primitiveUnitType = CSS_IDENT; 799 switch (e) { 800 case DSLICE: 801 m_value.ident = CSSValueSlice; 802 break; 803 case DCLONE: 804 m_value.ident = CSSValueClone; 805 break; 806 } 807} 808 809template<> inline CSSPrimitiveValue::operator EBoxDecorationBreak() const 810{ 811 switch (m_value.ident) { 812 case CSSValueSlice: 813 return DSLICE; 814 case CSSValueClone: 815 return DCLONE; 816 } 817 818 ASSERT_NOT_REACHED(); 819 return DSLICE; 820} 821#endif 822 823template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BackgroundEdgeOrigin e) 824 : CSSValue(PrimitiveClass) 825{ 826 m_primitiveUnitType = CSS_IDENT; 827 switch (e) { 828 case TopEdge: 829 m_value.ident = CSSValueTop; 830 break; 831 case RightEdge: 832 m_value.ident = CSSValueRight; 833 break; 834 case BottomEdge: 835 m_value.ident = CSSValueBottom; 836 break; 837 case LeftEdge: 838 m_value.ident = CSSValueLeft; 839 break; 840 } 841} 842 843template<> inline CSSPrimitiveValue::operator BackgroundEdgeOrigin() const 844{ 845 switch (m_value.ident) { 846 case CSSValueTop: 847 return TopEdge; 848 case CSSValueRight: 849 return RightEdge; 850 case CSSValueBottom: 851 return BottomEdge; 852 case CSSValueLeft: 853 return LeftEdge; 854 } 855 856 ASSERT_NOT_REACHED(); 857 return TopEdge; 858} 859 860template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxSizing e) 861 : CSSValue(PrimitiveClass) 862{ 863 m_primitiveUnitType = CSS_IDENT; 864 switch (e) { 865 case BORDER_BOX: 866 m_value.ident = CSSValueBorderBox; 867 break; 868 case CONTENT_BOX: 869 m_value.ident = CSSValueContentBox; 870 break; 871 } 872} 873 874template<> inline CSSPrimitiveValue::operator EBoxSizing() const 875{ 876 switch (m_value.ident) { 877 case CSSValueBorderBox: 878 return BORDER_BOX; 879 case CSSValueContentBox: 880 return CONTENT_BOX; 881 } 882 883 ASSERT_NOT_REACHED(); 884 return BORDER_BOX; 885} 886 887template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDirection e) 888 : CSSValue(PrimitiveClass) 889{ 890 m_primitiveUnitType = CSS_IDENT; 891 switch (e) { 892 case BNORMAL: 893 m_value.ident = CSSValueNormal; 894 break; 895 case BREVERSE: 896 m_value.ident = CSSValueReverse; 897 break; 898 } 899} 900 901template<> inline CSSPrimitiveValue::operator EBoxDirection() const 902{ 903 switch (m_value.ident) { 904 case CSSValueNormal: 905 return BNORMAL; 906 case CSSValueReverse: 907 return BREVERSE; 908 } 909 910 ASSERT_NOT_REACHED(); 911 return BNORMAL; 912} 913 914template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxLines e) 915 : CSSValue(PrimitiveClass) 916{ 917 m_primitiveUnitType = CSS_IDENT; 918 switch (e) { 919 case SINGLE: 920 m_value.ident = CSSValueSingle; 921 break; 922 case MULTIPLE: 923 m_value.ident = CSSValueMultiple; 924 break; 925 } 926} 927 928template<> inline CSSPrimitiveValue::operator EBoxLines() const 929{ 930 switch (m_value.ident) { 931 case CSSValueSingle: 932 return SINGLE; 933 case CSSValueMultiple: 934 return MULTIPLE; 935 } 936 937 ASSERT_NOT_REACHED(); 938 return SINGLE; 939} 940 941template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxOrient e) 942 : CSSValue(PrimitiveClass) 943{ 944 m_primitiveUnitType = CSS_IDENT; 945 switch (e) { 946 case HORIZONTAL: 947 m_value.ident = CSSValueHorizontal; 948 break; 949 case VERTICAL: 950 m_value.ident = CSSValueVertical; 951 break; 952 } 953} 954 955template<> inline CSSPrimitiveValue::operator EBoxOrient() const 956{ 957 switch (m_value.ident) { 958 case CSSValueHorizontal: 959 case CSSValueInlineAxis: 960 return HORIZONTAL; 961 case CSSValueVertical: 962 case CSSValueBlockAxis: 963 return VERTICAL; 964 } 965 966 ASSERT_NOT_REACHED(); 967 return HORIZONTAL; 968} 969 970template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECaptionSide e) 971 : CSSValue(PrimitiveClass) 972{ 973 m_primitiveUnitType = CSS_IDENT; 974 switch (e) { 975 case CAPLEFT: 976 m_value.ident = CSSValueLeft; 977 break; 978 case CAPRIGHT: 979 m_value.ident = CSSValueRight; 980 break; 981 case CAPTOP: 982 m_value.ident = CSSValueTop; 983 break; 984 case CAPBOTTOM: 985 m_value.ident = CSSValueBottom; 986 break; 987 } 988} 989 990template<> inline CSSPrimitiveValue::operator ECaptionSide() const 991{ 992 switch (m_value.ident) { 993 case CSSValueLeft: 994 return CAPLEFT; 995 case CSSValueRight: 996 return CAPRIGHT; 997 case CSSValueTop: 998 return CAPTOP; 999 case CSSValueBottom: 1000 return CAPBOTTOM; 1001 } 1002 1003 ASSERT_NOT_REACHED(); 1004 return CAPTOP; 1005} 1006 1007template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EClear e) 1008 : CSSValue(PrimitiveClass) 1009{ 1010 m_primitiveUnitType = CSS_IDENT; 1011 switch (e) { 1012 case CNONE: 1013 m_value.ident = CSSValueNone; 1014 break; 1015 case CLEFT: 1016 m_value.ident = CSSValueLeft; 1017 break; 1018 case CRIGHT: 1019 m_value.ident = CSSValueRight; 1020 break; 1021 case CBOTH: 1022 m_value.ident = CSSValueBoth; 1023 break; 1024 } 1025} 1026 1027template<> inline CSSPrimitiveValue::operator EClear() const 1028{ 1029 switch (m_value.ident) { 1030 case CSSValueNone: 1031 return CNONE; 1032 case CSSValueLeft: 1033 return CLEFT; 1034 case CSSValueRight: 1035 return CRIGHT; 1036 case CSSValueBoth: 1037 return CBOTH; 1038 } 1039 1040 ASSERT_NOT_REACHED(); 1041 return CNONE; 1042} 1043 1044template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e) 1045 : CSSValue(PrimitiveClass) 1046{ 1047 m_primitiveUnitType = CSS_IDENT; 1048 switch (e) { 1049 case CURSOR_AUTO: 1050 m_value.ident = CSSValueAuto; 1051 break; 1052 case CURSOR_CROSS: 1053 m_value.ident = CSSValueCrosshair; 1054 break; 1055 case CURSOR_DEFAULT: 1056 m_value.ident = CSSValueDefault; 1057 break; 1058 case CURSOR_POINTER: 1059 m_value.ident = CSSValuePointer; 1060 break; 1061 case CURSOR_MOVE: 1062 m_value.ident = CSSValueMove; 1063 break; 1064 case CURSOR_CELL: 1065 m_value.ident = CSSValueCell; 1066 break; 1067 case CURSOR_VERTICAL_TEXT: 1068 m_value.ident = CSSValueVerticalText; 1069 break; 1070 case CURSOR_CONTEXT_MENU: 1071 m_value.ident = CSSValueContextMenu; 1072 break; 1073 case CURSOR_ALIAS: 1074 m_value.ident = CSSValueAlias; 1075 break; 1076 case CURSOR_COPY: 1077 m_value.ident = CSSValueCopy; 1078 break; 1079 case CURSOR_NONE: 1080 m_value.ident = CSSValueNone; 1081 break; 1082 case CURSOR_PROGRESS: 1083 m_value.ident = CSSValueProgress; 1084 break; 1085 case CURSOR_NO_DROP: 1086 m_value.ident = CSSValueNoDrop; 1087 break; 1088 case CURSOR_NOT_ALLOWED: 1089 m_value.ident = CSSValueNotAllowed; 1090 break; 1091 case CURSOR_WEBKIT_ZOOM_IN: 1092 m_value.ident = CSSValueWebkitZoomIn; 1093 break; 1094 case CURSOR_WEBKIT_ZOOM_OUT: 1095 m_value.ident = CSSValueWebkitZoomOut; 1096 break; 1097 case CURSOR_E_RESIZE: 1098 m_value.ident = CSSValueEResize; 1099 break; 1100 case CURSOR_NE_RESIZE: 1101 m_value.ident = CSSValueNeResize; 1102 break; 1103 case CURSOR_NW_RESIZE: 1104 m_value.ident = CSSValueNwResize; 1105 break; 1106 case CURSOR_N_RESIZE: 1107 m_value.ident = CSSValueNResize; 1108 break; 1109 case CURSOR_SE_RESIZE: 1110 m_value.ident = CSSValueSeResize; 1111 break; 1112 case CURSOR_SW_RESIZE: 1113 m_value.ident = CSSValueSwResize; 1114 break; 1115 case CURSOR_S_RESIZE: 1116 m_value.ident = CSSValueSResize; 1117 break; 1118 case CURSOR_W_RESIZE: 1119 m_value.ident = CSSValueWResize; 1120 break; 1121 case CURSOR_EW_RESIZE: 1122 m_value.ident = CSSValueEwResize; 1123 break; 1124 case CURSOR_NS_RESIZE: 1125 m_value.ident = CSSValueNsResize; 1126 break; 1127 case CURSOR_NESW_RESIZE: 1128 m_value.ident = CSSValueNeswResize; 1129 break; 1130 case CURSOR_NWSE_RESIZE: 1131 m_value.ident = CSSValueNwseResize; 1132 break; 1133 case CURSOR_COL_RESIZE: 1134 m_value.ident = CSSValueColResize; 1135 break; 1136 case CURSOR_ROW_RESIZE: 1137 m_value.ident = CSSValueRowResize; 1138 break; 1139 case CURSOR_TEXT: 1140 m_value.ident = CSSValueText; 1141 break; 1142 case CURSOR_WAIT: 1143 m_value.ident = CSSValueWait; 1144 break; 1145 case CURSOR_HELP: 1146 m_value.ident = CSSValueHelp; 1147 break; 1148 case CURSOR_ALL_SCROLL: 1149 m_value.ident = CSSValueAllScroll; 1150 break; 1151 case CURSOR_WEBKIT_GRAB: 1152 m_value.ident = CSSValueWebkitGrab; 1153 break; 1154 case CURSOR_WEBKIT_GRABBING: 1155 m_value.ident = CSSValueWebkitGrabbing; 1156 break; 1157 } 1158} 1159 1160template<> inline CSSPrimitiveValue::operator ECursor() const 1161{ 1162 if (m_value.ident == CSSValueCopy) 1163 return CURSOR_COPY; 1164 if (m_value.ident == CSSValueNone) 1165 return CURSOR_NONE; 1166 return static_cast<ECursor>(m_value.ident - CSSValueAuto); 1167} 1168 1169 1170#if ENABLE(CURSOR_VISIBILITY) 1171template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CursorVisibility e) 1172 : CSSValue(PrimitiveClass) 1173{ 1174 m_primitiveUnitType = CSS_IDENT; 1175 switch (e) { 1176 case CursorVisibilityAuto: 1177 m_value.ident = CSSValueAuto; 1178 break; 1179 case CursorVisibilityAutoHide: 1180 m_value.ident = CSSValueAutoHide; 1181 break; 1182 } 1183} 1184 1185template<> inline CSSPrimitiveValue::operator CursorVisibility() const 1186{ 1187 if (m_value.ident == CSSValueAuto) 1188 return CursorVisibilityAuto; 1189 if (m_value.ident == CSSValueAutoHide) 1190 return CursorVisibilityAutoHide; 1191 1192 ASSERT_NOT_REACHED(); 1193 return CursorVisibilityAuto; 1194} 1195#endif 1196 1197template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e) 1198 : CSSValue(PrimitiveClass) 1199{ 1200 m_primitiveUnitType = CSS_IDENT; 1201 switch (e) { 1202 case INLINE: 1203 m_value.ident = CSSValueInline; 1204 break; 1205 case BLOCK: 1206 m_value.ident = CSSValueBlock; 1207 break; 1208 case LIST_ITEM: 1209 m_value.ident = CSSValueListItem; 1210 break; 1211 case RUN_IN: 1212 m_value.ident = CSSValueRunIn; 1213 break; 1214 case COMPACT: 1215 m_value.ident = CSSValueCompact; 1216 break; 1217 case INLINE_BLOCK: 1218 m_value.ident = CSSValueInlineBlock; 1219 break; 1220 case TABLE: 1221 m_value.ident = CSSValueTable; 1222 break; 1223 case INLINE_TABLE: 1224 m_value.ident = CSSValueInlineTable; 1225 break; 1226 case TABLE_ROW_GROUP: 1227 m_value.ident = CSSValueTableRowGroup; 1228 break; 1229 case TABLE_HEADER_GROUP: 1230 m_value.ident = CSSValueTableHeaderGroup; 1231 break; 1232 case TABLE_FOOTER_GROUP: 1233 m_value.ident = CSSValueTableFooterGroup; 1234 break; 1235 case TABLE_ROW: 1236 m_value.ident = CSSValueTableRow; 1237 break; 1238 case TABLE_COLUMN_GROUP: 1239 m_value.ident = CSSValueTableColumnGroup; 1240 break; 1241 case TABLE_COLUMN: 1242 m_value.ident = CSSValueTableColumn; 1243 break; 1244 case TABLE_CELL: 1245 m_value.ident = CSSValueTableCell; 1246 break; 1247 case TABLE_CAPTION: 1248 m_value.ident = CSSValueTableCaption; 1249 break; 1250 case BOX: 1251 m_value.ident = CSSValueWebkitBox; 1252 break; 1253 case INLINE_BOX: 1254 m_value.ident = CSSValueWebkitInlineBox; 1255 break; 1256 case FLEX: 1257 m_value.ident = CSSValueWebkitFlex; 1258 break; 1259 case INLINE_FLEX: 1260 m_value.ident = CSSValueWebkitInlineFlex; 1261 break; 1262 case GRID: 1263 m_value.ident = CSSValueWebkitGrid; 1264 break; 1265 case INLINE_GRID: 1266 m_value.ident = CSSValueWebkitInlineGrid; 1267 break; 1268 case NONE: 1269 m_value.ident = CSSValueNone; 1270 break; 1271 } 1272} 1273 1274template<> inline CSSPrimitiveValue::operator EDisplay() const 1275{ 1276 if (m_value.ident == CSSValueNone) 1277 return NONE; 1278 1279 EDisplay display = static_cast<EDisplay>(m_value.ident - CSSValueInline); 1280 ASSERT(display >= INLINE && display <= NONE); 1281 return display; 1282} 1283 1284template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EEmptyCell e) 1285 : CSSValue(PrimitiveClass) 1286{ 1287 m_primitiveUnitType = CSS_IDENT; 1288 switch (e) { 1289 case SHOW: 1290 m_value.ident = CSSValueShow; 1291 break; 1292 case HIDE: 1293 m_value.ident = CSSValueHide; 1294 break; 1295 } 1296} 1297 1298template<> inline CSSPrimitiveValue::operator EEmptyCell() const 1299{ 1300 switch (m_value.ident) { 1301 case CSSValueShow: 1302 return SHOW; 1303 case CSSValueHide: 1304 return HIDE; 1305 } 1306 1307 ASSERT_NOT_REACHED(); 1308 return SHOW; 1309} 1310 1311template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignItems e) 1312 : CSSValue(PrimitiveClass) 1313{ 1314 m_primitiveUnitType = CSS_IDENT; 1315 switch (e) { 1316 case AlignAuto: 1317 m_value.ident = CSSValueAuto; 1318 break; 1319 case AlignFlexStart: 1320 m_value.ident = CSSValueFlexStart; 1321 break; 1322 case AlignFlexEnd: 1323 m_value.ident = CSSValueFlexEnd; 1324 break; 1325 case AlignCenter: 1326 m_value.ident = CSSValueCenter; 1327 break; 1328 case AlignStretch: 1329 m_value.ident = CSSValueStretch; 1330 break; 1331 case AlignBaseline: 1332 m_value.ident = CSSValueBaseline; 1333 break; 1334 } 1335} 1336 1337template<> inline CSSPrimitiveValue::operator EAlignItems() const 1338{ 1339 switch (m_value.ident) { 1340 case CSSValueAuto: 1341 return AlignAuto; 1342 case CSSValueFlexStart: 1343 return AlignFlexStart; 1344 case CSSValueFlexEnd: 1345 return AlignFlexEnd; 1346 case CSSValueCenter: 1347 return AlignCenter; 1348 case CSSValueStretch: 1349 return AlignStretch; 1350 case CSSValueBaseline: 1351 return AlignBaseline; 1352 } 1353 1354 ASSERT_NOT_REACHED(); 1355 return AlignFlexStart; 1356} 1357 1358template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EJustifyContent e) 1359 : CSSValue(PrimitiveClass) 1360{ 1361 m_primitiveUnitType = CSS_IDENT; 1362 switch (e) { 1363 case JustifyFlexStart: 1364 m_value.ident = CSSValueFlexStart; 1365 break; 1366 case JustifyFlexEnd: 1367 m_value.ident = CSSValueFlexEnd; 1368 break; 1369 case JustifyCenter: 1370 m_value.ident = CSSValueCenter; 1371 break; 1372 case JustifySpaceBetween: 1373 m_value.ident = CSSValueSpaceBetween; 1374 break; 1375 case JustifySpaceAround: 1376 m_value.ident = CSSValueSpaceAround; 1377 break; 1378 } 1379} 1380 1381template<> inline CSSPrimitiveValue::operator EJustifyContent() const 1382{ 1383 switch (m_value.ident) { 1384 case CSSValueFlexStart: 1385 return JustifyFlexStart; 1386 case CSSValueFlexEnd: 1387 return JustifyFlexEnd; 1388 case CSSValueCenter: 1389 return JustifyCenter; 1390 case CSSValueSpaceBetween: 1391 return JustifySpaceBetween; 1392 case CSSValueSpaceAround: 1393 return JustifySpaceAround; 1394 } 1395 1396 ASSERT_NOT_REACHED(); 1397 return JustifyFlexStart; 1398} 1399 1400template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexDirection e) 1401 : CSSValue(PrimitiveClass) 1402{ 1403 m_primitiveUnitType = CSS_IDENT; 1404 switch (e) { 1405 case FlowRow: 1406 m_value.ident = CSSValueRow; 1407 break; 1408 case FlowRowReverse: 1409 m_value.ident = CSSValueRowReverse; 1410 break; 1411 case FlowColumn: 1412 m_value.ident = CSSValueColumn; 1413 break; 1414 case FlowColumnReverse: 1415 m_value.ident = CSSValueColumnReverse; 1416 break; 1417 } 1418} 1419 1420template<> inline CSSPrimitiveValue::operator EFlexDirection() const 1421{ 1422 switch (m_value.ident) { 1423 case CSSValueRow: 1424 return FlowRow; 1425 case CSSValueRowReverse: 1426 return FlowRowReverse; 1427 case CSSValueColumn: 1428 return FlowColumn; 1429 case CSSValueColumnReverse: 1430 return FlowColumnReverse; 1431 } 1432 1433 ASSERT_NOT_REACHED(); 1434 return FlowRow; 1435} 1436 1437template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignContent e) 1438 : CSSValue(PrimitiveClass) 1439{ 1440 m_primitiveUnitType = CSS_IDENT; 1441 switch (e) { 1442 case AlignContentFlexStart: 1443 m_value.ident = CSSValueFlexStart; 1444 break; 1445 case AlignContentFlexEnd: 1446 m_value.ident = CSSValueFlexEnd; 1447 break; 1448 case AlignContentCenter: 1449 m_value.ident = CSSValueCenter; 1450 break; 1451 case AlignContentSpaceBetween: 1452 m_value.ident = CSSValueSpaceBetween; 1453 break; 1454 case AlignContentSpaceAround: 1455 m_value.ident = CSSValueSpaceAround; 1456 break; 1457 case AlignContentStretch: 1458 m_value.ident = CSSValueStretch; 1459 break; 1460 } 1461} 1462 1463template<> inline CSSPrimitiveValue::operator EAlignContent() const 1464{ 1465 switch (m_value.ident) { 1466 case CSSValueFlexStart: 1467 return AlignContentFlexStart; 1468 case CSSValueFlexEnd: 1469 return AlignContentFlexEnd; 1470 case CSSValueCenter: 1471 return AlignContentCenter; 1472 case CSSValueSpaceBetween: 1473 return AlignContentSpaceBetween; 1474 case CSSValueSpaceAround: 1475 return AlignContentSpaceAround; 1476 case CSSValueStretch: 1477 return AlignContentStretch; 1478 } 1479 1480 ASSERT_NOT_REACHED(); 1481 return AlignContentStretch; 1482} 1483 1484template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexWrap e) 1485 : CSSValue(PrimitiveClass) 1486{ 1487 m_primitiveUnitType = CSS_IDENT; 1488 switch (e) { 1489 case FlexNoWrap: 1490 m_value.ident = CSSValueNowrap; 1491 break; 1492 case FlexWrap: 1493 m_value.ident = CSSValueWrap; 1494 break; 1495 case FlexWrapReverse: 1496 m_value.ident = CSSValueWrapReverse; 1497 break; 1498 } 1499} 1500 1501template<> inline CSSPrimitiveValue::operator EFlexWrap() const 1502{ 1503 switch (m_value.ident) { 1504 case CSSValueNowrap: 1505 return FlexNoWrap; 1506 case CSSValueWrap: 1507 return FlexWrap; 1508 case CSSValueWrapReverse: 1509 return FlexWrapReverse; 1510 } 1511 1512 ASSERT_NOT_REACHED(); 1513 return FlexNoWrap; 1514} 1515 1516template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e) 1517 : CSSValue(PrimitiveClass) 1518{ 1519 m_primitiveUnitType = CSS_IDENT; 1520 switch (e) { 1521 case NoFloat: 1522 m_value.ident = CSSValueNone; 1523 break; 1524 case LeftFloat: 1525 m_value.ident = CSSValueLeft; 1526 break; 1527 case RightFloat: 1528 m_value.ident = CSSValueRight; 1529 break; 1530 } 1531} 1532 1533template<> inline CSSPrimitiveValue::operator EFloat() const 1534{ 1535 switch (m_value.ident) { 1536 case CSSValueLeft: 1537 return LeftFloat; 1538 case CSSValueRight: 1539 return RightFloat; 1540 case CSSValueNone: 1541 case CSSValueCenter: // Non-standard CSS value 1542 return NoFloat; 1543 } 1544 1545 ASSERT_NOT_REACHED(); 1546 return NoFloat; 1547} 1548 1549template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineBreak e) 1550 : CSSValue(PrimitiveClass) 1551{ 1552 m_primitiveUnitType = CSS_IDENT; 1553 switch (e) { 1554 case LineBreakAuto: 1555 m_value.ident = CSSValueAuto; 1556 break; 1557 case LineBreakLoose: 1558 m_value.ident = CSSValueLoose; 1559 break; 1560 case LineBreakNormal: 1561 m_value.ident = CSSValueNormal; 1562 break; 1563 case LineBreakStrict: 1564 m_value.ident = CSSValueStrict; 1565 break; 1566 case LineBreakAfterWhiteSpace: 1567 m_value.ident = CSSValueAfterWhiteSpace; 1568 break; 1569 } 1570} 1571 1572template<> inline CSSPrimitiveValue::operator LineBreak() const 1573{ 1574 switch (m_value.ident) { 1575 case CSSValueAuto: 1576 return LineBreakAuto; 1577 case CSSValueLoose: 1578 return LineBreakLoose; 1579 case CSSValueNormal: 1580 return LineBreakNormal; 1581 case CSSValueStrict: 1582 return LineBreakStrict; 1583 case CSSValueAfterWhiteSpace: 1584 return LineBreakAfterWhiteSpace; 1585 } 1586 1587 ASSERT_NOT_REACHED(); 1588 return LineBreakAuto; 1589} 1590 1591template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStylePosition e) 1592 : CSSValue(PrimitiveClass) 1593{ 1594 m_primitiveUnitType = CSS_IDENT; 1595 switch (e) { 1596 case OUTSIDE: 1597 m_value.ident = CSSValueOutside; 1598 break; 1599 case INSIDE: 1600 m_value.ident = CSSValueInside; 1601 break; 1602 } 1603} 1604 1605template<> inline CSSPrimitiveValue::operator EListStylePosition() const 1606{ 1607 switch (m_value.ident) { 1608 case CSSValueOutside: 1609 return OUTSIDE; 1610 case CSSValueInside: 1611 return INSIDE; 1612 } 1613 1614 ASSERT_NOT_REACHED(); 1615 return OUTSIDE; 1616} 1617 1618template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e) 1619 : CSSValue(PrimitiveClass) 1620{ 1621 m_primitiveUnitType = CSS_IDENT; 1622 switch (e) { 1623 case Afar: 1624 m_value.ident = CSSValueAfar; 1625 break; 1626 case Amharic: 1627 m_value.ident = CSSValueAmharic; 1628 break; 1629 case AmharicAbegede: 1630 m_value.ident = CSSValueAmharicAbegede; 1631 break; 1632 case ArabicIndic: 1633 m_value.ident = CSSValueArabicIndic; 1634 break; 1635 case Armenian: 1636 m_value.ident = CSSValueArmenian; 1637 break; 1638 case Asterisks: 1639 m_value.ident = CSSValueAsterisks; 1640 break; 1641 case BinaryListStyle: 1642 m_value.ident = CSSValueBinary; 1643 break; 1644 case Bengali: 1645 m_value.ident = CSSValueBengali; 1646 break; 1647 case Cambodian: 1648 m_value.ident = CSSValueCambodian; 1649 break; 1650 case Circle: 1651 m_value.ident = CSSValueCircle; 1652 break; 1653 case CjkEarthlyBranch: 1654 m_value.ident = CSSValueCjkEarthlyBranch; 1655 break; 1656 case CjkHeavenlyStem: 1657 m_value.ident = CSSValueCjkHeavenlyStem; 1658 break; 1659 case CJKIdeographic: 1660 m_value.ident = CSSValueCjkIdeographic; 1661 break; 1662 case DecimalLeadingZero: 1663 m_value.ident = CSSValueDecimalLeadingZero; 1664 break; 1665 case DecimalListStyle: 1666 m_value.ident = CSSValueDecimal; 1667 break; 1668 case Devanagari: 1669 m_value.ident = CSSValueDevanagari; 1670 break; 1671 case Disc: 1672 m_value.ident = CSSValueDisc; 1673 break; 1674 case Ethiopic: 1675 m_value.ident = CSSValueEthiopic; 1676 break; 1677 case EthiopicAbegede: 1678 m_value.ident = CSSValueEthiopicAbegede; 1679 break; 1680 case EthiopicAbegedeAmEt: 1681 m_value.ident = CSSValueEthiopicAbegedeAmEt; 1682 break; 1683 case EthiopicAbegedeGez: 1684 m_value.ident = CSSValueEthiopicAbegedeGez; 1685 break; 1686 case EthiopicAbegedeTiEr: 1687 m_value.ident = CSSValueEthiopicAbegedeTiEr; 1688 break; 1689 case EthiopicAbegedeTiEt: 1690 m_value.ident = CSSValueEthiopicAbegedeTiEt; 1691 break; 1692 case EthiopicHalehameAaEr: 1693 m_value.ident = CSSValueEthiopicHalehameAaEr; 1694 break; 1695 case EthiopicHalehameAaEt: 1696 m_value.ident = CSSValueEthiopicHalehameAaEt; 1697 break; 1698 case EthiopicHalehameAmEt: 1699 m_value.ident = CSSValueEthiopicHalehameAmEt; 1700 break; 1701 case EthiopicHalehameGez: 1702 m_value.ident = CSSValueEthiopicHalehameGez; 1703 break; 1704 case EthiopicHalehameOmEt: 1705 m_value.ident = CSSValueEthiopicHalehameOmEt; 1706 break; 1707 case EthiopicHalehameSidEt: 1708 m_value.ident = CSSValueEthiopicHalehameSidEt; 1709 break; 1710 case EthiopicHalehameSoEt: 1711 m_value.ident = CSSValueEthiopicHalehameSoEt; 1712 break; 1713 case EthiopicHalehameTiEr: 1714 m_value.ident = CSSValueEthiopicHalehameTiEr; 1715 break; 1716 case EthiopicHalehameTiEt: 1717 m_value.ident = CSSValueEthiopicHalehameTiEt; 1718 break; 1719 case EthiopicHalehameTig: 1720 m_value.ident = CSSValueEthiopicHalehameTig; 1721 break; 1722 case Footnotes: 1723 m_value.ident = CSSValueFootnotes; 1724 break; 1725 case Georgian: 1726 m_value.ident = CSSValueGeorgian; 1727 break; 1728 case Gujarati: 1729 m_value.ident = CSSValueGujarati; 1730 break; 1731 case Gurmukhi: 1732 m_value.ident = CSSValueGurmukhi; 1733 break; 1734 case Hangul: 1735 m_value.ident = CSSValueHangul; 1736 break; 1737 case HangulConsonant: 1738 m_value.ident = CSSValueHangulConsonant; 1739 break; 1740 case Hebrew: 1741 m_value.ident = CSSValueHebrew; 1742 break; 1743 case Hiragana: 1744 m_value.ident = CSSValueHiragana; 1745 break; 1746 case HiraganaIroha: 1747 m_value.ident = CSSValueHiraganaIroha; 1748 break; 1749 case Kannada: 1750 m_value.ident = CSSValueKannada; 1751 break; 1752 case Katakana: 1753 m_value.ident = CSSValueKatakana; 1754 break; 1755 case KatakanaIroha: 1756 m_value.ident = CSSValueKatakanaIroha; 1757 break; 1758 case Khmer: 1759 m_value.ident = CSSValueKhmer; 1760 break; 1761 case Lao: 1762 m_value.ident = CSSValueLao; 1763 break; 1764 case LowerAlpha: 1765 m_value.ident = CSSValueLowerAlpha; 1766 break; 1767 case LowerArmenian: 1768 m_value.ident = CSSValueLowerArmenian; 1769 break; 1770 case LowerGreek: 1771 m_value.ident = CSSValueLowerGreek; 1772 break; 1773 case LowerHexadecimal: 1774 m_value.ident = CSSValueLowerHexadecimal; 1775 break; 1776 case LowerLatin: 1777 m_value.ident = CSSValueLowerLatin; 1778 break; 1779 case LowerNorwegian: 1780 m_value.ident = CSSValueLowerNorwegian; 1781 break; 1782 case LowerRoman: 1783 m_value.ident = CSSValueLowerRoman; 1784 break; 1785 case Malayalam: 1786 m_value.ident = CSSValueMalayalam; 1787 break; 1788 case Mongolian: 1789 m_value.ident = CSSValueMongolian; 1790 break; 1791 case Myanmar: 1792 m_value.ident = CSSValueMyanmar; 1793 break; 1794 case NoneListStyle: 1795 m_value.ident = CSSValueNone; 1796 break; 1797 case Octal: 1798 m_value.ident = CSSValueOctal; 1799 break; 1800 case Oriya: 1801 m_value.ident = CSSValueOriya; 1802 break; 1803 case Oromo: 1804 m_value.ident = CSSValueOromo; 1805 break; 1806 case Persian: 1807 m_value.ident = CSSValuePersian; 1808 break; 1809 case Sidama: 1810 m_value.ident = CSSValueSidama; 1811 break; 1812 case Somali: 1813 m_value.ident = CSSValueSomali; 1814 break; 1815 case Square: 1816 m_value.ident = CSSValueSquare; 1817 break; 1818 case Telugu: 1819 m_value.ident = CSSValueTelugu; 1820 break; 1821 case Thai: 1822 m_value.ident = CSSValueThai; 1823 break; 1824 case Tibetan: 1825 m_value.ident = CSSValueTibetan; 1826 break; 1827 case Tigre: 1828 m_value.ident = CSSValueTigre; 1829 break; 1830 case TigrinyaEr: 1831 m_value.ident = CSSValueTigrinyaEr; 1832 break; 1833 case TigrinyaErAbegede: 1834 m_value.ident = CSSValueTigrinyaErAbegede; 1835 break; 1836 case TigrinyaEt: 1837 m_value.ident = CSSValueTigrinyaEt; 1838 break; 1839 case TigrinyaEtAbegede: 1840 m_value.ident = CSSValueTigrinyaEtAbegede; 1841 break; 1842 case UpperAlpha: 1843 m_value.ident = CSSValueUpperAlpha; 1844 break; 1845 case UpperArmenian: 1846 m_value.ident = CSSValueUpperArmenian; 1847 break; 1848 case UpperGreek: 1849 m_value.ident = CSSValueUpperGreek; 1850 break; 1851 case UpperHexadecimal: 1852 m_value.ident = CSSValueUpperHexadecimal; 1853 break; 1854 case UpperLatin: 1855 m_value.ident = CSSValueUpperLatin; 1856 break; 1857 case UpperNorwegian: 1858 m_value.ident = CSSValueUpperNorwegian; 1859 break; 1860 case UpperRoman: 1861 m_value.ident = CSSValueUpperRoman; 1862 break; 1863 case Urdu: 1864 m_value.ident = CSSValueUrdu; 1865 break; 1866 } 1867} 1868 1869template<> inline CSSPrimitiveValue::operator EListStyleType() const 1870{ 1871 switch (m_value.ident) { 1872 case CSSValueNone: 1873 return NoneListStyle; 1874 default: 1875 return static_cast<EListStyleType>(m_value.ident - CSSValueDisc); 1876 } 1877} 1878 1879template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarginCollapse e) 1880 : CSSValue(PrimitiveClass) 1881{ 1882 m_primitiveUnitType = CSS_IDENT; 1883 switch (e) { 1884 case MCOLLAPSE: 1885 m_value.ident = CSSValueCollapse; 1886 break; 1887 case MSEPARATE: 1888 m_value.ident = CSSValueSeparate; 1889 break; 1890 case MDISCARD: 1891 m_value.ident = CSSValueDiscard; 1892 break; 1893 } 1894} 1895 1896template<> inline CSSPrimitiveValue::operator EMarginCollapse() const 1897{ 1898 switch (m_value.ident) { 1899 case CSSValueCollapse: 1900 return MCOLLAPSE; 1901 case CSSValueSeparate: 1902 return MSEPARATE; 1903 case CSSValueDiscard: 1904 return MDISCARD; 1905 } 1906 1907 ASSERT_NOT_REACHED(); 1908 return MCOLLAPSE; 1909} 1910 1911template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeBehavior e) 1912 : CSSValue(PrimitiveClass) 1913{ 1914 m_primitiveUnitType = CSS_IDENT; 1915 switch (e) { 1916 case MNONE: 1917 m_value.ident = CSSValueNone; 1918 break; 1919 case MSCROLL: 1920 m_value.ident = CSSValueScroll; 1921 break; 1922 case MSLIDE: 1923 m_value.ident = CSSValueSlide; 1924 break; 1925 case MALTERNATE: 1926 m_value.ident = CSSValueAlternate; 1927 break; 1928 } 1929} 1930 1931template<> inline CSSPrimitiveValue::operator EMarqueeBehavior() const 1932{ 1933 switch (m_value.ident) { 1934 case CSSValueNone: 1935 return MNONE; 1936 case CSSValueScroll: 1937 return MSCROLL; 1938 case CSSValueSlide: 1939 return MSLIDE; 1940 case CSSValueAlternate: 1941 return MALTERNATE; 1942 } 1943 1944 ASSERT_NOT_REACHED(); 1945 return MNONE; 1946} 1947 1948template<> inline CSSPrimitiveValue::CSSPrimitiveValue(RegionFragment e) 1949 : CSSValue(PrimitiveClass) 1950{ 1951 m_primitiveUnitType = CSS_IDENT; 1952 switch (e) { 1953 case AutoRegionFragment: 1954 m_value.ident = CSSValueAuto; 1955 break; 1956 case BreakRegionFragment: 1957 m_value.ident = CSSValueBreak; 1958 break; 1959 } 1960} 1961 1962template<> inline CSSPrimitiveValue::operator RegionFragment() const 1963{ 1964 switch (m_value.ident) { 1965 case CSSValueAuto: 1966 return AutoRegionFragment; 1967 case CSSValueBreak: 1968 return BreakRegionFragment; 1969 } 1970 1971 ASSERT_NOT_REACHED(); 1972 return AutoRegionFragment; 1973} 1974 1975template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeDirection e) 1976 : CSSValue(PrimitiveClass) 1977{ 1978 m_primitiveUnitType = CSS_IDENT; 1979 switch (e) { 1980 case MFORWARD: 1981 m_value.ident = CSSValueForwards; 1982 break; 1983 case MBACKWARD: 1984 m_value.ident = CSSValueBackwards; 1985 break; 1986 case MAUTO: 1987 m_value.ident = CSSValueAuto; 1988 break; 1989 case MUP: 1990 m_value.ident = CSSValueUp; 1991 break; 1992 case MDOWN: 1993 m_value.ident = CSSValueDown; 1994 break; 1995 case MLEFT: 1996 m_value.ident = CSSValueLeft; 1997 break; 1998 case MRIGHT: 1999 m_value.ident = CSSValueRight; 2000 break; 2001 } 2002} 2003 2004template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const 2005{ 2006 switch (m_value.ident) { 2007 case CSSValueForwards: 2008 return MFORWARD; 2009 case CSSValueBackwards: 2010 return MBACKWARD; 2011 case CSSValueAuto: 2012 return MAUTO; 2013 case CSSValueAhead: 2014 case CSSValueUp: // We don't support vertical languages, so AHEAD just maps to UP. 2015 return MUP; 2016 case CSSValueReverse: 2017 case CSSValueDown: // REVERSE just maps to DOWN, since we don't do vertical text. 2018 return MDOWN; 2019 case CSSValueLeft: 2020 return MLEFT; 2021 case CSSValueRight: 2022 return MRIGHT; 2023 } 2024 2025 ASSERT_NOT_REACHED(); 2026 return MAUTO; 2027} 2028 2029template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e) 2030 : CSSValue(PrimitiveClass) 2031{ 2032 m_primitiveUnitType = CSS_IDENT; 2033 switch (e) { 2034 case NBNORMAL: 2035 m_value.ident = CSSValueNormal; 2036 break; 2037 case SPACE: 2038 m_value.ident = CSSValueSpace; 2039 break; 2040 } 2041} 2042 2043template<> inline CSSPrimitiveValue::operator ENBSPMode() const 2044{ 2045 switch (m_value.ident) { 2046 case CSSValueSpace: 2047 return SPACE; 2048 case CSSValueNormal: 2049 return NBNORMAL; 2050 } 2051 2052 ASSERT_NOT_REACHED(); 2053 return NBNORMAL; 2054} 2055 2056template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e) 2057 : CSSValue(PrimitiveClass) 2058{ 2059 m_primitiveUnitType = CSS_IDENT; 2060 switch (e) { 2061 case OVISIBLE: 2062 m_value.ident = CSSValueVisible; 2063 break; 2064 case OHIDDEN: 2065 m_value.ident = CSSValueHidden; 2066 break; 2067 case OSCROLL: 2068 m_value.ident = CSSValueScroll; 2069 break; 2070 case OAUTO: 2071 m_value.ident = CSSValueAuto; 2072 break; 2073 case OMARQUEE: 2074 m_value.ident = CSSValueWebkitMarquee; 2075 break; 2076 case OOVERLAY: 2077 m_value.ident = CSSValueOverlay; 2078 break; 2079 case OPAGEDX: 2080 m_value.ident = CSSValueWebkitPagedX; 2081 break; 2082 case OPAGEDY: 2083 m_value.ident = CSSValueWebkitPagedY; 2084 break; 2085 } 2086} 2087 2088template<> inline CSSPrimitiveValue::operator EOverflow() const 2089{ 2090 switch (m_value.ident) { 2091 case CSSValueVisible: 2092 return OVISIBLE; 2093 case CSSValueHidden: 2094 return OHIDDEN; 2095 case CSSValueScroll: 2096 return OSCROLL; 2097 case CSSValueAuto: 2098 return OAUTO; 2099 case CSSValueWebkitMarquee: 2100 return OMARQUEE; 2101 case CSSValueOverlay: 2102 return OOVERLAY; 2103 case CSSValueWebkitPagedX: 2104 return OPAGEDX; 2105 case CSSValueWebkitPagedY: 2106 return OPAGEDY; 2107 } 2108 2109 ASSERT_NOT_REACHED(); 2110 return OVISIBLE; 2111} 2112 2113template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e) 2114 : CSSValue(PrimitiveClass) 2115{ 2116 m_primitiveUnitType = CSS_IDENT; 2117 switch (e) { 2118 case PBAUTO: 2119 m_value.ident = CSSValueAuto; 2120 break; 2121 case PBALWAYS: 2122 m_value.ident = CSSValueAlways; 2123 break; 2124 case PBAVOID: 2125 m_value.ident = CSSValueAvoid; 2126 break; 2127 } 2128} 2129 2130template<> inline CSSPrimitiveValue::operator EPageBreak() const 2131{ 2132 switch (m_value.ident) { 2133 case CSSValueAuto: 2134 return PBAUTO; 2135 case CSSValueLeft: 2136 case CSSValueRight: 2137 case CSSValueAlways: 2138 return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always." 2139 case CSSValueAvoid: 2140 return PBAVOID; 2141 } 2142 2143 ASSERT_NOT_REACHED(); 2144 return PBAUTO; 2145} 2146 2147template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e) 2148 : CSSValue(PrimitiveClass) 2149{ 2150 m_primitiveUnitType = CSS_IDENT; 2151 switch (e) { 2152 case StaticPosition: 2153 m_value.ident = CSSValueStatic; 2154 break; 2155 case RelativePosition: 2156 m_value.ident = CSSValueRelative; 2157 break; 2158 case AbsolutePosition: 2159 m_value.ident = CSSValueAbsolute; 2160 break; 2161 case FixedPosition: 2162 m_value.ident = CSSValueFixed; 2163 break; 2164 case StickyPosition: 2165#if ENABLE(CSS_STICKY_POSITION) 2166 m_value.ident = CSSValueWebkitSticky; 2167#endif 2168 break; 2169 } 2170} 2171 2172template<> inline CSSPrimitiveValue::operator EPosition() const 2173{ 2174 switch (m_value.ident) { 2175 case CSSValueStatic: 2176 return StaticPosition; 2177 case CSSValueRelative: 2178 return RelativePosition; 2179 case CSSValueAbsolute: 2180 return AbsolutePosition; 2181 case CSSValueFixed: 2182 return FixedPosition; 2183#if ENABLE(CSS_STICKY_POSITION) 2184 case CSSValueWebkitSticky: 2185 return StickyPosition; 2186#endif 2187 } 2188 2189 ASSERT_NOT_REACHED(); 2190 return StaticPosition; 2191} 2192 2193template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EResize e) 2194 : CSSValue(PrimitiveClass) 2195{ 2196 m_primitiveUnitType = CSS_IDENT; 2197 switch (e) { 2198 case RESIZE_BOTH: 2199 m_value.ident = CSSValueBoth; 2200 break; 2201 case RESIZE_HORIZONTAL: 2202 m_value.ident = CSSValueHorizontal; 2203 break; 2204 case RESIZE_VERTICAL: 2205 m_value.ident = CSSValueVertical; 2206 break; 2207 case RESIZE_NONE: 2208 m_value.ident = CSSValueNone; 2209 break; 2210 } 2211} 2212 2213template<> inline CSSPrimitiveValue::operator EResize() const 2214{ 2215 switch (m_value.ident) { 2216 case CSSValueBoth: 2217 return RESIZE_BOTH; 2218 case CSSValueHorizontal: 2219 return RESIZE_HORIZONTAL; 2220 case CSSValueVertical: 2221 return RESIZE_VERTICAL; 2222 case CSSValueAuto: 2223 ASSERT_NOT_REACHED(); // Depends on settings, thus should be handled by the caller. 2224 return RESIZE_NONE; 2225 case CSSValueNone: 2226 return RESIZE_NONE; 2227 } 2228 2229 ASSERT_NOT_REACHED(); 2230 return RESIZE_NONE; 2231} 2232 2233template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETableLayout e) 2234 : CSSValue(PrimitiveClass) 2235{ 2236 m_primitiveUnitType = CSS_IDENT; 2237 switch (e) { 2238 case TAUTO: 2239 m_value.ident = CSSValueAuto; 2240 break; 2241 case TFIXED: 2242 m_value.ident = CSSValueFixed; 2243 break; 2244 } 2245} 2246 2247template<> inline CSSPrimitiveValue::operator ETableLayout() const 2248{ 2249 switch (m_value.ident) { 2250 case CSSValueFixed: 2251 return TFIXED; 2252 case CSSValueAuto: 2253 return TAUTO; 2254 } 2255 2256 ASSERT_NOT_REACHED(); 2257 return TAUTO; 2258} 2259 2260template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e) 2261 : CSSValue(PrimitiveClass) 2262{ 2263 m_primitiveUnitType = CSS_IDENT; 2264 switch (e) { 2265 case TASTART: 2266 m_value.ident = CSSValueStart; 2267 break; 2268 case TAEND: 2269 m_value.ident = CSSValueEnd; 2270 break; 2271 case LEFT: 2272 m_value.ident = CSSValueLeft; 2273 break; 2274 case RIGHT: 2275 m_value.ident = CSSValueRight; 2276 break; 2277 case CENTER: 2278 m_value.ident = CSSValueCenter; 2279 break; 2280 case JUSTIFY: 2281 m_value.ident = CSSValueJustify; 2282 break; 2283 case WEBKIT_LEFT: 2284 m_value.ident = CSSValueWebkitLeft; 2285 break; 2286 case WEBKIT_RIGHT: 2287 m_value.ident = CSSValueWebkitRight; 2288 break; 2289 case WEBKIT_CENTER: 2290 m_value.ident = CSSValueWebkitCenter; 2291 break; 2292 } 2293} 2294 2295template<> inline CSSPrimitiveValue::operator ETextAlign() const 2296{ 2297 switch (m_value.ident) { 2298 case CSSValueWebkitAuto: // Legacy -webkit-auto. Eqiuvalent to start. 2299 case CSSValueStart: 2300 return TASTART; 2301 case CSSValueEnd: 2302 return TAEND; 2303 default: 2304 return static_cast<ETextAlign>(m_value.ident - CSSValueLeft); 2305 } 2306} 2307 2308#if ENABLE(CSS3_TEXT) 2309template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextAlignLast e) 2310 : CSSValue(PrimitiveClass) 2311{ 2312 m_primitiveUnitType = CSS_IDENT; 2313 switch (e) { 2314 case TextAlignLastStart: 2315 m_value.ident = CSSValueStart; 2316 break; 2317 case TextAlignLastEnd: 2318 m_value.ident = CSSValueEnd; 2319 break; 2320 case TextAlignLastLeft: 2321 m_value.ident = CSSValueLeft; 2322 break; 2323 case TextAlignLastRight: 2324 m_value.ident = CSSValueRight; 2325 break; 2326 case TextAlignLastCenter: 2327 m_value.ident = CSSValueCenter; 2328 break; 2329 case TextAlignLastJustify: 2330 m_value.ident = CSSValueJustify; 2331 break; 2332 case TextAlignLastAuto: 2333 m_value.ident = CSSValueAuto; 2334 break; 2335 } 2336} 2337 2338template<> inline CSSPrimitiveValue::operator TextAlignLast() const 2339{ 2340 switch (m_value.ident) { 2341 case CSSValueAuto: 2342 return TextAlignLastAuto; 2343 case CSSValueStart: 2344 return TextAlignLastStart; 2345 case CSSValueEnd: 2346 return TextAlignLastEnd; 2347 case CSSValueLeft: 2348 return TextAlignLastLeft; 2349 case CSSValueRight: 2350 return TextAlignLastRight; 2351 case CSSValueCenter: 2352 return TextAlignLastCenter; 2353 case CSSValueJustify: 2354 return TextAlignLastJustify; 2355 } 2356 2357 ASSERT_NOT_REACHED(); 2358 return TextAlignLastAuto; 2359} 2360 2361template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextJustify e) 2362 : CSSValue(PrimitiveClass) 2363{ 2364 m_primitiveUnitType = CSS_IDENT; 2365 switch (e) { 2366 case TextJustifyAuto: 2367 m_value.ident = CSSValueAuto; 2368 break; 2369 case TextJustifyNone: 2370 m_value.ident = CSSValueNone; 2371 break; 2372 case TextJustifyInterWord: 2373 m_value.ident = CSSValueInterWord; 2374 break; 2375 case TextJustifyInterIdeograph: 2376 m_value.ident = CSSValueInterIdeograph; 2377 break; 2378 case TextJustifyInterCluster: 2379 m_value.ident = CSSValueInterCluster; 2380 break; 2381 case TextJustifyDistribute: 2382 m_value.ident = CSSValueDistribute; 2383 break; 2384 case TextJustifyKashida: 2385 m_value.ident = CSSValueKashida; 2386 break; 2387 } 2388} 2389 2390template<> inline CSSPrimitiveValue::operator TextJustify() const 2391{ 2392 switch (m_value.ident) { 2393 case CSSValueAuto: 2394 return TextJustifyAuto; 2395 case CSSValueNone: 2396 return TextJustifyNone; 2397 case CSSValueInterWord: 2398 return TextJustifyInterWord; 2399 case CSSValueInterIdeograph: 2400 return TextJustifyInterIdeograph; 2401 case CSSValueInterCluster: 2402 return TextJustifyInterCluster; 2403 case CSSValueDistribute: 2404 return TextJustifyDistribute; 2405 case CSSValueKashida: 2406 return TextJustifyKashida; 2407 } 2408 2409 ASSERT_NOT_REACHED(); 2410 return TextJustifyAuto; 2411} 2412#endif // CSS3_TEXT 2413 2414template<> inline CSSPrimitiveValue::operator TextDecoration() const 2415{ 2416 switch (m_value.ident) { 2417 case CSSValueNone: 2418 return TextDecorationNone; 2419 case CSSValueUnderline: 2420 return TextDecorationUnderline; 2421 case CSSValueOverline: 2422 return TextDecorationOverline; 2423 case CSSValueLineThrough: 2424 return TextDecorationLineThrough; 2425 case CSSValueBlink: 2426 return TextDecorationBlink; 2427 } 2428 2429 ASSERT_NOT_REACHED(); 2430 return TextDecorationNone; 2431} 2432 2433#if ENABLE(CSS3_TEXT) 2434template<> inline CSSPrimitiveValue::operator TextDecorationStyle() const 2435{ 2436 switch (m_value.ident) { 2437 case CSSValueSolid: 2438 return TextDecorationStyleSolid; 2439 case CSSValueDouble: 2440 return TextDecorationStyleDouble; 2441 case CSSValueDotted: 2442 return TextDecorationStyleDotted; 2443 case CSSValueDashed: 2444 return TextDecorationStyleDashed; 2445 case CSSValueWavy: 2446 return TextDecorationStyleWavy; 2447 } 2448 2449 ASSERT_NOT_REACHED(); 2450 return TextDecorationStyleSolid; 2451} 2452 2453template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextUnderlinePosition e) 2454 : CSSValue(PrimitiveClass) 2455{ 2456 m_primitiveUnitType = CSS_IDENT; 2457 switch (e) { 2458 case TextUnderlinePositionAuto: 2459 m_value.ident = CSSValueAuto; 2460 break; 2461 case TextUnderlinePositionAlphabetic: 2462 m_value.ident = CSSValueAlphabetic; 2463 break; 2464 case TextUnderlinePositionUnder: 2465 m_value.ident = CSSValueUnder; 2466 break; 2467 } 2468 2469 // FIXME: Implement support for 'under left' and 'under right' values. 2470} 2471 2472template<> inline CSSPrimitiveValue::operator TextUnderlinePosition() const 2473{ 2474 switch (m_value.ident) { 2475 case CSSValueAuto: 2476 return TextUnderlinePositionAuto; 2477 case CSSValueAlphabetic: 2478 return TextUnderlinePositionAlphabetic; 2479 case CSSValueUnder: 2480 return TextUnderlinePositionUnder; 2481 } 2482 2483 // FIXME: Implement support for 'under left' and 'under right' values. 2484 2485 ASSERT_NOT_REACHED(); 2486 return TextUnderlinePositionAuto; 2487} 2488#endif // CSS3_TEXT 2489 2490template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e) 2491 : CSSValue(PrimitiveClass) 2492{ 2493 m_primitiveUnitType = CSS_IDENT; 2494 switch (e) { 2495 case TSNONE: 2496 m_value.ident = CSSValueNone; 2497 break; 2498 case TSDISC: 2499 m_value.ident = CSSValueDisc; 2500 break; 2501 case TSCIRCLE: 2502 m_value.ident = CSSValueCircle; 2503 break; 2504 case TSSQUARE: 2505 m_value.ident = CSSValueSquare; 2506 break; 2507 } 2508} 2509 2510template<> inline CSSPrimitiveValue::operator ETextSecurity() const 2511{ 2512 switch (m_value.ident) { 2513 case CSSValueNone: 2514 return TSNONE; 2515 case CSSValueDisc: 2516 return TSDISC; 2517 case CSSValueCircle: 2518 return TSCIRCLE; 2519 case CSSValueSquare: 2520 return TSSQUARE; 2521 } 2522 2523 ASSERT_NOT_REACHED(); 2524 return TSNONE; 2525} 2526 2527template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextTransform e) 2528 : CSSValue(PrimitiveClass) 2529{ 2530 m_primitiveUnitType = CSS_IDENT; 2531 switch (e) { 2532 case CAPITALIZE: 2533 m_value.ident = CSSValueCapitalize; 2534 break; 2535 case UPPERCASE: 2536 m_value.ident = CSSValueUppercase; 2537 break; 2538 case LOWERCASE: 2539 m_value.ident = CSSValueLowercase; 2540 break; 2541 case TTNONE: 2542 m_value.ident = CSSValueNone; 2543 break; 2544 } 2545} 2546 2547template<> inline CSSPrimitiveValue::operator ETextTransform() const 2548{ 2549 switch (m_value.ident) { 2550 case CSSValueCapitalize: 2551 return CAPITALIZE; 2552 case CSSValueUppercase: 2553 return UPPERCASE; 2554 case CSSValueLowercase: 2555 return LOWERCASE; 2556 case CSSValueNone: 2557 return TTNONE; 2558 } 2559 2560 ASSERT_NOT_REACHED(); 2561 return TTNONE; 2562} 2563 2564template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e) 2565 : CSSValue(PrimitiveClass) 2566{ 2567 m_primitiveUnitType = CSS_IDENT; 2568 switch (e) { 2569 case UBNormal: 2570 m_value.ident = CSSValueNormal; 2571 break; 2572 case Embed: 2573 m_value.ident = CSSValueEmbed; 2574 break; 2575 case Override: 2576 m_value.ident = CSSValueBidiOverride; 2577 break; 2578 case Isolate: 2579 m_value.ident = CSSValueWebkitIsolate; 2580 break; 2581 case IsolateOverride: 2582 m_value.ident = CSSValueWebkitIsolateOverride; 2583 break; 2584 case Plaintext: 2585 m_value.ident = CSSValueWebkitPlaintext; 2586 break; 2587 } 2588} 2589 2590template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const 2591{ 2592 switch (m_value.ident) { 2593 case CSSValueNormal: 2594 return UBNormal; 2595 case CSSValueEmbed: 2596 return Embed; 2597 case CSSValueBidiOverride: 2598 return Override; 2599 case CSSValueWebkitIsolate: 2600 return Isolate; 2601 case CSSValueWebkitIsolateOverride: 2602 return IsolateOverride; 2603 case CSSValueWebkitPlaintext: 2604 return Plaintext; 2605 } 2606 2607 ASSERT_NOT_REACHED(); 2608 return UBNormal; 2609} 2610 2611template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserDrag e) 2612 : CSSValue(PrimitiveClass) 2613{ 2614 m_primitiveUnitType = CSS_IDENT; 2615 switch (e) { 2616 case DRAG_AUTO: 2617 m_value.ident = CSSValueAuto; 2618 break; 2619 case DRAG_NONE: 2620 m_value.ident = CSSValueNone; 2621 break; 2622 case DRAG_ELEMENT: 2623 m_value.ident = CSSValueElement; 2624 break; 2625 } 2626} 2627 2628template<> inline CSSPrimitiveValue::operator EUserDrag() const 2629{ 2630 switch (m_value.ident) { 2631 case CSSValueAuto: 2632 return DRAG_AUTO; 2633 case CSSValueNone: 2634 return DRAG_NONE; 2635 case CSSValueElement: 2636 return DRAG_ELEMENT; 2637 } 2638 2639 ASSERT_NOT_REACHED(); 2640 return DRAG_AUTO; 2641} 2642 2643template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserModify e) 2644 : CSSValue(PrimitiveClass) 2645{ 2646 m_primitiveUnitType = CSS_IDENT; 2647 switch (e) { 2648 case READ_ONLY: 2649 m_value.ident = CSSValueReadOnly; 2650 break; 2651 case READ_WRITE: 2652 m_value.ident = CSSValueReadWrite; 2653 break; 2654 case READ_WRITE_PLAINTEXT_ONLY: 2655 m_value.ident = CSSValueReadWritePlaintextOnly; 2656 break; 2657 } 2658} 2659 2660template<> inline CSSPrimitiveValue::operator EUserModify() const 2661{ 2662 switch (m_value.ident) { 2663 case CSSValueReadOnly: 2664 return READ_ONLY; 2665 case CSSValueReadWrite: 2666 return READ_WRITE; 2667 case CSSValueReadWritePlaintextOnly: 2668 return READ_WRITE_PLAINTEXT_ONLY; 2669 } 2670 2671 ASSERT_NOT_REACHED(); 2672 return READ_ONLY; 2673} 2674 2675template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e) 2676 : CSSValue(PrimitiveClass) 2677{ 2678 m_primitiveUnitType = CSS_IDENT; 2679 switch (e) { 2680 case SELECT_NONE: 2681 m_value.ident = CSSValueNone; 2682 break; 2683 case SELECT_TEXT: 2684 m_value.ident = CSSValueText; 2685 break; 2686 case SELECT_ALL: 2687 m_value.ident = CSSValueAll; 2688 break; 2689 } 2690} 2691 2692template<> inline CSSPrimitiveValue::operator EUserSelect() const 2693{ 2694 switch (m_value.ident) { 2695 case CSSValueAuto: 2696 return SELECT_TEXT; 2697 case CSSValueNone: 2698 return SELECT_NONE; 2699 case CSSValueText: 2700 return SELECT_TEXT; 2701 case CSSValueAll: 2702 return SELECT_ALL; 2703 } 2704 2705 ASSERT_NOT_REACHED(); 2706 return SELECT_TEXT; 2707} 2708 2709template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVerticalAlign a) 2710 : CSSValue(PrimitiveClass) 2711{ 2712 m_primitiveUnitType = CSS_IDENT; 2713 switch (a) { 2714 case TOP: 2715 m_value.ident = CSSValueTop; 2716 break; 2717 case BOTTOM: 2718 m_value.ident = CSSValueBottom; 2719 break; 2720 case MIDDLE: 2721 m_value.ident = CSSValueMiddle; 2722 break; 2723 case BASELINE: 2724 m_value.ident = CSSValueBaseline; 2725 break; 2726 case TEXT_BOTTOM: 2727 m_value.ident = CSSValueTextBottom; 2728 break; 2729 case TEXT_TOP: 2730 m_value.ident = CSSValueTextTop; 2731 break; 2732 case SUB: 2733 m_value.ident = CSSValueSub; 2734 break; 2735 case SUPER: 2736 m_value.ident = CSSValueSuper; 2737 break; 2738 case BASELINE_MIDDLE: 2739 m_value.ident = CSSValueWebkitBaselineMiddle; 2740 break; 2741 case LENGTH: 2742 m_value.ident = CSSValueInvalid; 2743 } 2744} 2745 2746template<> inline CSSPrimitiveValue::operator EVerticalAlign() const 2747{ 2748 switch (m_value.ident) { 2749 case CSSValueTop: 2750 return TOP; 2751 case CSSValueBottom: 2752 return BOTTOM; 2753 case CSSValueMiddle: 2754 return MIDDLE; 2755 case CSSValueBaseline: 2756 return BASELINE; 2757 case CSSValueTextBottom: 2758 return TEXT_BOTTOM; 2759 case CSSValueTextTop: 2760 return TEXT_TOP; 2761 case CSSValueSub: 2762 return SUB; 2763 case CSSValueSuper: 2764 return SUPER; 2765 case CSSValueWebkitBaselineMiddle: 2766 return BASELINE_MIDDLE; 2767 } 2768 2769 ASSERT_NOT_REACHED(); 2770 return TOP; 2771} 2772 2773template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e) 2774 : CSSValue(PrimitiveClass) 2775{ 2776 m_primitiveUnitType = CSS_IDENT; 2777 switch (e) { 2778 case VISIBLE: 2779 m_value.ident = CSSValueVisible; 2780 break; 2781 case HIDDEN: 2782 m_value.ident = CSSValueHidden; 2783 break; 2784 case COLLAPSE: 2785 m_value.ident = CSSValueCollapse; 2786 break; 2787 } 2788} 2789 2790template<> inline CSSPrimitiveValue::operator EVisibility() const 2791{ 2792 switch (m_value.ident) { 2793 case CSSValueHidden: 2794 return HIDDEN; 2795 case CSSValueVisible: 2796 return VISIBLE; 2797 case CSSValueCollapse: 2798 return COLLAPSE; 2799 } 2800 2801 ASSERT_NOT_REACHED(); 2802 return VISIBLE; 2803} 2804 2805template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWhiteSpace e) 2806 : CSSValue(PrimitiveClass) 2807{ 2808 m_primitiveUnitType = CSS_IDENT; 2809 switch (e) { 2810 case NORMAL: 2811 m_value.ident = CSSValueNormal; 2812 break; 2813 case PRE: 2814 m_value.ident = CSSValuePre; 2815 break; 2816 case PRE_WRAP: 2817 m_value.ident = CSSValuePreWrap; 2818 break; 2819 case PRE_LINE: 2820 m_value.ident = CSSValuePreLine; 2821 break; 2822 case NOWRAP: 2823 m_value.ident = CSSValueNowrap; 2824 break; 2825 case KHTML_NOWRAP: 2826 m_value.ident = CSSValueWebkitNowrap; 2827 break; 2828 } 2829} 2830 2831template<> inline CSSPrimitiveValue::operator EWhiteSpace() const 2832{ 2833 switch (m_value.ident) { 2834 case CSSValueWebkitNowrap: 2835 return KHTML_NOWRAP; 2836 case CSSValueNowrap: 2837 return NOWRAP; 2838 case CSSValuePre: 2839 return PRE; 2840 case CSSValuePreWrap: 2841 return PRE_WRAP; 2842 case CSSValuePreLine: 2843 return PRE_LINE; 2844 case CSSValueNormal: 2845 return NORMAL; 2846 } 2847 2848 ASSERT_NOT_REACHED(); 2849 return NORMAL; 2850} 2851 2852template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e) 2853 : CSSValue(PrimitiveClass) 2854{ 2855 m_primitiveUnitType = CSS_IDENT; 2856 switch (e) { 2857 case NormalWordBreak: 2858 m_value.ident = CSSValueNormal; 2859 break; 2860 case BreakAllWordBreak: 2861 m_value.ident = CSSValueBreakAll; 2862 break; 2863 case BreakWordBreak: 2864 m_value.ident = CSSValueBreakWord; 2865 break; 2866 } 2867} 2868 2869template<> inline CSSPrimitiveValue::operator EWordBreak() const 2870{ 2871 switch (m_value.ident) { 2872 case CSSValueBreakAll: 2873 return BreakAllWordBreak; 2874 case CSSValueBreakWord: 2875 return BreakWordBreak; 2876 case CSSValueNormal: 2877 return NormalWordBreak; 2878 } 2879 2880 ASSERT_NOT_REACHED(); 2881 return NormalWordBreak; 2882} 2883 2884template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflowWrap e) 2885 : CSSValue(PrimitiveClass) 2886{ 2887 m_primitiveUnitType = CSS_IDENT; 2888 switch (e) { 2889 case NormalOverflowWrap: 2890 m_value.ident = CSSValueNormal; 2891 break; 2892 case BreakOverflowWrap: 2893 m_value.ident = CSSValueBreakWord; 2894 break; 2895 } 2896} 2897 2898template<> inline CSSPrimitiveValue::operator EOverflowWrap() const 2899{ 2900 switch (m_value.ident) { 2901 case CSSValueBreakWord: 2902 return BreakOverflowWrap; 2903 case CSSValueNormal: 2904 return NormalOverflowWrap; 2905 } 2906 2907 ASSERT_NOT_REACHED(); 2908 return NormalOverflowWrap; 2909} 2910 2911template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e) 2912 : CSSValue(PrimitiveClass) 2913{ 2914 m_primitiveUnitType = CSS_IDENT; 2915 switch (e) { 2916 case LTR: 2917 m_value.ident = CSSValueLtr; 2918 break; 2919 case RTL: 2920 m_value.ident = CSSValueRtl; 2921 break; 2922 } 2923} 2924 2925template<> inline CSSPrimitiveValue::operator TextDirection() const 2926{ 2927 switch (m_value.ident) { 2928 case CSSValueLtr: 2929 return LTR; 2930 case CSSValueRtl: 2931 return RTL; 2932 } 2933 2934 ASSERT_NOT_REACHED(); 2935 return LTR; 2936} 2937 2938template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WritingMode e) 2939 : CSSValue(PrimitiveClass) 2940{ 2941 m_primitiveUnitType = CSS_IDENT; 2942 switch (e) { 2943 case TopToBottomWritingMode: 2944 m_value.ident = CSSValueHorizontalTb; 2945 break; 2946 case RightToLeftWritingMode: 2947 m_value.ident = CSSValueVerticalRl; 2948 break; 2949 case LeftToRightWritingMode: 2950 m_value.ident = CSSValueVerticalLr; 2951 break; 2952 case BottomToTopWritingMode: 2953 m_value.ident = CSSValueHorizontalBt; 2954 break; 2955 } 2956} 2957 2958template<> inline CSSPrimitiveValue::operator WritingMode() const 2959{ 2960 switch (m_value.ident) { 2961 case CSSValueHorizontalTb: 2962 return TopToBottomWritingMode; 2963 case CSSValueVerticalRl: 2964 return RightToLeftWritingMode; 2965 case CSSValueVerticalLr: 2966 return LeftToRightWritingMode; 2967 case CSSValueHorizontalBt: 2968 return BottomToTopWritingMode; 2969 } 2970 2971 ASSERT_NOT_REACHED(); 2972 return TopToBottomWritingMode; 2973} 2974 2975template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextCombine e) 2976 : CSSValue(PrimitiveClass) 2977{ 2978 m_primitiveUnitType = CSS_IDENT; 2979 switch (e) { 2980 case TextCombineNone: 2981 m_value.ident = CSSValueNone; 2982 break; 2983 case TextCombineHorizontal: 2984 m_value.ident = CSSValueHorizontal; 2985 break; 2986 } 2987} 2988 2989template<> inline CSSPrimitiveValue::operator TextCombine() const 2990{ 2991 switch (m_value.ident) { 2992 case CSSValueNone: 2993 return TextCombineNone; 2994 case CSSValueHorizontal: 2995 return TextCombineHorizontal; 2996 } 2997 2998 ASSERT_NOT_REACHED(); 2999 return TextCombineNone; 3000} 3001 3002template<> inline CSSPrimitiveValue::CSSPrimitiveValue(RubyPosition position) 3003 : CSSValue(PrimitiveClass) 3004{ 3005 m_primitiveUnitType = CSS_IDENT; 3006 switch (position) { 3007 case RubyPositionBefore: 3008 m_value.ident = CSSValueBefore; 3009 break; 3010 case RubyPositionAfter: 3011 m_value.ident = CSSValueAfter; 3012 break; 3013 } 3014} 3015 3016template<> inline CSSPrimitiveValue::operator RubyPosition() const 3017{ 3018 switch (m_value.ident) { 3019 case CSSValueBefore: 3020 return RubyPositionBefore; 3021 case CSSValueAfter: 3022 return RubyPositionAfter; 3023 } 3024 3025 ASSERT_NOT_REACHED(); 3026 return RubyPositionBefore; 3027} 3028 3029template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisPosition position) 3030 : CSSValue(PrimitiveClass) 3031{ 3032 m_primitiveUnitType = CSS_IDENT; 3033 switch (position) { 3034 case TextEmphasisPositionOver: 3035 m_value.ident = CSSValueOver; 3036 break; 3037 case TextEmphasisPositionUnder: 3038 m_value.ident = CSSValueUnder; 3039 break; 3040 } 3041} 3042 3043template<> inline CSSPrimitiveValue::operator TextEmphasisPosition() const 3044{ 3045 switch (m_value.ident) { 3046 case CSSValueOver: 3047 return TextEmphasisPositionOver; 3048 case CSSValueUnder: 3049 return TextEmphasisPositionUnder; 3050 } 3051 3052 ASSERT_NOT_REACHED(); 3053 return TextEmphasisPositionOver; 3054} 3055 3056template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextOverflow overflow) 3057 : CSSValue(PrimitiveClass) 3058{ 3059 m_primitiveUnitType = CSS_IDENT; 3060 switch (overflow) { 3061 case TextOverflowClip: 3062 m_value.ident = CSSValueClip; 3063 break; 3064 case TextOverflowEllipsis: 3065 m_value.ident = CSSValueEllipsis; 3066 break; 3067 } 3068} 3069 3070template<> inline CSSPrimitiveValue::operator TextOverflow() const 3071{ 3072 switch (m_value.ident) { 3073 case CSSValueClip: 3074 return TextOverflowClip; 3075 case CSSValueEllipsis: 3076 return TextOverflowEllipsis; 3077 } 3078 3079 ASSERT_NOT_REACHED(); 3080 return TextOverflowClip; 3081} 3082 3083template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisFill fill) 3084 : CSSValue(PrimitiveClass) 3085{ 3086 m_primitiveUnitType = CSS_IDENT; 3087 switch (fill) { 3088 case TextEmphasisFillFilled: 3089 m_value.ident = CSSValueFilled; 3090 break; 3091 case TextEmphasisFillOpen: 3092 m_value.ident = CSSValueOpen; 3093 break; 3094 } 3095} 3096 3097template<> inline CSSPrimitiveValue::operator TextEmphasisFill() const 3098{ 3099 switch (m_value.ident) { 3100 case CSSValueFilled: 3101 return TextEmphasisFillFilled; 3102 case CSSValueOpen: 3103 return TextEmphasisFillOpen; 3104 } 3105 3106 ASSERT_NOT_REACHED(); 3107 return TextEmphasisFillFilled; 3108} 3109 3110template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisMark mark) 3111 : CSSValue(PrimitiveClass) 3112{ 3113 m_primitiveUnitType = CSS_IDENT; 3114 switch (mark) { 3115 case TextEmphasisMarkDot: 3116 m_value.ident = CSSValueDot; 3117 break; 3118 case TextEmphasisMarkCircle: 3119 m_value.ident = CSSValueCircle; 3120 break; 3121 case TextEmphasisMarkDoubleCircle: 3122 m_value.ident = CSSValueDoubleCircle; 3123 break; 3124 case TextEmphasisMarkTriangle: 3125 m_value.ident = CSSValueTriangle; 3126 break; 3127 case TextEmphasisMarkSesame: 3128 m_value.ident = CSSValueSesame; 3129 break; 3130 case TextEmphasisMarkNone: 3131 case TextEmphasisMarkAuto: 3132 case TextEmphasisMarkCustom: 3133 ASSERT_NOT_REACHED(); 3134 m_value.ident = CSSValueNone; 3135 break; 3136 } 3137} 3138 3139template<> inline CSSPrimitiveValue::operator TextEmphasisMark() const 3140{ 3141 switch (m_value.ident) { 3142 case CSSValueNone: 3143 return TextEmphasisMarkNone; 3144 case CSSValueDot: 3145 return TextEmphasisMarkDot; 3146 case CSSValueCircle: 3147 return TextEmphasisMarkCircle; 3148 case CSSValueDoubleCircle: 3149 return TextEmphasisMarkDoubleCircle; 3150 case CSSValueTriangle: 3151 return TextEmphasisMarkTriangle; 3152 case CSSValueSesame: 3153 return TextEmphasisMarkSesame; 3154 } 3155 3156 ASSERT_NOT_REACHED(); 3157 return TextEmphasisMarkNone; 3158} 3159 3160template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextOrientation e) 3161 : CSSValue(PrimitiveClass) 3162{ 3163 m_primitiveUnitType = CSS_IDENT; 3164 switch (e) { 3165 case TextOrientationSideways: 3166 m_value.ident = CSSValueSideways; 3167 break; 3168 case TextOrientationSidewaysRight: 3169 m_value.ident = CSSValueSidewaysRight; 3170 break; 3171 case TextOrientationVerticalRight: 3172 m_value.ident = CSSValueVerticalRight; 3173 break; 3174 case TextOrientationUpright: 3175 m_value.ident = CSSValueUpright; 3176 break; 3177 } 3178} 3179 3180template<> inline CSSPrimitiveValue::operator TextOrientation() const 3181{ 3182 switch (m_value.ident) { 3183 case CSSValueSideways: 3184 return TextOrientationSideways; 3185 case CSSValueSidewaysRight: 3186 return TextOrientationSidewaysRight; 3187 case CSSValueVerticalRight: 3188 return TextOrientationVerticalRight; 3189 case CSSValueUpright: 3190 return TextOrientationUpright; 3191 } 3192 3193 ASSERT_NOT_REACHED(); 3194 return TextOrientationVerticalRight; 3195} 3196 3197template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e) 3198 : CSSValue(PrimitiveClass) 3199{ 3200 m_primitiveUnitType = CSS_IDENT; 3201 switch (e) { 3202 case PE_NONE: 3203 m_value.ident = CSSValueNone; 3204 break; 3205 case PE_STROKE: 3206 m_value.ident = CSSValueStroke; 3207 break; 3208 case PE_FILL: 3209 m_value.ident = CSSValueFill; 3210 break; 3211 case PE_PAINTED: 3212 m_value.ident = CSSValuePainted; 3213 break; 3214 case PE_VISIBLE: 3215 m_value.ident = CSSValueVisible; 3216 break; 3217 case PE_VISIBLE_STROKE: 3218 m_value.ident = CSSValueVisiblestroke; 3219 break; 3220 case PE_VISIBLE_FILL: 3221 m_value.ident = CSSValueVisiblefill; 3222 break; 3223 case PE_VISIBLE_PAINTED: 3224 m_value.ident = CSSValueVisiblepainted; 3225 break; 3226 case PE_AUTO: 3227 m_value.ident = CSSValueAuto; 3228 break; 3229 case PE_ALL: 3230 m_value.ident = CSSValueAll; 3231 break; 3232 } 3233} 3234 3235template<> inline CSSPrimitiveValue::operator EPointerEvents() const 3236{ 3237 switch (m_value.ident) { 3238 case CSSValueAll: 3239 return PE_ALL; 3240 case CSSValueAuto: 3241 return PE_AUTO; 3242 case CSSValueNone: 3243 return PE_NONE; 3244 case CSSValueVisiblepainted: 3245 return PE_VISIBLE_PAINTED; 3246 case CSSValueVisiblefill: 3247 return PE_VISIBLE_FILL; 3248 case CSSValueVisiblestroke: 3249 return PE_VISIBLE_STROKE; 3250 case CSSValueVisible: 3251 return PE_VISIBLE; 3252 case CSSValuePainted: 3253 return PE_PAINTED; 3254 case CSSValueFill: 3255 return PE_FILL; 3256 case CSSValueStroke: 3257 return PE_STROKE; 3258 } 3259 3260 ASSERT_NOT_REACHED(); 3261 return PE_ALL; 3262} 3263 3264template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontDescription::Kerning kerning) 3265 : CSSValue(PrimitiveClass) 3266{ 3267 m_primitiveUnitType = CSS_IDENT; 3268 switch (kerning) { 3269 case FontDescription::AutoKerning: 3270 m_value.ident = CSSValueAuto; 3271 return; 3272 case FontDescription::NormalKerning: 3273 m_value.ident = CSSValueNormal; 3274 return; 3275 case FontDescription::NoneKerning: 3276 m_value.ident = CSSValueNone; 3277 return; 3278 } 3279 3280 ASSERT_NOT_REACHED(); 3281 m_value.ident = CSSValueAuto; 3282} 3283 3284template<> inline CSSPrimitiveValue::operator FontDescription::Kerning() const 3285{ 3286 switch (m_value.ident) { 3287 case CSSValueAuto: 3288 return FontDescription::AutoKerning; 3289 case CSSValueNormal: 3290 return FontDescription::NormalKerning; 3291 case CSSValueNone: 3292 return FontDescription::NoneKerning; 3293 } 3294 3295 ASSERT_NOT_REACHED(); 3296 return FontDescription::AutoKerning; 3297} 3298 3299template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothingMode smoothing) 3300 : CSSValue(PrimitiveClass) 3301{ 3302 m_primitiveUnitType = CSS_IDENT; 3303 switch (smoothing) { 3304 case AutoSmoothing: 3305 m_value.ident = CSSValueAuto; 3306 return; 3307 case NoSmoothing: 3308 m_value.ident = CSSValueNone; 3309 return; 3310 case Antialiased: 3311 m_value.ident = CSSValueAntialiased; 3312 return; 3313 case SubpixelAntialiased: 3314 m_value.ident = CSSValueSubpixelAntialiased; 3315 return; 3316 } 3317 3318 ASSERT_NOT_REACHED(); 3319 m_value.ident = CSSValueAuto; 3320} 3321 3322template<> inline CSSPrimitiveValue::operator FontSmoothingMode() const 3323{ 3324 switch (m_value.ident) { 3325 case CSSValueAuto: 3326 return AutoSmoothing; 3327 case CSSValueNone: 3328 return NoSmoothing; 3329 case CSSValueAntialiased: 3330 return Antialiased; 3331 case CSSValueSubpixelAntialiased: 3332 return SubpixelAntialiased; 3333 } 3334 3335 ASSERT_NOT_REACHED(); 3336 return AutoSmoothing; 3337} 3338 3339template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontWeight weight) 3340 : CSSValue(PrimitiveClass) 3341{ 3342 m_primitiveUnitType = CSS_IDENT; 3343 switch (weight) { 3344 case FontWeight900: 3345 m_value.ident = CSSValue900; 3346 return; 3347 case FontWeight800: 3348 m_value.ident = CSSValue800; 3349 return; 3350 case FontWeight700: 3351 m_value.ident = CSSValue700; 3352 return; 3353 case FontWeight600: 3354 m_value.ident = CSSValue600; 3355 return; 3356 case FontWeight500: 3357 m_value.ident = CSSValue500; 3358 return; 3359 case FontWeight400: 3360 m_value.ident = CSSValue400; 3361 return; 3362 case FontWeight300: 3363 m_value.ident = CSSValue300; 3364 return; 3365 case FontWeight200: 3366 m_value.ident = CSSValue200; 3367 return; 3368 case FontWeight100: 3369 m_value.ident = CSSValue100; 3370 return; 3371 } 3372 3373 ASSERT_NOT_REACHED(); 3374 m_value.ident = CSSValueNormal; 3375} 3376 3377template<> inline CSSPrimitiveValue::operator FontWeight() const 3378{ 3379 switch (m_value.ident) { 3380 case CSSValueBold: 3381 return FontWeightBold; 3382 case CSSValueNormal: 3383 return FontWeightNormal; 3384 case CSSValue900: 3385 return FontWeight900; 3386 case CSSValue800: 3387 return FontWeight800; 3388 case CSSValue700: 3389 return FontWeight700; 3390 case CSSValue600: 3391 return FontWeight600; 3392 case CSSValue500: 3393 return FontWeight500; 3394 case CSSValue400: 3395 return FontWeight400; 3396 case CSSValue300: 3397 return FontWeight300; 3398 case CSSValue200: 3399 return FontWeight200; 3400 case CSSValue100: 3401 return FontWeight100; 3402 } 3403 3404 ASSERT_NOT_REACHED(); 3405 return FontWeightNormal; 3406} 3407 3408template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontItalic italic) 3409 : CSSValue(PrimitiveClass) 3410{ 3411 m_primitiveUnitType = CSS_IDENT; 3412 switch (italic) { 3413 case FontItalicOff: 3414 m_value.ident = CSSValueNormal; 3415 return; 3416 case FontItalicOn: 3417 m_value.ident = CSSValueItalic; 3418 return; 3419 } 3420 3421 ASSERT_NOT_REACHED(); 3422 m_value.ident = CSSValueNormal; 3423} 3424 3425template<> inline CSSPrimitiveValue::operator FontItalic() const 3426{ 3427 switch (m_value.ident) { 3428 case CSSValueOblique: 3429 // FIXME: oblique is the same as italic for the moment... 3430 case CSSValueItalic: 3431 return FontItalicOn; 3432 case CSSValueNormal: 3433 return FontItalicOff; 3434 } 3435 ASSERT_NOT_REACHED(); 3436 return FontItalicOff; 3437} 3438 3439template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps) 3440 : CSSValue(PrimitiveClass) 3441{ 3442 m_primitiveUnitType = CSS_IDENT; 3443 switch (smallCaps) { 3444 case FontSmallCapsOff: 3445 m_value.ident = CSSValueNormal; 3446 return; 3447 case FontSmallCapsOn: 3448 m_value.ident = CSSValueSmallCaps; 3449 return; 3450 } 3451 3452 ASSERT_NOT_REACHED(); 3453 m_value.ident = CSSValueNormal; 3454} 3455 3456template<> inline CSSPrimitiveValue::operator FontSmallCaps() const 3457{ 3458 switch (m_value.ident) { 3459 case CSSValueSmallCaps: 3460 return FontSmallCapsOn; 3461 case CSSValueNormal: 3462 return FontSmallCapsOff; 3463 } 3464 ASSERT_NOT_REACHED(); 3465 return FontSmallCapsOff; 3466} 3467 3468template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e) 3469 : CSSValue(PrimitiveClass) 3470{ 3471 m_primitiveUnitType = CSS_IDENT; 3472 switch (e) { 3473 case AutoTextRendering: 3474 m_value.ident = CSSValueAuto; 3475 break; 3476 case OptimizeSpeed: 3477 m_value.ident = CSSValueOptimizespeed; 3478 break; 3479 case OptimizeLegibility: 3480 m_value.ident = CSSValueOptimizelegibility; 3481 break; 3482 case GeometricPrecision: 3483 m_value.ident = CSSValueGeometricprecision; 3484 break; 3485 } 3486} 3487 3488template<> inline CSSPrimitiveValue::operator TextRenderingMode() const 3489{ 3490 switch (m_value.ident) { 3491 case CSSValueAuto: 3492 return AutoTextRendering; 3493 case CSSValueOptimizespeed: 3494 return OptimizeSpeed; 3495 case CSSValueOptimizelegibility: 3496 return OptimizeLegibility; 3497 case CSSValueGeometricprecision: 3498 return GeometricPrecision; 3499 } 3500 3501 ASSERT_NOT_REACHED(); 3502 return AutoTextRendering; 3503} 3504 3505template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColorSpace space) 3506 : CSSValue(PrimitiveClass) 3507{ 3508 m_primitiveUnitType = CSS_IDENT; 3509 switch (space) { 3510 case ColorSpaceDeviceRGB: 3511 m_value.ident = CSSValueDefault; 3512 break; 3513 case ColorSpaceSRGB: 3514 m_value.ident = CSSValueSrgb; 3515 break; 3516 case ColorSpaceLinearRGB: 3517 // CSS color correction does not support linearRGB yet. 3518 ASSERT_NOT_REACHED(); 3519 m_value.ident = CSSValueDefault; 3520 break; 3521 } 3522} 3523 3524template<> inline CSSPrimitiveValue::operator ColorSpace() const 3525{ 3526 switch (m_value.ident) { 3527 case CSSValueDefault: 3528 return ColorSpaceDeviceRGB; 3529 case CSSValueSrgb: 3530 return ColorSpaceSRGB; 3531 } 3532 3533 ASSERT_NOT_REACHED(); 3534 return ColorSpaceDeviceRGB; 3535} 3536 3537template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens) 3538 : CSSValue(PrimitiveClass) 3539{ 3540 m_primitiveUnitType = CSS_IDENT; 3541 switch (hyphens) { 3542 case HyphensNone: 3543 m_value.ident = CSSValueNone; 3544 break; 3545 case HyphensManual: 3546 m_value.ident = CSSValueManual; 3547 break; 3548 case HyphensAuto: 3549 m_value.ident = CSSValueAuto; 3550 break; 3551 } 3552} 3553 3554template<> inline CSSPrimitiveValue::operator Hyphens() const 3555{ 3556 switch (m_value.ident) { 3557 case CSSValueNone: 3558 return HyphensNone; 3559 case CSSValueManual: 3560 return HyphensManual; 3561 case CSSValueAuto: 3562 return HyphensAuto; 3563 } 3564 3565 ASSERT_NOT_REACHED(); 3566 return HyphensAuto; 3567} 3568 3569template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineSnap gridSnap) 3570 : CSSValue(PrimitiveClass) 3571{ 3572 m_primitiveUnitType = CSS_IDENT; 3573 switch (gridSnap) { 3574 case LineSnapNone: 3575 m_value.ident = CSSValueNone; 3576 break; 3577 case LineSnapBaseline: 3578 m_value.ident = CSSValueBaseline; 3579 break; 3580 case LineSnapContain: 3581 m_value.ident = CSSValueContain; 3582 break; 3583 } 3584} 3585 3586template<> inline CSSPrimitiveValue::operator LineSnap() const 3587{ 3588 switch (m_value.ident) { 3589 case CSSValueNone: 3590 return LineSnapNone; 3591 case CSSValueBaseline: 3592 return LineSnapBaseline; 3593 case CSSValueContain: 3594 return LineSnapContain; 3595 } 3596 3597 ASSERT_NOT_REACHED(); 3598 return LineSnapNone; 3599} 3600 3601template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineAlign lineAlign) 3602 : CSSValue(PrimitiveClass) 3603{ 3604 m_primitiveUnitType = CSS_IDENT; 3605 switch (lineAlign) { 3606 case LineAlignNone: 3607 m_value.ident = CSSValueNone; 3608 break; 3609 case LineAlignEdges: 3610 m_value.ident = CSSValueEdges; 3611 break; 3612 } 3613} 3614 3615template<> inline CSSPrimitiveValue::operator LineAlign() const 3616{ 3617 switch (m_value.ident) { 3618 case CSSValueNone: 3619 return LineAlignNone; 3620 case CSSValueEdges: 3621 return LineAlignEdges; 3622 } 3623 3624 ASSERT_NOT_REACHED(); 3625 return LineAlignNone; 3626} 3627 3628template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ESpeak e) 3629 : CSSValue(PrimitiveClass) 3630{ 3631 m_primitiveUnitType = CSS_IDENT; 3632 switch (e) { 3633 case SpeakNone: 3634 m_value.ident = CSSValueNone; 3635 break; 3636 case SpeakNormal: 3637 m_value.ident = CSSValueNormal; 3638 break; 3639 case SpeakSpellOut: 3640 m_value.ident = CSSValueSpellOut; 3641 break; 3642 case SpeakDigits: 3643 m_value.ident = CSSValueDigits; 3644 break; 3645 case SpeakLiteralPunctuation: 3646 m_value.ident = CSSValueLiteralPunctuation; 3647 break; 3648 case SpeakNoPunctuation: 3649 m_value.ident = CSSValueNoPunctuation; 3650 break; 3651 } 3652} 3653 3654template<> inline CSSPrimitiveValue::operator Order() const 3655{ 3656 switch (m_value.ident) { 3657 case CSSValueLogical: 3658 return LogicalOrder; 3659 case CSSValueVisual: 3660 return VisualOrder; 3661 } 3662 3663 ASSERT_NOT_REACHED(); 3664 return LogicalOrder; 3665} 3666 3667template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Order e) 3668 : CSSValue(PrimitiveClass) 3669{ 3670 m_primitiveUnitType = CSS_IDENT; 3671 switch (e) { 3672 case LogicalOrder: 3673 m_value.ident = CSSValueLogical; 3674 break; 3675 case VisualOrder: 3676 m_value.ident = CSSValueVisual; 3677 break; 3678 } 3679} 3680 3681template<> inline CSSPrimitiveValue::operator ESpeak() const 3682{ 3683 switch (m_value.ident) { 3684 case CSSValueNone: 3685 return SpeakNone; 3686 case CSSValueNormal: 3687 return SpeakNormal; 3688 case CSSValueSpellOut: 3689 return SpeakSpellOut; 3690 case CSSValueDigits: 3691 return SpeakDigits; 3692 case CSSValueLiteralPunctuation: 3693 return SpeakLiteralPunctuation; 3694 case CSSValueNoPunctuation: 3695 return SpeakNoPunctuation; 3696 } 3697 3698 ASSERT_NOT_REACHED(); 3699 return SpeakNormal; 3700} 3701 3702template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode) 3703 : CSSValue(PrimitiveClass) 3704{ 3705 m_primitiveUnitType = CSS_IDENT; 3706 switch (blendMode) { 3707 case BlendModeNormal: 3708 m_value.ident = CSSValueNormal; 3709 break; 3710 case BlendModeMultiply: 3711 m_value.ident = CSSValueMultiply; 3712 break; 3713 case BlendModeScreen: 3714 m_value.ident = CSSValueScreen; 3715 break; 3716 case BlendModeOverlay: 3717 m_value.ident = CSSValueOverlay; 3718 break; 3719 case BlendModeDarken: 3720 m_value.ident = CSSValueDarken; 3721 break; 3722 case BlendModeLighten: 3723 m_value.ident = CSSValueLighten; 3724 break; 3725 case BlendModeColorDodge: 3726 m_value.ident = CSSValueColorDodge; 3727 break; 3728 case BlendModeColorBurn: 3729 m_value.ident = CSSValueColorBurn; 3730 break; 3731 case BlendModeHardLight: 3732 m_value.ident = CSSValueHardLight; 3733 break; 3734 case BlendModeSoftLight: 3735 m_value.ident = CSSValueSoftLight; 3736 break; 3737 case BlendModeDifference: 3738 m_value.ident = CSSValueDifference; 3739 break; 3740 case BlendModeExclusion: 3741 m_value.ident = CSSValueExclusion; 3742 break; 3743 case BlendModeHue: 3744 m_value.ident = CSSValueHue; 3745 break; 3746 case BlendModeSaturation: 3747 m_value.ident = CSSValueSaturation; 3748 break; 3749 case BlendModeColor: 3750 m_value.ident = CSSValueColor; 3751 break; 3752 case BlendModeLuminosity: 3753 m_value.ident = CSSValueLuminosity; 3754 break; 3755 } 3756} 3757 3758template<> inline CSSPrimitiveValue::operator BlendMode() const 3759{ 3760 switch (m_value.ident) { 3761 case CSSValueNormal: 3762 return BlendModeNormal; 3763 case CSSValueMultiply: 3764 return BlendModeMultiply; 3765 case CSSValueScreen: 3766 return BlendModeScreen; 3767 case CSSValueOverlay: 3768 return BlendModeOverlay; 3769 case CSSValueDarken: 3770 return BlendModeDarken; 3771 case CSSValueLighten: 3772 return BlendModeLighten; 3773 case CSSValueColorDodge: 3774 return BlendModeColorDodge; 3775 case CSSValueColorBurn: 3776 return BlendModeColorBurn; 3777 case CSSValueHardLight: 3778 return BlendModeHardLight; 3779 case CSSValueSoftLight: 3780 return BlendModeSoftLight; 3781 case CSSValueDifference: 3782 return BlendModeDifference; 3783 case CSSValueExclusion: 3784 return BlendModeExclusion; 3785 case CSSValueHue: 3786 return BlendModeHue; 3787 case CSSValueSaturation: 3788 return BlendModeSaturation; 3789 case CSSValueColor: 3790 return BlendModeColor; 3791 case CSSValueLuminosity: 3792 return BlendModeLuminosity; 3793 } 3794 3795 ASSERT_NOT_REACHED(); 3796 return BlendModeNormal; 3797} 3798 3799#if ENABLE(SVG) 3800 3801template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e) 3802 : CSSValue(PrimitiveClass) 3803{ 3804 m_primitiveUnitType = CSS_IDENT; 3805 switch (e) { 3806 case ButtCap: 3807 m_value.ident = CSSValueButt; 3808 break; 3809 case RoundCap: 3810 m_value.ident = CSSValueRound; 3811 break; 3812 case SquareCap: 3813 m_value.ident = CSSValueSquare; 3814 break; 3815 } 3816} 3817 3818template<> inline CSSPrimitiveValue::operator LineCap() const 3819{ 3820 switch (m_value.ident) { 3821 case CSSValueButt: 3822 return ButtCap; 3823 case CSSValueRound: 3824 return RoundCap; 3825 case CSSValueSquare: 3826 return SquareCap; 3827 } 3828 3829 ASSERT_NOT_REACHED(); 3830 return ButtCap; 3831} 3832 3833template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineJoin e) 3834 : CSSValue(PrimitiveClass) 3835{ 3836 m_primitiveUnitType = CSS_IDENT; 3837 switch (e) { 3838 case MiterJoin: 3839 m_value.ident = CSSValueMiter; 3840 break; 3841 case RoundJoin: 3842 m_value.ident = CSSValueRound; 3843 break; 3844 case BevelJoin: 3845 m_value.ident = CSSValueBevel; 3846 break; 3847 } 3848} 3849 3850template<> inline CSSPrimitiveValue::operator LineJoin() const 3851{ 3852 switch (m_value.ident) { 3853 case CSSValueMiter: 3854 return MiterJoin; 3855 case CSSValueRound: 3856 return RoundJoin; 3857 case CSSValueBevel: 3858 return BevelJoin; 3859 } 3860 3861 ASSERT_NOT_REACHED(); 3862 return MiterJoin; 3863} 3864 3865template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WindRule e) 3866 : CSSValue(PrimitiveClass) 3867{ 3868 m_primitiveUnitType = CSS_IDENT; 3869 switch (e) { 3870 case RULE_NONZERO: 3871 m_value.ident = CSSValueNonzero; 3872 break; 3873 case RULE_EVENODD: 3874 m_value.ident = CSSValueEvenodd; 3875 break; 3876 } 3877} 3878 3879template<> inline CSSPrimitiveValue::operator WindRule() const 3880{ 3881 switch (m_value.ident) { 3882 case CSSValueNonzero: 3883 return RULE_NONZERO; 3884 case CSSValueEvenodd: 3885 return RULE_EVENODD; 3886 } 3887 3888 ASSERT_NOT_REACHED(); 3889 return RULE_NONZERO; 3890} 3891 3892 3893template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignmentBaseline e) 3894 : CSSValue(PrimitiveClass) 3895{ 3896 m_primitiveUnitType = CSS_IDENT; 3897 switch (e) { 3898 case AB_AUTO: 3899 m_value.ident = CSSValueAuto; 3900 break; 3901 case AB_BASELINE: 3902 m_value.ident = CSSValueBaseline; 3903 break; 3904 case AB_BEFORE_EDGE: 3905 m_value.ident = CSSValueBeforeEdge; 3906 break; 3907 case AB_TEXT_BEFORE_EDGE: 3908 m_value.ident = CSSValueTextBeforeEdge; 3909 break; 3910 case AB_MIDDLE: 3911 m_value.ident = CSSValueMiddle; 3912 break; 3913 case AB_CENTRAL: 3914 m_value.ident = CSSValueCentral; 3915 break; 3916 case AB_AFTER_EDGE: 3917 m_value.ident = CSSValueAfterEdge; 3918 break; 3919 case AB_TEXT_AFTER_EDGE: 3920 m_value.ident = CSSValueTextAfterEdge; 3921 break; 3922 case AB_IDEOGRAPHIC: 3923 m_value.ident = CSSValueIdeographic; 3924 break; 3925 case AB_ALPHABETIC: 3926 m_value.ident = CSSValueAlphabetic; 3927 break; 3928 case AB_HANGING: 3929 m_value.ident = CSSValueHanging; 3930 break; 3931 case AB_MATHEMATICAL: 3932 m_value.ident = CSSValueMathematical; 3933 break; 3934 } 3935} 3936 3937template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const 3938{ 3939 switch (m_value.ident) { 3940 case CSSValueAuto: 3941 return AB_AUTO; 3942 case CSSValueBaseline: 3943 return AB_BASELINE; 3944 case CSSValueBeforeEdge: 3945 return AB_BEFORE_EDGE; 3946 case CSSValueTextBeforeEdge: 3947 return AB_TEXT_BEFORE_EDGE; 3948 case CSSValueMiddle: 3949 return AB_MIDDLE; 3950 case CSSValueCentral: 3951 return AB_CENTRAL; 3952 case CSSValueAfterEdge: 3953 return AB_AFTER_EDGE; 3954 case CSSValueTextAfterEdge: 3955 return AB_TEXT_AFTER_EDGE; 3956 case CSSValueIdeographic: 3957 return AB_IDEOGRAPHIC; 3958 case CSSValueAlphabetic: 3959 return AB_ALPHABETIC; 3960 case CSSValueHanging: 3961 return AB_HANGING; 3962 case CSSValueMathematical: 3963 return AB_MATHEMATICAL; 3964 } 3965 3966 ASSERT_NOT_REACHED(); 3967 return AB_AUTO; 3968} 3969 3970#endif 3971 3972template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderCollapse e) 3973 : CSSValue(PrimitiveClass) 3974{ 3975 m_primitiveUnitType = CSS_IDENT; 3976 switch (e) { 3977 case BSEPARATE: 3978 m_value.ident = CSSValueSeparate; 3979 break; 3980 case BCOLLAPSE: 3981 m_value.ident = CSSValueCollapse; 3982 break; 3983 } 3984} 3985 3986template<> inline CSSPrimitiveValue::operator EBorderCollapse() const 3987{ 3988 switch (m_value.ident) { 3989 case CSSValueSeparate: 3990 return BSEPARATE; 3991 case CSSValueCollapse: 3992 return BCOLLAPSE; 3993 } 3994 3995 ASSERT_NOT_REACHED(); 3996 return BSEPARATE; 3997} 3998 3999template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderFit e) 4000 : CSSValue(PrimitiveClass) 4001{ 4002 m_primitiveUnitType = CSS_IDENT; 4003 switch (e) { 4004 case BorderFitBorder: 4005 m_value.ident = CSSValueBorder; 4006 break; 4007 case BorderFitLines: 4008 m_value.ident = CSSValueLines; 4009 break; 4010 } 4011} 4012 4013template<> inline CSSPrimitiveValue::operator EBorderFit() const 4014{ 4015 switch (m_value.ident) { 4016 case CSSValueBorder: 4017 return BorderFitBorder; 4018 case CSSValueLines: 4019 return BorderFitLines; 4020 } 4021 4022 ASSERT_NOT_REACHED(); 4023 return BorderFitLines; 4024} 4025 4026template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e) 4027 : CSSValue(PrimitiveClass) 4028{ 4029 m_primitiveUnitType = CSS_IDENT; 4030 switch (e) { 4031 case ImageRenderingAuto: 4032 m_value.ident = CSSValueAuto; 4033 break; 4034 case ImageRenderingCrispEdges: 4035 m_value.ident = CSSValueWebkitCrispEdges; 4036 break; 4037 case ImageRenderingOptimizeSpeed: 4038 m_value.ident = CSSValueOptimizespeed; 4039 break; 4040 case ImageRenderingOptimizeQuality: 4041 m_value.ident = CSSValueOptimizequality; 4042 break; 4043 } 4044} 4045 4046template<> inline CSSPrimitiveValue::operator EImageRendering() const 4047{ 4048 switch (m_value.ident) { 4049 case CSSValueAuto: 4050 return ImageRenderingAuto; 4051 case CSSValueWebkitOptimizeContrast: 4052 case CSSValueWebkitCrispEdges: 4053 return ImageRenderingCrispEdges; 4054 case CSSValueOptimizespeed: 4055 return ImageRenderingOptimizeSpeed; 4056 case CSSValueOptimizequality: 4057 return ImageRenderingOptimizeQuality; 4058 } 4059 4060 ASSERT_NOT_REACHED(); 4061 return ImageRenderingAuto; 4062} 4063 4064template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETransformStyle3D e) 4065 : CSSValue(PrimitiveClass) 4066{ 4067 m_primitiveUnitType = CSS_IDENT; 4068 switch (e) { 4069 case TransformStyle3DFlat: 4070 m_value.ident = CSSValueFlat; 4071 break; 4072 case TransformStyle3DPreserve3D: 4073 m_value.ident = CSSValuePreserve3d; 4074 break; 4075 } 4076} 4077 4078template<> inline CSSPrimitiveValue::operator ETransformStyle3D() const 4079{ 4080 switch (m_value.ident) { 4081 case CSSValueFlat: 4082 return TransformStyle3DFlat; 4083 case CSSValuePreserve3d: 4084 return TransformStyle3DPreserve3D; 4085 } 4086 4087 ASSERT_NOT_REACHED(); 4088 return TransformStyle3DFlat; 4089} 4090 4091template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColumnAxis e) 4092 : CSSValue(PrimitiveClass) 4093{ 4094 m_primitiveUnitType = CSS_IDENT; 4095 switch (e) { 4096 case HorizontalColumnAxis: 4097 m_value.ident = CSSValueHorizontal; 4098 break; 4099 case VerticalColumnAxis: 4100 m_value.ident = CSSValueVertical; 4101 break; 4102 case AutoColumnAxis: 4103 m_value.ident = CSSValueAuto; 4104 break; 4105 } 4106} 4107 4108template<> inline CSSPrimitiveValue::operator ColumnAxis() const 4109{ 4110 switch (m_value.ident) { 4111 case CSSValueHorizontal: 4112 return HorizontalColumnAxis; 4113 case CSSValueVertical: 4114 return VerticalColumnAxis; 4115 case CSSValueAuto: 4116 return AutoColumnAxis; 4117 } 4118 4119 ASSERT_NOT_REACHED(); 4120 return AutoColumnAxis; 4121} 4122 4123template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColumnProgression e) 4124 : CSSValue(PrimitiveClass) 4125{ 4126 m_primitiveUnitType = CSS_IDENT; 4127 switch (e) { 4128 case NormalColumnProgression: 4129 m_value.ident = CSSValueNormal; 4130 break; 4131 case ReverseColumnProgression: 4132 m_value.ident = CSSValueReverse; 4133 break; 4134 } 4135} 4136 4137template<> inline CSSPrimitiveValue::operator ColumnProgression() const 4138{ 4139 switch (m_value.ident) { 4140 case CSSValueNormal: 4141 return NormalColumnProgression; 4142 case CSSValueReverse: 4143 return ReverseColumnProgression; 4144 } 4145 4146 ASSERT_NOT_REACHED(); 4147 return NormalColumnProgression; 4148} 4149 4150template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WrapFlow wrapFlow) 4151: CSSValue(PrimitiveClass) 4152{ 4153 m_primitiveUnitType = CSS_IDENT; 4154 switch (wrapFlow) { 4155 case WrapFlowAuto: 4156 m_value.ident = CSSValueAuto; 4157 break; 4158 case WrapFlowBoth: 4159 m_value.ident = CSSValueBoth; 4160 break; 4161 case WrapFlowStart: 4162 m_value.ident = CSSValueStart; 4163 break; 4164 case WrapFlowEnd: 4165 m_value.ident = CSSValueEnd; 4166 break; 4167 case WrapFlowMaximum: 4168 m_value.ident = CSSValueMaximum; 4169 break; 4170 case WrapFlowClear: 4171 m_value.ident = CSSValueClear; 4172 break; 4173 } 4174} 4175 4176template<> inline CSSPrimitiveValue::operator WrapFlow() const 4177{ 4178 switch (m_value.ident) { 4179 case CSSValueAuto: 4180 return WrapFlowAuto; 4181 case CSSValueBoth: 4182 return WrapFlowBoth; 4183 case CSSValueStart: 4184 return WrapFlowStart; 4185 case CSSValueEnd: 4186 return WrapFlowEnd; 4187 case CSSValueMaximum: 4188 return WrapFlowMaximum; 4189 case CSSValueClear: 4190 return WrapFlowClear; 4191 } 4192 4193 ASSERT_NOT_REACHED(); 4194 return WrapFlowAuto; 4195} 4196 4197template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WrapThrough wrapThrough) 4198: CSSValue(PrimitiveClass) 4199{ 4200 m_primitiveUnitType = CSS_IDENT; 4201 switch (wrapThrough) { 4202 case WrapThroughWrap: 4203 m_value.ident = CSSValueWrap; 4204 break; 4205 case WrapThroughNone: 4206 m_value.ident = CSSValueNone; 4207 break; 4208 } 4209} 4210 4211template<> inline CSSPrimitiveValue::operator WrapThrough() const 4212{ 4213 switch (m_value.ident) { 4214 case CSSValueWrap: 4215 return WrapThroughWrap; 4216 case CSSValueNone: 4217 return WrapThroughNone; 4218 } 4219 4220 ASSERT_NOT_REACHED(); 4221 return WrapThroughWrap; 4222} 4223 4224template<> inline CSSPrimitiveValue::operator GridAutoFlow() const 4225{ 4226 switch (m_value.ident) { 4227 case CSSValueNone: 4228 return AutoFlowNone; 4229 case CSSValueColumn: 4230 return AutoFlowColumn; 4231 case CSSValueRow: 4232 return AutoFlowRow; 4233 } 4234 4235 ASSERT_NOT_REACHED(); 4236 return AutoFlowNone; 4237 4238} 4239 4240template<> inline CSSPrimitiveValue::CSSPrimitiveValue(GridAutoFlow flow) 4241 : CSSValue(PrimitiveClass) 4242{ 4243 m_primitiveUnitType = CSS_IDENT; 4244 switch (flow) { 4245 case AutoFlowNone: 4246 m_value.ident = CSSValueNone; 4247 break; 4248 case AutoFlowColumn: 4249 m_value.ident = CSSValueColumn; 4250 break; 4251 case AutoFlowRow: 4252 m_value.ident = CSSValueRow; 4253 break; 4254 } 4255} 4256 4257enum LengthConversion { 4258 AnyConversion = ~0, 4259 FixedIntegerConversion = 1 << 0, 4260 FixedFloatConversion = 1 << 1, 4261 AutoConversion = 1 << 2, 4262 PercentConversion = 1 << 3, 4263 FractionConversion = 1 << 4, 4264 CalculatedConversion = 1 << 5, 4265 ViewportPercentageConversion = 1 << 6 4266}; 4267 4268template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const 4269{ 4270#if ENABLE(CSS_VARIABLES) 4271 ASSERT(!hasVariableReference()); 4272#endif 4273 if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle)) 4274 return Length(Undefined); 4275 if ((supported & FixedIntegerConversion) && isLength()) 4276 return computeLength<Length>(style, rootStyle, multiplier, computingFontSize); 4277 if ((supported & FixedFloatConversion) && isLength()) 4278 return Length(computeLength<double>(style, rootStyle, multiplier), Fixed); 4279 if ((supported & PercentConversion) && isPercentage()) 4280 return Length(getDoubleValue(), Percent); 4281 if ((supported & FractionConversion) && isNumber()) 4282 return Length(getDoubleValue() * 100.0, Percent); 4283 if ((supported & AutoConversion) && getIdent() == CSSValueAuto) 4284 return Length(Auto); 4285 if ((supported & CalculatedConversion) && isCalculated()) 4286 return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier)); 4287 if ((supported & ViewportPercentageConversion) && isViewportPercentageLength()) 4288 return viewportPercentageLength(); 4289 return Length(Undefined); 4290} 4291 4292#if ENABLE(SVG) 4293 4294template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBufferedRendering e) 4295 : CSSValue(PrimitiveClass) 4296{ 4297 m_primitiveUnitType = CSS_IDENT; 4298 switch (e) { 4299 case BR_AUTO: 4300 m_value.ident = CSSValueAuto; 4301 break; 4302 case BR_DYNAMIC: 4303 m_value.ident = CSSValueDynamic; 4304 break; 4305 case BR_STATIC: 4306 m_value.ident = CSSValueStatic; 4307 break; 4308 } 4309} 4310 4311template<> inline CSSPrimitiveValue::operator EBufferedRendering() const 4312{ 4313 switch (m_value.ident) { 4314 case CSSValueAuto: 4315 return BR_AUTO; 4316 case CSSValueDynamic: 4317 return BR_DYNAMIC; 4318 case CSSValueStatic: 4319 return BR_STATIC; 4320 } 4321 4322 ASSERT_NOT_REACHED(); 4323 return BR_AUTO; 4324} 4325 4326template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e) 4327 : CSSValue(PrimitiveClass) 4328{ 4329 m_primitiveUnitType = CSS_IDENT; 4330 switch (e) { 4331 case CI_AUTO: 4332 m_value.ident = CSSValueAuto; 4333 break; 4334 case CI_SRGB: 4335 m_value.ident = CSSValueSrgb; 4336 break; 4337 case CI_LINEARRGB: 4338 m_value.ident = CSSValueLinearrgb; 4339 break; 4340 } 4341} 4342 4343template<> inline CSSPrimitiveValue::operator EColorInterpolation() const 4344{ 4345 switch (m_value.ident) { 4346 case CSSValueSrgb: 4347 return CI_SRGB; 4348 case CSSValueLinearrgb: 4349 return CI_LINEARRGB; 4350 case CSSValueAuto: 4351 return CI_AUTO; 4352 } 4353 4354 ASSERT_NOT_REACHED(); 4355 return CI_AUTO; 4356} 4357 4358template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e) 4359 : CSSValue(PrimitiveClass) 4360{ 4361 m_primitiveUnitType = CSS_IDENT; 4362 switch (e) { 4363 case CR_AUTO: 4364 m_value.ident = CSSValueAuto; 4365 break; 4366 case CR_OPTIMIZESPEED: 4367 m_value.ident = CSSValueOptimizespeed; 4368 break; 4369 case CR_OPTIMIZEQUALITY: 4370 m_value.ident = CSSValueOptimizequality; 4371 break; 4372 } 4373} 4374 4375template<> inline CSSPrimitiveValue::operator EColorRendering() const 4376{ 4377 switch (m_value.ident) { 4378 case CSSValueOptimizespeed: 4379 return CR_OPTIMIZESPEED; 4380 case CSSValueOptimizequality: 4381 return CR_OPTIMIZEQUALITY; 4382 case CSSValueAuto: 4383 return CR_AUTO; 4384 } 4385 4386 ASSERT_NOT_REACHED(); 4387 return CR_AUTO; 4388} 4389 4390template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDominantBaseline e) 4391 : CSSValue(PrimitiveClass) 4392{ 4393 m_primitiveUnitType = CSS_IDENT; 4394 switch (e) { 4395 case DB_AUTO: 4396 m_value.ident = CSSValueAuto; 4397 break; 4398 case DB_USE_SCRIPT: 4399 m_value.ident = CSSValueUseScript; 4400 break; 4401 case DB_NO_CHANGE: 4402 m_value.ident = CSSValueNoChange; 4403 break; 4404 case DB_RESET_SIZE: 4405 m_value.ident = CSSValueResetSize; 4406 break; 4407 case DB_CENTRAL: 4408 m_value.ident = CSSValueCentral; 4409 break; 4410 case DB_MIDDLE: 4411 m_value.ident = CSSValueMiddle; 4412 break; 4413 case DB_TEXT_BEFORE_EDGE: 4414 m_value.ident = CSSValueTextBeforeEdge; 4415 break; 4416 case DB_TEXT_AFTER_EDGE: 4417 m_value.ident = CSSValueTextAfterEdge; 4418 break; 4419 case DB_IDEOGRAPHIC: 4420 m_value.ident = CSSValueIdeographic; 4421 break; 4422 case DB_ALPHABETIC: 4423 m_value.ident = CSSValueAlphabetic; 4424 break; 4425 case DB_HANGING: 4426 m_value.ident = CSSValueHanging; 4427 break; 4428 case DB_MATHEMATICAL: 4429 m_value.ident = CSSValueMathematical; 4430 break; 4431 } 4432} 4433 4434template<> inline CSSPrimitiveValue::operator EDominantBaseline() const 4435{ 4436 switch (m_value.ident) { 4437 case CSSValueAuto: 4438 return DB_AUTO; 4439 case CSSValueUseScript: 4440 return DB_USE_SCRIPT; 4441 case CSSValueNoChange: 4442 return DB_NO_CHANGE; 4443 case CSSValueResetSize: 4444 return DB_RESET_SIZE; 4445 case CSSValueIdeographic: 4446 return DB_IDEOGRAPHIC; 4447 case CSSValueAlphabetic: 4448 return DB_ALPHABETIC; 4449 case CSSValueHanging: 4450 return DB_HANGING; 4451 case CSSValueMathematical: 4452 return DB_MATHEMATICAL; 4453 case CSSValueCentral: 4454 return DB_CENTRAL; 4455 case CSSValueMiddle: 4456 return DB_MIDDLE; 4457 case CSSValueTextAfterEdge: 4458 return DB_TEXT_AFTER_EDGE; 4459 case CSSValueTextBeforeEdge: 4460 return DB_TEXT_BEFORE_EDGE; 4461 } 4462 4463 ASSERT_NOT_REACHED(); 4464 return DB_AUTO; 4465} 4466 4467template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e) 4468 : CSSValue(PrimitiveClass) 4469{ 4470 m_primitiveUnitType = CSS_IDENT; 4471 switch (e) { 4472 case SR_AUTO: 4473 m_value.ident = CSSValueAuto; 4474 break; 4475 case SR_OPTIMIZESPEED: 4476 m_value.ident = CSSValueOptimizespeed; 4477 break; 4478 case SR_CRISPEDGES: 4479 m_value.ident = CSSValueCrispedges; 4480 break; 4481 case SR_GEOMETRICPRECISION: 4482 m_value.ident = CSSValueGeometricprecision; 4483 break; 4484 } 4485} 4486 4487template<> inline CSSPrimitiveValue::operator EShapeRendering() const 4488{ 4489 switch (m_value.ident) { 4490 case CSSValueAuto: 4491 return SR_AUTO; 4492 case CSSValueOptimizespeed: 4493 return SR_OPTIMIZESPEED; 4494 case CSSValueCrispedges: 4495 return SR_CRISPEDGES; 4496 case CSSValueGeometricprecision: 4497 return SR_GEOMETRICPRECISION; 4498 } 4499 4500 ASSERT_NOT_REACHED(); 4501 return SR_AUTO; 4502} 4503 4504template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAnchor e) 4505 : CSSValue(PrimitiveClass) 4506{ 4507 m_primitiveUnitType = CSS_IDENT; 4508 switch (e) { 4509 case TA_START: 4510 m_value.ident = CSSValueStart; 4511 break; 4512 case TA_MIDDLE: 4513 m_value.ident = CSSValueMiddle; 4514 break; 4515 case TA_END: 4516 m_value.ident = CSSValueEnd; 4517 break; 4518 } 4519} 4520 4521template<> inline CSSPrimitiveValue::operator ETextAnchor() const 4522{ 4523 switch (m_value.ident) { 4524 case CSSValueStart: 4525 return TA_START; 4526 case CSSValueMiddle: 4527 return TA_MIDDLE; 4528 case CSSValueEnd: 4529 return TA_END; 4530 } 4531 4532 ASSERT_NOT_REACHED(); 4533 return TA_START; 4534} 4535 4536template<> inline CSSPrimitiveValue::CSSPrimitiveValue(SVGWritingMode e) 4537 : CSSValue(PrimitiveClass) 4538{ 4539 m_primitiveUnitType = CSS_IDENT; 4540 switch (e) { 4541 case WM_LRTB: 4542 m_value.ident = CSSValueLrTb; 4543 break; 4544 case WM_LR: 4545 m_value.ident = CSSValueLr; 4546 break; 4547 case WM_RLTB: 4548 m_value.ident = CSSValueRlTb; 4549 break; 4550 case WM_RL: 4551 m_value.ident = CSSValueRl; 4552 break; 4553 case WM_TBRL: 4554 m_value.ident = CSSValueTbRl; 4555 break; 4556 case WM_TB: 4557 m_value.ident = CSSValueTb; 4558 break; 4559 } 4560} 4561 4562template<> inline CSSPrimitiveValue::operator SVGWritingMode() const 4563{ 4564 switch (m_value.ident) { 4565 case CSSValueLrTb: 4566 return WM_LRTB; 4567 case CSSValueLr: 4568 return WM_LR; 4569 case CSSValueRlTb: 4570 return WM_RLTB; 4571 case CSSValueRl: 4572 return WM_RL; 4573 case CSSValueTbRl: 4574 return WM_TBRL; 4575 case CSSValueTb: 4576 return WM_TB; 4577 } 4578 4579 ASSERT_NOT_REACHED(); 4580 return WM_LRTB; 4581} 4582 4583template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVectorEffect e) 4584 : CSSValue(PrimitiveClass) 4585{ 4586 m_primitiveUnitType = CSS_IDENT; 4587 switch (e) { 4588 case VE_NONE: 4589 m_value.ident = CSSValueNone; 4590 break; 4591 case VE_NON_SCALING_STROKE: 4592 m_value.ident = CSSValueNonScalingStroke; 4593 break; 4594 } 4595} 4596 4597template<> inline CSSPrimitiveValue::operator EVectorEffect() const 4598{ 4599 switch (m_value.ident) { 4600 case CSSValueNone: 4601 return VE_NONE; 4602 case CSSValueNonScalingStroke: 4603 return VE_NON_SCALING_STROKE; 4604 } 4605 4606 ASSERT_NOT_REACHED(); 4607 return VE_NONE; 4608} 4609 4610template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMaskType e) 4611 : CSSValue(PrimitiveClass) 4612{ 4613 m_primitiveUnitType = CSS_IDENT; 4614 switch (e) { 4615 case MT_LUMINANCE: 4616 m_value.ident = CSSValueLuminance; 4617 break; 4618 case MT_ALPHA: 4619 m_value.ident = CSSValueAlpha; 4620 break; 4621 } 4622} 4623 4624template<> inline CSSPrimitiveValue::operator EMaskType() const 4625{ 4626 switch (m_value.ident) { 4627 case CSSValueLuminance: 4628 return MT_LUMINANCE; 4629 case CSSValueAlpha: 4630 return MT_ALPHA; 4631 } 4632 4633 ASSERT_NOT_REACHED(); 4634 return MT_LUMINANCE; 4635} 4636 4637#endif // ENABLE(SVG) 4638 4639#if ENABLE(CSS_IMAGE_ORIENTATION) 4640 4641template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ImageOrientationEnum e) 4642 : CSSValue(PrimitiveClass) 4643{ 4644 m_primitiveUnitType = CSS_DEG; 4645 switch (e) { 4646 case OriginTopLeft: 4647 m_value.num = 0; 4648 break; 4649 case OriginRightTop: 4650 m_value.num = 90; 4651 break; 4652 case OriginBottomRight: 4653 m_value.num = 180; 4654 break; 4655 case OriginLeftBottom: 4656 m_value.num = 270; 4657 break; 4658 case OriginTopRight: 4659 case OriginLeftTop: 4660 case OriginBottomLeft: 4661 case OriginRightBottom: 4662 ASSERT_NOT_REACHED(); 4663 } 4664} 4665 4666template<> inline CSSPrimitiveValue::operator ImageOrientationEnum() const 4667{ 4668 ASSERT(isAngle()); 4669 double quarters = 4 * getDoubleValue(CSS_TURN); 4670 int orientation = 3 & static_cast<int>(quarters < 0 ? floor(quarters) : ceil(quarters)); 4671 switch (orientation) { 4672 case 0: 4673 return OriginTopLeft; 4674 case 1: 4675 return OriginRightTop; 4676 case 2: 4677 return OriginBottomRight; 4678 case 3: 4679 return OriginLeftBottom; 4680 } 4681 4682 ASSERT_NOT_REACHED(); 4683 return OriginTopLeft; 4684} 4685 4686#endif // ENABLE(CSS_IMAGE_ORIENTATION) 4687 4688} 4689 4690#endif 4691