示例#1
0
        public static Length?ToBorderWidth(this CSSValue value)
        {
            if (value is CSSPrimitiveValue <Length> )
            {
                return(((CSSPrimitiveValue <Length>)value).Value);
            }
            else if (value is CSSPrimitiveValue <Number> && ((CSSPrimitiveValue <Number>)value).Value == Number.Zero)
            {
                return(Length.Zero);
            }
            else if (value.Is("thin"))
            {
                return(Length.Thin);
            }
            else if (value.Is("medium"))
            {
                return(Length.Medium);
            }
            else if (value.Is("thick"))
            {
                return(Length.Thick);
            }

            return(null);
        }
示例#2
0
        static SizeMode?Check(CSSValue value)
        {
            var distance = value.ToDistance();

            if (distance != null)
            {
                return new SizeMode {
                           Width = distance
                }
            }
            ;
            else if (value.Is(Keywords.Auto))
            {
                return new SizeMode {
                }
            }
            ;
            else if (value.Is(Keywords.Cover))
            {
                return new SizeMode {
                           IsCovered = true
                }
            }
            ;
            else if (value.Is(Keywords.Contain))
            {
                return new SizeMode {
                           IsContained = true
                }
            }
            ;

            return(null);
        }
示例#3
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)
        {
            if (value.Is(Keywords.Normal))
            {
                _mode = _normal;
            }
            else if (value.Is(Keywords.None))
            {
                _mode = null;
            }
            else if (value is CSSValueList)
            {
                return(Evaluate((CSSValueList)value));
            }
            else
            {
                var mode = Evaluate(value);

                if (mode == null)
                {
                    return(false);
                }

                _mode = mode;
            }

            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.Is(Keywords.Flat))
                _flat = true;
            else if (value.Is(Keywords.Preserve3d))
                _flat = false;
            else
                return false;

            return true;
        }
示例#5
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)
        {
            if (value.Is(Keywords.Slice))
            {
                _clone = false;
            }
            else if (value.Is(Keywords.Clone))
            {
                _clone = true;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#6
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)
        {
            if (value.Is(Keywords.Ltr))
            {
                _mode = DirectionMode.Ltr;
            }
            else if (value.Is(Keywords.Rtl))
            {
                _mode = DirectionMode.Rtl;
            }
            else
            {
                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)
        {
            if (value.Is(Keywords.Show))
            {
                _visible = true;
            }
            else if (value.Is(Keywords.Hide))
            {
                _visible = false;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#8
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)
        {
            if (value.Is(Keywords.Fixed))
            {
                _fixed = true;
            }
            else if (value.Is(Keywords.Auto))
            {
                _fixed = false;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#9
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)
        {
            if (value.Is(Keywords.Separate))
            {
                _separate = true;
            }
            else if (value.Is(Keywords.Collapse))
            {
                _separate = false;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#10
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)
        {
            if (value.Is(Keywords.Top))
            {
                _top = true;
            }
            else if (value.Is(Keywords.Bottom))
            {
                _top = false;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#11
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)
        {
            if (value.Is(Keywords.Auto))
            {
                _mode = BreakMode.Auto;
            }
            else if (value.Is(Keywords.Avoid))
            {
                _mode = BreakMode.Avoid;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#12
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)
        {
            //Is a keyword indicating that columns are filled sequentially.
            if (value.Is(Keywords.Auto))
            {
                _balanced = false;
            }
            //Is a keyword indicating that content is equally divided between columns.
            else if (value.Is(Keywords.Balance))
            {
                _balanced = true;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#13
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)
        {
            //The element does not span multiple columns.
            if (value.Is(Keywords.None))
            {
                _span = false;
            }
            //The element spans across all columns.
            else if (value.Is(Keywords.All))
            {
                _span = true;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#14
0
        public static CSSImageValue AsImage(this CSSValue value)
        {
            if (value is CSSImageValue)
            {
                return((CSSImageValue)value);
            }
            else if (value is CSSPrimitiveValue <Location> )
            {
                return(CSSImageValue.FromUrl(((CSSPrimitiveValue <Location>)value).Value));
            }
            else if (value.Is("none"))
            {
                return(CSSImageValue.None);
            }

            return(null);
        }
        /// <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.Is(Keywords.None))
            {
                _shadows.Clear();
            }
            else if (value is CSSValueList)
            {
                return(Evaluate((CSSValueList)value));
            }
            else
            {
                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)
        {
            if (value.Is(Keywords.Normal))
            {
                _spacing = null;
            }
            else if (value.ToLength().HasValue)
            {
                _spacing = value.ToLength();
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#17
0
        static SizeMode?Check(CSSValue horizontal, CSSValue vertical)
        {
            var width  = horizontal.ToDistance();
            var height = vertical.ToDistance();

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

            return(new SizeMode {
                Width = width, Height = height
            });
        }
        /// <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 distance = value.ToDistance();

            if (distance != null)
            {
                _value = distance;
            }
            else if (value.Is(Keywords.Auto))
            {
                _value = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#19
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)
        {
            var shape = value.ToShape();

            if (shape != null)
            {
                _shape = shape;
            }
            else if (value.Is(Keywords.Auto))
            {
                _shape = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#20
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)
        {
            var number = value.ToInteger();

            if (number != null)
            {
                _value = number.Value;
            }
            else if (value.Is(Keywords.Auto))
            {
                _value = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#21
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)
        {
            var width = value.ToLength();

            if (width.HasValue)
            {
                _width = width.Value;
            }
            else if (value.Is(Keywords.Auto))
            {
                _width = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#22
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)
        {
            var color = value.ToColor();

            if (color.HasValue)
            {
                _mode = color.Value;
            }
            else if (value.Is(Keywords.Invert))
            {
                _mode = Colors.Invert;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#23
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)
        {
            var gap = value.ToLength();

            if (gap.HasValue)
            {
                _gap = gap.Value;
            }
            else if (value.Is(Keywords.Normal))
            {
                _gap = _normal;
            }
            else
            {
                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 aspectValue = value.ToSingle();

            if (aspectValue.HasValue)
            {
                _aspectValue = aspectValue;
            }
            else if (value.Is(Keywords.None))
            {
                _aspectValue = null;
            }
            else
            {
                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 count = value.ToInteger();

            if (count.HasValue)
            {
                _count = count.Value;
            }
            else if (value.Is(Keywords.Auto))
            {
                _count = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#26
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)
        {
            var distance = value.ToLength();

            if (distance.HasValue)
            {
                _distance = distance.Value;
            }
            //Is a keyword indicating that no perspective transform has to be applied.
            else if (value.Is(Keywords.None))
            {
                _distance = Length.Zero;
            }
            else
            {
                return(false);
            }

            return(true);
        }
        static CSSPrimitiveValue ToNumber(CSSValue value)
        {
            var number = value.ToInteger();

            if (number != null)
            {
                var n = number.Value;

                if (n >= 0)
                {
                    return((CSSPrimitiveValue)value);
                }
            }
            else if (value.Is(Keywords.Infinite))
            {
                return(new CSSPrimitiveValue(Number.Infinite));
            }

            return(null);
        }
示例#28
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)
        {
            if (value.Is(Keywords.None))
            {
                _transforms.Clear();
                return(true);
            }

            var transform = value.ToTransform();

            if (transform != null)
            {
                _transforms.Clear();
                _transforms.Add(transform);
                return(true);
            }

            var list = value as CSSValueList;

            if (list != null)
            {
                var transforms = new ITransform[list.Length];

                for (int i = 0; i < transforms.Length; i++)
                {
                    transforms[i] = list[i].ToTransform();

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

                _transforms.Clear();
                _transforms.AddRange(transforms);
                return(true);
            }

            return(false);
        }
示例#29
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)
        {
            if (value.Is(Keywords.None))
            {
                _quotes.Clear();
            }
            else if (value is CSSValueList)
            {
                var values = (CSSValueList)value;

                if (values.Length % 2 != 0)
                {
                    return(false);
                }

                var quotes = new List <Tuple <String, String> >();

                for (int i = 0; i < values.Length; i += 2)
                {
                    var open  = values[i].ToCssString();
                    var close = values[i + 1].ToCssString();

                    if (open == null || close == null)
                    {
                        return(false);
                    }

                    quotes.Add(Tuple.Create(open, close));
                }

                _quotes = quotes;
            }
            else
            {
                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 mode = value.ToDecorationLine();

            if (mode.HasValue)
            {
                _line.Clear();
                _line.Add(mode.Value);
            }
            else if (value.Is(Keywords.None))
            {
                _line.Clear();
            }
            else if (value is CSSValueList)
            {
                var values = (CSSValueList)value;
                var list   = new List <TextDecorationLine>();

                foreach (var item in values)
                {
                    mode = item.ToDecorationLine();

                    if (mode == null)
                    {
                        return(false);
                    }

                    list.Add(mode.Value);
                }

                _line = list;
            }
            else
            {
                return(false);
            }

            return(true);
        }