/// <summary>The <see cref="Ast.Selectors.PseudoNode"/> visit implementation</summary>
 /// <param name="pseudoNode">The pseudo AST node</param>
 /// <returns>The modified AST node if modified otherwise the original node</returns>
 public override AstNode VisitPseudoNode(PseudoNode pseudoNode)
 {
     return(new PseudoNode(
                pseudoNode.NumberOfColons,
                pseudoNode.Ident,
                pseudoNode.FunctionalPseudoNode != null ? (FunctionalPseudoNode)pseudoNode.FunctionalPseudoNode.Accept(this) : null));
 }
        /// <summary>Creates the list of hash class attrib pseudo nodes.</summary>
        /// <param name="hashClassAttribPseudoNegationTreeNodes">The hash class attrib pseudo node tree.</param>
        /// <returns>The list of hash class attrib pseudo nodes.</returns>
        private static IEnumerable <HashClassAtNameAttribPseudoNegationNode> CreateHashClassAttribPseudoNegationNodes(IEnumerable <CommonTree> hashClassAttribPseudoNegationTreeNodes)
        {
            return(hashClassAttribPseudoNegationTreeNodes.Select(hashClassAttribPseudoNegationNode =>
            {
                var child = hashClassAttribPseudoNegationNode.Children().FirstOrDefault();
                string hash = null;
                string replacementToken = null;
                string cssClass = null;
                string atName = null;
                AttribNode attribNode = null;
                PseudoNode pseudoNode = null;
                NegationNode negationNode = null;

                if (child != null)
                {
                    var nodeText = child.Text;
                    if (nodeText == T(CssParser.HASHIDENTIFIER))
                    {
                        hash = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.CLASSIDENTIFIER))
                    {
                        cssClass = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.ATIDENTIFIER))
                    {
                        atName = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.ATTRIBIDENTIFIER))
                    {
                        attribNode = CreateAttribNode(child);
                    }
                    else if (nodeText == T(CssParser.PSEUDOIDENTIFIER))
                    {
                        pseudoNode = CreatePseudoNode(child);
                    }
                    else if (nodeText == T(CssParser.NEGATIONIDENTIFIER))
                    {
                        negationNode = CreateNegationNode(child);
                    }
                    else if (nodeText == T(CssParser.REPLACEMENTTOKENIDENTIFIER))
                    {
                        replacementToken = child.FirstChildText();
                    }
                }

                return new HashClassAtNameAttribPseudoNegationNode(hash, cssClass, replacementToken, atName, attribNode, pseudoNode, negationNode);
            }));
        }
Ejemplo n.º 3
0
        /// <summary>The <see cref="PseudoNode"/> visit implementation</summary>
        /// <param name="pseudoNode">The pseudo AST node</param>
        /// <returns>The modified AST node if modified otherwise the original node</returns>
        public override AstNode VisitPseudoNode(PseudoNode pseudoNode)
        {
            // pseudo
            // /* '::' starts a pseudo-element, ':' a pseudo-class */
            // /* Exceptions: :first-line, :first-letter, :before and :after. */
            // /* Note that pseudo-elements are restricted to one per selector and */
            // /* occur only in the last simple_selector_sequence. */
            // : ':' ':'? [ IDENT | functional_pseudo ]
            // ;
            for (var count = 0; count < pseudoNode.NumberOfColons; count++)
            {
                _printerFormatter.Append(CssConstants.Colon);
            }

            if (pseudoNode.FunctionalPseudoNode != null)
            {
                pseudoNode.FunctionalPseudoNode.Accept(this);
            }
            else if (!string.IsNullOrWhiteSpace(pseudoNode.Ident))
            {
                _printerFormatter.Append(pseudoNode.Ident);

                // TODO - Spec issue - Should this be configuration driven?
                // IE6 has a bug where the "first-letter" and "first-line"
                // pseudo-classes need to be separated from the opening curly-brace
                // of the following rule set by a space or it doesn't get picked up.
                // So if the last-outputted word was "first-letter" or "first-line",
                // add a space now (since we know the next character at this point
                // is the opening brace of a rule-set).
                if (pseudoNode.Ident == "first-letter" || pseudoNode.Ident == "first-line")
                {
                    _printerFormatter.Append(CssConstants.SingleSpace);
                }
            }

            return(pseudoNode);
        }
Ejemplo n.º 4
0
 /// <summary>The <see cref="Ast.Selectors.PseudoNode"/> visit implementation</summary>
 /// <param name="pseudoNode">The pseudo AST node</param>
 /// <returns>The modified AST node if modified otherwise the original node</returns>
 public virtual AstNode VisitPseudoNode(PseudoNode pseudoNode)
 {
     return(pseudoNode);
 }