Beispiel #1
0
 public ChildFunctionState(CssSelectorConstructor parent, Boolean withOptionalSelector = true)
 {
     _parent  = parent;
     _allowOf = withOptionalSelector;
     _valid   = true;
     _sign    = 1;
     _state   = ParseState.Initial;
 }
Beispiel #2
0
            Boolean OnBeforeOf(CssToken token)
            {
                if (token.Type == CssTokenType.Whitespace)
                {
                    return(false);
                }

                if (token.Data.Equals("of", StringComparison.OrdinalIgnoreCase))
                {
                    valid  = allowOf;
                    state  = ParseState.AfterOf;
                    nested = Pool.NewSelectorConstructor();
                    return(false);
                }
                else if (token.Type == CssTokenType.RoundBracketClose)
                {
                    return(true);
                }

                valid = false;
                return(false);
            }
Beispiel #3
0
            Boolean OnBeforeOf(CssToken token)
            {
                if (token.Type == CssTokenType.Whitespace)
                {
                    return(false);
                }

                if (token.Data.Isi(Keywords.Of))
                {
                    _valid  = _allowOf;
                    _state  = ParseState.AfterOf;
                    _nested = _parent.CreateChild();
                    return(false);
                }
                else if (token.Type == CssTokenType.RoundBracketClose)
                {
                    return(true);
                }

                _valid = false;
                return(false);
            }
            Boolean OnBeforeOf(CssToken token)
            {
                if (token.Type == CssTokenType.Whitespace)
                {
                    return(false);
                }

                if (token.Data.Isi("of"))
                {
                    valid  = allowOf;
                    state  = ParseState.AfterOf;
                    nested = Pool.NewSelectorConstructor();
                    return(false);
                }
                else if (token.Type == CssTokenType.RoundBracketClose)
                {
                    return(true);
                }

                valid = false;
                return(false);
            }
        /// <summary>
        /// Invoked once a pseudo class has been found in the token enumerator.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns>True if no error occurred, otherwise false.</returns>
        Boolean OnPseudoClassFunction(CssToken token)
        {
            if (token.Type == CssTokenType.Whitespace)
            {
                return(true);
            }

            switch (attrName)
            {
            case pseudoClassFunctionNthChild:
            case pseudoClassFunctionNthLastChild:
            {
                switch (token.Type)
                {
                case CssTokenType.Ident:
                case CssTokenType.Number:
                case CssTokenType.Dimension:
                    attrValue += token.ToValue();
                    return(true);

                case CssTokenType.Delim:
                    var chr = token.Data[0];

                    if (chr == Specification.Plus || chr == Specification.Minus)
                    {
                        attrValue += token.Data;
                        return(true);
                    }

                    break;
                }

                break;
            }

            case pseudoClassFunctionNot:
            {
                if (nested == null)
                {
                    nested = new CssSelectorConstructor();
                }

                if (token.Type != CssTokenType.RoundBracketClose || nested.state != State.Data)
                {
                    nested.Apply(token);
                    return(true);
                }

                break;
            }

            case pseudoClassFunctionDir:
            {
                if (token.Type == CssTokenType.Ident)
                {
                    attrValue = token.Data;
                }

                state = State.PseudoClassFunctionEnd;
                return(true);
            }

            case pseudoClassFunctionLang:
            {
                if (token.Type == CssTokenType.Ident)
                {
                    attrValue = token.Data;
                }

                state = State.PseudoClassFunctionEnd;
                return(true);
            }

            case pseudoClassFunctionContains:
            {
                if (token.Type == CssTokenType.String || token.Type == CssTokenType.Ident)
                {
                    attrValue = token.Data;
                }

                state = State.PseudoClassFunctionEnd;
                return(true);
            }
            }

            return(OnPseudoClassFunctionEnd(token));
        }
Beispiel #6
0
 public MatchesFunctionState()
 {
     _nested = Pool.NewSelectorConstructor();
 }
Beispiel #7
0
 public NotFunctionState()
 {
     _nested          = Pool.NewSelectorConstructor();
     _nested.IsNested = true;
 }
Beispiel #8
0
 public HostContextFunctionState(CssSelectorConstructor parent)
 {
     _selector = parent.CreateChild();
 }
Beispiel #9
0
 public MatchesFunctionState(CssSelectorConstructor parent)
 {
     _selector = parent.CreateChild();
 }
Beispiel #10
0
 public HasFunctionState(CssSelectorConstructor parent)
 {
     _nested = parent.CreateChild();
 }
Beispiel #11
0
 public NotFunctionState(CssSelectorConstructor parent)
 {
     _selector         = parent.CreateChild();
     _selector._nested = true;
 }
 public HostContextFunctionState()
 {
     _nested = Pool.NewSelectorConstructor();
 }