Esempio n. 1
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
     {
         _rules.Add(rule, Owner, this);
     }
 }
Esempio n. 2
0
 internal void Add(CssRule rule)
 {
     if (rule != null)
     {
         _parent.AppendChild(rule);
     }
 }
Esempio n. 3
0
 internal void Insert(Int32 index, CssRule rule)
 {
     if (rule == null)
     {
         throw new DomException(DomError.Syntax);
     }
     else if (rule.Type == CssRuleType.Charset)
     {
         throw new DomException(DomError.Syntax);
     }
     else if (index > Length || index < 0)
     {
         throw new DomException(DomError.IndexSizeError);
     }
     else if (rule.Type == CssRuleType.Namespace && HasDeclarativeRules)
     {
         throw new DomException(DomError.InvalidState);
     }
     else if (index == Length)
     {
         _parent.AppendChild(rule);
     }
     else
     {
         _parent.InsertBefore(this[index], rule);
     }
 }
Esempio n. 4
0
 internal void Remove(CssRule rule)
 {
     if (rule != null)
     {
         _parent.RemoveChild(rule);
     }
 }
Esempio n. 5
0
 internal void Remove(CssRule rule)
 {
     if (rule != null)
     {
         _parent.RemoveChild(rule);
     }
 }
Esempio n. 6
0
 internal void Add(CssRule rule, ICssStyleSheet owner, ICssRule parent)
 {
     if (rule != null)
     {
         _rules.Add(rule);
         rule.Owner = owner;
         rule.Parent = parent;
     }
 }
Esempio n. 7
0
        internal void Add(CssRule rule)
        {
            if (rule != null)
            {
                if (_filterDisplayAndVisibilityOnly && FilterRuleOnAddOrInsert(rule))
                {
                    return;
                }

                _parent.AppendChild(rule);
            }
        }
Esempio n. 8
0
        internal void Insert(CssRule value, Int32 index, ICssStyleSheet owner, ICssRule parent)
        {
            if (value == null)
                throw new DomException(DomError.Syntax);
            else if (value.Type == CssRuleType.Charset)
                throw new DomException(DomError.Syntax);
            else if (index > _rules.Count)
                throw new DomException(DomError.IndexSizeError);
            else if (value.Type == CssRuleType.Namespace && _rules.Any(m => (m.Type != CssRuleType.Import && m.Type != CssRuleType.Charset && m.Type != CssRuleType.Namespace)))
                throw new DomException(DomError.InvalidState);

            _rules.Insert(index, value);
            value.Owner = owner;
            value.Parent = parent;
        }
Esempio n. 9
0
        /// <summary>
        /// Ignores all CSS style rules except the ones which impact the following two properties :
        /// - Display
        /// - Visibility
        /// </summary>
        private bool FilterRuleOnAddOrInsert(CssRule rule)
        {
            switch (rule.Type)
            {
            case CssRuleType.Charset:
            case CssRuleType.Import:
            case CssRuleType.Namespace:
            case CssRuleType.FontFace:
            case CssRuleType.Viewport:
                return(false);

            case CssRuleType.Page:
            case CssRuleType.Keyframe:
            case CssRuleType.Keyframes:
                return(true);

            case CssRuleType.Style:
                var styleRule = (CssStyleRule)rule;
                if (styleRule.Style.Declarations.Any(property => property is CssDisplayProperty || property is CssVisibilityProperty))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            case CssRuleType.Media:
            case CssRuleType.Supports:
            case CssRuleType.Document:
                var groupingRule = (ICssGroupingRule)rule;
                if (groupingRule.Rules.Length > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            default:
                return(true);
            }
        }
Esempio n. 10
0
        internal void Insert(Int32 index, CssRule rule)
        {
            if (rule == null)
                throw new DomException(DomError.Syntax);

            if (rule.Type == CssRuleType.Charset)
                throw new DomException(DomError.Syntax);

            if (index > Length || index < 0)
                throw new DomException(DomError.IndexSizeError);

            if (rule.Type == CssRuleType.Namespace && HasDeclarativeRules)
                throw new DomException(DomError.InvalidState);

            if (index == Length)
            {
                _parent.AppendChild(rule);
            }
            else
            {
                _parent.InsertBefore(this[index], rule);
            }
        }
Esempio n. 11
0
        internal void Insert(Int32 index, CssRule rule)
        {
            if (rule == null)
            {
                throw new DomException(DomError.Syntax);
            }

            if (rule.Type == CssRuleType.Charset)
            {
                throw new DomException(DomError.Syntax);
            }

            if (index > Length || index < 0)
            {
                throw new DomException(DomError.IndexSizeError);
            }

            if (rule.Type == CssRuleType.Namespace && HasDeclarativeRules)
            {
                throw new DomException(DomError.InvalidState);
            }

            if (_filterDisplayAndVisibilityOnly && FilterRuleOnAddOrInsert(rule))
            {
                return;
            }

            if (index == Length)
            {
                _parent.AppendChild(rule);
            }
            else
            {
                _parent.InsertBefore(this[index], rule);
            }
        }
Esempio n. 12
0
        static Boolean IsDeclarativeRule(CssRule rule)
        {
            var type = rule.Type;

            return(type != CssRuleType.Import && type != CssRuleType.Charset && type != CssRuleType.Namespace);
        }
Esempio n. 13
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner  = owner;
     value.Parent = parent;
 }
Esempio n. 14
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Esempio n. 15
0
 CssStyleDeclaration(CssRule parent, CssParser parser)
 {
     _parent = parent;
     _parser = parser;
 }
Esempio n. 16
0
 static Boolean IsDeclarativeRule(CssRule rule)
 {
     var type = rule.Type;
     return type != CssRuleType.Import && type != CssRuleType.Charset && type != CssRuleType.Namespace;
 }
Esempio n. 17
0
 internal void Add(CssRule rule)
 {
     if (rule != null)
     {
         _parent.AppendChild(rule);
     }
 }
Esempio n. 18
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
         _rules.Add(rule, Owner, this);
 }
Esempio n. 19
0
 /// <summary>
 /// Creates a new CSS style declaration.
 /// </summary>
 /// <param name="parent">The parent of the style declaration.</param>
 internal CssStyleDeclaration(CssRule parent)
     : this(parent, parent.Parser)
 {
 }
Esempio n. 20
0
 CssStyleDeclaration(CssRule parent, CssParser parser)
 {
     _parent = parent;
     _parser = parser;
     _declarations = new List<CssProperty>();
 }
Esempio n. 21
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner = owner;
     value.Parent = parent;
 }
Esempio n. 22
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Esempio n. 23
0
 internal void AddRule(CssRule rule)
 {
     _rules.Add(rule, Owner, this);
 }
Esempio n. 24
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
         _rules.Add(rule, this, null);
 }