/// <summary> /// 4.4.5. Hash-rest state /// </summary> CssToken HashRest() { while (true) { var current = GetNext(); if (current.IsName()) { _stringBuffer.Append(current); } else if (IsValidEscape(current)) { current = GetNext(); _stringBuffer.Append(ConsumeEscape(current)); } else if (current == Symbols.ReverseSolidus) { RaiseErrorOccurred(ErrorCode.InvalidCharacter); Back(); return(CssKeywordToken.Hash(FlushBuffer())); } else { Back(); return(CssKeywordToken.Hash(FlushBuffer())); } } }
/// <summary> /// 4.4.5. Hash-rest state /// </summary> CssToken HashRest(Char current) { while (true) { if (current.IsName()) { _stringBuffer.Append(current); } else if (IsValidEscape(current)) { current = _src.Next; _stringBuffer.Append(ConsumeEscape(current)); } else if (current == Specification.ReverseSolidus) { RaiseErrorOccurred(ErrorCode.InvalidCharacter); _src.Back(); return(CssKeywordToken.Hash(FlushBuffer())); } else { _src.Back(); return(CssKeywordToken.Hash(FlushBuffer())); } current = _src.Next; } }
public void RecycleSelectorConstructorBuild() { var divIdent = new CssKeywordToken(CssTokenType.Ident, "div", new TextPosition()); var sc1 = Pool.NewSelectorConstructor(); sc1.Apply(divIdent); Assert.AreNotEqual(SimpleSelector.All, sc1.ToPool()); var sc2 = Pool.NewSelectorConstructor(); Assert.AreEqual(SimpleSelector.All, sc2.ToPool()); Assert.AreSame(sc1, sc2); }
/// <summary> /// 4.4.10. Ident-rest state /// </summary> CssToken IdentRest(Char current) { while (true) { if (current.IsName()) { _stringBuffer.Append(current); } else if (IsValidEscape(current)) { current = GetNext(); _stringBuffer.Append(ConsumeEscape(current)); } else if (current == Symbols.RoundBracketOpen) { var fn = _stringBuffer.ToString().ToLowerInvariant(); if (fn == FunctionNames.Url) { _stringBuffer.Clear(); return(UrlStart(CssTokenType.Url)); } else if (fn == FunctionNames.Domain) { _stringBuffer.Clear(); return(UrlStart(CssTokenType.Domain)); } else if (fn == FunctionNames.Url_Prefix) { _stringBuffer.Clear(); return(UrlStart(CssTokenType.UrlPrefix)); } return(CssKeywordToken.Function(FlushBuffer())); } //false could be replaced with a transform whitespace flag, which is set to true if in SVG transform mode. //else if (false && Specification.IsSpaceCharacter(current)) // InstantSwitch(TransformFunctionWhitespace); else { Back(); return(CssKeywordToken.Ident(FlushBuffer())); } current = GetNext(); } }
/// <summary> /// 4.4.11. Transform-function-whitespace state /// </summary> CssToken TransformFunctionWhitespace(Char current) { while (true) { current = GetNext(); if (current == Symbols.RoundBracketOpen) { Back(); return(CssKeywordToken.Function(FlushBuffer())); } else if (!current.IsSpaceCharacter()) { Back(2); return(CssKeywordToken.Ident(FlushBuffer())); } } }
/// <summary> /// 4.4.11. Transform-function-whitespace state /// </summary> CssToken TransformFunctionWhitespace(Char current) { while (true) { current = _src.Next; if (current == Specification.RoundBracketOpen) { _src.Back(); return(CssKeywordToken.Function(FlushBuffer())); } else if (!current.IsSpaceCharacter()) { _src.Back(2); return(CssKeywordToken.Ident(FlushBuffer())); } } }
/// <summary> /// 4.4.8. At-keyword-rest state /// </summary> CssToken AtKeywordRest(Char current) { while (true) { if (current.IsName()) { _stringBuffer.Append(current); } else if (IsValidEscape(current)) { current = GetNext(); _stringBuffer.Append(ConsumeEscape(current)); } else { Back(); return(CssKeywordToken.At(FlushBuffer())); } current = GetNext(); } }