Skip to content

Commit d9110cc

Browse files
committed
Exposed IStyleCollection #51
1 parent ebbf557 commit d9110cc

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace AngleSharp.Css.Dom
2+
{
3+
using System.Collections.Generic;
4+
5+
/// <summary>
6+
/// Represents a list of CSS stylesheets.
7+
/// </summary>
8+
public interface IStyleCollection : IEnumerable<ICssStyleRule>
9+
{
10+
/// <summary>
11+
/// Gets the associated render device.
12+
/// </summary>
13+
IRenderDevice Device { get; }
14+
}
15+
}

src/AngleSharp.Css/Dom/Internal/StyleCollection.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ namespace AngleSharp.Css.Dom
44
using System.Collections;
55
using System.Collections.Generic;
66

7-
/// <summary>
8-
/// Represents a list of CSS stylesheets.
9-
/// </summary>
10-
sealed class StyleCollection : IEnumerable<ICssStyleRule>
7+
sealed class StyleCollection : IStyleCollection
118
{
129
#region Fields
1310

src/AngleSharp.Css/Dom/StyleCollectionExtensions.cs renamed to src/AngleSharp.Css/Extensions/StyleCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace AngleSharp.Css
1111
/// <summary>
1212
/// A set of useful extension methods for the StyleCollection class.
1313
/// </summary>
14-
static class StyleCollectionExtensions
14+
public static class StyleCollectionExtensions
1515
{
1616
#region Methods
1717

@@ -20,7 +20,7 @@ static class StyleCollectionExtensions
2020
/// </summary>
2121
/// <param name="window">The window to host the style collection.</param>
2222
/// <returns>The device-bound style collection.</returns>
23-
public static StyleCollection GetStyleCollection(this IWindow window)
23+
public static IStyleCollection GetStyleCollection(this IWindow window)
2424
{
2525
var document = window.Document;
2626
var ctx = document.Context;
@@ -40,7 +40,7 @@ public static StyleCollection GetStyleCollection(this IWindow window)
4040
/// <param name="element">The element that is questioned.</param>
4141
/// <param name="pseudoSelector">The optional pseudo selector to use.</param>
4242
/// <returns>The style declaration containing all the declarations.</returns>
43-
public static ICssStyleDeclaration ComputeDeclarations(this StyleCollection rules, IElement element, String pseudoSelector = null)
43+
public static ICssStyleDeclaration ComputeDeclarations(this IStyleCollection rules, IElement element, String pseudoSelector = null)
4444
{
4545
var computedStyle = new CssStyleDeclaration(element.Owner?.Context);
4646
var nodes = element.GetAncestors().OfType<IElement>();
@@ -74,7 +74,7 @@ public static ICssStyleDeclaration ComputeDeclarations(this StyleCollection rule
7474
/// <param name="element">The element to compute the cascade for.</param>
7575
/// <param name="parent">The potential parent for the cascade.</param>
7676
/// <returns>Returns the cascaded read-only style declaration.</returns>
77-
public static ICssStyleDeclaration ComputeCascadedStyle(this StyleCollection styleCollection, IElement element, ICssStyleDeclaration parent = null)
77+
public static ICssStyleDeclaration ComputeCascadedStyle(this IStyleCollection styleCollection, IElement element, ICssStyleDeclaration parent = null)
7878
{
7979
var computedStyle = new CssStyleDeclaration(element.Owner?.Context);
8080
var rules = styleCollection.SortBySpecificity(element);

0 commit comments

Comments
 (0)