Exemplo n.º 1
0
        protected virtual ParseItem ParseName(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseItem name = null;

            if (tokens.CurrentToken.TokenType == CssTokenType.Asterisk)
            {
                StarHackPropertyName customName = new StarHackPropertyName();
                if (customName.Parse(itemFactory, text, tokens))
                {
                    name = customName;
                    Children.Add(customName);
                }
            }
            else if (tokens.CurrentToken.TokenType == CssTokenType.Identifier)
            {
                CssClassifierContextType contextType = CssClassifierContextType.PropertyName;
                if (text.CompareTo(tokens.CurrentToken.Start, "--", true))
                {
                    IsCustomProperty = true;
                    contextType      = CssClassifierContextType.CustomPropertyName;
                }

                name = Children.AddCurrentAndAdvance(tokens, contextType);
            }

            return(name);
        }
Exemplo n.º 2
0
        public bool IsKeywordText(ITextProvider textProvider, string keywordText)
        {
            if (this.TokenType == RdTokenType.Keyword)
            {
                return(textProvider.CompareTo(this.Start, this.Length, keywordText, ignoreCase: false));
            }

            return(false);
        }
Exemplo n.º 3
0
 internal static bool Compare(int start, int length, ITextProvider textProvider, string compareText, bool ignoreCase)
 {
     if (textProvider == null || length == 0)
     {
         return(string.IsNullOrEmpty(compareText));
     }
     else
     {
         return(length == compareText.Length &&
                textProvider.CompareTo(start, compareText, ignoreCase));
     }
 }
Exemplo n.º 4
0
        internal static bool CompareTokens(CssToken token1, CssToken token2, ITextProvider textProvider1, ITextProvider textProvider2)
        {
            if (token1.TokenType != token2.TokenType)
            {
                return(false);
            }

            if (token1.IsComparableByType())
            {
                return(true);
            }

            if (token1.Length == token2.Length &&
                textProvider1 != null &&
                textProvider2 != null)
            {
                return(textProvider1.CompareTo(token1.Start, textProvider2, token2.Start, token1.Length, ignoreCase: false));
            }

            return(false);
        }
Exemplo n.º 5
0
        private static bool FindElementName(ITextProvider text, ITextRange name, string[][] indexArray, bool ignoreCase)
        {
            Char ch = text[name.Start];

            if (ch < 'A' || ch > 'z')
            {
                return(false);
            }

            ch -= 'A';
            string[] elementNames = indexArray[ch];
            if (elementNames != null)
            {
                for (int i = 0; i < elementNames.Length; i++)
                {
                    if (elementNames[i].Length == name.Length && text.CompareTo(name.Start, name.Length, elementNames[i], ignoreCase))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 6
0
 public bool CompareTo(int position, int length, string text, bool ignoreCase)
 {
     return(_text.CompareTo(position, length, text, ignoreCase));
 }
Exemplo n.º 7
0
 public bool CompareTo(int streamPosition, string text, bool ignoreCase)
 {
     return(Text.CompareTo(streamPosition, text, ignoreCase));
 }
Exemplo n.º 8
0
        internal static ParseItem ParseDirective(ComplexItem parent, ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            Debug.Assert(tokens.CurrentToken.TokenType == CssTokenType.At);

            CssToken  atToken   = tokens.CurrentToken;
            CssToken  nameToken = tokens.Peek(1);
            ParseItem pi        = null;

            if (nameToken.TokenType == CssTokenType.At && AllowDoubleAt(text))
            {
                // Ignore the first @ in @@directive
                atToken   = nameToken;
                nameToken = tokens.Peek(2);
            }

            if (nameToken.TokenType == CssTokenType.Identifier &&
                nameToken.Start == atToken.AfterEnd)
            {
                if ("charset".Length == nameToken.Length && text.CompareTo(nameToken.Start, "charset", ignoreCase: false))
                {
                    // must be lowercase, and not encoded
                    pi = itemFactory.Create <CharsetDirective>(parent);
                }
                else if ("import".Length == nameToken.Length && text.CompareTo(nameToken.Start, "import", ignoreCase: true))
                {
                    pi = itemFactory.Create <ImportDirective>(parent);
                }
                else if ("page".Length == nameToken.Length && text.CompareTo(nameToken.Start, "page", ignoreCase: true))
                {
                    pi = itemFactory.Create <PageDirective>(parent);
                }
                else if ("media".Length == nameToken.Length && text.CompareTo(nameToken.Start, "media", ignoreCase: true))
                {
                    pi = itemFactory.Create <MediaDirective>(parent);
                }
                else if ("namespace".Length == nameToken.Length && text.CompareTo(nameToken.Start, "namespace", ignoreCase: true))
                {
                    // CSS3 Namespaces
                    // http://www.w3.org/TR/css3-namespace/
                    pi = itemFactory.Create <NamespaceDirective>(parent);
                }
                else if (TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "keyframes", ignoreCase: true) ||
                         TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "-moz-keyframes", ignoreCase: true) ||
                         TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "-ms-keyframes", ignoreCase: true) ||
                         TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "-o-keyframes", ignoreCase: true) ||
                         TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "-webkit-keyframes", ignoreCase: true))
                {
                    // CSS3 Animations
                    // http://www.w3.org/TR/2009/WD-css3-animations-20090320/
                    pi = itemFactory.Create <KeyFramesDirective>(parent);
                }
                else if (TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "font-face", ignoreCase: true))
                {
                    // CSS3 Webfonts
                    // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-descriptions
                    pi = itemFactory.Create <FontFaceDirective>(parent);
                }
                else if (TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "counter", ignoreCase: true))
                {
                    pi = itemFactory.Create <CounterDirective>(parent);
                }
                else if (TextRange.CompareDecoded(nameToken.Start, nameToken.Length, text, "viewport", ignoreCase: true))
                {
                    pi = itemFactory.Create <ViewportDirective>(parent);
                }
            }

            if (pi == null)
            {
                // some other stuff, like @top-center/left/top/middle... or @footnoote in CSS3
                pi = itemFactory.Create <UnknownDirective>(parent);
            }

            pi.Parse(itemFactory, text, tokens);

            return(pi);
        }
Exemplo n.º 9
0
 public bool CompareTo(int position, int length, string text, bool ignoreCase)
 => Text.CompareTo(position, length, text, ignoreCase);
Exemplo n.º 10
0
 public bool CompareTo(int position, ITextProvider otherProvider, int otherPosition, int length, bool ignoreCase)
 {
     return(otherProvider.CompareTo(otherPosition, _text, position, length, ignoreCase));
 }
Exemplo n.º 11
0
        private static bool FindElementName(ITextProvider text, ITextRange name, string[][] indexArray, bool ignoreCase) {
            Char ch = text[name.Start];
            if (ch < 'A' || ch > 'z')
                return false;

            ch -= 'A';
            string[] elementNames = indexArray[ch];
            if (elementNames != null) {
                for (int i = 0; i < elementNames.Length; i++) {
                    if (elementNames[i].Length == name.Length && text.CompareTo(name.Start, name.Length, elementNames[i], ignoreCase))
                        return true;
                }
            }
            return false;
        }