private void BuildRenderCSSProperty(RenderTreeBuilder builder, CSSProperty token) { builder.OpenElement(Next(), "span"); builder.AddAttribute(Next(), "class", _themeCssProperty); builder.AddContent(Next(), token.Content + ":"); builder.CloseElement(); }
/// <summary> /// Adds a declaration. /// </summary> /// <param name="property">The new property.</param> void AddDeclaration(CSSProperty property) { this.property = property; var rule = CurrentRule as IStyleDeclaration; if (rule != null) { rule.Style.List.Add(property); } }
/// <summary> /// Closes a property. /// </summary> void CloseProperty() { if (property != null) { property.Value = value; } value = null; property = null; }
/// <summary> /// Takes a string and transforms it into a CSS value. /// </summary> /// <param name="source">The string to parse.</param> /// <param name="quirksMode">Optional: The status of the quirks mode flag (usually not set).</param> /// <returns>The CSSValue object.</returns> public static CSSValue ParseValue(String source, Boolean quirksMode = false) { var parser = new CssParser(source); var property = new CSSProperty(String.Empty); parser.property = property; parser.IsQuirksMode = quirksMode; parser.skipExceptions = false; parser.state = CssState.BeforeValue; parser.Parse(); return(property.Value); }
/// <summary> /// Takes a comma separated string and transforms it into a list of CSS values. /// </summary> /// <param name="source">The string to parse.</param> /// <param name="quirksMode">Optional: The status of the quirks mode flag (usually not set).</param> /// <returns>The CSSValueList object.</returns> internal static CSSValuePool ParseMultipleValues(String source, Boolean quirksMode = false) { var parser = new CssParser(source); var pool = new CSSValuePool(); var property = new CSSProperty(String.Empty); property.Value = pool; parser.property = property; parser.IsQuirksMode = quirksMode; parser.skipExceptions = false; parser.state = CssState.InValuePool; parser.Parse(); return(pool); }
/// <summary> /// Takes a string and transforms it into a list of CSS values. /// </summary> /// <param name="source">The string to parse.</param> /// <param name="quirksMode">Optional: The status of the quirks mode flag (usually not set).</param> /// <returns>The CSSValueList object.</returns> internal static CSSValueList ParseValueList(String source, Boolean quirksMode = false) { var parser = new CssParser(source); var list = new CSSValueList(); var property = new CSSProperty(String.Empty); property.Value = list; parser.property = property; parser.IsQuirksMode = quirksMode; parser.skipExceptions = false; parser.state = CssState.InValueList; parser.Parse(); return(list); }
/// <summary> /// Called before the property name has been detected. /// </summary> /// <param name="token">The current token.</param> /// <returns>The status.</returns> Boolean InDeclaration(CssToken token) { if (token.Type == CssTokenType.CurlyBracketClose) { CloseProperty(); SwitchTo(CurrentRule is CSSKeyframeRule ? CssState.KeyframesData : CssState.Data); return(CloseRule()); } else if (token.Type == CssTokenType.Ident) { AddDeclaration(CSSProperty.Create(((CssKeywordToken)token).Data)); SwitchTo(CssState.AfterProperty); return(true); } return(false); }
Boolean Check(CSSValue[] values) { var target = new CSSProperty[] { new CSSPaddingTopProperty(), new CSSPaddingRightProperty(), new CSSPaddingBottomProperty(), new CSSPaddingLeftProperty() }; for (int i = 0; i < 4; i++) { target[i].Value = values[i]; if (target[i].Value != values[i]) { return(false); } } _top = (CSSPaddingTopProperty)target[0]; _right = (CSSPaddingRightProperty)target[1]; _bottom = (CSSPaddingBottomProperty)target[2]; _left = (CSSPaddingLeftProperty)target[3]; return(true); }
Boolean Check(CSSValue[] values) { var target = new CSSProperty[] { new CSSBorderBottomLeftRadiusProperty(), new CSSBorderBottomRightRadiusProperty(), new CSSBorderTopLeftRadiusProperty(), new CSSBorderTopRightRadiusProperty() }; for (int i = 0; i < 4; i++) { target[i].Value = values[i]; if (target[i].Value != values[i]) { return(false); } } _bottomLeft = (CSSBorderBottomLeftRadiusProperty)target[0]; _bottomRight = (CSSBorderBottomRightRadiusProperty)target[1]; _topLeft = (CSSBorderTopLeftRadiusProperty)target[2]; _topRight = (CSSBorderTopRightRadiusProperty)target[3]; return(true); }
/// <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); }
public CssRuleViewModel(CSSProperty declaration) { Init(declaration); name = declaration.Name; children.Add(new CssRuleViewModel(declaration.Value)); }
Boolean Check(CSSValue[] values) { var target = new CSSProperty[] { new CSSPaddingTopProperty(), new CSSPaddingRightProperty(), new CSSPaddingBottomProperty(), new CSSPaddingLeftProperty() }; for (int i = 0; i < 4; i++) { target[i].Value = values[i]; if (target[i].Value != values[i]) return false; } _top = (CSSPaddingTopProperty)target[0]; _right = (CSSPaddingRightProperty)target[1]; _bottom = (CSSPaddingBottomProperty)target[2]; _left = (CSSPaddingLeftProperty)target[3]; return true; }