Esempio n. 1
0
 public void calc_specificity()
 {
     if (!string.IsNullOrEmpty(_right._tag) && _right._tag != "*")
     {
         _specificity.d = 1;
     }
     foreach (var i in _right._attrs)
     {
         if (i.attribute == "id")
         {
             _specificity.b++;
         }
         else if (i.attribute == "class")
         {
             _specificity.c += i.class_val.Count;
         }
         else
         {
             _specificity.c++;
         }
     }
     if (_left != null)
     {
         _left.calc_specificity();
         _specificity += _left._specificity;
     }
 }
Esempio n. 2
0
        bool parse_selectors(string txt, style styles, media_query_list media)
        {
            var tokens = new List <string>();

            html.split_string(txt.Trim(), tokens, ",");
            var added_something = false;

            foreach (var tok in tokens)
            {
                var selector = new css_selector(media);
                selector._style = styles;
                if (selector.parse(tok.Trim()))
                {
                    selector.calc_specificity();
                    add_selector(selector);
                    added_something = true;
                }
            }
            return(added_something);
        }