GetCssValue() public static method

Detects what kind of value cssText contains and returns an instance of the correct CssValue class
public static GetCssValue ( string cssText, bool readOnly ) : CssValue
cssText string The text to parse for a CSS value
readOnly bool Specifies if this instance is read-only
return CssValue
        public override ICssValue GetPropertyCssValue(string propertyName)
        {
            if (_collectedStyles.ContainsKey(propertyName))
            {
                CssCollectedProperty scp = _collectedStyles[propertyName];
                if (scp.CssValue.CssValueType == CssValueType.Inherit)
                {
                    // get style from parent chain
                    return(getParentStyle(propertyName));
                }
                return(scp.CssValue.GetAbsoluteValue(propertyName, _element));
            }

            // should this property inherit?
            CssXmlDocument doc = (CssXmlDocument)_element.OwnerDocument;

            if (doc.CssPropertyProfile.IsInheritable(propertyName))
            {
                ICssValue parValue = getParentStyle(propertyName);
                if (parValue != null)
                {
                    return(parValue);
                }
            }

            string initValue = doc.CssPropertyProfile.GetInitialValue(propertyName);

            if (initValue == null)
            {
                return(null);
            }
            return(CssValue.GetCssValue(initValue, false).GetAbsoluteValue(propertyName, _element));
        }
Example #2
0
 public CssValue GetInitialCssValue(string propertyName)
 {
     if (_properties.ContainsKey(propertyName))
     {
         CssProperty cssProp = _properties[propertyName];
         if (cssProp.InitialCssValue == null)
         {
             cssProp.InitialCssValue = CssValue.GetCssValue(cssProp.InitialValue, false);
         }
         return(cssProp.InitialCssValue);
     }
     return(null);
 }
 /// <summary>
 /// Used to retrieve the object representation of the value of a CSS property if it has been explicitly set
 /// within this declaration block. This method returns null if the property is a shorthand property.
 /// Shorthand property values can only be accessed and modified as strings, using the getPropertyValue and
 /// setProperty methods.
 /// </summary>
 /// <param name="propertyName">The name of the CSS property. See the CSS property index.</param>
 /// <returns>Returns the value of the property if it has been explicitly set for this declaration block.
 /// Returns null if the property has not been set.</returns>
 public virtual ICssValue GetPropertyCssValue(string propertyName)
 {
     if (_styles.ContainsKey(propertyName))
     {
         CssStyleBlock scs = _styles[propertyName];
         if (scs.CssValue == null)
         {
             scs.CssValue = CssValue.GetCssValue(scs.Value, ReadOnly);
         }
         return(scs.CssValue);
     }
     return(null);
 }
Example #4
0
 /// <summary>
 /// Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block. This method returns null if the property is a shorthand property. Shorthand property values can only be accessed and modified as strings, using the getPropertyValue and setProperty methods.
 /// </summary>
 /// <param name="propertyName">The name of the CSS property. See the CSS property index.</param>
 /// <returns>Returns the value of the property if it has been explicitly set for this declaration block. Returns null if the property has not been set.</returns>
 public virtual ICssValue GetPropertyCssValue(string propertyName)
 {
     if (styles.ContainsKey(propertyName))
     {
         SharpCssStyle scs = (SharpCssStyle)styles[propertyName];
         if (scs.CssValue == null)
         {
             scs.CssValue = CssValue.GetCssValue(scs.Value, ReadOnly);
         }
         return(scs.CssValue);
     }
     else
     {
         return(null);
     }
 }
Example #5
0
 /// <summary>
 /// Used to retrieve the object representation of the value of a CSS property if it has been explicitly set
 /// within this declaration block. This method returns null if the property is a shorthand property.
 /// Shorthand property values can only be accessed and modified as strings, using the getPropertyValue and
 /// setProperty methods.
 /// </summary>
 /// <param name="propertyName">The name of the CSS property. See the CSS property index.</param>
 /// <returns>Returns the value of the property if it has been explicitly set for this declaration block.
 /// Returns null if the property has not been set.</returns>
 public virtual ICssValue GetPropertyCssValue(string propertyName)
 {
     if (string.IsNullOrWhiteSpace(propertyName))
     {
         return(null);
     }
     if (_styles.ContainsKey(propertyName))
     {
         CssStyleBlock scs = _styles[propertyName];
         if (propertyName.Equals(SvgConstants.AttrFontFamily, StringComparison.OrdinalIgnoreCase))
         {
             scs.CssValue = new CssValue(CssValueType.PrimitiveValue, scs.Value, ReadOnly);
         }
         else if (scs.CssValue == null)
         {
             scs.CssValue = CssValue.GetCssValue(scs.Value, ReadOnly);
         }
         return(scs.CssValue);
     }
     return(null);
 }