/// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var list = value as CSSValueList;
            var v1 = value;
            var v2 = value;

            if (list != null)
            {
                if (list.Length != 2)
                    return false;

                v1 = list[0];
                v2 = list[1];
            }

            var c1 = v1.AsCalc();
            var c2 = v2.AsCalc();

            if (c1 != null && c2 != null)
            {
                _h = c1;
                _v = c2;
            }
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
 internal CSSPerspectiveOriginProperty()
     : base(PropertyNames.PerspectiveOrigin)
 {
     _inherited = false;
     _x = CSSCalcValue.Center;
     _y = CSSCalcValue.Center;
 }
 internal CSSBorderRadiusPartProperty(String name)
     : base(name)
 {
     _inherited = false;
     _h = CSSCalcValue.Zero;
     _v = CSSCalcValue.Zero;
 }
 internal CSSFontSizeProperty()
     : base(PropertyNames.FontSize)
 {
     _mode = FontSize.Medium;
     _size = null;
     _inherited = true;
 }
 internal CSSTransformOriginProperty()
     : base(PropertyNames.TransformOrigin)
 {
     _inherited = false;
     _x = CSSCalcValue.Center;
     _y = CSSCalcValue.Center;
     _z = CSSCalcValue.Zero;
 }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var calc = value.AsCalc();

            if (calc != null)
                _mode = calc;
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
 internal CSSBorderRadiusProperty()
     : base(PropertyNames.BorderRadius)
 {
     _inherited = false;
     _topRightHorizontal = CSSCalcValue.Zero;
     _bottomRightHorizontal = CSSCalcValue.Zero;
     _bottomLeftHorizontal = CSSCalcValue.Zero;
     _topLeftHorizontal = CSSCalcValue.Zero;
     _topRightVertical = CSSCalcValue.Zero;
     _bottomRightVertical = CSSCalcValue.Zero;
     _bottomLeftVertical = CSSCalcValue.Zero;
     _topLeftVertical = CSSCalcValue.Zero;
 }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            //TODO
            //UNITLESS in QUIRKSMODE
            var calc = value.AsCalc();

            if (calc != null)
                _value = calc;
            else if (value.Is("auto"))
                _value = null;
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
示例#9
0
        protected override Boolean IsValid(CSSValue value)
        {
            //TODO
            //UNITLESS in QUIRKSMODE
            var calc = value.AsCalc();

            if (calc != null)
            {
                _margin = calc;
            }
            else if (value.Is("auto"))
            {
                _margin = null;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            //TODO
            //UNITLESS in QUIRKSMODE
            FontSize? size;
            var calc = value.AsCalc();

            if (calc != null)
            {
                _size = calc;
                _mode = FontSize.Custom;
            }
            else if ((size = value.ToFontSize()).HasValue)
            {
                _size = null;
                _mode = size.Value;
            }
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
        protected override Boolean IsValid(CSSValue value)
        {
            //TODO
            //UNITLESS in QUIRKSMODE
            FontSizeMode size;
            CSSCalcValue calc = value.AsCalc();

            if (calc != null)
            {
                _size = new CalcFontSizeMode(calc);
            }
            else if (value is CSSIdentifierValue && _sizes.TryGetValue(((CSSIdentifierValue)value).Value, out size))
            {
                _size = size;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
示例#12
0
        protected override Boolean IsValid(CSSValue value)
        {
            CSSCalcValue calc = value.AsCalc();

            if (calc != null)
            {
                _mode = new CalcLineHeightMode(calc);
            }
            else if (value.Is("normal"))
            {
                _mode = _normal;
            }
            else if (value.ToNumber().HasValue)
            {
                _mode = new MultipleLineHeightMode(value.ToNumber().Value);
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
        Boolean SetXY(CSSValueList list)
        {
            if (list.Length == 2)
            {
                var x = GetMode(list[0], "left", "right");
                var y = GetMode(list[1], "top", "bottom");

                if (y == null || x == null)
                {
                    x = GetMode(list[1], "left", "right");
                    y = GetMode(list[0], "top", "bottom");
                }

                if (x != null && y != null)
                {
                    _x = x;
                    _y = y;
                    return(true);
                }
            }

            return(false);
        }
示例#14
0
        Boolean SetXYZ(CSSValueList list)
        {
            var z = CSSCalcValue.Zero;

            if (list.Length == 3)
            {
                if (!list[2].ToLength().HasValue)
                {
                    return(false);
                }

                z = list[2].AsCalc();
            }

            if (z != CSSCalcValue.Zero || list.Length == 2)
            {
                var x = GetMode(list[0], "left", "right");
                var y = GetMode(list[1], "top", "bottom");

                if (y == null || x == null)
                {
                    x = GetMode(list[1], "left", "right");
                    y = GetMode(list[0], "top", "bottom");
                }

                if (x != null && y != null)
                {
                    _x = x;
                    _y = y;
                    _z = z;
                    return(true);
                }
            }

            return(false);
        }
示例#15
0
 protected CSSMarginPartProperty(String name)
     : base(name)
 {
     _inherited = false;
     _margin    = CSSCalcValue.Zero;
 }
        Boolean SetSingle(CSSValue value)
        {
            var calc = value.AsCalc();

            if (calc != null)
            {
                _x = calc;
                _y = calc;
                return true;
            }
            else if (value is CSSIdentifierValue)
            {
                var ident = ((CSSIdentifierValue)value).Value;

                switch (ident.ToLower())
                {
                    case "left":
                        _x = CSSCalcValue.Zero;
                        _y = CSSCalcValue.Center;
                        return true;

                    case "center":
                        _x = CSSCalcValue.Center;
                        _y = CSSCalcValue.Center;
                        return true;

                    case "right":
                        _x = CSSCalcValue.Full;
                        _y = CSSCalcValue.Center;
                        return true;

                    case "top":
                        _x = CSSCalcValue.Center;
                        _y = CSSCalcValue.Zero;
                        return true;

                    case "bottom":
                        _x = CSSCalcValue.Center;
                        _y = CSSCalcValue.Full;
                        return true;
                }
            }

            return false;
        }
示例#17
0
 public CalcCoordinateMode(CSSCalcValue calc)
 {
     _calc = calc;
 }
示例#18
0
 internal CSSMinWidthProperty()
     : base(PropertyNames.MinWidth)
 {
     _inherited = false;
     _mode      = CSSCalcValue.Zero;
 }
示例#19
0
 internal CSSTextIndentProperty()
     : base(PropertyNames.TextIndent)
 {
     _inherited = true;
     _indent    = CSSCalcValue.Zero;
 }
示例#20
0
 protected CSSPaddingPartProperty(String name)
     : base(name)
 {
     _inherited = false;
     _padding   = CSSCalcValue.Zero;
 }
示例#21
0
 public RadialLinearGradient(CSSCalcValue x, CSSCalcValue y, CSSCalcValue width, CSSCalcValue height, GradientStop[] stops, Boolean repeating)
 {
     _stops = stops;
     _x = x;
     _y = y;
     _width = width;
     _height = height;
     _repeating = repeating;
 }
示例#22
0
 internal CSSMaxHeightProperty()
     : base(PropertyNames.MaxHeight)
 {
     _inherited = false;
     _mode      = null;
 }
 internal CSSCoordinateProperty(String name)
     : base(name)
 {
     _inherited = false;
     _value = null;
 }
        Boolean Check(CSSValueList arguments)
        {
            var count = arguments.Length;
            var splitIndex = arguments.Length;

            for (var i = 0; i < splitIndex; i++)
                if (arguments[i] == CSSValue.Delimiter)
                    splitIndex = i;

            if (count - 1 > splitIndex + 4 || splitIndex > 4 || splitIndex == count - 1 || splitIndex == 0)
                return false;

            var values = new CSSCalcValue[4];

            for (int i = 0; i < splitIndex; i++)
            {
                values[i] = arguments[i].AsCalc();

                for (int j = 2 * i + 1; j < 4; j += i + 1)
                    values[j] = values[i];

                if (values[i] == null)
                    return false;
            }

            _topLeftHorizontal = values[0];
            _topRightHorizontal = values[1];
            _bottomRightHorizontal = values[2];
            _bottomLeftHorizontal = values[3];

            if (splitIndex != count)
            {
                splitIndex++;
                count -= splitIndex;

                for (int i = 0; i < count; i++)
                {
                    values[i] = arguments[i + splitIndex].AsCalc();

                    for (int j = 2 * i + 1; j < 4; j += i + 1)
                        values[j] = values[i];

                    if (values[i] == null)
                        return false;
                }
            }

            _topLeftVertical = values[0];
            _topRightVertical = values[1];
            _bottomRightVertical = values[2];
            _bottomLeftVertical = values[3];

            return true;
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            if (value == CSSValue.Inherit)
                return true;
            else if (value is CSSValueList)
                return Check((CSSValueList)value);

            var calc = value.AsCalc();

            if (calc == null)
                return false;

            _bottomLeftHorizontal = _bottomLeftVertical = _bottomRightHorizontal = _bottomRightVertical = _topLeftHorizontal = _topLeftVertical = _topRightHorizontal = _topRightVertical = calc;
            return true;
        }
示例#26
0
 /// <summary>
 /// Creates a new gradient stop.
 /// </summary>
 /// <param name="color">The color of the stop.</param>
 /// <param name="location">The location of the stop.</param>
 public GradientStop(Color color, CSSCalcValue location)
 {
     _color = color;
     _location = location;
 }
示例#27
0
 public CalcLineHeightMode(CSSCalcValue calc)
 {
     _calc = calc;
 }
 internal CSSMinHeightProperty()
     : base(PropertyNames.MinHeight)
 {
     _inherited = false;
     _mode = CSSCalcValue.Zero;
 }
 /// <summary>
 /// The auto keyword that scales the background image in the corresponding
 /// direction such that its intrinsic proportion is maintained.
 /// </summary>
 public CalcSizeMode(CSSCalcValue width = null, CSSCalcValue height = null)
 {
     _width  = width;
     _height = height;
 }
 internal CSSMaxHeightProperty()
     : base(PropertyNames.MaxHeight)
 {
     _inherited = false;
     _mode = null;
 }
示例#31
0
 public CalcFontSizeMode(CSSCalcValue calc)
 {
     _calc = calc;
 }
 /// <summary>
 /// The auto keyword that scales the background image in the corresponding
 /// direction such that its intrinsic proportion is maintained.
 /// </summary>
 public CalcSizeMode(CSSCalcValue width = null, CSSCalcValue height = null)
 {
     _width = width;
     _height = height;
 }
 public CalcImageWidthMode(CSSCalcValue calc)
 {
     _calc = calc;
 }
        Boolean SetXY(CSSValueList list)
        {
            if (list.Length == 2)
            {
                var x = GetMode(list[0], "left", "right");
                var y = GetMode(list[1], "top", "bottom");

                if (y == null || x == null)
                {
                    x = GetMode(list[1], "left", "right");
                    y = GetMode(list[0], "top", "bottom");
                }

                if (x != null && y != null)
                {
                    _x = x;
                    _y = y;
                    return true;
                }
            }

            return false;
        }
示例#35
0
 /// <summary>
 /// Creates a new image value from a radial gradient.
 /// </summary>
 /// <param name="x">The x-coordinate.</param>
 /// <param name="y">The y-coordinate.</param>
 /// <param name="width">The width of the ellipse.</param>
 /// <param name="height">The height of the ellipse.</param>
 /// <param name="repeating">The repeating setting.</param>
 /// <param name="stops">A collection of stops to use.</param>
 /// <returns>A new image value using a radial gradient.</returns>
 public static CSSImageValue FromRadialGradient(CSSCalcValue x, CSSCalcValue y, CSSCalcValue width, CSSCalcValue height, Boolean repeating, params GradientStop[] stops)
 {
     return new RadialLinearGradient(x, y, width, height, stops, repeating);
 }
 public CalcImageWidthMode(CSSCalcValue calc)
 {
     _calc = calc;
 }
示例#37
0
 internal CSSMaxWidthProperty()
     : base(PropertyNames.MaxWidth)
 {
     _inherited = false;
     _mode      = null;
 }
        Boolean SetXYZ(CSSValueList list)
        {
            var z = CSSCalcValue.Zero;

            if (list.Length == 3)
            {
                if (!list[2].ToLength().HasValue)
                    return false;

                z = list[2].AsCalc();
            }

            if (z != CSSCalcValue.Zero || list.Length == 2)
            {
                var x = GetMode(list[0], "left", "right");
                var y = GetMode(list[1], "top", "bottom");

                if (y == null || x == null)
                {
                    x = GetMode(list[1], "left", "right");
                    y = GetMode(list[0], "top", "bottom");
                }

                if (x != null && y != null)
                {
                    _x = x;
                    _y = y;
                    _z = z;
                    return true;
                }
            }

            return false;
        }