Exemplo n.º 1
0
        public void CssParserIdentifier()
        {
            var teststring = "h1 { background: blue; }";
            var parser = new CssTokenizer(new SourceManager(teststring));
            var list = parser.Tokens;
            CssToken token = null;

            foreach (var item in list)
            {
                token = item;
                break;
            }

            Assert.AreEqual(CssTokenType.Ident, token.Type);
        }
Exemplo n.º 2
0
        public void CssParserAtRule()
        {
            var teststring = "@media { background: blue; }";
            var parser = new CssTokenizer(new SourceManager(teststring));
            var list = parser.Tokens;
            CssToken token = null;

            foreach (var item in list)
            {
                token = item;
                break;
            }

            Assert.AreEqual(CssTokenType.AtKeyword, token.Type);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new CSS parser instance parser with the specified stylesheet
        /// based on the given source manager.
        /// </summary>
        /// <param name="stylesheet">The stylesheet to be constructed.</param>
        /// <param name="source">The source to use.</param>
        internal CssParser(CSSStyleSheet stylesheet, SourceManager source)
        {
            ignore = true;
            buffer = new StringBuilder();
            tokenizer = new CssTokenizer(source);

            tokenizer.ErrorOccurred += (s, ev) =>
            {
                if (ErrorOccurred != null)
                    ErrorOccurred(this, ev);
            };

            started = false;
            sheet = stylesheet;
            open = new Stack<CSSRule>();
        }
Exemplo n.º 4
0
        public void CssParserUrlSingleQuoted()
        {
            var url = "http://someurl";
            var teststring = "url('" + url + "')";
            var parser = new CssTokenizer(new SourceManager(teststring));
            var list = parser.Tokens;
            CssStringToken token = null;

            foreach (var item in list)
            {
                token = item as CssStringToken;
                break;
            }

            Assert.AreEqual(url, token.Data);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new CSS parser instance parser with the specified stylesheet
        /// based on the given source manager.
        /// </summary>
        /// <param name="stylesheet">The stylesheet to be constructed.</param>
        /// <param name="source">The source to use.</param>
        internal CssParser(CSSStyleSheet stylesheet, SourceManager source)
        {
            ignore    = true;
            buffer    = new StringBuilder();
            tokenizer = new CssTokenizer(source);

            tokenizer.ErrorOccurred += (s, ev) =>
            {
                if (ErrorOccurred != null)
                {
                    ErrorOccurred(this, ev);
                }
            };

            started = false;
            sheet   = stylesheet;
            open    = new Stack <CSSRule>();
        }
 public CssSupportsState(CssTokenizer tokenizer, CssParser parser)
     : base(tokenizer, parser)
 {
 }
 public CssDocumentState(CssTokenizer tokenizer, CssParser parser)
     : base(tokenizer, parser)
 {
 }
 public CssFontFaceState(CssTokenizer tokenizer, CssParser parser)
     : base(tokenizer, parser)
 {
 }