Exemplo n.º 1
0
        // transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
        // -webkit-transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;

        public static CssValue PatchValue(CssValue value, Browser browser)
        {
            if (value.Kind != NodeKind.ValueList) return value;

            var a = (CssValueList)value;

            var list = new CssValueList(a.Seperator);

            foreach (var node in a)
            {
                if (node.Kind == NodeKind.ValueList) // For comma seperated componented lists
                {
                    list.Add(PatchValue(node, browser));
                }
                else if (node.Kind == NodeKind.String && node.ToString() == "transform")
                {
                    list.Add(new CssString(browser.Prefix.Text + "transform"));
                }
                else
                {
                    list.Add(node);
                }
            }

            return list;
        }
Exemplo n.º 2
0
        public static CssValue FromComponents(IEnumerable<CssValue> components)
        {
            // A property value can have one or more components.
            // Components are seperated by a space & may include functions, literals, dimensions, etc

            var enumerator = components.GetEnumerator();

            enumerator.MoveNext();

            var first = enumerator.Current;

            if (!enumerator.MoveNext())
            {
                return first;
            }

            var list = new CssValueList(ValueSeperator.Space);

            list.Add(first);
            list.Add(enumerator.Current);

            while (enumerator.MoveNext())
            {
                list.Add(enumerator.Current);
            }

            return list;
        }
Exemplo n.º 3
0
        public IEnumerable<CssFunction> ExpandFor(Browser[] browsers)
        {
            foreach (var browser in browsers)
            {
                var args2 = new CssValueList(ValueSeperator.Comma);

                var i = 0;
                foreach (var arg in args)
                {
                    // The legacy syntax didn't contain to on the direction
                    if (i == 0 && arg.ToString().StartsWith("to "))
                    {
                        args2.Add(CssValue.Parse(arg.ToString().Replace("to ", "")));
                    }
                    else
                    {
                        args2.Add(arg);
                    }

                    i++;
                }

                var name = browser.Prefix.Text + "linear-gradient";

                yield return new CssFunction(name, args2);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Filters font family values
        /// </summary>
        /// <param name="Property"></param>
        /// <returns></returns>
        public static CssValueList Font_Family_Used(ICssProperty Property)
        {
            if (Property == null)
            {
                throw new ArgumentNullException(nameof(Property));
            }
            Contract.EndContractBlock();

#if DISABLE_FONT_SYSTEM
            return(null);
#else
            CssValueList    curValues = (Property as CssMultiValueProperty).Computed;
            List <CssValue> retValues = new List <CssValue>();

            foreach (CssValue val in curValues)
            {
                switch (val.Type)
                {
                case ECssValueType.KEYWORD:
                {        // Replace generic font-family keywords with a list of our fallback font-familys for that family
                    var familyKeyword = val.AsEnum <EGenericFontFamily>();

                    switch (familyKeyword)
                    {
                    case EGenericFontFamily.Serif:
                    case EGenericFontFamily.SansSerif:
                    case EGenericFontFamily.Monospace:
                    case EGenericFontFamily.Cursive:
                    case EGenericFontFamily.Fantasy:
                    {
                        if (FontManager.GenericFamilyMap.TryGetValue(outFamily, out List <CssValue> GenericFontFamilys))
                        {
                            retValues.AddRange(GenericFontFamilys);
                        }
                    }
                    break;

                    default:
                        throw new NotImplementedException($"Unknown font-family keyword '{val.Value.ToString()}'");
                    }
                }
                break;

                case ECssValueType.STRING:
                {        // Remove any invalid font-familys
                    foreach (FontFamily family in SystemFonts.Families)
                    {
                        if (0 == Unicode.CaselessCompare(val.AsString, family.Name))
                        {        // Found it!
                            retValues.Add(val);
                            break;
                        }
                    }
                }
                break;

                default:
                {
                    retValues.Add(val);
                }
                break;
                }
            }

            return((retValues.Count > 0) ? new CssValueList(retValues) : null);
#endif
        }
Exemplo n.º 5
0
 public LinearGradient(CssValueList args)
 {
     this.args = args;
 }
        public void TestNoElements()
        {
            SetUpFindElementsReturnsEmpty();

            Actor.Invoking(x => x.AsksFor(CssValueList.For(Locator, "color"))).Should().Throw <WaitingException <bool> >();
        }
Exemplo n.º 7
0
        public void WriteValueList(CssValueList list)
        {
            var i = 0;

            foreach (var value in list)
            {
                if (i != 0)
                {
                    writer.Write(list.Seperator == ValueSeperator.Space ? " " : ", ");
                }

                WriteValue(value);

                i++;
            }
        }
Exemplo n.º 8
0
        // Read comma seperated values
        public CssValue ReadValueList()
        {
            // : #fffff
            // : $oranges
            // : url(file.css);

            var values = new List<CssValue>();

            do
            {
                if (current.Kind == TokenKind.Comma)    // read the comma & trailing whitespace
                {
                    Read();

                    ReadTrivia();
                }

                values.Add(CssValue.FromComponents(ReadComponents()));

            } while (current.Kind == TokenKind.Comma);

            var trivia = ReadTrivia(); // Trialing trivia

            if (values.Count == 1) return values[0];

            var list = new CssValueList(values, ValueSeperator.Comma);

            return list;
        }
Exemplo n.º 9
0
 public static Boolean VaryAll <T>(this IValueConverter <T> converter, CssValueList list)
 {
     return(converter.VaryAll(list, (c, v) => c.Validate(v)));
 }
Exemplo n.º 10
0
 public static Boolean VaryAll <T>(this IValueConverter <T> converter, CssValueList list, Action <T> setResult)
 {
     return(converter.VaryAll(list, (c, v) => c.TryConvert(v, setResult)));
 }