Skip to content

Commit 74f2641

Browse files
committed
Added GCPM declarations #7
1 parent 6459901 commit 74f2641

16 files changed

+308
-2
lines changed

doc/Values.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Types of Values
2+
3+
For details see [CSS2 specification](https://www.w3.org/TR/CSS2/cascade.html#value-stages).
4+
5+
* Specified values
6+
* Computed values
7+
* Used values
8+
* Actual values

src/AngleSharp.Css/Constants/CssKeywords.cs

+10
Original file line numberDiff line numberDiff line change
@@ -1531,5 +1531,15 @@ public static class CssKeywords
15311531
/// The visiblePainted keyword.
15321532
/// </summary>
15331533
public static readonly String VisiblePainted = "visiblePainted";
1534+
1535+
/// <summary>
1536+
/// The open keyword.
1537+
/// </summary>
1538+
public static readonly String Open;
1539+
1540+
/// <summary>
1541+
/// The closed keyword.
1542+
/// </summary>
1543+
public static readonly String Closed;
15341544
}
15351545
}

src/AngleSharp.Css/Constants/InitialValues.cs

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ static class InitialValues
2323
public static readonly ICssValue BackgroundOriginDecl = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox);
2424
public static readonly ICssValue BackgroundClipDecl = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.BorderBox);
2525
public static readonly ICssValue BackgroundAttachmentDecl = new Constant<BackgroundAttachment>(CssKeywords.Scroll, BackgroundAttachment.Scroll);
26+
public static readonly ICssValue BookmarkStateDecl = new Constant<BookmarkState>(CssKeywords.Open, BookmarkState.Open);
27+
public static readonly ICssValue BookmarkLabelDecl = new Constant<Object>(CssKeywords.None, null);
28+
public static readonly ICssValue BookmarkLevelDecl = new Constant<Int32>(CssKeywords.None, 0);
29+
public static readonly ICssValue FootnotePolicyDecl = new Constant<FootnotePolicy>(CssKeywords.Auto, FootnotePolicy.Auto);
30+
public static readonly ICssValue FootnoteDisplayDecl = new Constant<FootnoteDisplay>(CssKeywords.Block, FootnoteDisplay.Block);
31+
public static readonly ICssValue RunningDecl = new Identifier(CssKeywords.None);
32+
public static readonly ICssValue StringSetDecl = new Constant<Object>(CssKeywords.None, null);
2633
public static readonly ICssValue FontStyleDecl = new Constant<FontStyle>(CssKeywords.Normal, FontStyle.Normal);
2734
public static readonly ICssValue FontVariantDecl = new Constant<FontVariant>(CssKeywords.Normal, FontVariant.Normal);
2835
public static readonly ICssValue FontWeightDecl = new Constant<FontWeight>(CssKeywords.Normal, FontWeight.Normal);

src/AngleSharp.Css/Constants/PropertyNames.cs

+35
Original file line numberDiff line numberDiff line change
@@ -1306,5 +1306,40 @@ public static class PropertyNames
13061306
/// The orientation declaration.
13071307
/// </summary>
13081308
public static readonly String Orientation = "orientation";
1309+
1310+
/// <summary>
1311+
/// The string-set declaration.
1312+
/// </summary>
1313+
public static readonly String StringSet = "string-set";
1314+
1315+
/// <summary>
1316+
/// The running declaration.
1317+
/// </summary>
1318+
public static readonly String Running = "running";
1319+
1320+
/// <summary>
1321+
/// The footnote-display declaration.
1322+
/// </summary>
1323+
public static readonly String FootnoteDisplay = "footnote-display";
1324+
1325+
/// <summary>
1326+
/// The footnote-policy declaration.
1327+
/// </summary>
1328+
public static readonly String FootnotePolicy = "footnote-policy";
1329+
1330+
/// <summary>
1331+
/// The bookmark-level declaration.
1332+
/// </summary>
1333+
public static readonly String BookmarkLevel = "bookmark-level";
1334+
1335+
/// <summary>
1336+
/// The bookmark-label declaration.
1337+
/// </summary>
1338+
public static readonly String BookmarkLabel = "bookmark-label";
1339+
1340+
/// <summary>
1341+
/// The bookmark-state declaration.
1342+
/// </summary>
1343+
public static readonly String BookmarkState = "bookmark-state";
13091344
}
13101345
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class BookmarkLabelDeclaration
8+
{
9+
public static String Name = PropertyNames.BookmarkLabel;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.BookmarkLabelDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class BookmarkLevelDeclaration
8+
{
9+
public static String Name = PropertyNames.BookmarkLevel;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.BookmarkLevelDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class BookmarkStateDeclaration
8+
{
9+
public static String Name = PropertyNames.BookmarkState;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.BookmarkStateDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class FootnoteDisplayDeclaration
8+
{
9+
public static String Name = PropertyNames.FootnoteDisplay;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.FootnoteDisplayDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class FootnotePolicyDeclaration
8+
{
9+
public static String Name = PropertyNames.FootnotePolicy;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.FootnotePolicyDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class RunningDeclaration
8+
{
9+
public static String Name = PropertyNames.Running;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.RunningDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace AngleSharp.Css.Declarations
2+
{
3+
using AngleSharp.Css.Dom;
4+
using System;
5+
using static ValueConverters;
6+
7+
static class StringSetDeclaration
8+
{
9+
public static String Name = PropertyNames.StringSet;
10+
11+
public static IValueConverter Converter = Any;
12+
13+
public static ICssValue InitialValue = InitialValues.StringSetDecl;
14+
15+
public static PropertyFlags Flags = PropertyFlags.None;
16+
}
17+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace AngleSharp.Css.Dom
2+
{
3+
/// <summary>
4+
/// The selected bookmark state.
5+
/// </summary>
6+
public enum BookmarkState
7+
{
8+
/// <summary>
9+
/// The bookmarks of the nearest descendants of an element
10+
/// with a bookmark-state of open will be displayed.
11+
/// </summary>
12+
Open,
13+
/// <summary>
14+
/// Any bookmarks of descendant elements are not initially
15+
/// displayed.
16+
/// </summary>
17+
Closed,
18+
}
19+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace AngleSharp.Css.Dom
2+
{
3+
/// <summary>
4+
/// Represents the selected footnote display mode.
5+
/// </summary>
6+
public enum FootnoteDisplay
7+
{
8+
/// <summary>
9+
/// The footnote element is placed in the footnote
10+
/// area as a block element.
11+
/// </summary>
12+
Block,
13+
/// <summary>
14+
/// The footnote element is placed in the footnote
15+
/// area as an inline element.
16+
/// </summary>
17+
Inline,
18+
/// <summary>
19+
/// The user agent determines whether a given footnote
20+
/// element is placed as a block element or an inline
21+
/// element. If two or more footnotes could fit on the
22+
/// same line in the footnote area, they should be
23+
/// placed inline.
24+
/// </summary>
25+
Compact,
26+
}
27+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace AngleSharp.Css.Dom
2+
{
3+
/// <summary>
4+
/// Represents the selected footnote policy.
5+
/// </summary>
6+
public enum FootnotePolicy
7+
{
8+
/// <summary>
9+
/// The user agent chooses how to render footnotes, and may
10+
/// place the footnote body on a later page than the footnote
11+
/// reference. A footnote body must never be placed on a page
12+
/// before the footnote reference.
13+
/// </summary>
14+
Auto,
15+
/// <summary>
16+
/// If a given footnote body cannot be placed on the current
17+
/// page due to lack of space, the user agent introduces a
18+
/// forced page break at the start of the line containing
19+
/// the footnote reference, so that both the reference and
20+
/// the footnote body fall on the next page. Note that the
21+
/// user agent must honor widow and orphan settings when
22+
/// doing this, and so may need to insert the page break
23+
/// on an earlier line.
24+
/// </summary>
25+
Line,
26+
/// <summary>
27+
/// As with line, except a forced page break is introduced
28+
/// before the paragraph that contains the footnote.
29+
/// </summary>
30+
Block,
31+
}
32+
}

src/AngleSharp.Css/Extensions/StyleSheetExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class StyleSheetExtensions
1717
/// <typeparam name="TRule">The type of rules to get.</typeparam>
1818
/// <param name="sheets">The list of stylesheets to consider.</param>
1919
/// <returns>The list of rules.</returns>
20-
public static IEnumerable<TRule> RulesOf<TRule>(this IEnumerable<IStyleSheet> sheets)
20+
public static IEnumerable<TRule> GetRules<TRule>(this IEnumerable<IStyleSheet> sheets)
2121
where TRule : ICssRule
2222
{
2323
sheets = sheets ?? throw new ArgumentNullException(nameof(sheets));
@@ -79,7 +79,7 @@ public static IEnumerable<ICssStyleRule> StylesWith(this IEnumerable<IStyleSheet
7979
{
8080
selector = selector ?? throw new ArgumentNullException(nameof(selector));
8181
var selectorText = selector.Text;
82-
return sheets.RulesOf<ICssStyleRule>().Where(m => m.SelectorText == selectorText);
82+
return sheets.GetRules<ICssStyleRule>().Where(m => m.SelectorText == selectorText);
8383
}
8484

8585
/// <summary>

src/AngleSharp.Css/Factories/DefaultDeclarationFactory.cs

+49
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,55 @@ public class DefaultDeclarationFactory : IDeclarationFactory
1111
{
1212
private readonly Dictionary<String, DeclarationInfo> _declarations = new Dictionary<String, DeclarationInfo>(StringComparer.OrdinalIgnoreCase)
1313
{
14+
{
15+
BookmarkLabelDeclaration.Name, new DeclarationInfo(
16+
name: BookmarkLabelDeclaration.Name,
17+
converter: BookmarkLabelDeclaration.Converter,
18+
initialValue: BookmarkLabelDeclaration.InitialValue,
19+
flags: BookmarkLabelDeclaration.Flags)
20+
},
21+
{
22+
BookmarkLevelDeclaration.Name, new DeclarationInfo(
23+
name: BookmarkLevelDeclaration.Name,
24+
converter: BookmarkLevelDeclaration.Converter,
25+
initialValue: BookmarkLevelDeclaration.InitialValue,
26+
flags: BookmarkLevelDeclaration.Flags)
27+
},
28+
{
29+
BookmarkStateDeclaration.Name, new DeclarationInfo(
30+
name: BookmarkStateDeclaration.Name,
31+
converter: BookmarkStateDeclaration.Converter,
32+
initialValue: BookmarkStateDeclaration.InitialValue,
33+
flags: BookmarkStateDeclaration.Flags)
34+
},
35+
{
36+
FootnoteDisplayDeclaration.Name, new DeclarationInfo(
37+
name: FootnoteDisplayDeclaration.Name,
38+
converter: FootnoteDisplayDeclaration.Converter,
39+
initialValue: FootnoteDisplayDeclaration.InitialValue,
40+
flags: FootnoteDisplayDeclaration.Flags)
41+
},
42+
{
43+
FootnotePolicyDeclaration.Name, new DeclarationInfo(
44+
name: FootnotePolicyDeclaration.Name,
45+
converter: FootnotePolicyDeclaration.Converter,
46+
initialValue: FootnotePolicyDeclaration.InitialValue,
47+
flags: FootnotePolicyDeclaration.Flags)
48+
},
49+
{
50+
RunningDeclaration.Name, new DeclarationInfo(
51+
name: RunningDeclaration.Name,
52+
converter: RunningDeclaration.Converter,
53+
initialValue: RunningDeclaration.InitialValue,
54+
flags: RunningDeclaration.Flags)
55+
},
56+
{
57+
StringSetDeclaration.Name, new DeclarationInfo(
58+
name: StringSetDeclaration.Name,
59+
converter: StringSetDeclaration.Converter,
60+
initialValue: StringSetDeclaration.InitialValue,
61+
flags: StringSetDeclaration.Flags)
62+
},
1463
{
1564
CaptionSideDeclaration.Name, new DeclarationInfo(
1665
name: CaptionSideDeclaration.Name,

0 commit comments

Comments
 (0)