Ejemplo n.º 1
0
        /// <summary>
        /// Called before any token in the value regime had been seen.
        /// </summary>
        CssValue CreateValue(CssTokenType closing, ref CssToken token, out Boolean important)
        {
            var value = Pool.NewValueBuilder();

            _tokenizer.State = CssParseMode.Value;
            token            = _tokenizer.Get();

            while (token.Type != CssTokenType.Eof)
            {
                if (token.Is(CssTokenType.Semicolon, closing))
                {
                    break;
                }

                value.Apply(token);
                token = _tokenizer.Get();
            }

            important        = value.IsImportant;
            _tokenizer.State = CssParseMode.Data;

            if (value.IsValid || _parser.Options.IsToleratingInvalidValues)
            {
                return(value.ToPool());
            }

            value.ToPool();
            return(null);
        }
Ejemplo n.º 2
0
        CssValue CreateValue(CssTokenType closing, ref CssToken token, out Boolean important)
        {
            var value = Pool.NewValueBuilder();

            _tokenizer.IsInValue = true;
            token = NextToken();
            var start = token;

            CreateNewNode();

            while (token.Type != CssTokenType.Eof)
            {
                if (token.Is(CssTokenType.Semicolon, closing))
                {
                    break;
                }

                value.Apply(token);
                token = NextToken();
            }

            important            = value.IsImportant;
            _tokenizer.IsInValue = false;
            var result = value.ToPool();

            if (!value.IsValid && !_parser.Options.IsToleratingInvalidValues)
            {
                RaiseErrorOccurred(CssParseError.InvalidValue, start);
                result = null;
            }

            return(CloseNode(result));
        }
Ejemplo n.º 3
0
        void JumpToDeclEnd(ref CssToken current)
        {
            var scopes = 0;

            while (current.Type != CssTokenType.Eof)
            {
                if (current.Type == CssTokenType.CurlyBracketOpen)
                {
                    scopes++;
                }
                else if (scopes <= 0 && (current.Is(CssTokenType.CurlyBracketClose, CssTokenType.Semicolon)))
                {
                    break;
                }
                else if (current.Type == CssTokenType.CurlyBracketClose)
                {
                    scopes--;
                }

                current = NextToken();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called before any token in the value regime had been seen.
        /// </summary>
        protected CssValue CreateValue(ref CssToken token, out Boolean important)
        {
            var value = Pool.NewValueBuilder();
            _tokenizer.State = CssParseMode.Value;
            token = _tokenizer.Get();

            while (token.Type != CssTokenType.Eof)
            {
                if (token.Is(CssTokenType.Semicolon, CssTokenType.CurlyBracketClose) ||
                   (token.Type == CssTokenType.RoundBracketClose && value.IsReady))
                    break;

                value.Apply(token);
                token = _tokenizer.Get();
            }

            important = value.IsImportant;
            _tokenizer.State = CssParseMode.Data;
            return value.ToPool();
        }