protected static Boolean ValidatePeriodic(CSSValue v, CSSProperty t, CSSProperty r, CSSProperty b, CSSProperty l) { var values = v as CSSValueList ?? new CSSValueList(v); CSSValue top = null; CSSValue right = null; CSSValue bottom = null; CSSValue left = null; if (values.Length > 4) { return(false); } foreach (var value in values) { if (!t.CanStore(value, ref top) && !r.CanStore(value, ref right) && !b.CanStore(value, ref bottom) && !l.CanStore(value, ref left)) { return(false); } } right = right ?? top; bottom = bottom ?? top; left = left ?? right; return(t.TrySetValue(top) && r.TrySetValue(right) && b.TrySetValue(bottom) && l.TrySetValue(left)); }
protected static String SerializePeriodic(CSSProperty t, CSSProperty r, CSSProperty b, CSSProperty l) { var top = t.SerializeValue(); var right = r.SerializeValue(); var bottom = b.SerializeValue(); var left = l.SerializeValue(); return(SerializePeriodic(top, right, bottom, left)); }
internal static Boolean CheckSingleProperty(CSSProperty property, Int32 index, CSSValueList arguments) { if (index < arguments.Length) { var argument = arguments[index]; return(property.TrySetValue(argument)); } return(false); }
internal static Boolean CheckLastProperty(CSSProperty property, Int32 index, CSSValueList arguments) { if (arguments.Length - index > 1) { var newList = new CSSValueList(); while (index < arguments.Length) { newList.Add(arguments[index++]); } return(property.TrySetValue(newList)); } return(CheckSingleProperty(property, index, arguments)); }
/// <summary> /// Appends the given rule to the list of rules. /// </summary> /// <param name="rule">The rule to append.</param> /// <returns>The current font-face rule.</returns> internal CSSFontFaceRule AppendRule(CSSProperty rule) { _cssRules.List.Add(rule); return(this); }
/// <summary> /// Appends the given rule to the list of rules. /// </summary> /// <param name="rule">The rule to append.</param> /// <returns>The current font-face rule.</returns> internal CSSPageRule AppendRule(CSSProperty rule) { _style.List.Add(rule); return this; }
public CssRuleViewModel(CSSProperty declaration) { Init(declaration); name = declaration.Name; children.Add(new CssRuleViewModel(declaration.Value)); }
/// <summary> /// Creates a new property from the given source. /// </summary> /// <param name="source">The token iterator starting at the name of the property.</param> /// <returns>The new property.</returns> CSSProperty CreateDeclaration(IEnumerator<CssToken> source) { String name = ((CssKeywordToken)source.Current).Data; CSSProperty property = null; CSSValue value = CSSValue.Inherit; Boolean hasValue = SkipToNextNonWhitespace(source) && source.Current.Type == CssTokenType.Colon; if (hasValue) value = CreateValueList(source); //TODO switch (name) { case "azimuth": case "animation": case "animation-delay": case "animation-direction": case "animation-duration": case "animation-fill-mode": case "animation-iteration-count": case "animation-name": case "animation-play-state": case "animation-timing-function": case "background-attachment": case "background-color": case "background-clip": case "background-origin": case "background-size": case "background-image": case "background-position": case "background-repeat": case "background": case "border-color": case "border-spacing": case "border-collapse": case "border-style": case "border-radius": case "box-shadow": case "box-decoration-break": case "break-after": case "break-before": case "break-inside": case "backface-visibility": case "border-top-left-radius": case "border-top-right-radius": case "border-bottom-left-radius": case "border-bottom-right-radius": case "border-image": case "border-image-outset": case "border-image-repeat": case "border-image-source": case "border-image-slice": case "border-image-width": case "border-top": case "border-right": case "border-bottom": case "border-left": case "border-top-color": case "border-left-color": case "border-right-color": case "border-bottom-color": case "border-top-style": case "border-left-style": case "border-right-style": case "border-bottom-style": case "border-top-width": case "border-left-width": case "border-right-width": case "border-bottom-width": case "border-width": case "border": case "bottom": case "columns": case "column-count": case "column-fill": case "column-gap": case "column-rule-color": case "column-rule-style": case "column-rule-width": case "column-span": case "column-width": case "caption-side": case "clear": case "clip": case "color": case "content": case "counter-increment": case "counter-reset": case "cue-after": case "cue-before": case "cue": case "cursor": case "direction": case "display": case "elevation": case "empty-cells": case "float": case "font-family": case "font-size": case "font-style": case "font-variant": case "font-weight": case "font": case "height": case "left": case "letter-spacing": case "line-height": case "list-style-image": case "list-style-position": case "list-style-type": case "list-style": case "marquee-direction": case "marquee-play-count": case "marquee-speed": case "marquee-style": case "margin-right": case "margin-left": case "margin-top": case "margin-bottom": case "margin": case "max-height": case "max-width": case "min-height": case "min-width": case "opacity": case "orphans": case "outline-color": case "outline-style": case "outline-width": case "outline": case "overflow": case "padding-top": case "padding-right": case "padding-left": case "padding-bottom": case "padding": case "page-break-after": case "page-break-before": case "page-break-inside": case "pause-after": case "pause-before": case "pause": case "perspective": case "perspective-origin": case "pitch-range": case "pitch": case "play-during": case "position": case "quotes": case "richness": case "right": case "speak-header": case "speak-numeral": case "speak-punctuation": case "speak": case "speech-rate": case "stress": case "table-layout": case "text-align": case "text-decoration": case "text-indent": case "text-transform": case "transform": case "transform-origin": case "transform-style": case "transition": case "transition-delay": case "transition-duration": case "transition-timing-function": case "transition-property": case "top": case "unicode-bidi": case "vertical-align": case "visibility": case "voice-family": case "volume": case "white-space": case "widows": case "width": case "word-spacing": case "z-index": default: property = new CSSProperty(name); property.Value = value; break; } if (hasValue) { while (source.Current.Type == CssTokenType.Delim && ((CssDelimToken)source.Current).Data == Specification.EM && SkipToNextNonWhitespace(source)) { } property.Important = source.Current.Type == CssTokenType.Ident && ((CssKeywordToken)source.Current).Data.Equals("important", StringComparison.OrdinalIgnoreCase); } SkipBehindNextSemicolon(source); return property; }
/// <summary> /// Appends the given rule to the list of rules. /// </summary> /// <param name="rule">The rule to append.</param> /// <returns>The current font-face rule.</returns> internal CSSFontFaceRule AppendRule(CSSProperty rule) { _cssRules.List.Add(rule); return this; }
/// <summary> /// Appends the given rule to the list of rules. /// </summary> /// <param name="rule">The rule to append.</param> /// <returns>The current font-face rule.</returns> internal CSSPageRule AppendRule(CSSProperty rule) { _style.List.Add(rule); return(this); }