internal unsafe CSSPseudoClass_Nth(byte* data, byte* dataEnd, CSSPseudoClass pseudoClass, out bool success) { success = true; #region odd/even? if (toLower(*data) == 'o' && toLower(*(data + 1)) == 'd' && toLower(*(data + 2)) == 'd') { p_Odd = true; return; } if (toLower(*data) == 'e' && toLower(*(data + 1)) == 'v' && toLower(*(data + 2)) == 'e' && toLower(*(data + 3)) == 'n') { p_Even = true; return; } #endregion //parse the data as an arithmetic expression p_Expression = ArithmeticQueue.Parse(ref data, dataEnd); ArithmeticQueue flatten = p_Expression.Flatten(); //does the expression contain any substitutes? //if so, we add "n" as a substitute (IF it is n, if //it isn't then it is an invalid nth* class. LinkedListNode<ArithmeticOperand> currentOperand = flatten.Operands.First; while (currentOperand != null) { //is the operand a substitute? ArithmeticOperand current = currentOperand.Value; if (!current.IsSubstitution) { currentOperand = currentOperand.Next; continue; } //invalid? (the name has to be "n") if ((char)current.Value != 'n') { success = false; break; } p_HasNSubstitute = true; break; } //if there is no "n" substitute, pre-calculate the expression //so we don't have to constantly calculate everytime we check. if (success && !p_HasNSubstitute) { p_ExpressionResult = (int)p_Expression.Calculate(); } }
internal CSSSelectorType(string query, CSSSelectorElementTargetType type, LinkedList<CSSSelectorAttribute> attributes, CSSPseudoClass pseudoClass, CSSPseudoElement pseudoElement, CSSSelectorPreSelectorRelationship relationship, LinkedList<pseudoClassWithArg> pseudoClassArguments) { p_Query = query; p_Type = type; p_Attributes = attributes; p_PseudoElement = pseudoElement; p_PseudoClass = pseudoClass; p_ParentRelationship = relationship; p_PseudoClassArguments = pseudoClassArguments; }
public bool HasClass(CSSPseudoClass compare) { return (p_PseudoClass & compare) == compare; }
public pseudoClassWithArg(CSSPseudoClass c, ICSSPseudoClassArgument a) { cls = c; argument = a; }
private string getPseudoClassString(CSSPseudoClass cls) { switch (cls) { case CSSPseudoClass.FirstChild: return "first-child"; case CSSPseudoClass.FirstOfType: return "first-of-type"; case CSSPseudoClass.InRange: return "in-range"; case CSSPseudoClass.LastChild: return "last-child"; case CSSPseudoClass.LastOfType: return "last-of-type"; case CSSPseudoClass.NthChild: return "nth-child"; case CSSPseudoClass.NthLastChild: return "nth-last-child"; case CSSPseudoClass.NthLastOfType: return "nth-last-of-type"; case CSSPseudoClass.NthOfType: return "nth-of-type"; case CSSPseudoClass.OnlyChild: return "only-child"; case CSSPseudoClass.OnlyOfType: return "only-of-type"; case CSSPseudoClass.OutOfRange: return "out-of-range"; case CSSPseudoClass.ReadOnly: return "read-only"; case CSSPseudoClass.ReadWrite: return "read-write"; default: return cls.ToString().ToLower(); } }