AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.7.1" />

 WindowExtensions

static class WindowExtensions
A set of useful extension methods for the Window class.
using AngleSharp.Css; using AngleSharp.Dom; using AngleSharp.Dom.Collections; using AngleSharp.Dom.Css; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace AngleSharp.Extensions { [DebuggerStepThrough] internal static class WindowExtensions { public static CssStyleDeclaration ComputeDefaultStyle(this IWindow window, IElement element) { throw new NotImplementedException(); } public static CssStyleDeclaration ComputeRawStyle(this IWindow window, IElement element) { throw new NotImplementedException(); } public static CssStyleDeclaration ComputeUsedStyle(this IWindow window, IElement element) { throw new NotImplementedException(); } public static CssStyleDeclaration ComputeCascadedStyle(this StyleCollection styleCollection, IElement element) { CssStyleDeclaration cssStyleDeclaration = new CssStyleDeclaration(); IEnumerable<CssStyleRule> enumerable = styleCollection.SortBySpecifity(element); foreach (CssStyleRule item in enumerable) { CssStyleDeclaration style = item.Style; cssStyleDeclaration.SetDeclarations(style.Declarations); } return cssStyleDeclaration; } public static StyleCollection GetStyleCollection(this IWindow window) { RenderDevice device = new RenderDevice(window.OuterWidth, window.OuterHeight); IEnumerable<CssStyleSheet> sheets = window.Document.GetStyleSheets().OfType<CssStyleSheet>(); return new StyleCollection(sheets, device); } private static IEnumerable<CssStyleRule> SortBySpecifity(this IEnumerable<CssStyleRule> rules, IElement element) { return from m in rules where m.Selector.Match(element) orderby m.Selector.Specifity select m; } } }