static Boolean Check(CSSValue value, ref Position position)
        {
            var calc = value.AsCalc();

            if (calc != null)
            {
                position.X = calc;
            }
            else if (value.Is("left"))
            {
                position.X = CSSCalcValue.Zero;
            }
            else if (value.Is("right"))
            {
                position.X = CSSCalcValue.Full;
            }
            else if (value.Is("top"))
            {
                position.Y = CSSCalcValue.Zero;
            }
            else if (value.Is("bottom"))
            {
                position.Y = CSSCalcValue.Full;
            }
            else if (!value.Is("center"))
            {
                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)
        {
            var calc = value.AsCalc();

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

            return true;
        }
        static SizeMode Check(CSSValue horizontal, CSSValue vertical)
        {
            var width = horizontal.AsCalc();
            var height = vertical.AsCalc();

            if (width == null && !horizontal.Is("auto"))
                return null;
            else if (height == null && !vertical.Is("auto"))
                return null;

            return new CalcSizeMode(width, height);
        }
Пример #4
0
        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;
                    _z = CSSCalcValue.Zero;
                    return(true);

                case "center":
                    _x = CSSCalcValue.Center;
                    _y = CSSCalcValue.Center;
                    _z = CSSCalcValue.Zero;
                    return(true);

                case "right":
                    _x = CSSCalcValue.Full;
                    _y = CSSCalcValue.Center;
                    _z = CSSCalcValue.Zero;
                    return(true);

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

                case "bottom":
                    _x = CSSCalcValue.Center;
                    _y = CSSCalcValue.Full;
                    _z = CSSCalcValue.Zero;
                    return(true);
                }
            }

            return(false);
        }
        /// <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;
        }
        static SizeMode Check(CSSValue value)
        {
            var calc = value.AsCalc();

            if (calc != null)
                return new CalcSizeMode(calc);
            else if (value.Is("auto"))
                return _default;
            else if (value.Is("cover"))
                return _cover;
            else if (value.Is("contain"))
                return _contain;

            return null;
        }
Пример #7
0
        protected override Boolean IsValid(CSSValue value)
        {
            var indent = value.AsCalc();

            if (indent != null)
            {
                _indent = indent;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
Пример #8
0
        protected override Boolean IsValid(CSSValue value)
        {
            var calc = value.AsCalc();

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

            return(true);
        }
        static SizeMode Check(CSSValue horizontal, CSSValue vertical)
        {
            var width  = horizontal.AsCalc();
            var height = vertical.AsCalc();

            if (width == null && !horizontal.Is("auto"))
            {
                return(null);
            }
            else if (height == null && !vertical.Is("auto"))
            {
                return(null);
            }

            return(new CalcSizeMode(width, height));
        }
        static ImageWidthMode ToMode(CSSValue value)
        {
            if (value.Is("auto"))
                return _auto;

            var multiple = value.ToNumber();

            if (multiple.HasValue)
                return new MultipleImageWidthMode(multiple.Value);

            var calc = value.AsCalc();

            if (calc != null)
                return new CalcImageWidthMode(calc);

            return null;
        }
Пример #11
0
        protected override Boolean IsValid(CSSValue value)
        {
            //TODO
            //UNITLESS in QUIRKSMODE
            var calc = value.AsCalc();

            if (calc != null)
            {
                _padding = calc;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
        static CSSCalcValue GetMode(CSSValue value, String minIdentifier, String maxIdentifier)
        {
            var calc = value.AsCalc();

            if (calc == null && value is CSSIdentifierValue)
            {
                var ident = ((CSSIdentifierValue)value).Value;

                if (minIdentifier.Equals(ident, StringComparison.OrdinalIgnoreCase))
                    calc = CSSCalcValue.Zero;
                else if (maxIdentifier.Equals(ident, StringComparison.OrdinalIgnoreCase))
                    calc = CSSCalcValue.Full;
                else if ("center".Equals(ident, StringComparison.OrdinalIgnoreCase))
                    calc = CSSCalcValue.Center;
            }

            return calc;
        }
Пример #13
0
        protected override Boolean IsValid(CSSValue value)
        {
            var calc = value.AsCalc();

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

            return(true);
        }
        protected override Boolean IsValid(CSSValue value)
        {
            var calc = value.AsCalc();

            if (calc != null)
            {
                _top = _bottom = _right = _left = calc;
            }
            else if (value is CSSValueList)
            {
                return(Evaluate((CSSValueList)value));
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
Пример #15
0
        protected override Boolean IsValid(CSSValue value)
        {
            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);
        }
Пример #16
0
        /// <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;
        }
        static SizeMode Check(CSSValue value)
        {
            var calc = value.AsCalc();

            if (calc != null)
            {
                return(new CalcSizeMode(calc));
            }
            else if (value.Is("auto"))
            {
                return(_default);
            }
            else if (value.Is("cover"))
            {
                return(_cover);
            }
            else if (value.Is("contain"))
            {
                return(_contain);
            }

            return(null);
        }
Пример #18
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);
        }
        static ImageWidthMode ToMode(CSSValue value)
        {
            if (value.Is("auto"))
            {
                return(_auto);
            }

            var multiple = value.ToNumber();

            if (multiple.HasValue)
            {
                return(new MultipleImageWidthMode(multiple.Value));
            }

            var calc = value.AsCalc();

            if (calc != null)
            {
                return(new CalcImageWidthMode(calc));
            }

            return(null);
        }
        static CSSCalcValue GetMode(CSSValue value, String minIdentifier, String maxIdentifier)
        {
            var calc = value.AsCalc();

            if (calc == null && value is CSSIdentifierValue)
            {
                var ident = ((CSSIdentifierValue)value).Value;

                if (minIdentifier.Equals(ident, StringComparison.OrdinalIgnoreCase))
                {
                    calc = CSSCalcValue.Zero;
                }
                else if (maxIdentifier.Equals(ident, StringComparison.OrdinalIgnoreCase))
                {
                    calc = CSSCalcValue.Full;
                }
                else if ("center".Equals(ident, StringComparison.OrdinalIgnoreCase))
                {
                    calc = CSSCalcValue.Center;
                }
            }

            return(calc);
        }
        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;
        }
        /// <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;
        }
        static Boolean Check(CSSValue left, CSSValue right, ref Position position)
        {
            var horizontal = left.AsCalc();
            var vertical   = right.AsCalc();

            if (horizontal == null)
            {
                if (left.Is("left"))
                {
                    horizontal = CSSCalcValue.Zero;
                }
                else if (left.Is("right"))
                {
                    horizontal = CSSCalcValue.Full;
                }
                else if (left.Is("center"))
                {
                    horizontal = CSSCalcValue.Center;
                }
                else if (left.Is("top"))
                {
                    horizontal = vertical;
                    vertical   = CSSCalcValue.Zero;
                }
                else if (left.Is("bottom"))
                {
                    horizontal = vertical;
                    vertical   = CSSCalcValue.Full;
                }
            }

            if (vertical == null)
            {
                if (right.Is("top"))
                {
                    vertical = CSSCalcValue.Zero;
                }
                else if (right.Is("bottom"))
                {
                    vertical = CSSCalcValue.Full;
                }
                else if (right.Is("center"))
                {
                    vertical = CSSCalcValue.Center;
                }
                else if (right.Is("left"))
                {
                    vertical   = horizontal;
                    horizontal = CSSCalcValue.Zero;
                }
                else if (right.Is("right"))
                {
                    vertical   = horizontal;
                    horizontal = CSSCalcValue.Full;
                }
            }

            if (horizontal == null || vertical == null)
            {
                return(false);
            }

            position.X = horizontal;
            position.Y = vertical;
            return(true);
        }