internal StyleSheetList(CssXmlDocument document) { doc = document; XmlNodeList pis = document.SelectNodes("/processing-instruction()"); styleSheets = new List<StyleSheet>(); foreach (XmlProcessingInstruction pi in pis) { if (Regex.IsMatch(pi.Data, "type=[\"']text\\/css[\"']")) { styleSheets.Add(new CssStyleSheet(pi, CssStyleSheetType.Author)); } else { styleSheets.Add(new StyleSheet(pi)); } } XmlNodeList styleNodes; foreach(string[] name in document.styleElements) { styleNodes = document.SelectNodes( "//*[local-name()='" + name[1] + "' and namespace-uri()='" + name[0] + "'][@type='text/css']"); foreach(XmlElement elm in styleNodes) { styleSheets.Add(new CssStyleSheet(elm, CssStyleSheetType.Author)); } } }
private CssStyleDeclaration getStyles(string xmlContent, string style, string localName) { CssXmlDocument doc = loadXml(xmlContent, style); XmlElement elm = getElm(doc, localName); return((CssStyleDeclaration)doc.GetComputedStyle(elm, "")); }
public virtual ICssStyleDeclaration GetComputedStyle(string pseudoElt) { CssXmlDocument ownerDoc = this.OwnerDocument; if (_isImported && _importDocument != null && _importNode != null) { ownerDoc = _importDocument; } if (_cachedCSD == null) { CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(this); MediaList currentMedia = ownerDoc.Media; if (ownerDoc.UserAgentStyleSheet != null) { ownerDoc.UserAgentStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd); } ((StyleSheetList)ownerDoc.StyleSheets).GetStylesForElement(this, pseudoElt, csd); ((CssStyleDeclaration)Style).GetStylesForElement(csd, 0); if (ownerDoc.UserStyleSheet != null) { ownerDoc.UserStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd); } _cachedCSD = csd; } return(_cachedCSD); }
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)); }
private CssXmlDocument loadXml(string content, string style) { CssXmlDocument doc = TestUtil.GetXmlDoc(content, style); doc.CssPropertyProfile.Add("inher", true, "init"); doc.CssPropertyProfile.Add("not", false, "init"); doc.CssPropertyProfile.Add("font-size", true, "12px"); return(doc); }
public void Init() { if(!initDone) { doc = new CssXmlDocument(); doc.AddStyleElement("http://www.w3.org/2000/svg", "style"); doc.Load("http://www.sharpvectors.org/tests/css_unittest_01.svg"); cssStyleSheet = (CssStyleSheet)doc.StyleSheets[0]; colorRules = (CssStyleDeclaration)((CssStyleRule)cssStyleSheet.CssRules[4]).Style; initDone = true; } }
public static CssXmlDocument GetXmlDoc(string content, string style) { CssXmlDocument doc = new CssXmlDocument(); doc.AddStyleElement("", "style"); string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<root>"; xml += "<style type='text/css'>" + style + "</style>"; xml += content; xml += "</root>"; doc.LoadXml(xml); return doc; }
public void Init() { if (!initDone) { doc = new CssXmlDocument(); doc.AddStyleElement("http://www.w3.org/2000/svg", "style"); doc.Load("http://www.sharpvectors.org/tests/css_unittest_01.svg"); cssStyleSheet = (CssStyleSheet)doc.StyleSheets[0]; colorRules = (CssStyleDeclaration)((CssStyleRule)cssStyleSheet.CssRules[4]).Style; initDone = true; } }
public static CssXmlDocument GetXmlDoc(string content, string style) { CssXmlDocument doc = new CssXmlDocument(); doc.AddStyleElement("", "style"); string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<root>"; xml += "<style type='text/css'>" + style + "</style>"; xml += content; xml += "</root>"; doc.LoadXml(xml); return(doc); }
private ICssValue getParentStyle(string propertyName) { CssXmlDocument doc = _element.OwnerDocument as CssXmlDocument; XmlElement parentNode = _element.ParentNode as XmlElement; if (doc != null && parentNode != null) { ICssStyleDeclaration parentCsd = doc.GetComputedStyle(parentNode, string.Empty); if (parentCsd == null) { return(null); } return(parentCsd.GetPropertyCssValue(propertyName)); } return(null); }
public CssXmlElement(string prefix, string localname, string ns, CssXmlDocument doc) : base(prefix, localname, ns, doc) { }
/// <summary> /// Uses the specified CSS XML document with Static state to true. /// </summary> /// <param name="cssXmlDocument">The CSS XML document.</param> public static IDisposable Use(CssXmlDocument cssXmlDocument) { return new StaticSection(cssXmlDocument); }
protected internal CssXmlElement(string prefix, string localname, string ns, CssXmlDocument doc) : base(prefix, localname, ns, doc) { }
private XmlElement getElm(CssXmlDocument doc, string localname) { return((XmlElement)doc.GetElementsByTagName(localname)[0]); }
/// <summary> /// Uses the specified CSS XML document with Static state to true. /// </summary> /// <param name="cssXmlDocument">The CSS XML document.</param> public static IDisposable Use(CssXmlDocument cssXmlDocument) { return(new StaticSection(cssXmlDocument)); }
/// <summary> /// Initializes a new instance of the <see cref="StaticSection"/> class. /// </summary> /// <param name="cssXmlDocument">The CSS XML document.</param> private StaticSection(CssXmlDocument cssXmlDocument) { _cssXmlDocument = cssXmlDocument; _previousStatic = cssXmlDocument.Static; cssXmlDocument.Static = true; }
private XmlElement getElm(CssXmlDocument doc, string localname) { return (XmlElement)doc.GetElementsByTagName(localname)[0]; }
public static XmlElement GetXmlElement(string content, string style, string localName) { CssXmlDocument doc = GetXmlDoc(content, style); return((XmlElement)doc.SelectSingleNode("//*[local-name()='" + localName + "']")); }
public virtual void TestTypeFromDocument() { CssXmlDocument doc = new CssXmlDocument(); doc.LoadXml("<dummy />"); XmlElement elm = doc.DocumentElement; Assert.AreEqual(elmType, elm.GetType()); }
public virtual void TestTypeFromCreateElement() { CssXmlDocument doc = new CssXmlDocument(); XmlElement elm = doc.CreateElement("", "dummy", ""); Assert.AreEqual(elm.GetType(), elmType); }