public ICssValue GetPresentationAttribute(string name) { if (!presentationAttributes.ContainsKey(name)) { ICssValue result; string attValue = GetAttribute(name, string.Empty).Trim(); if (attValue != null && attValue.Length > 0) { if (isImportant.IsMatch(attValue)) { result = null; } else { result = CssValue.GetCssValue(attValue, false); } } else { result = null; } presentationAttributes[name] = result; } return(presentationAttributes[name]); }
public ICssValue GetPresentationAttribute(string name) { if (!_presentationAttributes.ContainsKey(name)) { ICssValue result; string attValue = GetAttribute(name, string.Empty).Trim(); if (!string.IsNullOrWhiteSpace(attValue)) { if (_isImportant.IsMatch(attValue)) { result = null; } else { result = CssValue.GetCssValue(attValue, false); } } else { result = null; } _presentationAttributes[name] = result; } return(_presentationAttributes[name]); }
public void PresAttUpdating() { SvgStyleableElement elm = Util.GetXmlElement("<title fill='black' />", "", "title") as SvgStyleableElement; Assert.AreEqual(CssValue.GetCssValue("black", false).CssText, elm.GetPresentationAttribute("fill").CssText); elm.SetAttribute("fill", "red"); Assert.AreEqual(CssValue.GetCssValue("red", false).CssText, elm.GetPresentationAttribute("fill").CssText); }
public void PresAttSettingNew() { SvgStyleableElement elm = Util.GetXmlElement("<title />", "", "title") as SvgStyleableElement; Assert.IsNull(elm.GetPresentationAttribute("stroke")); elm.SetAttribute("stroke", "red"); Assert.AreEqual(CssValue.GetCssValue("red", false).CssText, elm.GetPresentationAttribute("stroke").CssText); }
public void TestExsFontSize() { CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(getElm()); csd.CollectProperty("font-size", 1, CssValue.GetCssValue("2ex", false), CssStyleSheetType.Author, ""); CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("font-size") as CssPrimitiveValue; Assert.AreEqual(10, cssPrimValue.GetFloatValue(CssPrimitiveType.Px)); }
public void TestEmsNotFontSize() { CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(getElm()); csd.CollectProperty("notFontSize", 1, CssValue.GetCssValue("2em", false), CssStyleSheetType.Author, ""); CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("notFontSize") as CssPrimitiveValue; Assert.AreEqual(typeof(CssAbsPrimitiveLengthValue), cssPrimValue.GetType()); Assert.AreEqual(20, cssPrimValue.GetFloatValue(CssPrimitiveType.Px)); }
public void TestFuncAttr() { XmlElement elm = getElm(); elm.SetAttribute("kalle", "", "roffe"); CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm); csd.CollectProperty("foo", 1, CssValue.GetCssValue("attr(kalle)", false), CssStyleSheetType.Author, ""); CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("foo") as CssPrimitiveValue; Assert.IsNotNull(cssPrimValue); Assert.AreEqual("roffe", cssPrimValue.GetStringValue()); }
private CssValue _getCssValue(string cssText) { return(CssValue.GetCssValue(cssText, false)); }
public void TestCssUnknownNames() { CssValue cssValue = CssValue.GetCssValue("somedummyname", false); Assert.IsTrue(!(cssValue is CssPrimitiveRgbValue)); }