Ejemplo n.º 1
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
     {
         _rules.Add(rule, Owner, this);
     }
 }
Ejemplo n.º 2
0
 internal void Add(CssRule rule)
 {
     if (rule != null)
     {
         _parent.AppendChild(rule);
     }
 }
Ejemplo 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);
     }
 }
Ejemplo n.º 4
0
 internal void Remove(CssRule rule)
 {
     if (rule != null)
     {
         _parent.RemoveChild(rule);
     }
 }
Ejemplo n.º 5
0
 internal void Remove(CssRule rule)
 {
     if (rule != null)
     {
         _parent.RemoveChild(rule);
     }
 }
Ejemplo n.º 6
0
 internal void Add(CssRule rule, ICssStyleSheet owner, ICssRule parent)
 {
     if (rule != null)
     {
         _rules.Add(rule);
         rule.Owner = owner;
         rule.Parent = parent;
     }
 }
Ejemplo n.º 7
0
        internal void Add(CssRule rule)
        {
            if (rule != null)
            {
                if (_filterDisplayAndVisibilityOnly && FilterRuleOnAddOrInsert(rule))
                {
                    return;
                }

                _parent.AppendChild(rule);
            }
        }
Ejemplo 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;
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 12
0
        static Boolean IsDeclarativeRule(CssRule rule)
        {
            var type = rule.Type;

            return(type != CssRuleType.Import && type != CssRuleType.Charset && type != CssRuleType.Namespace);
        }
Ejemplo n.º 13
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner  = owner;
     value.Parent = parent;
 }
Ejemplo n.º 14
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Ejemplo n.º 15
0
 CssStyleDeclaration(CssRule parent, CssParser parser)
 {
     _parent = parent;
     _parser = parser;
 }
Ejemplo n.º 16
0
 static Boolean IsDeclarativeRule(CssRule rule)
 {
     var type = rule.Type;
     return type != CssRuleType.Import && type != CssRuleType.Charset && type != CssRuleType.Namespace;
 }
Ejemplo n.º 17
0
 internal void Add(CssRule rule)
 {
     if (rule != null)
     {
         _parent.AppendChild(rule);
     }
 }
Ejemplo n.º 18
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
         _rules.Add(rule, Owner, this);
 }
Ejemplo 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)
 {
 }
Ejemplo n.º 20
0
 CssStyleDeclaration(CssRule parent, CssParser parser)
 {
     _parent = parent;
     _parser = parser;
     _declarations = new List<CssProperty>();
 }
Ejemplo n.º 21
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner = owner;
     value.Parent = parent;
 }
Ejemplo n.º 22
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Ejemplo n.º 23
0
 internal void AddRule(CssRule rule)
 {
     _rules.Add(rule, Owner, this);
 }
Ejemplo n.º 24
0
 internal void AddRule(CssRule rule)
 {
     if (rule != null)
         _rules.Add(rule, this, null);
 }