protected override CssStyleDeclaration getCSD() { CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(getElm()); csd.CollectProperty("foo", 1, _getCssValue("bar"), CssStyleSheetType.Author, String.Empty); csd.CollectProperty("length", 1, _getCssValue("23cm"), CssStyleSheetType.Author, "important"); return(csd); }
public void CollectOverrideImportant1() { XmlElement elm = getElm(); CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm); csd.CollectProperty("foo", 100, _getCssValue("value1"), CssStyleSheetType.Author, ""); csd.CollectProperty("foo", 1, _getCssValue("value2"), CssStyleSheetType.Author, "important"); Assert.AreEqual("foo:value2 !important;", csd.CssText); }
public void Collect() { XmlElement elm = getElm(); CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm); Assert.AreEqual(0, csd.Length); csd.CollectProperty("foo", 1, _getCssValue("12px"), CssStyleSheetType.Author, "important"); Assert.AreEqual(1, csd.Length); Assert.AreEqual("foo:12px !important;", csd.CssText); csd.CollectProperty("bar", 1, _getCssValue("test"), CssStyleSheetType.Author, ""); Assert.AreEqual(2, csd.Length); Assert.AreEqual("foo:12px !important;bar:test;", csd.CssText); }
public override ICssStyleDeclaration GetComputedStyle(string pseudoElt) { SvgDocument ownerDoc = this.OwnerDocument; if (_isImported && _importDocument != null && _importNode != null) { ownerDoc = (SvgDocument)_importDocument; } if (_cachedCSD == null) { CssCollectedStyleDeclaration csd = (CssCollectedStyleDeclaration)base.GetComputedStyle(pseudoElt); var propNames = ownerDoc.CssPropertyProfile.GetAllPropertyNames(); IEnumerator <string> cssPropNames = propNames.GetEnumerator(); while (cssPropNames.MoveNext()) { string cssPropName = cssPropNames.Current; CssValue cssValue = (CssValue)GetPresentationAttribute(cssPropName); if (cssValue != null) { csd.CollectProperty(cssPropName, 0, cssValue, CssStyleSheetType.NonCssPresentationalHints, string.Empty); } } _cachedCSD = csd; } return(_cachedCSD); }
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()); }
public override ICssStyleDeclaration GetComputedStyle(string pseudoElt) { if (cachedCSD == null) { CssCollectedStyleDeclaration csd = (CssCollectedStyleDeclaration)base.GetComputedStyle(pseudoElt); IEnumerator cssPropNames = OwnerDocument.CssPropertyProfile.GetAllPropertyNames().GetEnumerator(); while (cssPropNames.MoveNext()) { string cssPropName = (string)cssPropNames.Current; CssValue cssValue = (CssValue)GetPresentationAttribute(cssPropName); if (cssValue != null) { csd.CollectProperty(cssPropName, 0, cssValue, CssStyleSheetType.NonCssPresentationalHints, String.Empty); } } cachedCSD = csd; } return(cachedCSD); }