Exemplo n.º 1
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (CssFontFaceRule)rule;

            _style.Clear();
            _style.SetDeclarations(newRule._style);
        }
Exemplo n.º 2
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssUnknownRule;

            _prelude = newRule._prelude;
            base.ReplaceWith(rule);
        }
Exemplo n.º 3
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssKeyframesRule;

            _name = newRule._name;
            base.ReplaceWith(rule);
        }
Exemplo n.º 4
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssDeclarationRule)rule;
     _declarations.Clear();
     _declarations.AddRange(newRule._declarations);
     newRule._declarations.Clear();
 }
Exemplo n.º 5
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssStyleRule)rule;
     _selector = newRule._selector;
     _style.Clear();
     _style.SetDeclarations(newRule._style.Declarations);
 }
Exemplo n.º 6
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = rule as CSSMediaRule;

            _media.Import(newRule._media);
        }
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = (ICssSupportsRule)rule;

            _condition = newRule.Condition;
        }
Exemplo n.º 8
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = rule as CssSupportsRule;

            ConditionText = newRule.ConditionText;
        }
Exemplo n.º 9
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CSSStyleRule;

            _style.TakeFrom(newRule._style);
            _selector = newRule._selector;
        }
Exemplo n.º 10
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssImportRule;
     _href = newRule._href;
     _media.Import(newRule._media);
     _styleSheet = newRule._styleSheet;
 }
Exemplo n.º 11
0
 protected override void ReplaceWith(ICssRule rule)
 {
     base.ReplaceWith(rule);
     var newRule = rule as CssDocumentRule;
     _conditions.Clear();
     _conditions.AddRange(newRule._conditions);
 }
Exemplo n.º 12
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (ICssKeyframeRule)rule;

            _style.SetDeclarations(newRule.Style);
            _selector = newRule.Key;
        }
Exemplo n.º 13
0
 /// <summary>
 /// The constructor used internally when collecting styles for a specified element
 /// </summary>
 internal CssStyleDeclaration()
 {
     _origin     = CssStyleSheetType.Collector;
     _readOnly   = true;
     _parentRule = null;
     _styles     = new Dictionary <string, CssStyleBlock>(StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 14
0
        /// <summary>
        /// 验证规则
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        protected virtual bool Validate(ICssRule rule)
        {
            if (rule is ICssStyleRule styleRule)
            {
                return(Validate(styleRule.Style));
            }
            else if (rule is ICssGroupingRule groupingRule)
            {
                return(groupingRule.Rules.All(child => Validate(child)));
            }
            else if (rule is ICssPageRule pageRule)
            {
                return(Validate(pageRule.Style));
            }
            else if (rule is ICssKeyframesRule keyFramesRule)
            {
                return(keyFramesRule.Rules.OfType <ICssKeyframeRule>().All(child => Validate(child)));
            }
            else if (rule is ICssKeyframeRule keyFrameRule)
            {
                return(Validate(keyFrameRule.Style));
            }
            else if (rule is ICssImportRule importRule)
            {
                return(EmbedStyleSheets);
            }

            return(false);
        }
Exemplo n.º 15
0
        public void Insert(Int32 index, ICssRule 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)
            {
                _rules.Add(rule);
            }
            else
            {
                _rules.Insert(index, rule);
            }
        }
Exemplo n.º 16
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssNamespaceRule;
     _namespaceUri = newRule._namespaceUri;
     _prefix = newRule._prefix;
     base.ReplaceWith(rule);
 }
Exemplo n.º 17
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = (ICssImportRule)rule;

            _media.Replace(newRule.Media);
        }
Exemplo n.º 18
0
 public void Add(ICssRule rule)
 {
     if (rule != null)
     {
         _rules.Add(rule);
     }
 }
Exemplo n.º 19
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssNamespaceRule;

            _namespaceUri = newRule._namespaceUri;
            _prefix       = newRule._prefix;
        }
Exemplo n.º 20
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CSSGroupingRule;

            _rules.Clear();
            _rules.Import(newRule._rules, Owner, Parent);
        }
Exemplo n.º 21
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (ICssKeyframesRule)rule;

            _name = newRule.Name;
            ReplaceWith(newRule.Rules);
        }
Exemplo n.º 22
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssUnknownRule;

            _prelude = newRule._prelude;
            _content = newRule._content;
        }
Exemplo n.º 23
0
 public void Remove(ICssRule rule)
 {
     if (rule != null)
     {
         _rules.Remove(rule);
     }
 }
Exemplo n.º 24
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssCharsetRule;

            CharacterSet = newRule.CharacterSet;
            base.ReplaceWith(rule);
        }
Exemplo n.º 25
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (ICssImportRule)rule;

            _media.Replace(newRule.Media);
            _href       = newRule.Href;
            _styleSheet = newRule.Sheet;
        }
Exemplo n.º 26
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (CssKeyframeRule)rule;

            _selector = newRule._selector;
            _style.Clear();
            _style.SetDeclarations(newRule._style.Declarations);
        }
Exemplo n.º 27
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssImportRule;
     _href = newRule._href;
     _styleSheet = null;
     //TODO Load New StyleSheet
     base.ReplaceWith(rule);
 }
Exemplo n.º 28
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssKeyframesRule;

            _name = newRule._name;
            _rules.Clear();
            _rules.Import(newRule._rules, Owner, Parent);
        }
Exemplo n.º 29
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (CssDeclarationRule)rule;

            _declarations.Clear();
            _declarations.AddRange(newRule._declarations);
            newRule._declarations.Clear();
        }
Exemplo n.º 30
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssImportRule;

            _href = newRule._href;
            _media.Import(newRule._media);
            _styleSheet = newRule._styleSheet;
        }
Exemplo n.º 31
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = rule as CssDocumentRule;

            _conditions.Clear();
            _conditions.AddRange(newRule._conditions);
        }
Exemplo n.º 32
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = rule as CSSSupportsRule;

            _condition = newRule._condition;
            _used      = newRule._used;
        }
Exemplo n.º 33
0
        public CssStyleDeclaration(string css, CssRule parentRule, bool readOnly, CssStyleSheetType origin)
        {
            _origin = origin;
            _readOnly = readOnly;
            _parentRule = parentRule;

            parseString(css);
        }
Exemplo n.º 34
0
 internal void Add(CssRule rule, ICssStyleSheet owner, ICssRule parent)
 {
     if (rule != null)
     {
         _rules.Add(rule);
         rule.Owner = owner;
         rule.Parent = parent;
     }
 }
Exemplo n.º 35
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CssImportRule;

            _href       = newRule._href;
            _styleSheet = null;
            //TODO Load New StyleSheet
            base.ReplaceWith(rule);
        }
Exemplo n.º 36
0
        /// <summary>
        /// The constructor for CssStyleDeclaration
        /// </summary>
        /// <param name="css">The string to parse for CSS</param>
        /// <param name="parentRule">The parent rule or parent stylesheet</param>
        /// <param name="readOnly">True if this instance is readonly</param>
        /// <param name="origin">The type of CssStyleSheet</param>
        public CssStyleDeclaration(ref string css, CssRule parentRule, bool readOnly, CssStyleSheetType origin)
            : this()
        {
            _origin     = origin;
            _readOnly   = readOnly;
            _parentRule = parentRule;

            css = ParseString(css);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Removes an at-rule from the document.
        /// </summary>
        /// <param name="tag">Tag the style belongs to</param>
        /// <param name="rule">Rule to be removed</param>
        /// <returns>true, if the rule can be removed; false, otherwise.</returns>
        private bool RemoveAtRule(IElement tag, ICssRule rule)
        {
            var e = new RemovingAtRuleEventArgs {
                Tag = tag, Rule = rule
            };

            OnRemovingAtRule(e);
            return(!e.Cancel);
        }
Exemplo n.º 38
0
 internal void Import(CssRuleList rules, ICssStyleSheet owner, ICssRule parent)
 {
     while (rules._rules.Count > 0)
     {
         var newRule = rules._rules[0];
         rules._rules.RemoveAt(0);
         newRule.Parent = parent;
         newRule.Owner = owner;
         _rules.Add(newRule);
     }
 }
Exemplo n.º 39
0
        public CssRuleViewModel(ICssRule rule)
        {
            Init(rule);

            switch (rule.Type)
            {
                case CssRuleType.FontFace:
                    var font = (ICssFontFaceRule)rule;
                    name = "@font-face";
                    //How to populate ?
                    break;

                case CssRuleType.Keyframe:
                    var keyframe = (ICssKeyframeRule)rule;
                    name = keyframe.KeyText;
                    Populate(keyframe.Style);
                    break;

                case CssRuleType.Keyframes:
                    var keyframes = (ICssKeyframesRule)rule;
                    name = "@keyframes " + keyframes.Name;
                    Populate(keyframes.Rules);
                    break;

                case CssRuleType.Media:
                    var media = (ICssMediaRule)rule;
                    name = "@media " + media.Media.MediaText;
                    Populate(media.Rules);
                    break;

                case CssRuleType.Page:
                    var page = (ICssPageRule)rule;
                    name = "@page " + page.SelectorText;
                    Populate(page.Style);
                    break;

                case CssRuleType.Style:
                    var style = (ICssStyleRule)rule;
                    name = style.SelectorText;
                    Populate(style.Style);
                    break;

                case CssRuleType.Supports:
                    var support = (ICssSupportsRule)rule;
                    name = "@supports " + support.ConditionText;
                    Populate(support.Rules);
                    break;

                default:
                    name = rule.CssText;
                    break;
            }
        }
Exemplo n.º 40
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssGroupingRule)rule;
     _rules.Clear();
     _rules.Import(newRule._rules, Owner, Parent);
 }
Exemplo n.º 41
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner = owner;
     value.Parent = parent;
 }
Exemplo n.º 42
0
 protected override void ReplaceWith(ICssRule rule)
 {
     base.ReplaceWith(rule);
     var newRule = rule as CssSupportsRule;
     ConditionText = newRule.ConditionText;
 }
Exemplo n.º 43
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssUnknownRule;
     _prelude = newRule._prelude;
     base.ReplaceWith(rule);
 }
Exemplo n.º 44
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssKeyframesRule;
     _name = newRule._name;
     base.ReplaceWith(rule);
 }
Exemplo n.º 45
0
 /// <summary>
 /// The constructor used internally when collecting styles for a specified element
 /// </summary>
 internal CssStyleDeclaration()
 {
     _origin = CssStyleSheetType.Collector;
     _readOnly = true;
     _parentRule = null;
 }
Exemplo n.º 46
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CSSGroupingRule;
     _rules.List.Clear();
     _rules.List.AddRange(newRule._rules.List);
 }
Exemplo n.º 47
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssUnknownRule;
     _prelude = newRule._prelude;
     _content = newRule._content;
 }
Exemplo n.º 48
0
 /// <summary>
 /// Replaces the current object with the given rule.
 /// The types are equal.
 /// </summary>
 /// <param name="rule">The new rule.</param>
 protected abstract void ReplaceWith(ICssRule rule);
Exemplo n.º 49
0
 protected virtual void ReplaceWith(ICssRule rule)
 {
     ReplaceAll(rule);
 }
Exemplo n.º 50
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CSSKeyframesRule;
     _name = newRule._name;
     _rules.List.Clear();
     _rules.List.AddRange(newRule._rules.List);
 }
Exemplo n.º 51
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssKeyframesRule;
     _name = newRule._name;
     _rules.Clear();
     _rules.Import(newRule._rules, Owner, Parent);
 }
Exemplo n.º 52
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Exemplo n.º 53
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssCharsetRule;
     CharacterSet = newRule.CharacterSet;
 }
Exemplo n.º 54
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;
        }
Exemplo n.º 55
0
 protected override void ReplaceWith(ICssRule rule)
 {
     base.ReplaceWith(rule);
     var newRule = rule as CssMediaRule;
     _media.Import(newRule._media);
 }