diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/CSSPrimitiveValueMappings.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/CSSPrimitiveValueMappings.h')
-rw-r--r-- | Source/WebCore/css/CSSPrimitiveValueMappings.h | 1559 |
1 files changed, 1051 insertions, 508 deletions
diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h index 9a6260c8c..d9dbdb751 100644 --- a/Source/WebCore/css/CSSPrimitiveValueMappings.h +++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h @@ -27,33 +27,30 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CSSPrimitiveValueMappings_h -#define CSSPrimitiveValueMappings_h +#pragma once #include "CSSCalculationValue.h" +#include "CSSFontFamily.h" #include "CSSPrimitiveValue.h" #include "CSSReflectionDirection.h" -#include "ColorSpace.h" +#include "CSSToLengthConversionData.h" #include "CSSValueKeywords.h" -#include "FontDescription.h" -#include "FontSmoothingMode.h" #include "GraphicsTypes.h" -#if ENABLE(CSS_IMAGE_ORIENTATION) -#include "ImageOrientation.h" -#endif #include "Length.h" #include "LineClampValue.h" #include "Path.h" #include "RenderStyleConstants.h" #include "SVGRenderStyleDefs.h" -#include "TextDirection.h" -#include "TextRenderingMode.h" +#include "TextFlags.h" #include "ThemeTypes.h" #include "UnicodeBidi.h" #include "WritingMode.h" - #include <wtf/MathExtras.h> +#if ENABLE(CSS_IMAGE_ORIENTATION) +#include "ImageOrientation.h" +#endif + namespace WebCore { template<> inline CSSPrimitiveValue::CSSPrimitiveValue(short i) @@ -81,8 +78,8 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(unsigned short i) template<> inline CSSPrimitiveValue::operator unsigned short() const { - if (m_primitiveUnitType == CSS_NUMBER) - return clampTo<unsigned short>(m_value.num); + if (primitiveType() == CSS_NUMBER) + return value<unsigned short>(); ASSERT_NOT_REACHED(); return 0; @@ -90,8 +87,8 @@ template<> inline CSSPrimitiveValue::operator unsigned short() const template<> inline CSSPrimitiveValue::operator int() const { - if (m_primitiveUnitType == CSS_NUMBER) - return clampTo<int>(m_value.num); + if (primitiveType() == CSS_NUMBER) + return value<int>(); ASSERT_NOT_REACHED(); return 0; @@ -99,8 +96,8 @@ template<> inline CSSPrimitiveValue::operator int() const template<> inline CSSPrimitiveValue::operator unsigned() const { - if (m_primitiveUnitType == CSS_NUMBER) - return clampTo<unsigned>(m_value.num); + if (primitiveType() == CSS_NUMBER) + return value<unsigned>(); ASSERT_NOT_REACHED(); return 0; @@ -116,8 +113,8 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(float i) template<> inline CSSPrimitiveValue::operator float() const { - if (m_primitiveUnitType == CSS_NUMBER) - return clampTo<float>(m_value.num); + if (primitiveType() == CSS_NUMBER) + return value<float>(); ASSERT_NOT_REACHED(); return 0.0f; @@ -132,11 +129,11 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineClampValue i) template<> inline CSSPrimitiveValue::operator LineClampValue() const { - if (m_primitiveUnitType == CSS_NUMBER) - return LineClampValue(clampTo<int>(m_value.num), LineClampLineCount); + if (primitiveType() == CSS_NUMBER) + return LineClampValue(value<int>(), LineClampLineCount); - if (m_primitiveUnitType == CSS_PERCENTAGE) - return LineClampValue(clampTo<int>(m_value.num), LineClampPercentage); + if (primitiveType() == CSS_PERCENTAGE) + return LineClampValue(value<int>(), LineClampPercentage); ASSERT_NOT_REACHED(); return LineClampValue(); @@ -525,6 +522,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case MediaTimeRemainingPart: m_value.valueID = CSSValueMediaTimeRemainingDisplay; break; + case MediaControlsLightBarBackgroundPart: + m_value.valueID = CSSValueMediaControlsLightBarBackground; + break; + case MediaControlsDarkBarBackgroundPart: + m_value.valueID = CSSValueMediaControlsDarkBarBackground; + break; case MenulistPart: m_value.valueID = CSSValueMenulist; break; @@ -553,14 +556,10 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) m_value.valueID = CSSValueRatingLevelIndicator; break; case ProgressBarPart: -#if ENABLE(PROGRESS_ELEMENT) m_value.valueID = CSSValueProgressBar; -#endif break; case ProgressBarValuePart: -#if ENABLE(PROGRESS_ELEMENT) m_value.valueID = CSSValueProgressBarValue; -#endif break; case SliderHorizontalPart: m_value.valueID = CSSValueSliderHorizontal; @@ -604,11 +603,21 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case CapsLockIndicatorPart: m_value.valueID = CSSValueCapsLockIndicator; break; - case InputSpeechButtonPart: -#if ENABLE(INPUT_SPEECH) - m_value.valueID = CSSValueWebkitInputSpeechButton; +#if ENABLE(ATTACHMENT_ELEMENT) + case AttachmentPart: + m_value.valueID = CSSValueAttachment; + break; #endif +#if ENABLE(SERVICE_CONTROLS) + case ImageControlsButtonPart: + m_value.valueID = CSSValueImageControlsButton; break; +#endif +#if ENABLE(APPLE_PAY) + case ApplePayButtonPart: + m_value.valueID = CSSValueApplePayButton; + break; +#endif } } @@ -895,45 +904,45 @@ template<> inline CSSPrimitiveValue::operator EBoxDecorationBreak() const } #endif -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BackgroundEdgeOrigin e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Edge e) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_VALUE_ID; switch (e) { - case TopEdge: + case Edge::Top: m_value.valueID = CSSValueTop; break; - case RightEdge: + case Edge::Right: m_value.valueID = CSSValueRight; break; - case BottomEdge: + case Edge::Bottom: m_value.valueID = CSSValueBottom; break; - case LeftEdge: + case Edge::Left: m_value.valueID = CSSValueLeft; break; } } -template<> inline CSSPrimitiveValue::operator BackgroundEdgeOrigin() const +template<> inline CSSPrimitiveValue::operator Edge() const { ASSERT(isValueID()); switch (m_value.valueID) { case CSSValueTop: - return TopEdge; + return Edge::Top; case CSSValueRight: - return RightEdge; + return Edge::Right; case CSSValueBottom: - return BottomEdge; + return Edge::Bottom; case CSSValueLeft: - return LeftEdge; + return Edge::Left; default: break; } ASSERT_NOT_REACHED(); - return TopEdge; + return Edge::Top; } template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxSizing e) @@ -1149,112 +1158,112 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e) { m_primitiveUnitType = CSS_VALUE_ID; switch (e) { - case CURSOR_AUTO: + case CursorAuto: m_value.valueID = CSSValueAuto; break; - case CURSOR_CROSS: + case CursorCross: m_value.valueID = CSSValueCrosshair; break; - case CURSOR_DEFAULT: + case CursorDefault: m_value.valueID = CSSValueDefault; break; - case CURSOR_POINTER: + case CursorPointer: m_value.valueID = CSSValuePointer; break; - case CURSOR_MOVE: + case CursorMove: m_value.valueID = CSSValueMove; break; - case CURSOR_CELL: + case CursorCell: m_value.valueID = CSSValueCell; break; - case CURSOR_VERTICAL_TEXT: + case CursorVerticalText: m_value.valueID = CSSValueVerticalText; break; - case CURSOR_CONTEXT_MENU: + case CursorContextMenu: m_value.valueID = CSSValueContextMenu; break; - case CURSOR_ALIAS: + case CursorAlias: m_value.valueID = CSSValueAlias; break; - case CURSOR_COPY: + case CursorCopy: m_value.valueID = CSSValueCopy; break; - case CURSOR_NONE: + case CursorNone: m_value.valueID = CSSValueNone; break; - case CURSOR_PROGRESS: + case CursorProgress: m_value.valueID = CSSValueProgress; break; - case CURSOR_NO_DROP: + case CursorNoDrop: m_value.valueID = CSSValueNoDrop; break; - case CURSOR_NOT_ALLOWED: + case CursorNotAllowed: m_value.valueID = CSSValueNotAllowed; break; - case CURSOR_WEBKIT_ZOOM_IN: - m_value.valueID = CSSValueWebkitZoomIn; + case CursorZoomIn: + m_value.valueID = CSSValueZoomIn; break; - case CURSOR_WEBKIT_ZOOM_OUT: - m_value.valueID = CSSValueWebkitZoomOut; + case CursorZoomOut: + m_value.valueID = CSSValueZoomOut; break; - case CURSOR_E_RESIZE: + case CursorEResize: m_value.valueID = CSSValueEResize; break; - case CURSOR_NE_RESIZE: + case CursorNeResize: m_value.valueID = CSSValueNeResize; break; - case CURSOR_NW_RESIZE: + case CursorNwResize: m_value.valueID = CSSValueNwResize; break; - case CURSOR_N_RESIZE: + case CursorNResize: m_value.valueID = CSSValueNResize; break; - case CURSOR_SE_RESIZE: + case CursorSeResize: m_value.valueID = CSSValueSeResize; break; - case CURSOR_SW_RESIZE: + case CursorSwResize: m_value.valueID = CSSValueSwResize; break; - case CURSOR_S_RESIZE: + case CursorSResize: m_value.valueID = CSSValueSResize; break; - case CURSOR_W_RESIZE: + case CursorWResize: m_value.valueID = CSSValueWResize; break; - case CURSOR_EW_RESIZE: + case CursorEwResize: m_value.valueID = CSSValueEwResize; break; - case CURSOR_NS_RESIZE: + case CursorNsResize: m_value.valueID = CSSValueNsResize; break; - case CURSOR_NESW_RESIZE: + case CursorNeswResize: m_value.valueID = CSSValueNeswResize; break; - case CURSOR_NWSE_RESIZE: + case CursorNwseResize: m_value.valueID = CSSValueNwseResize; break; - case CURSOR_COL_RESIZE: + case CursorColResize: m_value.valueID = CSSValueColResize; break; - case CURSOR_ROW_RESIZE: + case CursorRowResize: m_value.valueID = CSSValueRowResize; break; - case CURSOR_TEXT: + case CursorText: m_value.valueID = CSSValueText; break; - case CURSOR_WAIT: + case CursorWait: m_value.valueID = CSSValueWait; break; - case CURSOR_HELP: + case CursorHelp: m_value.valueID = CSSValueHelp; break; - case CURSOR_ALL_SCROLL: + case CursorAllScroll: m_value.valueID = CSSValueAllScroll; break; - case CURSOR_WEBKIT_GRAB: + case CursorWebkitGrab: m_value.valueID = CSSValueWebkitGrab; break; - case CURSOR_WEBKIT_GRABBING: + case CursorWebkitGrabbing: m_value.valueID = CSSValueWebkitGrabbing; break; } @@ -1263,15 +1272,20 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e) template<> inline CSSPrimitiveValue::operator ECursor() const { ASSERT(isValueID()); - - if (m_value.valueID == CSSValueCopy) - return CURSOR_COPY; - if (m_value.valueID == CSSValueNone) - return CURSOR_NONE; - return static_cast<ECursor>(m_value.valueID - CSSValueAuto); + switch (m_value.valueID) { + case CSSValueCopy: + return CursorCopy; + case CSSValueWebkitZoomIn: + return CursorZoomIn; + case CSSValueWebkitZoomOut: + return CursorZoomOut; + case CSSValueNone: + return CursorNone; + default: + return static_cast<ECursor>(m_value.valueID - CSSValueAuto); + } } - #if ENABLE(CURSOR_VISIBILITY) template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CursorVisibility e) : CSSValue(PrimitiveClass) @@ -1315,9 +1329,6 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e) case LIST_ITEM: m_value.valueID = CSSValueListItem; break; - case RUN_IN: - m_value.valueID = CSSValueRunIn; - break; case COMPACT: m_value.valueID = CSSValueCompact; break; @@ -1361,20 +1372,25 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e) m_value.valueID = CSSValueWebkitInlineBox; break; case FLEX: - m_value.valueID = CSSValueWebkitFlex; + case WEBKIT_FLEX: + m_value.valueID = CSSValueFlex; break; case INLINE_FLEX: - m_value.valueID = CSSValueWebkitInlineFlex; + case WEBKIT_INLINE_FLEX: + m_value.valueID = CSSValueInlineFlex; break; case GRID: - m_value.valueID = CSSValueWebkitGrid; + m_value.valueID = CSSValueGrid; break; case INLINE_GRID: - m_value.valueID = CSSValueWebkitInlineGrid; + m_value.valueID = CSSValueInlineGrid; break; case NONE: m_value.valueID = CSSValueNone; break; + case CONTENTS: + m_value.valueID = CSSValueContents; + break; } } @@ -1387,6 +1403,10 @@ template<> inline CSSPrimitiveValue::operator EDisplay() const EDisplay display = static_cast<EDisplay>(m_value.valueID - CSSValueInline); ASSERT(display >= INLINE && display <= NONE); + if (display == WEBKIT_FLEX) + return FLEX; + if (display == WEBKIT_INLINE_FLEX) + return INLINE_FLEX; return display; } @@ -1421,103 +1441,6 @@ template<> inline CSSPrimitiveValue::operator EEmptyCell() const return SHOW; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignItems e) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (e) { - case AlignAuto: - m_value.valueID = CSSValueAuto; - break; - case AlignFlexStart: - m_value.valueID = CSSValueFlexStart; - break; - case AlignFlexEnd: - m_value.valueID = CSSValueFlexEnd; - break; - case AlignCenter: - m_value.valueID = CSSValueCenter; - break; - case AlignStretch: - m_value.valueID = CSSValueStretch; - break; - case AlignBaseline: - m_value.valueID = CSSValueBaseline; - break; - } -} - -template<> inline CSSPrimitiveValue::operator EAlignItems() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueAuto: - return AlignAuto; - case CSSValueFlexStart: - return AlignFlexStart; - case CSSValueFlexEnd: - return AlignFlexEnd; - case CSSValueCenter: - return AlignCenter; - case CSSValueStretch: - return AlignStretch; - case CSSValueBaseline: - return AlignBaseline; - default: - break; - } - - ASSERT_NOT_REACHED(); - return AlignFlexStart; -} - -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EJustifyContent e) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (e) { - case JustifyFlexStart: - m_value.valueID = CSSValueFlexStart; - break; - case JustifyFlexEnd: - m_value.valueID = CSSValueFlexEnd; - break; - case JustifyCenter: - m_value.valueID = CSSValueCenter; - break; - case JustifySpaceBetween: - m_value.valueID = CSSValueSpaceBetween; - break; - case JustifySpaceAround: - m_value.valueID = CSSValueSpaceAround; - break; - } -} - -template<> inline CSSPrimitiveValue::operator EJustifyContent() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueFlexStart: - return JustifyFlexStart; - case CSSValueFlexEnd: - return JustifyFlexEnd; - case CSSValueCenter: - return JustifyCenter; - case CSSValueSpaceBetween: - return JustifySpaceBetween; - case CSSValueSpaceAround: - return JustifySpaceAround; - default: - break; - } - - ASSERT_NOT_REACHED(); - return JustifyFlexStart; -} - template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexDirection e) : CSSValue(PrimitiveClass) { @@ -1706,6 +1629,29 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineBreak e) } } +template<> inline CSSPrimitiveValue::operator HangingPunctuation() const +{ + ASSERT(isValueID()); + + switch (m_value.valueID) { + case CSSValueNone: + return NoHangingPunctuation; + case CSSValueFirst: + return FirstHangingPunctuation; + case CSSValueLast: + return LastHangingPunctuation; + case CSSValueAllowEnd: + return AllowEndHangingPunctuation; + case CSSValueForceEnd: + return ForceEndHangingPunctuation; + default: + break; + } + + ASSERT_NOT_REACHED(); + return NoHangingPunctuation; +} + template<> inline CSSPrimitiveValue::operator LineBreak() const { ASSERT(isValueID()); @@ -2237,9 +2183,6 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e) case OAUTO: m_value.valueID = CSSValueAuto; break; - case OMARQUEE: - m_value.valueID = CSSValueWebkitMarquee; - break; case OOVERLAY: m_value.valueID = CSSValueOverlay; break; @@ -2265,8 +2208,6 @@ template<> inline CSSPrimitiveValue::operator EOverflow() const return OSCROLL; case CSSValueAuto: return OAUTO; - case CSSValueWebkitMarquee: - return OMARQUEE; case CSSValueOverlay: return OOVERLAY; case CSSValueWebkitPagedX: @@ -2281,42 +2222,131 @@ template<> inline CSSPrimitiveValue::operator EOverflow() const return OVISIBLE; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BreakBetween e) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_VALUE_ID; switch (e) { - case PBAUTO: + case AutoBreakBetween: m_value.valueID = CSSValueAuto; break; - case PBALWAYS: - m_value.valueID = CSSValueAlways; - break; - case PBAVOID: + case AvoidBreakBetween: m_value.valueID = CSSValueAvoid; break; + case AvoidColumnBreakBetween: + m_value.valueID = CSSValueAvoidColumn; + break; + case AvoidPageBreakBetween: + m_value.valueID = CSSValueAvoidPage; + break; + case AvoidRegionBreakBetween: + m_value.valueID = CSSValueAvoidRegion; + break; + case ColumnBreakBetween: + m_value.valueID = CSSValueColumn; + break; + case PageBreakBetween: + m_value.valueID = CSSValuePage; + break; + case RegionBreakBetween: + m_value.valueID = CSSValueRegion; + break; + case LeftPageBreakBetween: + m_value.valueID = CSSValueLeft; + break; + case RightPageBreakBetween: + m_value.valueID = CSSValueRight; + break; + case RectoPageBreakBetween: + m_value.valueID = CSSValueRecto; + break; + case VersoPageBreakBetween: + m_value.valueID = CSSValueVerso; + break; } } -template<> inline CSSPrimitiveValue::operator EPageBreak() const +template<> inline CSSPrimitiveValue::operator BreakBetween() const { ASSERT(isValueID()); switch (m_value.valueID) { case CSSValueAuto: - return PBAUTO; + return AutoBreakBetween; + case CSSValueAvoid: + return AvoidBreakBetween; + case CSSValueAvoidColumn: + return AvoidColumnBreakBetween; + case CSSValueAvoidPage: + return AvoidPageBreakBetween; + case CSSValueAvoidRegion: + return AvoidRegionBreakBetween; + case CSSValueColumn: + return ColumnBreakBetween; + case CSSValuePage: + return PageBreakBetween; + case CSSValueRegion: + return RegionBreakBetween; case CSSValueLeft: + return LeftPageBreakBetween; case CSSValueRight: - case CSSValueAlways: - return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always." + return RightPageBreakBetween; + case CSSValueRecto: + return RectoPageBreakBetween; + case CSSValueVerso: + return VersoPageBreakBetween; + default: + break; + } + + ASSERT_NOT_REACHED(); + return AutoBreakBetween; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BreakInside e) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (e) { + case AutoBreakInside: + m_value.valueID = CSSValueAuto; + break; + case AvoidBreakInside: + m_value.valueID = CSSValueAvoid; + break; + case AvoidColumnBreakInside: + m_value.valueID = CSSValueAvoidColumn; + break; + case AvoidPageBreakInside: + m_value.valueID = CSSValueAvoidPage; + break; + case AvoidRegionBreakInside: + m_value.valueID = CSSValueAvoidRegion; + break; + } +} + +template<> inline CSSPrimitiveValue::operator BreakInside() const +{ + ASSERT(isValueID()); + + switch (m_value.valueID) { + case CSSValueAuto: + return AutoBreakInside; case CSSValueAvoid: - return PBAVOID; + return AvoidBreakInside; + case CSSValueAvoidColumn: + return AvoidColumnBreakInside; + case CSSValueAvoidPage: + return AvoidPageBreakInside; + case CSSValueAvoidRegion: + return AvoidRegionBreakInside; default: break; } ASSERT_NOT_REACHED(); - return PBAUTO; + return AutoBreakInside; } template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e) @@ -2337,9 +2367,7 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e) m_value.valueID = CSSValueFixed; break; case StickyPosition: -#if ENABLE(CSS_STICKY_POSITION) m_value.valueID = CSSValueWebkitSticky; -#endif break; } } @@ -2357,10 +2385,8 @@ template<> inline CSSPrimitiveValue::operator EPosition() const return AbsolutePosition; case CSSValueFixed: return FixedPosition; -#if ENABLE(CSS_STICKY_POSITION) case CSSValueWebkitSticky: return StickyPosition; -#endif default: break; } @@ -2565,18 +2591,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextJustify e) case TextJustifyInterWord: m_value.valueID = CSSValueInterWord; break; - case TextJustifyInterIdeograph: - m_value.valueID = CSSValueInterIdeograph; - break; - case TextJustifyInterCluster: - m_value.valueID = CSSValueInterCluster; - break; case TextJustifyDistribute: m_value.valueID = CSSValueDistribute; break; - case TextJustifyKashida: - m_value.valueID = CSSValueKashida; - break; } } @@ -2591,14 +2608,8 @@ template<> inline CSSPrimitiveValue::operator TextJustify() const return TextJustifyNone; case CSSValueInterWord: return TextJustifyInterWord; - case CSSValueInterIdeograph: - return TextJustifyInterIdeograph; - case CSSValueInterCluster: - return TextJustifyInterCluster; case CSSValueDistribute: return TextJustifyDistribute; - case CSSValueKashida: - return TextJustifyKashida; default: break; } @@ -3109,6 +3120,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e) case BreakAllWordBreak: m_value.valueID = CSSValueBreakAll; break; + case KeepAllWordBreak: + m_value.valueID = CSSValueKeepAll; + break; case BreakWordBreak: m_value.valueID = CSSValueBreakWord; break; @@ -3122,6 +3136,8 @@ template<> inline CSSPrimitiveValue::operator EWordBreak() const switch (m_value.valueID) { case CSSValueBreakAll: return BreakAllWordBreak; + case CSSValueKeepAll: + return KeepAllWordBreak; case CSSValueBreakWord: return BreakWordBreak; case CSSValueNormal: @@ -3222,8 +3238,13 @@ template<> inline CSSPrimitiveValue::operator WritingMode() const switch (m_value.valueID) { case CSSValueHorizontalTb: + case CSSValueLrTb: + case CSSValueRl: + case CSSValueRlTb: return TopToBottomWritingMode; case CSSValueVerticalRl: + case CSSValueTb: + case CSSValueTbRl: return RightToLeftWritingMode; case CSSValueVerticalLr: return LeftToRightWritingMode; @@ -3279,6 +3300,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(RubyPosition position) case RubyPositionAfter: m_value.valueID = CSSValueAfter; break; + case RubyPositionInterCharacter: + m_value.valueID = CSSValueInterCharacter; + break; } } @@ -3291,6 +3315,8 @@ template<> inline CSSPrimitiveValue::operator RubyPosition() const return RubyPositionBefore; case CSSValueAfter: return RubyPositionAfter; + case CSSValueInterCharacter: + return RubyPositionInterCharacter; default: break; } @@ -3420,16 +3446,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextOrientation e) { m_primitiveUnitType = CSS_VALUE_ID; switch (e) { - case TextOrientationSideways: + case TextOrientation::Sideways: m_value.valueID = CSSValueSideways; break; - case TextOrientationSidewaysRight: - m_value.valueID = CSSValueSidewaysRight; - break; - case TextOrientationVerticalRight: - m_value.valueID = CSSValueVerticalRight; + case TextOrientation::Mixed: + m_value.valueID = CSSValueMixed; break; - case TextOrientationUpright: + case TextOrientation::Upright: m_value.valueID = CSSValueUpright; break; } @@ -3441,19 +3464,21 @@ template<> inline CSSPrimitiveValue::operator TextOrientation() const switch (m_value.valueID) { case CSSValueSideways: - return TextOrientationSideways; + return TextOrientation::Sideways; case CSSValueSidewaysRight: - return TextOrientationSidewaysRight; + return TextOrientation::Sideways; case CSSValueVerticalRight: - return TextOrientationVerticalRight; + return TextOrientation::Mixed; + case CSSValueMixed: + return TextOrientation::Mixed; case CSSValueUpright: - return TextOrientationUpright; + return TextOrientation::Upright; default: break; } ASSERT_NOT_REACHED(); - return TextOrientationVerticalRight; + return TextOrientation::Mixed; } template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e) @@ -3477,13 +3502,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e) m_value.valueID = CSSValueVisible; break; case PE_VISIBLE_STROKE: - m_value.valueID = CSSValueVisiblestroke; + m_value.valueID = CSSValueVisibleStroke; break; case PE_VISIBLE_FILL: - m_value.valueID = CSSValueVisiblefill; + m_value.valueID = CSSValueVisibleFill; break; case PE_VISIBLE_PAINTED: - m_value.valueID = CSSValueVisiblepainted; + m_value.valueID = CSSValueVisiblePainted; break; case PE_AUTO: m_value.valueID = CSSValueAuto; @@ -3505,11 +3530,11 @@ template<> inline CSSPrimitiveValue::operator EPointerEvents() const return PE_AUTO; case CSSValueNone: return PE_NONE; - case CSSValueVisiblepainted: + case CSSValueVisiblePainted: return PE_VISIBLE_PAINTED; - case CSSValueVisiblefill: + case CSSValueVisibleFill: return PE_VISIBLE_FILL; - case CSSValueVisiblestroke: + case CSSValueVisibleStroke: return PE_VISIBLE_STROKE; case CSSValueVisible: return PE_VISIBLE; @@ -3527,18 +3552,18 @@ template<> inline CSSPrimitiveValue::operator EPointerEvents() const return PE_ALL; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontDescription::Kerning kerning) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Kerning kerning) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_VALUE_ID; switch (kerning) { - case FontDescription::AutoKerning: + case Kerning::Auto: m_value.valueID = CSSValueAuto; return; - case FontDescription::NormalKerning: + case Kerning::Normal: m_value.valueID = CSSValueNormal; return; - case FontDescription::NoneKerning: + case Kerning::NoShift: m_value.valueID = CSSValueNone; return; } @@ -3547,23 +3572,23 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontDescription::Kerning m_value.valueID = CSSValueAuto; } -template<> inline CSSPrimitiveValue::operator FontDescription::Kerning() const +template<> inline CSSPrimitiveValue::operator Kerning() const { ASSERT(isValueID()); switch (m_value.valueID) { case CSSValueAuto: - return FontDescription::AutoKerning; + return Kerning::Auto; case CSSValueNormal: - return FontDescription::NormalKerning; + return Kerning::Normal; case CSSValueNone: - return FontDescription::NoneKerning; + return Kerning::NoShift; default: break; } ASSERT_NOT_REACHED(); - return FontDescription::AutoKerning; + return Kerning::Auto; } template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ObjectFit fit) @@ -3804,13 +3829,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e) m_value.valueID = CSSValueAuto; break; case OptimizeSpeed: - m_value.valueID = CSSValueOptimizespeed; + m_value.valueID = CSSValueOptimizeSpeed; break; case OptimizeLegibility: - m_value.valueID = CSSValueOptimizelegibility; + m_value.valueID = CSSValueOptimizeLegibility; break; case GeometricPrecision: - m_value.valueID = CSSValueGeometricprecision; + m_value.valueID = CSSValueGeometricPrecision; break; } } @@ -3822,11 +3847,11 @@ template<> inline CSSPrimitiveValue::operator TextRenderingMode() const switch (m_value.valueID) { case CSSValueAuto: return AutoTextRendering; - case CSSValueOptimizespeed: + case CSSValueOptimizeSpeed: return OptimizeSpeed; - case CSSValueOptimizelegibility: + case CSSValueOptimizeLegibility: return OptimizeLegibility; - case CSSValueGeometricprecision: + case CSSValueGeometricPrecision: return GeometricPrecision; default: break; @@ -3836,42 +3861,6 @@ template<> inline CSSPrimitiveValue::operator TextRenderingMode() const return AutoTextRendering; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColorSpace space) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (space) { - case ColorSpaceDeviceRGB: - m_value.valueID = CSSValueDefault; - break; - case ColorSpaceSRGB: - m_value.valueID = CSSValueSrgb; - break; - case ColorSpaceLinearRGB: - // CSS color correction does not support linearRGB yet. - ASSERT_NOT_REACHED(); - m_value.valueID = CSSValueDefault; - break; - } -} - -template<> inline CSSPrimitiveValue::operator ColorSpace() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueDefault: - return ColorSpaceDeviceRGB; - case CSSValueSrgb: - return ColorSpaceSRGB; - default: - break; - } - - ASSERT_NOT_REACHED(); - return ColorSpaceDeviceRGB; -} - template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens) : CSSValue(PrimitiveClass) { @@ -4110,6 +4099,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode) case BlendModeLuminosity: m_value.valueID = CSSValueLuminosity; break; + case BlendModePlusDarker: + m_value.valueID = CSSValuePlusDarker; + break; + case BlendModePlusLighter: + m_value.valueID = CSSValuePlusLighter; + break; } } @@ -4150,6 +4145,10 @@ template<> inline CSSPrimitiveValue::operator BlendMode() const return BlendModeColor; case CSSValueLuminosity: return BlendModeLuminosity; + case CSSValuePlusDarker: + return BlendModePlusDarker; + case CSSValuePlusLighter: + return BlendModePlusLighter; default: break; } @@ -4158,7 +4157,37 @@ template<> inline CSSPrimitiveValue::operator BlendMode() const return BlendModeNormal; } -#if ENABLE(SVG) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Isolation isolation) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (isolation) { + case IsolationAuto: + m_value.valueID = CSSValueAuto; + break; + case IsolationIsolate: + m_value.valueID = CSSValueIsolate; + break; + default: + ASSERT_NOT_REACHED(); + } +} + +template<> inline CSSPrimitiveValue::operator Isolation() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueAuto: + return IsolationAuto; + case CSSValueIsolate: + return IsolationIsolate; + default: + break; + } + + ASSERT_NOT_REACHED(); + return IsolationAuto; +} template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e) : CSSValue(PrimitiveClass) @@ -4345,8 +4374,6 @@ template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const return AB_AUTO; } -#endif - template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderCollapse e) : CSSValue(PrimitiveClass) { @@ -4409,22 +4436,25 @@ template<> inline CSSPrimitiveValue::operator EBorderFit() const return BorderFitLines; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering imageRendering) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_VALUE_ID; - switch (e) { + switch (imageRendering) { case ImageRenderingAuto: m_value.valueID = CSSValueAuto; break; case ImageRenderingCrispEdges: - m_value.valueID = CSSValueWebkitCrispEdges; + m_value.valueID = CSSValueCrispEdges; + break; + case ImageRenderingPixelated: + m_value.valueID = CSSValuePixelated; break; case ImageRenderingOptimizeSpeed: - m_value.valueID = CSSValueOptimizespeed; + m_value.valueID = CSSValueOptimizeSpeed; break; case ImageRenderingOptimizeQuality: - m_value.valueID = CSSValueOptimizequality; + m_value.valueID = CSSValueOptimizeQuality; break; } } @@ -4437,11 +4467,14 @@ template<> inline CSSPrimitiveValue::operator EImageRendering() const case CSSValueAuto: return ImageRenderingAuto; case CSSValueWebkitOptimizeContrast: + case CSSValueCrispEdges: case CSSValueWebkitCrispEdges: return ImageRenderingCrispEdges; - case CSSValueOptimizespeed: + case CSSValuePixelated: + return ImageRenderingPixelated; + case CSSValueOptimizeSpeed: return ImageRenderingOptimizeSpeed; - case CSSValueOptimizequality: + case CSSValueOptimizeQuality: return ImageRenderingOptimizeQuality; default: break; @@ -4549,159 +4582,46 @@ template<> inline CSSPrimitiveValue::operator ColumnProgression() const return NormalColumnProgression; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WrapFlow wrapFlow) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (wrapFlow) { - case WrapFlowAuto: - m_value.valueID = CSSValueAuto; - break; - case WrapFlowBoth: - m_value.valueID = CSSValueBoth; - break; - case WrapFlowStart: - m_value.valueID = CSSValueStart; - break; - case WrapFlowEnd: - m_value.valueID = CSSValueEnd; - break; - case WrapFlowMaximum: - m_value.valueID = CSSValueMaximum; - break; - case WrapFlowClear: - m_value.valueID = CSSValueClear; - break; - } -} - -template<> inline CSSPrimitiveValue::operator WrapFlow() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueAuto: - return WrapFlowAuto; - case CSSValueBoth: - return WrapFlowBoth; - case CSSValueStart: - return WrapFlowStart; - case CSSValueEnd: - return WrapFlowEnd; - case CSSValueMaximum: - return WrapFlowMaximum; - case CSSValueClear: - return WrapFlowClear; - default: - break; - } - - ASSERT_NOT_REACHED(); - return WrapFlowAuto; -} - -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WrapThrough wrapThrough) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (wrapThrough) { - case WrapThroughWrap: - m_value.valueID = CSSValueWrap; - break; - case WrapThroughNone: - m_value.valueID = CSSValueNone; - break; - } -} - -template<> inline CSSPrimitiveValue::operator WrapThrough() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueWrap: - return WrapThroughWrap; - case CSSValueNone: - return WrapThroughNone; - default: - break; - } - - ASSERT_NOT_REACHED(); - return WrapThroughWrap; -} - -template<> inline CSSPrimitiveValue::operator GridAutoFlow() const -{ - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueNone: - return AutoFlowNone; - case CSSValueColumn: - return AutoFlowColumn; - case CSSValueRow: - return AutoFlowRow; - default: - break; - } - - ASSERT_NOT_REACHED(); - return AutoFlowNone; - -} - -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(GridAutoFlow flow) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_VALUE_ID; - switch (flow) { - case AutoFlowNone: - m_value.valueID = CSSValueNone; - break; - case AutoFlowColumn: - m_value.valueID = CSSValueColumn; - break; - case AutoFlowRow: - m_value.valueID = CSSValueRow; - break; - } -} - enum LengthConversion { AnyConversion = ~0, FixedIntegerConversion = 1 << 0, FixedFloatConversion = 1 << 1, AutoConversion = 1 << 2, PercentConversion = 1 << 3, - FractionConversion = 1 << 4, - CalculatedConversion = 1 << 5, - ViewportPercentageConversion = 1 << 6 + CalculatedConversion = 1 << 4 }; -template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const +inline bool CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle(int lengthConversion) const +{ + ASSERT(isFontRelativeLength()); + // This matches the implementation in CSSPrimitiveValue::computeLengthDouble(). + switch (m_primitiveUnitType) { + case CSS_EMS: + case CSS_EXS: + case CSS_CHS: + return lengthConversion & (FixedIntegerConversion | FixedFloatConversion); + default: + return false; + } +} + +template<int supported> Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) const { - if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle)) + if (isFontRelativeLength() && convertingToLengthRequiresNonNullStyle(supported) && !conversionData.style()) return Length(Undefined); if ((supported & FixedIntegerConversion) && isLength()) - return computeLength<Length>(style, rootStyle, multiplier, computingFontSize); + return computeLength<Length>(conversionData); if ((supported & FixedFloatConversion) && isLength()) - return Length(computeLength<double>(style, rootStyle, multiplier), Fixed); + return Length(computeLength<double>(conversionData), Fixed); if ((supported & PercentConversion) && isPercentage()) - return Length(getDoubleValue(), Percent); - if ((supported & FractionConversion) && isNumber()) - return Length(getDoubleValue() * 100.0, Percent); - if ((supported & AutoConversion) && getValueID() == CSSValueAuto) + return Length(doubleValue(), Percent); + if ((supported & AutoConversion) && valueID() == CSSValueAuto) return Length(Auto); if ((supported & CalculatedConversion) && isCalculated()) - return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier)); - if ((supported & ViewportPercentageConversion) && isViewportPercentageLength()) - return viewportPercentageLength(); + return Length(cssCalcValue()->createCalculationValue(conversionData)); return Length(Undefined); } -#if ENABLE(SVG) - template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBufferedRendering e) : CSSValue(PrimitiveClass) { @@ -4747,10 +4667,10 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e) m_value.valueID = CSSValueAuto; break; case CI_SRGB: - m_value.valueID = CSSValueSrgb; + m_value.valueID = CSSValueSRGB; break; case CI_LINEARRGB: - m_value.valueID = CSSValueLinearrgb; + m_value.valueID = CSSValueLinearRGB; break; } } @@ -4760,9 +4680,9 @@ template<> inline CSSPrimitiveValue::operator EColorInterpolation() const ASSERT(isValueID()); switch (m_value.valueID) { - case CSSValueSrgb: + case CSSValueSRGB: return CI_SRGB; - case CSSValueLinearrgb: + case CSSValueLinearRGB: return CI_LINEARRGB; case CSSValueAuto: return CI_AUTO; @@ -4783,10 +4703,10 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e) m_value.valueID = CSSValueAuto; break; case CR_OPTIMIZESPEED: - m_value.valueID = CSSValueOptimizespeed; + m_value.valueID = CSSValueOptimizeSpeed; break; case CR_OPTIMIZEQUALITY: - m_value.valueID = CSSValueOptimizequality; + m_value.valueID = CSSValueOptimizeQuality; break; } } @@ -4796,9 +4716,9 @@ template<> inline CSSPrimitiveValue::operator EColorRendering() const ASSERT(isValueID()); switch (m_value.valueID) { - case CSSValueOptimizespeed: + case CSSValueOptimizeSpeed: return CR_OPTIMIZESPEED; - case CSSValueOptimizequality: + case CSSValueOptimizeQuality: return CR_OPTIMIZEQUALITY; case CSSValueAuto: return CR_AUTO; @@ -4900,13 +4820,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e) m_value.valueID = CSSValueAuto; break; case SR_OPTIMIZESPEED: - m_value.valueID = CSSValueOptimizespeed; + m_value.valueID = CSSValueOptimizeSpeed; break; case SR_CRISPEDGES: m_value.valueID = CSSValueCrispedges; break; case SR_GEOMETRICPRECISION: - m_value.valueID = CSSValueGeometricprecision; + m_value.valueID = CSSValueGeometricPrecision; break; } } @@ -4918,11 +4838,11 @@ template<> inline CSSPrimitiveValue::operator EShapeRendering() const switch (m_value.valueID) { case CSSValueAuto: return SR_AUTO; - case CSSValueOptimizespeed: + case CSSValueOptimizeSpeed: return SR_OPTIMIZESPEED; case CSSValueCrispedges: return SR_CRISPEDGES; - case CSSValueGeometricprecision: + case CSSValueGeometricPrecision: return SR_GEOMETRICPRECISION; default: break; @@ -4968,55 +4888,18 @@ template<> inline CSSPrimitiveValue::operator ETextAnchor() const return TA_START; } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(SVGWritingMode e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(const Color& color) : CSSValue(PrimitiveClass) { - m_primitiveUnitType = CSS_VALUE_ID; - switch (e) { - case WM_LRTB: - m_value.valueID = CSSValueLrTb; - break; - case WM_LR: - m_value.valueID = CSSValueLr; - break; - case WM_RLTB: - m_value.valueID = CSSValueRlTb; - break; - case WM_RL: - m_value.valueID = CSSValueRl; - break; - case WM_TBRL: - m_value.valueID = CSSValueTbRl; - break; - case WM_TB: - m_value.valueID = CSSValueTb; - break; - } + m_primitiveUnitType = CSS_RGBCOLOR; + m_value.color = new Color(color); } -template<> inline CSSPrimitiveValue::operator SVGWritingMode() const +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSFontFamily fontFamily) + : CSSValue(PrimitiveClass) { - ASSERT(isValueID()); - - switch (m_value.valueID) { - case CSSValueLrTb: - return WM_LRTB; - case CSSValueLr: - return WM_LR; - case CSSValueRlTb: - return WM_RLTB; - case CSSValueRl: - return WM_RL; - case CSSValueTbRl: - return WM_TBRL; - case CSSValueTb: - return WM_TB; - default: - break; - } - - ASSERT_NOT_REACHED(); - return WM_LRTB; + m_primitiveUnitType = CSS_FONT_FAMILY; + m_value.fontFamily = new CSSFontFamily(WTFMove(fontFamily)); } template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVectorEffect e) @@ -5081,8 +4964,6 @@ template<> inline CSSPrimitiveValue::operator EMaskType() const return MT_LUMINANCE; } -#endif // ENABLE(SVG) - #if ENABLE(CSS_IMAGE_ORIENTATION) template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ImageOrientationEnum e) @@ -5113,7 +4994,7 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ImageOrientationEnum e) template<> inline CSSPrimitiveValue::operator ImageOrientationEnum() const { ASSERT(isAngle()); - double quarters = 4 * getDoubleValue(CSS_TURN); + double quarters = 4 * doubleValue(CSS_TURN); int orientation = 3 & static_cast<int>(quarters < 0 ? floor(quarters) : ceil(quarters)); switch (orientation) { case 0: @@ -5132,14 +5013,11 @@ template<> inline CSSPrimitiveValue::operator ImageOrientationEnum() const #endif // ENABLE(CSS_IMAGE_ORIENTATION) -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSBoxType cssBox) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_VALUE_ID; - switch (layoutBox) { - case BoundingBox: - m_value.valueID = CSSValueBoundingBox; - break; + switch (cssBox) { case MarginBox: m_value.valueID = CSSValueMarginBox; break; @@ -5152,6 +5030,15 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox) case ContentBox: m_value.valueID = CSSValueContentBox; break; + case Fill: + m_value.valueID = CSSValueFill; + break; + case Stroke: + m_value.valueID = CSSValueStroke; + break; + case ViewBox: + m_value.valueID = CSSValueViewBox; + break; case BoxMissing: ASSERT_NOT_REACHED(); m_value.valueID = CSSValueNone; @@ -5159,11 +5046,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox) } } -template<> inline CSSPrimitiveValue::operator LayoutBox() const +template<> inline CSSPrimitiveValue::operator CSSBoxType() const { - switch (getValueID()) { - case CSSValueBoundingBox: - return BoundingBox; + switch (valueID()) { case CSSValueMarginBox: return MarginBox; case CSSValueBorderBox: @@ -5172,6 +5057,13 @@ template<> inline CSSPrimitiveValue::operator LayoutBox() const return PaddingBox; case CSSValueContentBox: return ContentBox; + // The following are used in an SVG context. + case CSSValueFill: + return Fill; + case CSSValueStroke: + return Stroke; + case CSSValueViewBox: + return ViewBox; default: break; } @@ -5179,6 +5071,657 @@ template<> inline CSSPrimitiveValue::operator LayoutBox() const return BoxMissing; } +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ItemPosition itemPosition) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (itemPosition) { + case ItemPositionAuto: + m_value.valueID = CSSValueAuto; + break; + case ItemPositionNormal: + m_value.valueID = CSSValueNormal; + break; + case ItemPositionStretch: + m_value.valueID = CSSValueStretch; + break; + case ItemPositionBaseline: + m_value.valueID = CSSValueBaseline; + break; + case ItemPositionLastBaseline: + m_value.valueID = CSSValueLastBaseline; + break; + case ItemPositionCenter: + m_value.valueID = CSSValueCenter; + break; + case ItemPositionStart: + m_value.valueID = CSSValueStart; + break; + case ItemPositionEnd: + m_value.valueID = CSSValueEnd; + break; + case ItemPositionSelfStart: + m_value.valueID = CSSValueSelfStart; + break; + case ItemPositionSelfEnd: + m_value.valueID = CSSValueSelfEnd; + break; + case ItemPositionFlexStart: + m_value.valueID = CSSValueFlexStart; + break; + case ItemPositionFlexEnd: + m_value.valueID = CSSValueFlexEnd; + break; + case ItemPositionLeft: + m_value.valueID = CSSValueLeft; + break; + case ItemPositionRight: + m_value.valueID = CSSValueRight; + break; + } } +template<> inline CSSPrimitiveValue::operator ItemPosition() const +{ + switch (m_value.valueID) { + case CSSValueAuto: + return ItemPositionAuto; + case CSSValueNormal: + return ItemPositionNormal; + case CSSValueStretch: + return ItemPositionStretch; + case CSSValueBaseline: + return ItemPositionBaseline; + case CSSValueLastBaseline: + return ItemPositionLastBaseline; + case CSSValueCenter: + return ItemPositionCenter; + case CSSValueStart: + return ItemPositionStart; + case CSSValueEnd: + return ItemPositionEnd; + case CSSValueSelfStart: + return ItemPositionSelfStart; + case CSSValueSelfEnd: + return ItemPositionSelfEnd; + case CSSValueFlexStart: + return ItemPositionFlexStart; + case CSSValueFlexEnd: + return ItemPositionFlexEnd; + case CSSValueLeft: + return ItemPositionLeft; + case CSSValueRight: + return ItemPositionRight; + default: + break; + } + ASSERT_NOT_REACHED(); + return ItemPositionAuto; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(OverflowAlignment overflowAlignment) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (overflowAlignment) { + case OverflowAlignmentDefault: + m_value.valueID = CSSValueDefault; + break; + case OverflowAlignmentUnsafe: + m_value.valueID = CSSValueUnsafe; + break; + case OverflowAlignmentSafe: + m_value.valueID = CSSValueSafe; + break; + } +} + +template<> inline CSSPrimitiveValue::operator OverflowAlignment() const +{ + switch (m_value.valueID) { + case CSSValueUnsafe: + return OverflowAlignmentUnsafe; + case CSSValueSafe: + return OverflowAlignmentSafe; + default: + break; + } + ASSERT_NOT_REACHED(); + return OverflowAlignmentUnsafe; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ContentPosition contentPosition) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (contentPosition) { + case ContentPositionNormal: + m_value.valueID = CSSValueNormal; + break; + case ContentPositionBaseline: + m_value.valueID = CSSValueBaseline; + break; + case ContentPositionLastBaseline: + m_value.valueID = CSSValueLastBaseline; + break; + case ContentPositionCenter: + m_value.valueID = CSSValueCenter; + break; + case ContentPositionStart: + m_value.valueID = CSSValueStart; + break; + case ContentPositionEnd: + m_value.valueID = CSSValueEnd; + break; + case ContentPositionFlexStart: + m_value.valueID = CSSValueFlexStart; + break; + case ContentPositionFlexEnd: + m_value.valueID = CSSValueFlexEnd; + break; + case ContentPositionLeft: + m_value.valueID = CSSValueLeft; + break; + case ContentPositionRight: + m_value.valueID = CSSValueRight; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ContentPosition() const +{ + switch (m_value.valueID) { + case CSSValueNormal: + return ContentPositionNormal; + case CSSValueBaseline: + return ContentPositionBaseline; + case CSSValueLastBaseline: + return ContentPositionLastBaseline; + case CSSValueCenter: + return ContentPositionCenter; + case CSSValueStart: + return ContentPositionStart; + case CSSValueEnd: + return ContentPositionEnd; + case CSSValueFlexStart: + return ContentPositionFlexStart; + case CSSValueFlexEnd: + return ContentPositionFlexEnd; + case CSSValueLeft: + return ContentPositionLeft; + case CSSValueRight: + return ContentPositionRight; + default: + break; + } + ASSERT_NOT_REACHED(); + return ContentPositionNormal; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ContentDistributionType contentDistribution) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (contentDistribution) { + case ContentDistributionDefault: + m_value.valueID = CSSValueDefault; + break; + case ContentDistributionSpaceBetween: + m_value.valueID = CSSValueSpaceBetween; + break; + case ContentDistributionSpaceAround: + m_value.valueID = CSSValueSpaceAround; + break; + case ContentDistributionSpaceEvenly: + m_value.valueID = CSSValueSpaceEvenly; + break; + case ContentDistributionStretch: + m_value.valueID = CSSValueStretch; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ContentDistributionType() const +{ + switch (m_value.valueID) { + case CSSValueSpaceBetween: + return ContentDistributionSpaceBetween; + case CSSValueSpaceAround: + return ContentDistributionSpaceAround; + case CSSValueSpaceEvenly: + return ContentDistributionSpaceEvenly; + case CSSValueStretch: + return ContentDistributionStretch; + default: + break; + } + ASSERT_NOT_REACHED(); + return ContentDistributionStretch; +} + +template<> inline CSSPrimitiveValue::operator TextZoom() const +{ + ASSERT(isValueID()); + + switch (m_value.valueID) { + case CSSValueNormal: + return TextZoomNormal; + case CSSValueReset: + return TextZoomReset; + default: + break; + } + + ASSERT_NOT_REACHED(); + return TextZoomNormal; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextZoom textZoom) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (textZoom) { + case TextZoomNormal: + m_value.valueID = CSSValueNormal; + return; + case TextZoomReset: + m_value.valueID = CSSValueReset; + return; + } + + ASSERT_NOT_REACHED(); + m_value.valueID = CSSValueNormal; +} + +#if ENABLE(TOUCH_EVENTS) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TouchAction touchAction) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (touchAction) { + case TouchAction::Auto: + m_value.valueID = CSSValueAuto; + break; + case TouchAction::Manipulation: + m_value.valueID = CSSValueManipulation; + break; + } +} + +template<> inline CSSPrimitiveValue::operator TouchAction() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueAuto: + return TouchAction::Auto; + case CSSValueManipulation: + return TouchAction::Manipulation; + default: + break; + } + ASSERT_NOT_REACHED(); + return TouchAction::Auto; +} #endif + +#if ENABLE(CSS_SCROLL_SNAP) + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ScrollSnapStrictness strictness) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (strictness) { + case ScrollSnapStrictness::None: + m_value.valueID = CSSValueNone; + break; + case ScrollSnapStrictness::Proximity: + m_value.valueID = CSSValueProximity; + break; + case ScrollSnapStrictness::Mandatory: + m_value.valueID = CSSValueMandatory; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ScrollSnapStrictness() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueNone: + return ScrollSnapStrictness::None; + case CSSValueProximity: + return ScrollSnapStrictness::Proximity; + case CSSValueMandatory: + return ScrollSnapStrictness::Mandatory; + default: + ASSERT_NOT_REACHED(); + return ScrollSnapStrictness::None; + } +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ScrollSnapAxis axis) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (axis) { + case ScrollSnapAxis::XAxis: + m_value.valueID = CSSValueX; + break; + case ScrollSnapAxis::YAxis: + m_value.valueID = CSSValueY; + break; + case ScrollSnapAxis::Block: + m_value.valueID = CSSValueBlock; + break; + case ScrollSnapAxis::Inline: + m_value.valueID = CSSValueInline; + break; + case ScrollSnapAxis::Both: + m_value.valueID = CSSValueBoth; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ScrollSnapAxis() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueX: + return ScrollSnapAxis::XAxis; + case CSSValueY: + return ScrollSnapAxis::YAxis; + case CSSValueBlock: + return ScrollSnapAxis::Block; + case CSSValueInline: + return ScrollSnapAxis::Inline; + case CSSValueBoth: + return ScrollSnapAxis::Both; + default: + ASSERT_NOT_REACHED(); + return ScrollSnapAxis::Both; + } +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ScrollSnapAxisAlignType type) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (type) { + case ScrollSnapAxisAlignType::None: + m_value.valueID = CSSValueNone; + break; + case ScrollSnapAxisAlignType::Start: + m_value.valueID = CSSValueStart; + break; + case ScrollSnapAxisAlignType::Center: + m_value.valueID = CSSValueCenter; + break; + case ScrollSnapAxisAlignType::End: + m_value.valueID = CSSValueEnd; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ScrollSnapAxisAlignType() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueNone: + return ScrollSnapAxisAlignType::None; + case CSSValueStart: + return ScrollSnapAxisAlignType::Start; + case CSSValueCenter: + return ScrollSnapAxisAlignType::Center; + case CSSValueEnd: + return ScrollSnapAxisAlignType::End; + default: + ASSERT_NOT_REACHED(); + return ScrollSnapAxisAlignType::None; + } +} + +#endif + +#if ENABLE(CSS_TRAILING_WORD) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TrailingWord e) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (e) { + case TrailingWord::Auto: + m_value.valueID = CSSValueAuto; + break; + case TrailingWord::PartiallyBalanced: + m_value.valueID = CSSValueWebkitPartiallyBalanced; + break; + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator TrailingWord() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueAuto: + return TrailingWord::Auto; + case CSSValueWebkitPartiallyBalanced: + return TrailingWord::PartiallyBalanced; + default: + break; + } + ASSERT_NOT_REACHED(); + return TrailingWord::Auto; +} +#endif + +#if ENABLE(APPLE_PAY) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonStyle e) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (e) { + case ApplePayButtonStyle::White: + m_value.valueID = CSSValueWhite; + break; + case ApplePayButtonStyle::WhiteOutline: + m_value.valueID = CSSValueWhiteOutline; + break; + case ApplePayButtonStyle::Black: + m_value.valueID = CSSValueBlack; + break; + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator ApplePayButtonStyle() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueWhite: + return ApplePayButtonStyle::White; + case CSSValueWhiteOutline: + return ApplePayButtonStyle::WhiteOutline; + case CSSValueBlack: + return ApplePayButtonStyle::Black; + default: + break; + } + ASSERT_NOT_REACHED(); + return ApplePayButtonStyle::Black; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonType e) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (e) { + case ApplePayButtonType::Plain: + m_value.valueID = CSSValuePlain; + break; + case ApplePayButtonType::Buy: + m_value.valueID = CSSValueBuy; + break; + case ApplePayButtonType::SetUp: + m_value.valueID = CSSValueSetUp; + break; + case ApplePayButtonType::Donate: + m_value.valueID = CSSValueDonate; + break; + + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator ApplePayButtonType() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValuePlain: + return ApplePayButtonType::Plain; + case CSSValueBuy: + return ApplePayButtonType::Buy; + case CSSValueSetUp: + return ApplePayButtonType::SetUp; + case CSSValueDonate: + return ApplePayButtonType::Donate; + default: + break; + } + ASSERT_NOT_REACHED(); + return ApplePayButtonType::Plain; +} +#endif + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontVariantPosition position) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (position) { + case FontVariantPosition::Normal: + m_value.valueID = CSSValueNormal; + break; + case FontVariantPosition::Subscript: + m_value.valueID = CSSValueSub; + break; + case FontVariantPosition::Superscript: + m_value.valueID = CSSValueSuper; + break; + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator FontVariantPosition() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueNormal: + return FontVariantPosition::Normal; + case CSSValueSub: + return FontVariantPosition::Subscript; + case CSSValueSuper: + return FontVariantPosition::Superscript; + default: + break; + } + ASSERT_NOT_REACHED(); + return FontVariantPosition::Normal; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontVariantCaps caps) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (caps) { + case FontVariantCaps::Normal: + m_value.valueID = CSSValueNormal; + break; + case FontVariantCaps::Small: + m_value.valueID = CSSValueSmallCaps; + break; + case FontVariantCaps::AllSmall: + m_value.valueID = CSSValueAllSmallCaps; + break; + case FontVariantCaps::Petite: + m_value.valueID = CSSValuePetiteCaps; + break; + case FontVariantCaps::AllPetite: + m_value.valueID = CSSValueAllPetiteCaps; + break; + case FontVariantCaps::Unicase: + m_value.valueID = CSSValueUnicase; + break; + case FontVariantCaps::Titling: + m_value.valueID = CSSValueTitlingCaps; + break; + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator FontVariantCaps() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueNormal: + return FontVariantCaps::Normal; + case CSSValueSmallCaps: + return FontVariantCaps::Small; + case CSSValueAllSmallCaps: + return FontVariantCaps::AllSmall; + case CSSValuePetiteCaps: + return FontVariantCaps::Petite; + case CSSValueAllPetiteCaps: + return FontVariantCaps::AllPetite; + case CSSValueUnicase: + return FontVariantCaps::Unicase; + case CSSValueTitlingCaps: + return FontVariantCaps::Titling; + default: + break; + } + ASSERT_NOT_REACHED(); + return FontVariantCaps::Normal; +} + +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontVariantAlternates alternates) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_VALUE_ID; + switch (alternates) { + case FontVariantAlternates::Normal: + m_value.valueID = CSSValueNormal; + break; + case FontVariantAlternates::HistoricalForms: + m_value.valueID = CSSValueHistoricalForms; + break; + default: + ASSERT_NOT_REACHED(); + break; + } +} + +template<> inline CSSPrimitiveValue::operator FontVariantAlternates() const +{ + ASSERT(isValueID()); + switch (m_value.valueID) { + case CSSValueNormal: + return FontVariantAlternates::Normal; + case CSSValueHistoricalForms: + return FontVariantAlternates::HistoricalForms; + default: + break; + } + ASSERT_NOT_REACHED(); + return FontVariantAlternates::Normal; +} + +} |