Ejemplo n.º 1
0
            public override ISelector Produce()
            {
                if (!_valid || (_value == null))
                {
                    return(null);
                }

                var code = PseudoClassNames.Dir.StylesheetFunction(_value);

                return(SimpleSelector.PseudoClass(code));
            }
Ejemplo n.º 2
0
            public override ISelector Produce()
            {
                var valid = _selector.IsValid;
                var sel   = _selector.GetResult();

                if (valid)
                {
                    var code = PseudoClassNames.HostContext.StylesheetFunction(sel.Text);
                    return(SimpleSelector.PseudoClass(code));
                }
                return(null);
            }
Ejemplo n.º 3
0
            public override ISelector Produce()
            {
                var valid = _selector.IsValid;
                var sel   = _selector.GetResult();

                if (valid)
                {
                    var code = PseudoClassNames.Matches.StylesheetFunction(sel.Text);
                    return(SimpleSelector.PseudoClass(/*el => sel.Match(el),*/ code));
                }
                return(null);
            }
Ejemplo n.º 4
0
            public override ISelector Produce()
            {
                var valid = _nested.IsValid;
                var sel   = _nested.GetResult();

                if (valid)
                {
                    var code = PseudoClassNames.Has.StylesheetFunction(sel.Text);
                    return(SimpleSelector.PseudoClass(/*el => el.ChildNodes.QuerySelector(sel) != null,*/ code));
                }
                return(null);
            }
Ejemplo n.º 5
0
 private void OnClass(Token token)
 {
     _state = State.Data;
     _ready = true;
     if (token.Type == TokenType.Ident)
     {
         Insert(SimpleSelector.Class(token.Data));
     }
     else
     {
         _valid = false;
     }
 }
Ejemplo n.º 6
0
        private void OnDelim(Token token)
        {
            switch (token.Data[0])
            {
            case Symbols.Comma:
                InsertOr();
                _ready = false;
                break;

            case Symbols.GreaterThan:
                Insert(Combinator.Child);
                _ready = false;
                break;

            case Symbols.Plus:
                Insert(Combinator.AdjacentSibling);
                _ready = false;
                break;

            case Symbols.Tilde:
                Insert(Combinator.Sibling);
                _ready = false;
                break;

            case Symbols.Asterisk:
                Insert(SimpleSelector.All);
                _ready = true;
                break;

            case Symbols.Dot:
                _state = State.Class;
                _ready = false;
                break;

            case Symbols.Pipe:
                if ((_combinators.Count > 0) && (_combinators.Peek() == Combinator.Descendent))
                {
                    Insert(SimpleSelector.Type(string.Empty));
                }
                Insert(Combinator.Namespace);
                _ready = false;
                break;

            default:
                _valid = false;
                break;
            }
        }
Ejemplo n.º 7
0
        private void OnData(Token token)
        {
            switch (token.Type)
            {
            case TokenType.SquareBracketOpen:
                _attrName  = null;
                _attrValue = null;
                _attrOp    = string.Empty;
                _attrNs    = null;
                _state     = State.Attribute;
                _ready     = false;
                break;

            case TokenType.Colon:
                _state = State.PseudoClass;
                _ready = false;
                break;

            case TokenType.Hash:
                Insert(SimpleSelector.Id(token.Data));
                _ready = true;
                break;

            case TokenType.Ident:
                Insert(SimpleSelector.Type(token.Data));
                _ready = true;
                break;

            case TokenType.Whitespace:
                Insert(Combinator.Descendent);
                break;

            case TokenType.Delim:
                OnDelim(token);
                break;

            case TokenType.Comma:
                InsertOr();
                _ready = false;
                break;

            default:
                _valid = false;
                break;
            }
        }
Ejemplo n.º 8
0
 private ISelector CreateDefault(string name, string value)
 {
     return(SimpleSelector.AttrAvailable(name, value));
 }