/*
 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
 *           (C) 2000 Dirk Mueller (mueller@kde.org)
 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#pragma once

#include "WritingMode.h"
#include <limits>

namespace WebCore {

class TextStream;

static const size_t PrintColorAdjustBits = 1;
enum PrintColorAdjust : uint8_t {
    PrintColorAdjustEconomy,
    PrintColorAdjustExact
};

// The difference between two styles.  The following values are used:
// - StyleDifferenceEqual - The two styles are identical
// - StyleDifferenceRecompositeLayer - The layer needs its position and transform updated, but no repaint
// - StyleDifferenceRepaint - The object just needs to be repainted.
// - StyleDifferenceRepaintIfText - The object needs to be repainted if it contains text.
// - StyleDifferenceRepaintLayer - The layer and its descendant layers needs to be repainted.
// - StyleDifferenceLayoutPositionedMovementOnly - Only the position of this positioned object has been updated
// - StyleDifferenceSimplifiedLayout - Only overflow needs to be recomputed
// - StyleDifferenceSimplifiedLayoutAndPositionedMovement - Both positioned movement and simplified layout updates are required.
// - StyleDifferenceLayout - A full layout is required.
enum StyleDifference : uint8_t {
    StyleDifferenceEqual,
    StyleDifferenceRecompositeLayer,
    StyleDifferenceRepaint,
    StyleDifferenceRepaintIfText,
    StyleDifferenceRepaintLayer,
    StyleDifferenceLayoutPositionedMovementOnly,
    StyleDifferenceSimplifiedLayout,
    StyleDifferenceSimplifiedLayoutAndPositionedMovement,
    StyleDifferenceLayout,
    StyleDifferenceNewStyle
};

// When some style properties change, different amounts of work have to be done depending on
// context (e.g. whether the property is changing on an element which has a compositing layer).
// A simple StyleDifference does not provide enough information so we return a bit mask of
// StyleDifferenceContextSensitiveProperties from RenderStyle::diff() too.
enum class StyleDifferenceContextSensitiveProperty : uint8_t {
    None = 0,
    Transform   = 1 << 0,
    Opacity     = 1 << 1,
    Filter      = 1 << 2,
    ClipRect    = 1 << 3,
    ClipPath    = 1 << 4,
    WillChange  = 1 << 5,
};

// Static pseudo styles. Dynamic ones are produced on the fly.
enum class PseudoId : uint16_t {
    // The order must be None, public IDs, and then internal IDs.
    None,

    // Public:
    FirstLine,
    FirstLetter,
    Highlight,
    Marker,
    Before,
    After,
    Selection,
    Backdrop,
    Scrollbar,

    // Internal:
    ScrollbarThumb,
    ScrollbarButton,
    ScrollbarTrack,
    ScrollbarTrackPiece,
    ScrollbarCorner,
    Resizer,

    AfterLastInternalPseudoId,

    FirstPublicPseudoId = FirstLine,
    FirstInternalPseudoId = ScrollbarThumb,
    PublicPseudoIdMask = ((1 << FirstInternalPseudoId) - 1) & ~((1 << FirstPublicPseudoId) - 1)
};

class PseudoIdSet {
public:
    PseudoIdSet()
        : m_data(0)
    {
    }

    ALWAYS_INLINE PseudoIdSet(PseudoId pseudoId1, PseudoId pseudoId2, PseudoId pseudoId3, PseudoId pseudoId4, PseudoId pseudoId5, PseudoId pseudoId6)
    {
        ASSERT((sizeof(m_data) * 8) > pseudoId);
        add(pseudoId1);
        add(pseudoId2);
        add(pseudoId3);
        add(pseudoId4);
        add(pseudoId5);
        add(pseudoId6);
    }

#if 0
    PseudoIdSet(std::initializer_list<PseudoId> initializerList)
        : m_data(0)
    {
        for (PseudoId pseudoId : initializerList)
            add(pseudoId);
    }
#endif

    static PseudoIdSet fromMask(unsigned rawPseudoIdSet)
    {
        return PseudoIdSet(rawPseudoIdSet);
    }

    bool has(PseudoId pseudoId) const
    {
        ASSERT((sizeof(m_data) * 8) > pseudoId);
        return m_data & (1U << static_cast<unsigned>(pseudoId));
    }

    void add(PseudoId pseudoId)
    {
        ASSERT((sizeof(m_data) * 8) > pseudoId);
        m_data |= (1U << static_cast<unsigned>(pseudoId));
    }

    void merge(PseudoIdSet source)
    {
        m_data |= source.m_data;
    }

    PseudoIdSet operator &(const PseudoIdSet& pseudoIdSet) const
    {
        return PseudoIdSet(m_data & pseudoIdSet.m_data);
    }

    PseudoIdSet operator |(const PseudoIdSet& pseudoIdSet) const
    {
        return PseudoIdSet(m_data | pseudoIdSet.m_data);
    }

    explicit operator bool() const
    {
        return m_data;
    }

    unsigned data() const { return m_data; }
private:
    explicit PseudoIdSet(unsigned rawPseudoIdSet)
        : m_data(rawPseudoIdSet)
    {
    }

    unsigned m_data;
};

enum ColumnFill : uint8_t { ColumnFillBalance, ColumnFillAuto };

enum ColumnSpan : uint8_t { ColumnSpanNone = 0, ColumnSpanAll };

enum EBorderCollapse : uint8_t { BSEPARATE = 0, BCOLLAPSE = 1 };

// These have been defined in the order of their precedence for border-collapsing. Do
// not change this order! This order also must match the order in CSSValueKeywords.in.
enum EBorderStyle : uint8_t { BNONE, BHIDDEN, INSET, GROOVE, OUTSET, RIDGE, DOTTED, DASHED, SOLID, DOUBLE };

enum EBorderPrecedence : uint8_t { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };

enum OutlineIsAuto : uint8_t { AUTO_OFF = 0, AUTO_ON };

enum class PositionType : uint8_t {
    Static = 0,
    Relative = 1,
    Absolute = 2,
    Sticky = 3,
    // This value is required to pack our bits efficiently in RenderObject.
    Fixed = 6
};

enum class Float : uint8_t {
    None,
    Left,
    Right,
    InlineStart,
    InlineEnd,
};

enum class UsedFloat : uint8_t {
    None,
    Left,
    Right,
};

// Box decoration attributes. Not inherited.

enum EBoxDecorationBreak : uint8_t { DSLICE, DCLONE };

// Box attributes. Not inherited.

enum EBoxSizing : uint8_t { CONTENT_BOX, BORDER_BOX };

// Random visual rendering model attributes. Not inherited.

enum class Overflow : uint8_t {
    Visible,
    Hidden,
    Clip,
    Scroll,
    Auto,
    PagedX,
    PagedY
};

enum EVerticalAlign : uint8_t {
    BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
    TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
};

enum class Clear : uint8_t {
    None,
    Left,
    Right,
    InlineStart,
    InlineEnd,
    Both
};

enum class UsedClear : uint8_t {
    None,
    Left,
    Right,
    Both
};

enum ETableLayout : uint8_t {
    TAUTO, TFIXED
};

enum TextCombine : uint8_t {
    TextCombineNone, TextCombineHorizontal
};

enum EFillAttachment : uint8_t {
    ScrollBackgroundAttachment, LocalBackgroundAttachment, FixedBackgroundAttachment
};

enum EFillBox : uint8_t {
    BorderFillBox, PaddingFillBox, ContentFillBox, TextFillBox, NoClipFillBox
};

enum EFillRepeat : uint8_t {
    RepeatFill, NoRepeatFill, RoundFill, SpaceFill
};

enum EFillLayerType : uint8_t {
    BackgroundFillLayer, MaskFillLayer
};

// CSS3 Background Values
enum EFillSizeType : uint8_t { Contain, Cover, SizeLength, SizeNone };

// CSS3 <position>
enum class Edge : uint8_t { Top, Right, Bottom, Left };

// CSS3 Mask Mode

enum class MaskMode : uint8_t {
    Alpha,
    Luminance,
    MatchSource,
};

// CSS3 Marquee Properties

enum class MarqueeBehavior : uint8_t {
    None, Scroll, Slide, Alternate
};

enum class MarqueeDirection : uint8_t {
    Auto,
    Left,
    Right,
    Up,
    Down,
    Forward,
    Backward
};

// Deprecated Flexible Box Properties

enum EBoxPack : uint8_t { Start, Center, End, Justify };
enum EBoxAlignment : uint8_t { BSTRETCH, BSTART, BCENTER, BEND, BBASELINE };
enum EBoxOrient : uint8_t { HORIZONTAL, VERTICAL };
enum EBoxLines : uint8_t { SINGLE, MULTIPLE };
enum EBoxDirection : uint8_t { BNORMAL, BREVERSE };

// CSS3 Flexbox Properties

enum EAlignContent : uint8_t { AlignContentFlexStart, AlignContentFlexEnd, AlignContentCenter, AlignContentSpaceBetween, AlignContentSpaceAround, AlignContentStretch };
enum EFlexDirection : uint8_t { FlowRow, FlowRowReverse, FlowColumn, FlowColumnReverse };
enum EFlexWrap : uint8_t { FlexWrapNone, FlexWrap, FlexWrapReverse };
enum ItemPosition : uint8_t { ItemPositionLegacy, ItemPositionAuto, ItemPositionNormal, ItemPositionStretch, ItemPositionBaseline, ItemPositionLastBaseline, ItemPositionCenter, ItemPositionStart, ItemPositionEnd, ItemPositionSelfStart, ItemPositionSelfEnd, ItemPositionFlexStart, ItemPositionFlexEnd, ItemPositionLeft, ItemPositionRight };
enum OverflowAlignment : uint8_t {OverflowAlignmentDefault, OverflowAlignmentUnsafe, OverflowAlignmentSafe};
enum ItemPositionType : uint8_t {NonLegacyPosition, LegacyPosition};
enum ContentPosition : uint8_t {ContentPositionNormal, ContentPositionBaseline, ContentPositionLastBaseline, ContentPositionCenter, ContentPositionStart, ContentPositionEnd, ContentPositionFlexStart, ContentPositionFlexEnd, ContentPositionLeft, ContentPositionRight};
enum ContentDistributionType : uint8_t {ContentDistributionDefault, ContentDistributionSpaceBetween, ContentDistributionSpaceAround, ContentDistributionSpaceEvenly, ContentDistributionStretch};

enum ETextSecurity : uint8_t {
    TSNONE, TSDISC, TSCIRCLE, TSSQUARE
};

// CSS3 User Modify Properties

enum EUserModify : uint8_t {
    READ_ONLY, READ_WRITE, READ_WRITE_PLAINTEXT_ONLY
};

// CSS3 User Drag Values

enum EUserDrag : uint8_t {
    DRAG_AUTO, DRAG_NONE, DRAG_ELEMENT
};

// CSS3 User Select Values

enum EUserSelect : uint8_t {
    SELECT_NONE, SELECT_TEXT, SELECT_ALL
};

// CSS3 Image Values
enum ObjectFit : uint8_t {
    ObjectFitFill, ObjectFitContain, ObjectFitCover, ObjectFitNone, ObjectFitScaleDown
};

enum class AspectRatioType : uint8_t {
    Auto,
    Ratio,
    AutoAndRatio,
    AutoZero
};

enum class WordBreak : uint8_t {
    Normal,
    BreakAll,
    KeepAll,
    BreakWord
};

enum class OverflowWrap : uint8_t {
    Normal,
    BreakWord,
    Anywhere
};

enum ENBSPMode : uint8_t {
    NBNORMAL, SPACE
};

enum class LineBreak : uint8_t {
    Auto,
    Loose,
    Normal,
    Strict,
    AfterWhiteSpace,
    Anywhere
};

enum EResize : uint8_t {
    RESIZE_NONE, RESIZE_BOTH, RESIZE_HORIZONTAL, RESIZE_VERTICAL
};

// The order of this enum must match the order of the list style types in CSSValueKeywords.in.
enum EListStyleType {
    Disc,
    Circle,
    Square,
    DecimalListStyle,
    DecimalLeadingZero,
    ArabicIndic,
    BinaryListStyle,
    Bengali,
    Cambodian,
    Khmer,
    Devanagari,
    Gujarati,
    Gurmukhi,
    Kannada,
    LowerHexadecimal,
    Lao,
    Malayalam,
    Mongolian,
    Myanmar,
    Octal,
    Oriya,
    Persian,
    Urdu,
    Telugu,
    Tibetan,
    Thai,
    UpperHexadecimal,
    LowerRoman,
    UpperRoman,
    LowerGreek,
    LowerAlpha,
    LowerLatin,
    UpperAlpha,
    UpperLatin,
    Afar,
    EthiopicHalehameAaEt,
    EthiopicHalehameAaEr,
    Amharic,
    EthiopicHalehameAmEt,
    AmharicAbegede,
    EthiopicAbegedeAmEt,
    CjkEarthlyBranch,
    CjkHeavenlyStem,
    Ethiopic,
    EthiopicHalehameGez,
    EthiopicAbegede,
    EthiopicAbegedeGez,
    HangulConsonant,
    Hangul,
    LowerNorwegian,
    Oromo,
    EthiopicHalehameOmEt,
    Sidama,
    EthiopicHalehameSidEt,
    Somali,
    EthiopicHalehameSoEt,
    Tigre,
    EthiopicHalehameTig,
    TigrinyaEr,
    EthiopicHalehameTiEr,
    TigrinyaErAbegede,
    EthiopicAbegedeTiEr,
    TigrinyaEt,
    EthiopicHalehameTiEt,
    TigrinyaEtAbegede,
    EthiopicAbegedeTiEt,
    UpperGreek,
    UpperNorwegian,
    Asterisks,
    Footnotes,
    Hebrew,
    Armenian,
    LowerArmenian,
    UpperArmenian,
    Georgian,
    CJKIdeographic,
    Hiragana,
    Katakana,
    HiraganaIroha,
    KatakanaIroha,
    NoneListStyle
};

enum QuoteType : uint8_t {
    OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
};

enum EAnimationFillMode : uint8_t { AnimationFillModeNone, AnimationFillModeForwards, AnimationFillModeBackwards, AnimationFillModeBoth };

enum EAnimPlayState : uint8_t {
    AnimPlayStatePlaying = 0x0,
    AnimPlayStatePaused = 0x1
};

enum class WhiteSpace : uint8_t {
    Normal,
    Pre,
    PreWrap,
    PreLine,
    NoWrap,
    KHTMLNoWrap,
    BreakSpaces
};

// The order of this enum must match the order of the text align values in CSSValueKeywords.in.
enum class TextAlignMode : uint8_t {
    Left,
    Right,
    Center,
    Justify,
    WebKitLeft,
    WebKitRight,
    WebKitCenter,
    Start,
    End,
};

enum ETextTransform : uint8_t {
    CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
};

static const size_t TextDecorationBits = 4;
enum TextDecoration : uint8_t {
    TextDecorationNone = 0x0 ,
	TextDecorationUnderline = 0x1,
	TextDecorationOverline = 0x2,
	TextDecorationLineThrough= 0x4,
	TextDecorationBlink = 0x8
};
inline TextDecoration operator|(TextDecoration a, TextDecoration b) { return TextDecoration(int(a) | int(b)); }
inline TextDecoration& operator|=(TextDecoration& a, TextDecoration b) { return a = a | b; }

enum TextDecorationStyle : uint8_t {
    TextDecorationStyleSolid,
    TextDecorationStyleDouble,
    TextDecorationStyleDotted,
    TextDecorationStyleDashed,
    TextDecorationStyleWavy
};

enum TextAlignLast : uint8_t {
    TextAlignLastAuto, TextAlignLastStart, TextAlignLastEnd, TextAlignLastLeft, TextAlignLastRight, TextAlignLastCenter, TextAlignLastJustify
};

enum class TextUnderlinePosition : uint8_t {
    // FIXME: Implement support for 'under left' and 'under right' values.
    Auto,
    Under,
    FromFont
};

enum TextJustify : uint8_t {
    TextJustifyAuto, TextJustifyNone, TextJustifyInterWord, TextJustifyDistribute
};

enum TextZoom : uint8_t {
    TextZoomNormal, TextZoomReset
};

enum TextDecorationSkipItems : uint8_t {
    TextDecorationSkipNone = 0,
    TextDecorationSkipInk = 1 << 0,
    TextDecorationSkipObjects = 1 << 1,
    TextDecorationSkipAuto = 1 << 2
};
typedef unsigned TextDecorationSkip;

enum BreakBetween : uint8_t {
    AutoBreakBetween, AvoidBreakBetween, AvoidColumnBreakBetween, AvoidPageBreakBetween, ColumnBreakBetween, PageBreakBetween, LeftPageBreakBetween, RightPageBreakBetween, RectoPageBreakBetween, VersoPageBreakBetween
};
bool alwaysPageBreak(BreakBetween);

enum BreakInside : uint8_t {
    AutoBreakInside, AvoidBreakInside, AvoidColumnBreakInside, AvoidPageBreakInside
};

enum HangingPunctuation : uint8_t {
    NoHangingPunctuation = 0,
    FirstHangingPunctuation = 1 << 0,
    LastHangingPunctuation = 1 << 1,
    AllowEndHangingPunctuation = 1 << 2,
    ForceEndHangingPunctuation = 1 << 3
};
inline HangingPunctuation operator| (HangingPunctuation a, HangingPunctuation b) { return HangingPunctuation(int(a) | int(b)); }
inline HangingPunctuation& operator|= (HangingPunctuation& a, HangingPunctuation b) { return a = a | b; }

enum EEmptyCell : uint8_t {
    SHOW, HIDE
};

enum ECaptionSide : uint8_t {
    CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT
};

enum EListStylePosition : uint8_t { OUTSIDE, INSIDE };

enum EVisibility : uint8_t { VISIBLE, HIDDEN, COLLAPSE };

enum ECursor : uint8_t {
    // The following must match the order in CSSValueKeywords.in.
    CURSOR_AUTO,
    CURSOR_DEFAULT,
    CURSOR_CONTEXT_MENU,
    CURSOR_HELP,
    CURSOR_POINTER,
    CURSOR_PROGRESS,
    CURSOR_WAIT,
    CURSOR_CELL,
    CURSOR_CROSS,
    CURSOR_TEXT,
    CURSOR_VERTICAL_TEXT,
    CURSOR_ALIAS,
    CURSOR_MOVE,
    CURSOR_NO_DROP,
    CURSOR_NOT_ALLOWED,
    CURSOR_GRAB,
    CURSOR_GRABBING,
    CURSOR_E_RESIZE,
    CURSOR_N_RESIZE,
    CURSOR_NE_RESIZE,
    CURSOR_NW_RESIZE,
    CURSOR_S_RESIZE,
    CURSOR_SE_RESIZE,
    CURSOR_SW_RESIZE,
    CURSOR_W_RESIZE,
    CURSOR_EW_RESIZE,
    CURSOR_NS_RESIZE,
    CURSOR_NESW_RESIZE,
    CURSOR_NWSE_RESIZE,
    CURSOR_COL_RESIZE,
    CURSOR_ROW_RESIZE,
    CURSOR_ALL_SCROLL,
    CURSOR_ZOOM_IN,
    CURSOR_ZOOM_OUT,

    // The following are handled as exceptions so don't need to match.
    CURSOR_COPY,
    CURSOR_NONE
};

// The order of this enum must match the order of the display values in CSSValueKeywords.in.
enum class DisplayType : uint8_t {
    Inline,
    Block,
    ListItem,
    Compact,
    InlineBlock,
    Table,
    InlineTable,
    TableRowGroup,
    TableHeaderGroup,
    TableFooterGroup,
    TableRow,
    TableColumnGroup,
    TableColumn,
    TableCell,
    TableCaption,
    Box,
    InlineBox,
    Flex,
    WebKitFlex,
    InlineFlex,
    WebKitInlineFlex,
    Contents,
    Grid,
    InlineGrid,
    FlowRoot,
    Ruby,
    RubyBlock,
    RubyBase,
    RubyAnnotation,
    None
};

enum EInsideLink : uint8_t {
    NotInsideLink, InsideUnvisitedLink, InsideVisitedLink
};
    
enum EPointerEvents : uint8_t {
    PE_NONE, PE_AUTO, PE_STROKE, PE_FILL, PE_PAINTED, PE_VISIBLE,
    PE_VISIBLE_STROKE, PE_VISIBLE_FILL, PE_VISIBLE_PAINTED, PE_ALL
};

enum ETransformStyle3D : uint8_t {
    TransformStyle3DFlat, TransformStyle3DPreserve3D
};

enum EBackfaceVisibility : uint8_t {
    BackfaceVisibilityVisible, BackfaceVisibilityHidden
};

enum class TransformBox : uint8_t {
    StrokeBox,
    ContentBox,
    BorderBox,
    FillBox,
    ViewBox
};

enum ELineClampType : uint8_t { LineClampLineCount, LineClampPercentage };

enum Hyphens : uint8_t { HyphensNone, HyphensManual, HyphensAuto };

enum ESpeak : uint8_t { SpeakNone, SpeakNormal, SpeakSpellOut, SpeakDigits, SpeakLiteralPunctuation, SpeakNoPunctuation };

enum TextEmphasisFill : uint8_t { TextEmphasisFillFilled, TextEmphasisFillOpen };

enum TextEmphasisMark : uint8_t { TextEmphasisMarkNone, TextEmphasisMarkAuto, TextEmphasisMarkDot, TextEmphasisMarkCircle, TextEmphasisMarkDoubleCircle, TextEmphasisMarkTriangle, TextEmphasisMarkSesame, TextEmphasisMarkCustom };

enum TextEmphasisPositions : uint8_t {
    TextEmphasisPositionOver = 1 << 0,
    TextEmphasisPositionUnder = 1 << 1,
    TextEmphasisPositionLeft = 1 << 2,
    TextEmphasisPositionRight = 1 << 3
};
typedef unsigned TextEmphasisPosition;

enum class TextOrientation : uint8_t { Mixed, Upright, Sideways, SidewaysRight };

enum TextOverflow : uint8_t { TextOverflowClip = 0, TextOverflowEllipsis };

enum EImageRendering : uint8_t { ImageRenderingAuto, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingOptimizeContrast };

enum ImageResolutionSource : uint8_t { ImageResolutionSpecified = 0, ImageResolutionFromImage };

enum ImageResolutionSnap : uint8_t { ImageResolutionNoSnap = 0, ImageResolutionSnapPixels };

enum Order : uint8_t { LogicalOrder = 0, VisualOrder };

enum ColumnAxis : uint8_t { HorizontalColumnAxis, VerticalColumnAxis, AutoColumnAxis };

enum ColumnProgression : uint8_t { NormalColumnProgression, ReverseColumnProgression };

enum LineSnap : uint8_t { LineSnapNone, LineSnapBaseline, LineSnapContain };

enum LineAlign : uint8_t { LineAlignNone, LineAlignEdges };

enum RubyPosition : uint8_t { RubyPositionBefore, RubyPositionAfter, RubyPositionInterCharacter };

static const size_t GridAutoFlowBits = 4;
enum InternalGridAutoFlowAlgorithm : uint8_t {
    InternalAutoFlowAlgorithmSparse = 0x1,
    InternalAutoFlowAlgorithmDense = 0x2,
};

enum InternalGridAutoFlowDirection : uint8_t {
    InternalAutoFlowDirectionRow = 0x4,
    InternalAutoFlowDirectionColumn = 0x8
};

enum GridAutoFlow : uint8_t {
    AutoFlowRow = InternalAutoFlowAlgorithmSparse | InternalAutoFlowDirectionRow,
    AutoFlowColumn = InternalAutoFlowAlgorithmSparse | InternalAutoFlowDirectionColumn,
    AutoFlowRowDense = InternalAutoFlowAlgorithmDense | InternalAutoFlowDirectionRow,
    AutoFlowColumnDense = InternalAutoFlowAlgorithmDense | InternalAutoFlowDirectionColumn
};

enum AutoRepeatType : uint8_t {
    NoAutoRepeat,
    AutoFill,
    AutoFit
};

#if USE(FREETYPE)
// The maximum allowed font size is 32767 because `hb_position_t` is `int32_t`,
// where the first 16 bits are used to represent the integer part which effectively makes it `signed short`
static const float maximumAllowedFontSize = std::numeric_limits<short>::max();
#else
// Reasonable maximum to prevent insane font sizes from causing crashes on some platforms (such as Windows).
static const float maximumAllowedFontSize = 1000000.0f;
#endif

enum Isolation : uint8_t { IsolationAuto, IsolationIsolate };

enum TextIndentLine : uint8_t { TextIndentFirstLine, TextIndentEachLine };
enum TextIndentType : uint8_t { TextIndentNormal, TextIndentHanging };

// Fill, Stroke, ViewBox are just used for SVG.
enum class CSSBoxType : uint8_t {
    BoxMissing = 0,
    MarginBox,
    BorderBox,
    PaddingBox,
    ContentBox,
    FillBox,
    StrokeBox,
    ViewBox
};

#if ENABLE(CSS_SCROLL_SNAP)
enum class ScrollSnapStrictness : uint8_t {
    None,
    Proximity,
    Mandatory
};

enum class ScrollSnapAxis : uint8_t {
    XAxis,
    YAxis,
    Block,
    Inline,
    Both
};

enum class ScrollSnapAxisAlignType : uint8_t {
    None,
    Start,
    Center,
    End
};
#endif

// These are all minimized combinations of paint-order.
enum class PaintOrder : uint8_t {
    Normal,
    Fill,
    FillMarkers,
    Stroke,
    StrokeMarkers,
    Markers,
    MarkersStroke
};

enum class PaintType : uint8_t {
    Fill,
    Stroke,
    Markers
};

enum class FontLoadingBehavior : uint8_t {
    Auto, Block, Swap, Fallback, Optional
};

enum class EventListenerRegionType : uint8_t {
    Wheel           = 1 << 0,
    NonPassiveWheel = 1 << 1,
    MouseClick      = 1 << 2,
};

enum class MathStyle : uint8_t {
    Normal,
    Compact,
};

enum class Containment : uint8_t {
    Layout      = 1 << 0,
    Paint       = 1 << 1,
    Size        = 1 << 2,
    InlineSize  = 1 << 3,
    Style       = 1 << 4,
};

enum class ContainerType : uint8_t {
    None,
    Size,
    InlineSize,
};

enum class ContainIntrinsicSizeType : uint8_t {
    None,
    Length,
    AutoAndLength
};

enum class ContentVisibility : uint8_t {
    Visible,
    Auto,
    Hidden,
};

CSSBoxType transformBoxToCSSBoxType(TransformBox);

extern const float defaultMiterLimit;

TextStream& operator<<(TextStream&, EFillSizeType);
TextStream& operator<<(TextStream&, EFillAttachment);
TextStream& operator<<(TextStream&, EFillBox);
TextStream& operator<<(TextStream&, EFillRepeat);
TextStream& operator<<(TextStream&, MaskMode);
TextStream& operator<<(TextStream&, Edge);

} // namespace WebCore
