Exemplo n.º 1
0
        internal NthLastOfTypePseudoClassSelector(NthParameter n, int start, int stop, string filePath)
            : base("nth-last-of-type")
        {
            N = n;

            Start    = start;
            Stop     = stop;
            FilePath = filePath;
        }
Exemplo n.º 2
0
        internal NthChildPsuedoClassSelector(NthParameter child, int start, int stop, string filePath)
            : base("nth-child")
        {
            Child = child;

            Start    = start;
            Stop     = stop;
            FilePath = filePath;
        }
Exemplo n.º 3
0
        internal NthLastChildPseudoClassSelector(NthParameter lastChild, int start, int stop, string filePath)
            : base("nth-last-child")
        {
            LastChild = lastChild;

            Start    = start;
            Stop     = stop;
            FilePath = filePath;
        }
Exemplo n.º 4
0
        internal static new Selector Parse(string name, int start, int stop, string filePath)
        {
            name = name.Substring(1);
            switch (name)
            {
            case "link": return(LinkSingleton.BindToPosition(start, stop, filePath));

            case "visited": return(VisitedSingleton.BindToPosition(start, stop, filePath));

            case "active": return(ActiveSingleton.BindToPosition(start, stop, filePath));

            case "hover": return(HoverSingleton.BindToPosition(start, stop, filePath));

            case "focus": return(FocusSingleton.BindToPosition(start, stop, filePath));

            case "first-letter": return(FirstLetterSingleton.BindToPosition(start, stop, filePath));

            case "first-line": return(FirstLineSingleton.BindToPosition(start, stop, filePath));

            case "first-child": return(FirstChildSingleton.BindToPosition(start, stop, filePath));

            case "before": return(BeforeSingleton.BindToPosition(start, stop, filePath));

            case "after": return(AfterSingleton.BindToPosition(start, stop, filePath));

            case "last-child": return(LastChildSingleton.BindToPosition(start, stop, filePath));

            case "empty": return(EmptySingleton.BindToPosition(start, stop, filePath));

            case "checked": return(CheckedSingleton.BindToPosition(start, stop, filePath));

            case "disabled": return(DisabledSingleton.BindToPosition(start, stop, filePath));

            case "first-of-type": return(FirstOfTypeSingleton.BindToPosition(start, stop, filePath));

            case "last-of-type": return(LastOfTypeSingleton.BindToPosition(start, stop, filePath));

            case "only-child": return(OnlyChildSingleton.BindToPosition(start, stop, filePath));

            case "only-of-type": return(OnlyOfTypeSingleton.BindToPosition(start, stop, filePath));

            case "root": return(RootSingleton.BindToPosition(start, stop, filePath));

            case "target": return(TargetSingleton.BindToPosition(start, stop, filePath));

            case "enabled": return(EnabledSingleton.BindToPosition(start, stop, filePath));

            case "default": return(DefaultSingleton.BindToPosition(start, stop, filePath));

            case "valid": return(ValidSingleton.BindToPosition(start, stop, filePath));

            case "invalid": return(InvalidSingleton.BindToPosition(start, stop, filePath));

            case "in-range": return(InRangeSingleton.BindToPosition(start, stop, filePath));

            case "out-of-range": return(OutOfRangeSingleton.BindToPosition(start, stop, filePath));

            case "required": return(RequiredSingleton.BindToPosition(start, stop, filePath));

            case "optional": return(OptionalSingleton.BindToPosition(start, stop, filePath));

            case "read-only": return(ReadOnlySingleton.BindToPosition(start, stop, filePath));

            case "read-write": return(ReadWriteSingleton.BindToPosition(start, stop, filePath));
            }

            int i = name.IndexOf('(');

            if (!name.EndsWith(")"))
            {
                Current.RecordError(ErrorType.Parser, Position.Create(start, stop, filePath), "Unknown pseudo class [" + name + "]");
                throw new StoppedParsingException();
            }

            string inner = name.Substring(i + 1, name.Length - 1 - (i + 1));

            if (name.StartsWith("lang("))
            {
                return(new LangPseudoClassSelector(inner, start, stop, filePath));
            }
            if (name.StartsWith("not("))
            {
                return(new NotPseudoClassSelector(Selector.Parse(inner, start, stop, filePath), start, stop, filePath));
            }
            if (name.StartsWith("nth-last-child("))
            {
                return(new NthLastChildPseudoClassSelector(NthParameter.Parse(inner), start, stop, filePath));
            }
            if (name.StartsWith("nth-of-type("))
            {
                return(new NthOfTypePseudoClassSelector(NthParameter.Parse(inner), start, stop, filePath));
            }
            if (name.StartsWith("nth-last-of-type("))
            {
                return(new NthLastOfTypePseudoClassSelector(NthParameter.Parse(inner), start, stop, filePath));
            }
            if (name.StartsWith("nth-child("))
            {
                return(new NthChildPsuedoClassSelector(NthParameter.Parse(inner), start, stop, filePath));
            }

            Current.RecordError(ErrorType.Parser, Position.Create(start, stop, filePath), "Unknown pseudo class [" + name + "]");
            throw new StoppedParsingException();
        }
Exemplo n.º 5
0
        internal NthOfTypePseudoClassSelector(NthParameter n, int start, int stop, string filePath)
            : base("nth-of-type")
        {
            N = n;

            Start = start;
            Stop = stop;
            FilePath = filePath;
        }
Exemplo n.º 6
0
        internal NthLastChildPseudoClassSelector(NthParameter lastChild, int start, int stop, string filePath)
            : base("nth-last-child")
        {
            LastChild = lastChild;

            Start = start;
            Stop = stop;
            FilePath = filePath;
        }
Exemplo n.º 7
0
        internal NthChildPsuedoClassSelector(NthParameter child, int start, int stop, string filePath)
            : base("nth-child")
        {
            Child = child;

            Start = start;
            Stop = stop;
            FilePath = filePath;
        }