示例#1
0
        /// <summary>
        /// Consumes a single <see cref="CompoundSelector"/> and it's <see cref="ESelectorCombinator"/> (if available)
        /// </summary>
        /// <returns></returns>
        private static RelativeSelector Consume_Relative_Selector(DataConsumer <CssToken> Stream)
        {
            Stream.Consume_While(tok => tok.Type == ECssTokenType.Whitespace);// Consume all of the prefixing whitespace
            CompoundSelector Compound = Consume_Compound_Selector(Stream);

            if (Compound == null)
            {
                return(null);
            }

            if (!Starts_Combinator(Stream.Next))
            {
                return(new RelativeSelector(ESelectorCombinator.None, Compound));
            }
            else
            {
                CombinatorToken     Comb       = Consume_Combinator(Stream);
                ESelectorCombinator Combinator = ESelectorCombinator.None;
                if (Stream.Next.Type == ECssTokenType.Combinator)
                {
                    switch (Comb.Value)
                    {
                    case " ":
                    case ">>":
                        Combinator = ESelectorCombinator.Descendant;
                        break;

                    case ">":
                        Combinator = ESelectorCombinator.Child;
                        break;

                    case "+":
                        Combinator = ESelectorCombinator.Sibling_Adjacent;
                        break;

                    case "~":
                        Combinator = ESelectorCombinator.Sibling_Subsequent;
                        break;

                    default:
                        throw new CssParserException(string.Concat("Unrecognized Combinator(", Comb.Value, ")"));
                    }
                }

                return(new RelativeSelector(Combinator, Compound));
            }
        }
示例#2
0
 /// <summary>
 /// Creates a new selector sequence
 /// </summary>
 /// <param name="Chain"></param>
 /// <param name="Combinator">The combinator that comes AFTER the selector sequence.</param>
 public RelativeSelector(ESelectorCombinator Combinator, CompoundSelector Compound) : base(Compound)
 {
     this.Combinator = Combinator;
 }