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

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

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

            _name = newRule._name;
            base.ReplaceWith(rule);
        }
Esempio n. 4
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssDeclarationRule)rule;
     _declarations.Clear();
     _declarations.AddRange(newRule._declarations);
     newRule._declarations.Clear();
 }
Esempio n. 5
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssStyleRule)rule;
     _selector = newRule._selector;
     _style.Clear();
     _style.SetDeclarations(newRule._style.Declarations);
 }
Esempio 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;
        }
Esempio n. 8
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = rule as CssSupportsRule;

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

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

            _style.SetDeclarations(newRule.Style);
            _selector = newRule.Key;
        }
Esempio 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);
 }
Esempio 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);
        }
Esempio 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);
            }
        }
Esempio n. 16
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssNamespaceRule;
     _namespaceUri = newRule._namespaceUri;
     _prefix = newRule._prefix;
     base.ReplaceWith(rule);
 }
Esempio n. 17
0
        protected override void ReplaceWith(ICssRule rule)
        {
            base.ReplaceWith(rule);
            var newRule = (ICssImportRule)rule;

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

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

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

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

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

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

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

            _selector = newRule._selector;
            _style.Clear();
            _style.SetDeclarations(newRule._style.Declarations);
        }
Esempio 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);
 }
Esempio 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);
        }
Esempio n. 29
0
        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = (CssDeclarationRule)rule;

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

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

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

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

            parseString(css);
        }
Esempio n. 34
0
 internal void Add(CssRule rule, ICssStyleSheet owner, ICssRule parent)
 {
     if (rule != null)
     {
         _rules.Add(rule);
         rule.Owner = owner;
         rule.Parent = parent;
     }
 }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
     }
 }
Esempio 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;
            }
        }
Esempio n. 40
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = (CssGroupingRule)rule;
     _rules.Clear();
     _rules.Import(newRule._rules, Owner, Parent);
 }
Esempio n. 41
0
 internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent)
 {
     _rules.Add(value);
     value.Owner = owner;
     value.Parent = parent;
 }
Esempio n. 42
0
 protected override void ReplaceWith(ICssRule rule)
 {
     base.ReplaceWith(rule);
     var newRule = rule as CssSupportsRule;
     ConditionText = newRule.ConditionText;
 }
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssUnknownRule;
     _prelude = newRule._prelude;
     base.ReplaceWith(rule);
 }
Esempio n. 44
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssKeyframesRule;
     _name = newRule._name;
     base.ReplaceWith(rule);
 }
Esempio 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;
 }
Esempio n. 46
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CSSGroupingRule;
     _rules.List.Clear();
     _rules.List.AddRange(newRule._rules.List);
 }
Esempio n. 47
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssUnknownRule;
     _prelude = newRule._prelude;
     _content = newRule._content;
 }
Esempio 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);
Esempio n. 49
0
 protected virtual void ReplaceWith(ICssRule rule)
 {
     ReplaceAll(rule);
 }
Esempio 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);
 }
Esempio 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);
 }
Esempio n. 52
0
 internal CssStyleSheet(CssRule ownerRule, String url)
     : this(ownerRule.Parser, url, ownerRule.Owner)
 {
     _ownerRule = ownerRule;
 }
Esempio n. 53
0
 protected override void ReplaceWith(ICssRule rule)
 {
     var newRule = rule as CssCharsetRule;
     CharacterSet = newRule.CharacterSet;
 }
Esempio 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;
        }
Esempio n. 55
0
 protected override void ReplaceWith(ICssRule rule)
 {
     base.ReplaceWith(rule);
     var newRule = rule as CssMediaRule;
     _media.Import(newRule._media);
 }