Exemplo n.º 1
0
        protected override Value Clone()
        {
            SelectorBlockUnit result = new SelectorBlockUnit();

            result.Style = Style;
            return(result);
        }
Exemplo n.º 2
0
        public override Value ReadStartValue(CssLexer lexer)
        {
            // No longer in selector mode:
            lexer.SelectorMode = false;

            // Skip the {:
            lexer.Read();

            if (lexer.PropertyMapMode)
            {
                // Clear:
                lexer.PropertyMapMode = false;

                // Create map:
                PropertyMapUnit map = new PropertyMapUnit();

                // Create the style:
                Style mapStyle = new Style(lexer.Scope);

                // Read the values:
                mapStyle.LoadProperties(lexer, delegate(Style s, string pName, Css.Value value){
                    return(map.OnReadProperty(s, pName, value));
                });

                map.Style = mapStyle;

                return(map);
            }

            // Result:
            SelectorBlockUnit block = new SelectorBlockUnit();

            if (lexer.AtRuleMode)
            {
                // Clear at rule mode:
                lexer.AtRuleMode = false;

                List <Rule> rules = null;

                lexer.SkipJunk();

                while (lexer.Peek() != '}' && lexer.Peek() != '\0')
                {
                    Rule[] set;
                    Rule   single = lexer.ReadRules(out set);

                    if (single == null)
                    {
                        if (set != null)
                        {
                            if (rules == null)
                            {
                                rules = new List <Rule>();
                            }

                            for (int x = 0; x < set.Length; x++)
                            {
                                rules.Add(set[x]);
                            }
                        }
                    }
                    else
                    {
                        if (rules == null)
                        {
                            rules = new List <Rule>();
                        }

                        rules.Add(single);
                    }

                    lexer.SkipJunk();
                }

                block.Rules = rules;
            }
            else
            {
                // Create the style:
                Style style = new Style(lexer.Scope);

                // Read the values:
                style.LoadProperties(lexer, null);

                block.Style = style;
            }

            // Note that we do not read off the close bracket.
            // This is so the lexer knows it's done reading the value
            // and can terminate accordingly.

            return(block);
        }