Skip to content

Commit 8860892

Browse files
committed
Added running value
1 parent 3ff35e9 commit 8860892

File tree

6 files changed

+92
-8
lines changed

6 files changed

+92
-8
lines changed

src/AngleSharp.Css/Constants/CssKeywords.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1545,11 +1545,11 @@ public static class CssKeywords
15451545
/// <summary>
15461546
/// The open keyword.
15471547
/// </summary>
1548-
public static readonly String Open;
1548+
public static readonly String Open = "open";
15491549

15501550
/// <summary>
15511551
/// The closed keyword.
15521552
/// </summary>
1553-
public static readonly String Closed;
1553+
public static readonly String Closed = "closed";
15541554
}
15551555
}

src/AngleSharp.Css/Constants/FunctionNames.cs

+5
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,10 @@ public static class FunctionNames
256256
/// The content function.
257257
/// </summary>
258258
public static readonly String Content = "content";
259+
260+
/// <summary>
261+
/// The running function.
262+
/// </summary>
263+
public static readonly String Running = "running";
259264
}
260265
}

src/AngleSharp.Css/Declarations/RunningDeclaration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static class RunningDeclaration
88
{
99
public static String Name = PropertyNames.Running;
1010

11-
public static IValueConverter Converter = Any;
11+
public static IValueConverter Converter = IdentifierConverter;
1212

1313
public static ICssValue InitialValue = InitialValues.RunningDecl;
1414

src/AngleSharp.Css/Parser/Micro/FunctionParser.cs

+23-4
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,31 @@ public static CssVarValue ParseVar(this StringSource source)
9999

100100
public static CssContentValue ParseContent(this StringSource source)
101101
{
102-
var name = source.ParseCustomIdent();
103-
var f = source.SkipGetSkip();
102+
if (source.IsFunction(FunctionNames.Content))
103+
{
104+
var name = source.ParseCustomIdent();
105+
var f = source.SkipGetSkip();
106+
107+
if (name != null && f == Symbols.RoundBracketClose)
108+
{
109+
return new CssContentValue(name);
110+
}
111+
}
104112

105-
if (name != null && f == Symbols.RoundBracketClose)
113+
return null;
114+
}
115+
116+
public static CssRunningValue ParseRunning(this StringSource source)
117+
{
118+
if (source.IsFunction(FunctionNames.Running))
106119
{
107-
return new CssContentValue(name);
120+
var name = source.ParseCustomIdent();
121+
var f = source.SkipGetSkip();
122+
123+
if (name != null && f == Symbols.RoundBracketClose)
124+
{
125+
return new CssRunningValue(name);
126+
}
108127
}
109128

110129
return null;

src/AngleSharp.Css/ValueConverters.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ static class ValueConverters
240240
/// </summary>
241241
public static readonly IValueConverter ContentConverter = FromParser(FunctionParser.ParseContent);
242242

243+
/// <summary>
244+
/// Creates a converter for the running function.
245+
/// </summary>
246+
public static readonly IValueConverter RunningConverter = FromParser(FunctionParser.ParseRunning);
247+
243248
#endregion
244249

245250
#region Maps
@@ -388,7 +393,7 @@ static class ValueConverters
388393
/// <summary>
389394
/// Represents a converter for the PositionMode enumeration.
390395
/// </summary>
391-
public static readonly IValueConverter PositionModeConverter = Map.PositionModes.ToConverter();
396+
public static readonly IValueConverter PositionModeConverter = Or(Map.PositionModes.ToConverter(), RunningConverter);
392397

393398
/// <summary>
394399
/// Represents a converter for the OverflowMode enumeration.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
namespace AngleSharp.Css.Values
2+
{
3+
using AngleSharp.Css.Dom;
4+
using AngleSharp.Text;
5+
using System;
6+
7+
/// <summary>
8+
/// Represents a CSS running function call.
9+
/// </summary>
10+
sealed class CssRunningValue : ICssFunctionValue
11+
{
12+
#region Fields
13+
14+
private readonly String _ident;
15+
16+
#endregion
17+
18+
#region ctor
19+
20+
/// <summary>
21+
/// Creates a new running function call.
22+
/// </summary>
23+
/// <param name="ident">The used identifier argument.</param>
24+
public CssRunningValue(String ident)
25+
{
26+
_ident = ident;
27+
}
28+
29+
#endregion
30+
31+
#region Properties
32+
33+
/// <summary>
34+
/// Gets the used identifier.
35+
/// </summary>
36+
public String Identifier => _ident;
37+
38+
/// <summary>
39+
/// Gets the name of the function.
40+
/// </summary>
41+
public String Name => FunctionNames.Running;
42+
43+
/// <summary>
44+
/// Gets the arguments.
45+
/// </summary>
46+
public ICssValue[] Arguments => new ICssValue[] { new Identifier(_ident) };
47+
48+
/// <summary>
49+
/// Gets the CSS text representation.
50+
/// </summary>
51+
public String CssText => Name.CssFunction(_ident);
52+
53+
#endregion
54+
}
55+
}

0 commit comments

Comments
 (0)