protected override void ReplaceWith(ICssRule rule) { var newRule = (CssFontFaceRule)rule; _style.Clear(); _style.SetDeclarations(newRule._style); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssUnknownRule; _prelude = newRule._prelude; base.ReplaceWith(rule); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssKeyframesRule; _name = newRule._name; base.ReplaceWith(rule); }
protected override void ReplaceWith(ICssRule rule) { var newRule = (CssDeclarationRule)rule; _declarations.Clear(); _declarations.AddRange(newRule._declarations); newRule._declarations.Clear(); }
protected override void ReplaceWith(ICssRule rule) { var newRule = (CssStyleRule)rule; _selector = newRule._selector; _style.Clear(); _style.SetDeclarations(newRule._style.Declarations); }
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; }
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 CSSStyleRule; _style.TakeFrom(newRule._style); _selector = newRule._selector; }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssImportRule; _href = newRule._href; _media.Import(newRule._media); _styleSheet = newRule._styleSheet; }
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; }
/// <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); }
/// <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); }
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); } }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssNamespaceRule; _namespaceUri = newRule._namespaceUri; _prefix = newRule._prefix; base.ReplaceWith(rule); }
protected override void ReplaceWith(ICssRule rule) { base.ReplaceWith(rule); var newRule = (ICssImportRule)rule; _media.Replace(newRule.Media); }
public void Add(ICssRule rule) { if (rule != null) { _rules.Add(rule); } }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssNamespaceRule; _namespaceUri = newRule._namespaceUri; _prefix = newRule._prefix; }
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); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssUnknownRule; _prelude = newRule._prelude; _content = newRule._content; }
public void Remove(ICssRule rule) { if (rule != null) { _rules.Remove(rule); } }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssCharsetRule; CharacterSet = newRule.CharacterSet; base.ReplaceWith(rule); }
protected override void ReplaceWith(ICssRule rule) { var newRule = (ICssImportRule)rule; _media.Replace(newRule.Media); _href = newRule.Href; _styleSheet = newRule.Sheet; }
protected override void ReplaceWith(ICssRule rule) { var newRule = (CssKeyframeRule)rule; _selector = newRule._selector; _style.Clear(); _style.SetDeclarations(newRule._style.Declarations); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssImportRule; _href = newRule._href; _styleSheet = null; //TODO Load New StyleSheet base.ReplaceWith(rule); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssKeyframesRule; _name = newRule._name; _rules.Clear(); _rules.Import(newRule._rules, Owner, Parent); }
protected override void ReplaceWith(ICssRule rule) { base.ReplaceWith(rule); var newRule = rule as CSSSupportsRule; _condition = newRule._condition; _used = newRule._used; }
public CssStyleDeclaration(string css, CssRule parentRule, bool readOnly, CssStyleSheetType origin) { _origin = origin; _readOnly = readOnly; _parentRule = parentRule; parseString(css); }
internal void Add(CssRule rule, ICssStyleSheet owner, ICssRule parent) { if (rule != null) { _rules.Add(rule); rule.Owner = owner; rule.Parent = parent; } }
/// <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); }
/// <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); }
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); } }
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; } }
protected override void ReplaceWith(ICssRule rule) { var newRule = (CssGroupingRule)rule; _rules.Clear(); _rules.Import(newRule._rules, Owner, Parent); }
internal void Add(CssRule value, ICssStyleSheet owner, ICssRule parent) { _rules.Add(value); value.Owner = owner; value.Parent = parent; }
/// <summary> /// The constructor used internally when collecting styles for a specified element /// </summary> internal CssStyleDeclaration() { _origin = CssStyleSheetType.Collector; _readOnly = true; _parentRule = null; }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CSSGroupingRule; _rules.List.Clear(); _rules.List.AddRange(newRule._rules.List); }
/// <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);
protected virtual void ReplaceWith(ICssRule rule) { ReplaceAll(rule); }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CSSKeyframesRule; _name = newRule._name; _rules.List.Clear(); _rules.List.AddRange(newRule._rules.List); }
internal CssStyleSheet(CssRule ownerRule, String url) : this(ownerRule.Parser, url, ownerRule.Owner) { _ownerRule = ownerRule; }
protected override void ReplaceWith(ICssRule rule) { var newRule = rule as CssCharsetRule; CharacterSet = newRule.CharacterSet; }
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; }
protected override void ReplaceWith(ICssRule rule) { base.ReplaceWith(rule); var newRule = rule as CssMediaRule; _media.Import(newRule._media); }