/// <summary> /// Returns the given selector constructor to the pool. /// </summary> /// <param name="ctor">The constructor to recycle.</param> public static void ToPool(this CssSelectorConstructor ctor) { lock (_lock) { _selector.Push(ctor); } }
public ChildFunctionState(Func <Int32, Int32, ISelector, ISelector> creator, CssSelectorConstructor parent, Boolean withOptionalSelector = true) { _creator = creator; _parent = parent; _allowOf = withOptionalSelector; _valid = true; _sign = 1; _state = ParseState.Initial; }
/// <summary> /// Returns the given selector constructor to the pool and gets the /// constructed selector. /// </summary> /// <param name="ctor">The constructor to recycle.</param> /// <returns>The Selector that is contained in the constructor.</returns> public static ISelector ToPool(this CssSelectorConstructor ctor) { var result = ctor.Result; lock (_lock) { _selector.Push(ctor); } return(result); }
/// <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(StylesheetReader reader) { selector = Pool.NewSelectorConstructor(); sync = new Object(); skipExceptions = true; tokenizer = new Lexer(reader); started = false; function = new Stack <FunctionBuffer>(); sheet = stylesheet; open = new Stack <CSSRule>(); SwitchTo(CssState.Data); }
public HostContextFunctionState(CssSelectorConstructor parent) { _selector = parent.CreateChild(); }
public MatchesFunctionState(CssSelectorConstructor parent) { _selector = parent.CreateChild(); }
public HasFunctionState(CssSelectorConstructor parent) { _nested = parent.CreateChild(); }
public NotFunctionState(CssSelectorConstructor parent) { _selector = parent.CreateChild(); _selector._nested = true; }
/// <summary> /// Creates a new @page-rule from the given source. /// </summary> /// <param name="source">The token iterator.</param> /// <returns>The @page-rule.</returns> CSSPageRule CreatePageRule(IEnumerator<CssToken> source) { var page = new CSSPageRule(); page.ParentStyleSheet = sheet; page.ParentRule = CurrentRule; open.Push(page); var ctor = new CssSelectorConstructor(); ctor.IgnoreErrors = ignore; do { if (source.Current.Type == CssTokenType.CurlyBracketOpen) { if (SkipToNextNonWhitespace(source)) { var tokens = LimitToCurrentBlock(source); AppendDeclarations(tokens.GetEnumerator(), page.Style.List); break; } } ctor.PickSelector(source); } while (source.MoveNext()); page.Selector = ctor.Result; open.Pop(); return page; }
/// <summary> /// Takes a string and transforms it into a selector object. /// </summary> /// <param name="selector">The string to parse.</param> /// <param name="quirksMode">Optional: The status of the quirks mode flag (usually not set).</param> /// <returns>The Selector object.</returns> public static Selector ParseSelector(String selector, Boolean quirksMode = false) { var parser = new CssParser(selector); parser.IsQuirksMode = quirksMode; var tokens = parser.tokenizer.Iterator; var ctor = new CssSelectorConstructor(); while (tokens.MoveNext()) ctor.PickSelector(tokens); return ctor.Result; }