public void SortedRangeListChangeStampTest()
        {
            SortedRangeList <TestRange> list = new SortedRangeList <TestRange>();

            int stamp = list.ChangeStamp;

            list.ForceUpdateChangeStamp();
            Assert.AreNotEqual(stamp, list.ChangeStamp);
            stamp = list.ChangeStamp;

            list.Clear();
            Assert.AreEqual(stamp, list.ChangeStamp);

            list.Add(new TestRange(5, 1));
            list.Add(new TestRange(6, 1));
            Assert.AreNotEqual(stamp, list.ChangeStamp);
            stamp = list.ChangeStamp;

            list.IndexOf(list[0]);
            Assert.AreEqual(stamp, list.ChangeStamp);

            list.Remove(list[0]);
            Assert.AreNotEqual(stamp, list.ChangeStamp);
            stamp = list.ChangeStamp;

            list.Clear();
            Assert.AreNotEqual(stamp, list.ChangeStamp);
        }
Exemplo n.º 2
0
        private void UpdateDeclarationCache(ParseItem item)
        {
            var visitor = new CssItemCollector <Declaration>(true);

            item.Accept(visitor);

            HashSet <RuleBlock> rules = new HashSet <RuleBlock>();

            foreach (Declaration dec in visitor.Items)
            {
                RuleBlock rule = dec.Parent as RuleBlock;

                if (rule == null || rules.Contains(rule))
                {
                    continue;
                }

                var images = rule.Declarations.Where(d => d.PropertyName != null && d.PropertyName.Text.Contains("background"));

                foreach (Declaration image in images)
                {
                    if (!Cache.Contains(image))
                    {
                        Cache.Add(image);
                    }
                }

                rules.Add(rule);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Always called after parsing is done (full or incremental)
        /// </summary>
        public override void UpdateCachedChildren()
        {
            _declarations.Clear();
            _directives.Clear();

            int childCount = Children.Count;

            for (int i = 0; i < childCount; i++)
            {
                ParseItem child = Children[i];
                if (child is Declaration)
                {
                    if (_declarations == _emptyDeclarations)
                    {
                        _declarations = new SortedRangeList <Declaration>();
                    }

                    _declarations.Add((Declaration)child);
                }
                else if (child is AtDirective)
                {
                    if (_directives == _emptyDirectives)
                    {
                        _directives = new SortedRangeList <AtDirective>();
                    }

                    _directives.Add((AtDirective)child);
                }
            }

            base.UpdateCachedChildren();

            // tell the stylesheet to update in case we have new CustomProperties
            StyleSheet?.UpdateCachedChildren();
        }
        private void UpdateDeclarationCache(ParseItem item)
        {
            var visitor = new CssItemCollector <Declaration>(true);

            item.Accept(visitor);

            HashSet <RuleBlock> rules = new HashSet <RuleBlock>();

            foreach (Declaration dec in visitor.Items)
            {
                RuleBlock rule = dec.Parent as RuleBlock;
                if (rule == null || rules.Contains(rule))
                {
                    continue;
                }

                var vendors = rule.GetDeclarations().Where(d => d.IsValid && d.IsVendorSpecific());
                foreach (Declaration vendor in vendors)
                {
                    string      name     = GetStandardName(vendor);
                    Declaration standard = rule.GetDeclarations().FirstOrDefault(d => d.IsValid && d.PropertyName.Text == name);

                    if (standard != null)
                    {
                        if (!Cache.Contains(standard))
                        {
                            Cache.Add(standard);
                        }

                        if (GetValueText(standard) == GetValueText(vendor) && !Cache.Contains(vendor))
                        {
                            Cache.Add(vendor);
                        }
                    }
                }

                rules.Add(rule);
            }
        }
Exemplo n.º 5
0
        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector <Declaration>(true);

            item.Accept(visitor);

            foreach (TokenItem token in visitor.Items.Where(d => d.Important != null).Select(d => d.Important))
            {
                if (!_cache.Contains(token))
                {
                    _cache.Add(token);
                }
            }
        }
Exemplo n.º 6
0
        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector <Declaration>(true);

            item.Accept(visitor);

            foreach (Declaration dec in visitor.Items)
            {
                string text = dec.Text;

                if (text.StartsWith("var-", StringComparison.Ordinal))
                {
                    if (!_cache.Contains(dec))
                    {
                        _cache.Add(dec);
                    }
                }
            }
        }
        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector <SimpleSelector>(true);

            item.Accept(visitor);

            foreach (SimpleSelector ss in visitor.Items)
            {
                string text = ss.Text;

                if (ModernizrProvider.IsModernizr(text))
                {
                    if (!_cache.Contains(ss))
                    {
                        _cache.Add(ss);
                    }
                }
            }
        }