Esempio n. 1
0
        public CssRule CreateStyle(CssToken current)
        {
            var rule = new CssStyleRule(_parser);

            rule.Selector = CreateSelector(ref current);
            FillDeclarations(rule.Style);
            return(rule.Selector != null ? rule : null);
        }
Esempio n. 2
0
 public SvgStyleRule(CssStyleRule cssStyleRule)
 {
     Selectors = cssStyleRule?.Selectors ?? throw new ArgumentNullException(nameof(cssStyleRule));
     foreach (var p in cssStyleRule.Properties)
     {
         if (!Rules.TryPopulateProperty(p.Key, p.Value))
         {
             throw new Exception($"Unknown style property '{p.Key}:{p.Value}'");
         }
     }
 }
Esempio n. 3
0
 public SvgStyleRule(CssStyleRule cssStyleRule)
 {
     Selectors = cssStyleRule?.Selectors ?? throw new ArgumentNullException(nameof(cssStyleRule));
     foreach (var p in cssStyleRule.Properties)
     {
         if (!Rules.TryPopulateProperty(p.Key, p.Value))
         {
             // we should act like other things and ignore unknow properites
             //throw new Exception($"Unknown style property '{p.Key}:{p.Value}'");
         }
     }
 }
Esempio n. 4
0
        public CssStyleRule CreateStyle(CssStyleRule rule, CssToken current)
        {
            CollectTrivia(ref current);
            rule.SelectorText = GetArgument(ref current);

            if (current.Type != CssTokenType.CurlyBracketOpen)
            {
                SkipDeclarations(current);
                return(null);
            }

            FillDeclarations(rule.Style, NextToken());
            return(rule);
        }
Esempio n. 5
0
        public CssRule CreateStyle(CssToken current)
        {
            var rule  = new CssStyleRule(_parser);
            var start = current.Position;

            _nodes.Push(rule);
            CollectTrivia(ref current);
            rule.Selector = CreateSelector(ref current);
            var end = FillDeclarations(rule.Style);

            rule.SourceCode = CreateView(start, end);
            _nodes.Pop();
            return(rule.Selector != null ? rule : null);
        }
Esempio n. 6
0
        private ICssRule CreateStyleRule(ICssStyleSheet sheet, CssToken token)
        {
            var rule = new CssStyleRule(sheet);

            return(CreateStyle(rule, token));
        }