/// <summary> /// Creates a new shadow root. /// </summary> internal ShadowRoot(Element host, ShadowRootMode mode) : base(host.Owner, "#shadow-root", NodeType.DocumentFragment) { _host = host; _styleSheets = this.CreateStyleSheets(); _mode = mode; }
protected virtual IList <string> GetFontUrls() { List <string> fontUrls = new List <string>(); if (this.IsLoaded == false) { return(fontUrls); } XmlNodeList xmlList = this.SelectNodes(".//svg:font-face-uri", this.NamespaceManager); if (xmlList != null && xmlList.Count != 0) { foreach (XmlElement xmlNode in xmlList) { if (xmlNode.HasAttribute("href", SvgDocument.XLinkNamespace)) { string fontUrl = xmlNode.GetAttribute("href", SvgDocument.XLinkNamespace); if (!string.IsNullOrWhiteSpace(fontUrl)) { fontUrls.Add(fontUrl); } } else if (xmlNode.HasAttribute("href")) { string fontUrl = xmlNode.GetAttribute("href"); if (!string.IsNullOrWhiteSpace(fontUrl)) { fontUrls.Add(fontUrl); } } } } IStyleSheetList styleSheets = this.StyleSheets; if (styleSheets != null && styleSheets.Count != 0) { foreach (var styleSheet in styleSheets) { var cssSheet = styleSheet as CssStyleSheet; if (cssSheet == null) { continue; } GetFontUrl(cssSheet, fontUrls); } } GetFontUrl(this.UserAgentStyleSheet, fontUrls); GetFontUrl(this.UserStyleSheet, fontUrls); return(fontUrls); }
/// <summary> /// Sets the enabled style sheet sets in the list of style sheets. /// </summary> /// <param name="sheets">The list of style sheets.</param> /// <param name="name">The name of the set to enabled.</param> public static void EnableStyleSheetSet(this IStyleSheetList sheets, String name) { foreach (var sheet in sheets) { var title = sheet.Title; if (!String.IsNullOrEmpty(title)) { sheet.IsDisabled = title != name; } } }
/// <summary> /// Tries to find the matching namespace url for the given prefix. /// </summary> /// <param name="sheets">The list of style sheets.</param> /// <param name="prefix">The prefix of the namespace to find.</param> public static String?LocateNamespace(this IStyleSheetList sheets, String prefix) { var uri = default(String); var length = sheets.Length; for (var i = 0; i < length && uri is null; i++) { uri = sheets[i]?.LocateNamespace(prefix); } return(uri); }
/// <summary> /// Gets all possible style sheet sets from the list of style sheets. /// </summary> /// <param name="sheets">The list of style sheets.</param> /// <returns>An enumeration over all sets.</returns> public static IEnumerable <String> GetAllStyleSheetSets(this IStyleSheetList sheets) { var existing = new List <String>(); foreach (var sheet in sheets) { var title = sheet.Title; if (String.IsNullOrEmpty(title) || existing.Contains(title)) { continue; } existing.Add(title); yield return(title); } }
/// <summary> /// Gets the enabled style sheet sets from the list of style sheets. /// </summary> /// <param name="sheets">The list of style sheets.</param> /// <returns>An enumeration over the enabled sets.</returns> public static IEnumerable <String> GetEnabledStyleSheetSets(this IStyleSheetList sheets) { var excluded = new List <String>(); foreach (var sheet in sheets) { var title = sheet.Title; if (String.IsNullOrEmpty(title) || excluded.Contains(title)) { continue; } else if (sheet.IsDisabled) { excluded.Add(title); } } return(sheets.GetAllStyleSheetSets().Except(excluded)); }
/// <summary> /// Tries to find the matching namespace url for the given prefix. /// </summary> /// <param name="sheets">The list of style sheets.</param> /// <param name="prefix">The prefix of the namespace to find.</param> public static String LocateNamespace(this IStyleSheetList sheets, String prefix) { foreach (var sheet in sheets) { var css = sheet as CssStyleSheet; if (sheet.IsDisabled || css == null) { continue; } foreach (var rule in css.Rules.OfType <CssNamespaceRule>()) { if (rule.Prefix.Is(prefix)) { return(rule.NamespaceUri); } } } return(null); }
/// <summary> /// Creates a new document node. /// </summary> /// <param name="context">The context of the document.</param> /// <param name="source">The underlying source.</param> internal Document(IBrowsingContext context, TextSource source) : base(null, "#document", NodeType.Document) { _async = true; _designMode = false; _firedUnload = false; _salvageable = true; _shown = false; _preferredStyleSheetSet = String.Empty; _context = context ?? BrowsingContext.New(); _source = source; _referrer = String.Empty; _contentType = MimeTypes.ApplicationXml; _ready = DocumentReadyState.Loading; _sandbox = Sandboxes.None; _quirksMode = QuirksMode.Off; _tasks = new CancellableTasks(); _mutations = new MutationHost(Options); _loadingScripts = new Queue<HtmlScriptElement>(); _location = new Location(AboutBlank); _ranges = new List<WeakReference<Range>>(); _location.Changed += LocationChanged; _styleSheets = this.CreateStyleSheets(); _view = this.CreateWindow(); _loader = this.CreateLoader(); }