primitive selector expression
Inheritance: CssElementSelector
        public static bool IsCompatible(CssSimpleElementSelector sel1, CssSimpleElementSelector sel2)
        {
            //walk top of both

            var parOrSelf1 = GetTopParentOrSelf(sel1);
            var parOrSelf2 = GetTopParentOrSelf(sel2);
            return parOrSelf1.IsSameNameAndType(parOrSelf2);

        }
 static CssElementSelector GetTopParentOrSelf(CssSimpleElementSelector selector)
 {
     var parent = selector.Parent;
     if (parent == null)
     {
         return selector;
     }
     while (parent.Parent != null)
     {
         parent = parent.Parent;
     }
     return parent;
 }
Beispiel #3
0
        public void AddSelector(CssSimpleElementSelector primExpr)
        {
#if DEBUG
            if (primExpr == null)
            {

            }
#endif
            if (elementSelector == null)
            {
                elementSelector = primExpr;
            }
            else
            {
                CssCompundElementSelector combinatorExpr = this.elementSelector as CssCompundElementSelector;
                if (combinatorExpr != null)
                {
                    combinatorExpr.RightSelector = primExpr;
                }
                else
                {
                    CssSimpleElementSelector currentPrimExpr = this.elementSelector as CssSimpleElementSelector;
                    if (currentPrimExpr != null)
                    {
                        combinatorExpr = new CssCompundElementSelector(CssCombinatorOperator.Descendant);
                        combinatorExpr.LeftSelector = this.elementSelector;
                        combinatorExpr.RightSelector = primExpr;
                        this.elementSelector = combinatorExpr;
                    }
                    else
                    {
                    }
                }
            }
        }