This commit is contained in:
Florian Rappl 2024-01-21 01:01:36 +01:00
Родитель b755de0b94
Коммит 281d7955ae
297 изменённых файлов: 2382 добавлений и 2981 удалений

Просмотреть файл

@ -10,7 +10,7 @@
<icon>logo.png</icon> <icon>logo.png</icon>
<readme>README.md</readme> <readme>README.md</readme>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Extends the CSSOM from the core AngleSharp library.</description> <description>Extends the CSSOM from the core AngleSharp library. It parses CSS3 and is capable of performing a headless rendering evaluating the styles.</description>
<releaseNotes>https://github.com/AngleSharp/AngleSharp.Css/blob/main/CHANGELOG.md</releaseNotes> <releaseNotes>https://github.com/AngleSharp/AngleSharp.Css/blob/main/CHANGELOG.md</releaseNotes>
<copyright>Copyright 2016-2024, AngleSharp</copyright> <copyright>Copyright 2016-2024, AngleSharp</copyright>
<tags>html html5 css css3 dom styling library anglesharp angle</tags> <tags>html html5 css css3 dom styling library anglesharp angle</tags>

Просмотреть файл

@ -4,10 +4,8 @@
<RootNamespace>AngleSharp.Css</RootNamespace> <RootNamespace>AngleSharp.Css</RootNamespace>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks> <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net461;net472;net6.0;net7.0;net8.0</TargetFrameworks> <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net461;net472;net6.0;net7.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>9</LangVersion> <Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Css</RepositoryUrl> <RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Css</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>

Просмотреть файл

@ -20,7 +20,7 @@ namespace AngleSharp.Css
/// <param name="address">The address of the resource.</param> /// <param name="address">The address of the resource.</param>
/// <param name="element">The hosting element.</param> /// <param name="element">The hosting element.</param>
/// <returns>The async task.</returns> /// <returns>The async task.</returns>
public static Task<IStyleSheet> OpenStyleSheetAsync(this IBrowsingContext context, Url address, IElement element) => public static Task<IStyleSheet?> OpenStyleSheetAsync(this IBrowsingContext context, Url address, IElement element) =>
context.OpenStyleSheetAsync(address, element, CancellationToken.None); context.OpenStyleSheetAsync(address, element, CancellationToken.None);
/// <summary> /// <summary>
@ -31,21 +31,20 @@ namespace AngleSharp.Css
/// <param name="element">The hosting element.</param> /// <param name="element">The hosting element.</param>
/// <param name="cancel">The cancellation token.</param> /// <param name="cancel">The cancellation token.</param>
/// <returns>The async task.</returns> /// <returns>The async task.</returns>
public static async Task<IStyleSheet> OpenStyleSheetAsync(this IBrowsingContext context, Url address, IElement element, CancellationToken cancel) public static async Task<IStyleSheet?> OpenStyleSheetAsync(this IBrowsingContext context, Url address, IElement element, CancellationToken cancel)
{ {
var loader = context.GetService<IResourceLoader>(); var loader = context.GetService<IResourceLoader>();
var service = context.GetCssStyling(); var service = context.GetCssStyling();
if (loader != null && service != null) if (loader is not null && service is not null)
{ {
var request = element.CreateRequestFor(address); var request = element.CreateRequestFor(address);
var download = loader.FetchAsync(request); var download = loader.FetchAsync(request);
using (var response = await download.Task.ConfigureAwait(false)) using var response = await download.Task.ConfigureAwait(false);
{ var document = element.Owner ?? context.Active ?? throw new InvalidOperationException("Could not find a related documented.");
var options = new StyleOptions(element?.Owner ?? context.Active) { Element = element }; var options = new StyleOptions(document) { Element = element };
return await service.ParseStylesheetAsync(response, options, cancel).ConfigureAwait(false); return await service.ParseStylesheetAsync(response, options, cancel).ConfigureAwait(false);
}
} }
return null; return null;
@ -57,7 +56,7 @@ namespace AngleSharp.Css
return factory.Create(propertyName); return factory.Create(propertyName);
} }
internal static ICssProperty CreateShorthand(this IBrowsingContext context, String name, ICssValue[] longhands, Boolean important) internal static ICssProperty? CreateShorthand(this IBrowsingContext context, String name, ICssValue[] longhands, Boolean important)
{ {
var factory = context.GetFactory<IDeclarationFactory>(); var factory = context.GetFactory<IDeclarationFactory>();
var info = factory.Create(name); var info = factory.Create(name);
@ -79,7 +78,7 @@ namespace AngleSharp.Css
return factory.CreateProperties(info.Longhands, values, shorthand.IsImportant); return factory.CreateProperties(info.Longhands, values, shorthand.IsImportant);
} }
internal static CssProperty CreateProperty(this IBrowsingContext context, String propertyName) internal static CssProperty? CreateProperty(this IBrowsingContext context, String propertyName)
{ {
var info = context.GetDeclarationInfo(propertyName); var info = context.GetDeclarationInfo(propertyName);
@ -102,7 +101,7 @@ namespace AngleSharp.Css
private static ICssProperty[] CreateProperties(this IDeclarationFactory factory, String[] names, ICssValue[] values, Boolean important) private static ICssProperty[] CreateProperties(this IDeclarationFactory factory, String[] names, ICssValue[] values, Boolean important)
{ {
if (values != null && values.Length == names.Length) if (values.Length == names.Length)
{ {
var properties = new ICssProperty[names.Length]; var properties = new ICssProperty[names.Length];
@ -115,7 +114,7 @@ namespace AngleSharp.Css
return properties; return properties;
} }
return null; return [];
} }
} }
} }

Просмотреть файл

@ -18,7 +18,7 @@ namespace AngleSharp.Css
public static readonly ICssValue BackgroundRepeatDecl = new CssImageRepeatsValue(BackgroundRepeatHorizontalDecl, BackgroundRepeatVerticalDecl); public static readonly ICssValue BackgroundRepeatDecl = new CssImageRepeatsValue(BackgroundRepeatHorizontalDecl, BackgroundRepeatVerticalDecl);
public static readonly ICssValue BackgroundPositionXDecl = new CssLengthValue(0, CssLengthValue.Unit.Percent); public static readonly ICssValue BackgroundPositionXDecl = new CssLengthValue(0, CssLengthValue.Unit.Percent);
public static readonly ICssValue BackgroundPositionYDecl = new CssLengthValue(0, CssLengthValue.Unit.Percent); public static readonly ICssValue BackgroundPositionYDecl = new CssLengthValue(0, CssLengthValue.Unit.Percent);
public static readonly ICssValue BackgroundPositionDecl = new CssTupleValue(new [] { BackgroundPositionXDecl, BackgroundPositionYDecl }); public static readonly ICssValue BackgroundPositionDecl = new CssTupleValue([BackgroundPositionXDecl, BackgroundPositionYDecl]);
public static readonly ICssValue BackgroundSizeDecl = new CssBackgroundSizeValue(new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto), new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto)); public static readonly ICssValue BackgroundSizeDecl = new CssBackgroundSizeValue(new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto), new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto));
public static readonly ICssValue BackgroundOriginDecl = new CssConstantValue<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox); public static readonly ICssValue BackgroundOriginDecl = new CssConstantValue<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox);
public static readonly ICssValue BackgroundClipDecl = new CssConstantValue<BoxModel>(CssKeywords.BorderBox, BoxModel.BorderBox); public static readonly ICssValue BackgroundClipDecl = new CssConstantValue<BoxModel>(CssKeywords.BorderBox, BoxModel.BorderBox);
@ -204,13 +204,13 @@ namespace AngleSharp.Css
public static readonly ICssValue ZIndexDecl = new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto); public static readonly ICssValue ZIndexDecl = new CssConstantValue<CssLengthValue>(CssKeywords.Auto, CssLengthValue.Auto);
public static readonly ICssValue WidthDecl = CssLengthValue.Auto; public static readonly ICssValue WidthDecl = CssLengthValue.Auto;
public static readonly ICssValue HeightDecl = CssLengthValue.Auto; public static readonly ICssValue HeightDecl = CssLengthValue.Auto;
public static readonly ICssValue ScrollbarTrackColorDecl = CssColors.GetColor("scrollbar"); public static readonly ICssValue ScrollbarTrackColorDecl = CssColors.GetColor("scrollbar")!;
public static readonly ICssValue ScrollbarShadowColorDecl = CssColors.GetColor("threeddarkshadow"); public static readonly ICssValue ScrollbarShadowColorDecl = CssColors.GetColor("threeddarkshadow")!;
public static readonly ICssValue ScrollbarHighlightColorDecl = CssColors.GetColor("threedhighlight"); public static readonly ICssValue ScrollbarHighlightColorDecl = CssColors.GetColor("threedhighlight")!;
public static readonly ICssValue ScrollbarFaceColorDecl = CssColors.GetColor("threedface"); public static readonly ICssValue ScrollbarFaceColorDecl = CssColors.GetColor("threedface")!;
public static readonly ICssValue ScrollbarDarkshadowColorDecl = CssColors.GetColor("threeddarkshadow"); public static readonly ICssValue ScrollbarDarkshadowColorDecl = CssColors.GetColor("threeddarkshadow")!;
public static readonly ICssValue ScrollbarBaseColorDecl = CssColorValue.Transparent; public static readonly ICssValue ScrollbarBaseColorDecl = CssColorValue.Transparent;
public static readonly ICssValue ScrollbarArrowColorDecl = CssColors.GetColor("buttontext"); public static readonly ICssValue ScrollbarArrowColorDecl = CssColors.GetColor("buttontext")!;
public static readonly ICssValue Scrollbar3dLightColorDecl = CssColorValue.White; public static readonly ICssValue Scrollbar3dLightColorDecl = CssColorValue.White;
public static readonly ICssValue LetterSpacingDecl = CssLengthValue.Normal; public static readonly ICssValue LetterSpacingDecl = CssLengthValue.Normal;
public static readonly ICssValue FontSizeAdjustDecl = new CssLengthValue(1.0, CssLengthValue.Unit.Em); public static readonly ICssValue FontSizeAdjustDecl = new CssLengthValue(1.0, CssLengthValue.Unit.Em);

Просмотреть файл

@ -4,15 +4,10 @@
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class ClassValueConverter<T> : IValueConverter sealed class ClassValueConverter<T>(Func<StringSource, T> converter) : IValueConverter
where T : class, ICssValue where T : class, ICssValue
{ {
private readonly Func<StringSource, T> _converter; private readonly Func<StringSource, T> _converter = converter;
public ClassValueConverter(Func<StringSource, T> converter)
{
_converter = converter;
}
public ICssValue Convert(StringSource source) public ICssValue Convert(StringSource source)
{ {

Просмотреть файл

@ -4,23 +4,17 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Parser; using AngleSharp.Css.Parser;
using AngleSharp.Css.Values; using AngleSharp.Css.Values;
using AngleSharp.Text; using AngleSharp.Text;
using System;
using System.Collections.Generic; using System.Collections.Generic;
sealed class CounterValueConverter : IValueConverter sealed class CounterValueConverter(ICssValue defaultValue) : IValueConverter
{ {
private static readonly CssCounterValue[] NoneValue = Array.Empty<CssCounterValue>(); private static readonly CssCounterValue[] NoneValue = [];
private readonly ICssValue _defaultValue; private readonly ICssValue _defaultValue = defaultValue;
public CounterValueConverter(ICssValue defaultValue) public ICssValue? Convert(StringSource source)
{ {
_defaultValue = defaultValue; var counters = new List<ICssValue>();
}
public ICssValue Convert(StringSource source)
{
var counters = new List<CssCounterValue>();
if (!source.IsIdentifier(CssKeywords.None)) if (!source.IsIdentifier(CssKeywords.None))
{ {
@ -39,7 +33,7 @@ namespace AngleSharp.Css.Converters
counters.Add(new CssCounterValue(name, value)); counters.Add(new CssCounterValue(name, value));
} }
return new CssTupleValue<CssCounterValue>(counters.ToArray()); return new CssTupleValue([.. counters]);
} }
return new CssConstantValue<CssCounterValue[]>(CssKeywords.None, NoneValue); return new CssConstantValue<CssCounterValue[]>(CssKeywords.None, NoneValue);

Просмотреть файл

@ -7,22 +7,16 @@ namespace AngleSharp.Css.Converters
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
sealed class DictionaryValueConverter<T> : IValueConverter sealed class DictionaryValueConverter<T>(IDictionary<String, T> values) : IValueConverter
{ {
private readonly IDictionary<String, T> _values; private readonly IDictionary<String, T> _values = values;
public DictionaryValueConverter(IDictionary<String, T> values) public ICssValue? Convert(StringSource source)
{
_values = values;
}
public ICssValue Convert(StringSource source)
{ {
var pos = source.Index; var pos = source.Index;
var ident = source.ParseIdent(); var ident = source.ParseIdent();
var mode = default(T);
if (ident != null && _values.TryGetValue(ident, out mode)) if (ident is not null && _values.TryGetValue(ident, out var mode))
{ {
return new CssConstantValue<T>(ident.ToLowerInvariant(), mode); return new CssConstantValue<T>(ident.ToLowerInvariant(), mode);
} }

Просмотреть файл

@ -6,28 +6,23 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class FlowRelativeValueConverter : IValueConverter sealed class FlowRelativeValueConverter(IValueConverter converter) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
public FlowRelativeValueConverter(IValueConverter converter) public ICssValue? Convert(StringSource source)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{ {
var options = new ICssValue[2]; var options = new ICssValue[2];
var length = 0; var length = 0;
for (var i = 0; i < options.Length; i++) for (var i = 0; i < options.Length; i++)
{ {
options[i] = _converter.Convert(source); var option = _converter.Convert(source);
source.SkipSpacesAndComments(); source.SkipSpacesAndComments();
if (options[length] != null) if (option is not null)
{ {
length++; options[length++] = option;
} }
} }

Просмотреть файл

@ -6,20 +6,15 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class IdentifierValueConverter : IValueConverter sealed class IdentifierValueConverter(Func<StringSource, String> check) : IValueConverter
{ {
private readonly Func<StringSource, String> _check; private readonly Func<StringSource, String> _check = check;
public IdentifierValueConverter(Func<StringSource, String> check) public ICssValue? Convert(StringSource source)
{
_check = check;
}
public ICssValue Convert(StringSource source)
{ {
var result = _check.Invoke(source); var result = _check.Invoke(source);
if (result != null) if (result is not null)
{ {
return new CssIdentifierValue(result); return new CssIdentifierValue(result);
} }
@ -28,18 +23,12 @@ namespace AngleSharp.Css.Converters
} }
} }
sealed class IdentifierValueConverter<T> : IValueConverter sealed class IdentifierValueConverter<T>(String identifier, T result) : IValueConverter
{ {
private readonly String _identifier; private readonly String _identifier = identifier;
private readonly T _result; private readonly T _result = result;
public IdentifierValueConverter(String identifier, T result) public ICssValue? Convert(StringSource source)
{
_identifier = identifier;
_result = result;
}
public ICssValue Convert(StringSource source)
{ {
if (source.IsIdentifier(_identifier)) if (source.IsIdentifier(_identifier))
{ {

Просмотреть файл

@ -6,16 +6,11 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System.Collections.Generic; using System.Collections.Generic;
sealed class ListValueConverter : IValueConverter sealed class ListValueConverter(IValueConverter converter) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
public ListValueConverter(IValueConverter converter) public ICssValue? Convert(StringSource source)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{ {
var values = new List<ICssValue>(); var values = new List<ICssValue>();
@ -33,7 +28,7 @@ namespace AngleSharp.Css.Converters
values.Add(value); values.Add(value);
} }
return values.Count > 0 ? new CssListValue(values.ToArray()) : null; return values.Count > 0 ? new CssListValue([.. values]) : null;
} }
} }
} }

Просмотреть файл

@ -7,22 +7,14 @@ namespace AngleSharp.Css.Converters
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
sealed class OneOrMoreValueConverter : IValueConverter sealed class OneOrMoreValueConverter(IValueConverter converter, Int32 minimum, Int32 maximum, String separator) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
private readonly Int32 _minimum; private readonly Int32 _minimum = minimum;
private readonly Int32 _maximum; private readonly Int32 _maximum = maximum;
private readonly String _separator; private readonly String _separator = separator;
public OneOrMoreValueConverter(IValueConverter converter, Int32 minimum, Int32 maximum, String separator) public ICssValue? Convert(StringSource source)
{
_converter = converter;
_minimum = minimum;
_maximum = maximum;
_separator = separator;
}
public ICssValue Convert(StringSource source)
{ {
var values = new List<ICssValue>(); var values = new List<ICssValue>();
@ -37,7 +29,7 @@ namespace AngleSharp.Css.Converters
values.Add(value); values.Add(value);
} }
return values.Count >= _minimum ? new CssTupleValue(values.ToArray(), _separator) : null; return values.Count >= _minimum ? new CssTupleValue([.. values], _separator) : null;
} }
} }
} }

Просмотреть файл

@ -4,18 +4,12 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Values; using AngleSharp.Css.Values;
using AngleSharp.Text; using AngleSharp.Text;
sealed class OptionValueConverter : IValueConverter sealed class OptionValueConverter(IValueConverter converter, ICssValue defaultValue) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
private readonly ICssValue _defaultValue; private readonly ICssValue _defaultValue = defaultValue;
public OptionValueConverter(IValueConverter converter, ICssValue defaultValue) public ICssValue? Convert(StringSource source)
{
_converter = converter;
_defaultValue = defaultValue;
}
public ICssValue Convert(StringSource source)
{ {
if (source.IsDone || source.Current == Symbols.Comma) if (source.IsDone || source.Current == Symbols.Comma)
{ {

Просмотреть файл

@ -1,19 +1,14 @@
namespace AngleSharp.Css.Converters namespace AngleSharp.Css.Converters
{ {
using AngleSharp.Css.Dom; using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser; using AngleSharp.Css.Parser;
using AngleSharp.Text; using AngleSharp.Text;
sealed class OrValueConverter : IValueConverter sealed class OrValueConverter(IValueConverter[] converters) : IValueConverter
{ {
private readonly IValueConverter[] _converters; private readonly IValueConverter[] _converters = converters;
public OrValueConverter(IValueConverter[] converters) public ICssValue? Convert(StringSource source)
{
_converters = converters;
}
public ICssValue Convert(StringSource source)
{ {
var start = source.Index; var start = source.Index;

Просмотреть файл

@ -5,14 +5,9 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Values; using AngleSharp.Css.Values;
using AngleSharp.Text; using AngleSharp.Text;
sealed class OrderedOptionsConverter: IValueConverter sealed class OrderedOptionsConverter(params IValueConverter[] converters) : IValueConverter
{ {
private readonly IValueConverter[] _converters; private readonly IValueConverter[] _converters = converters;
public OrderedOptionsConverter(params IValueConverter[] converters)
{
_converters = converters;
}
public ICssValue Convert(StringSource source) public ICssValue Convert(StringSource source)
{ {

Просмотреть файл

@ -6,28 +6,23 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class PeriodicValueConverter : IValueConverter sealed class PeriodicValueConverter(IValueConverter converter) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
public PeriodicValueConverter(IValueConverter converter) public ICssValue? Convert(StringSource source)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{ {
var options = new ICssValue[4]; var options = new ICssValue[4];
var length = 0; var length = 0;
for (var i = 0; i < options.Length; i++) for (var i = 0; i < options.Length; i++)
{ {
options[i] = _converter.Convert(source); var option = _converter.Convert(source);
source.SkipSpacesAndComments(); source.SkipSpacesAndComments();
if (options[length] != null) if (option is not null)
{ {
length++; options[length++] = option;
} }
} }

Просмотреть файл

@ -6,28 +6,23 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class RadiusValueConverter : IValueConverter sealed class RadiusValueConverter(IValueConverter converter) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
public RadiusValueConverter(IValueConverter converter) public ICssValue? Convert(StringSource source)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{ {
var options = new ICssValue[2]; var options = new ICssValue[2];
var length = 0; var length = 0;
for (var i = 0; i < options.Length; i++) for (var i = 0; i < options.Length; i++)
{ {
options[i] = _converter.Convert(source); var option = _converter.Convert(source);
source.SkipSpacesAndComments(); source.SkipSpacesAndComments();
if (options[length] != null) if (option is not null)
{ {
length++; options[length++] = option;
} }
} }

Просмотреть файл

@ -5,17 +5,12 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class SeparatedEnumsConverter : IValueConverter sealed class SeparatedEnumsConverter(IValueConverter[] converters, Char seperator) : IValueConverter
{ {
private readonly IValueConverter[] _converters; private readonly IValueConverter[] _converters = converters;
private readonly Char _seperator; private readonly Char _seperator = seperator;
public SeparatedEnumsConverter(IValueConverter[] converters, Char seperator) public ICssValue? Convert(StringSource source)
{
_converters = converters;
_seperator = seperator;
}
public ICssValue Convert(StringSource source)
{ {
var value = _converters[0].Convert(source); var value = _converters[0].Convert(source);

Просмотреть файл

@ -5,18 +5,12 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class SeparatorConverter : IValueConverter sealed class SeparatorConverter(IValueConverter converter, Char seperator) : IValueConverter
{ {
private readonly IValueConverter _converter; private readonly IValueConverter _converter = converter;
private readonly Char _seperator; private readonly Char _seperator = seperator;
public SeparatorConverter(IValueConverter converter, Char seperator) public ICssValue? Convert(StringSource source)
{
_converter = converter;
_seperator = seperator;
}
public ICssValue Convert(StringSource source)
{ {
var value = _converter.Convert(source); var value = _converter.Convert(source);

Просмотреть файл

@ -5,16 +5,11 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Values; using AngleSharp.Css.Values;
using AngleSharp.Text; using AngleSharp.Text;
sealed class StandardValueConverter : IValueConverter sealed class StandardValueConverter(ICssValue defaultValue) : IValueConverter
{ {
private readonly ICssValue _defaultValue; private readonly ICssValue _defaultValue = defaultValue;
public StandardValueConverter(ICssValue defaultValue) public ICssValue? Convert(StringSource source)
{
_defaultValue = defaultValue;
}
public ICssValue Convert(StringSource source)
{ {
var ident = source.ParseIdent(); var ident = source.ParseIdent();

Просмотреть файл

@ -4,19 +4,11 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text; using AngleSharp.Text;
using System; using System;
sealed class StructValueConverter<T> : IValueConverter sealed class StructValueConverter<T>(Func<StringSource, T?> converter) : IValueConverter
where T : struct, ICssValue where T : struct, ICssValue
{ {
private readonly Func<StringSource, T?> _converter; private readonly Func<StringSource, T?> _converter = converter;
public StructValueConverter(Func<StringSource, T?> converter) public ICssValue? Convert(StringSource source) => _converter.Invoke(source);
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{
return _converter.Invoke(source);
}
} }
} }

Просмотреть файл

@ -5,14 +5,9 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Values; using AngleSharp.Css.Values;
using AngleSharp.Text; using AngleSharp.Text;
sealed class UnorderedOptionsConverter : IValueConverter sealed class UnorderedOptionsConverter(params IValueConverter[] converters) : IValueConverter
{ {
private readonly IValueConverter[] _converters; private readonly IValueConverter[] _converters = converters;
public UnorderedOptionsConverter(params IValueConverter[] converters)
{
_converters = converters;
}
public ICssValue Convert(StringSource source) public ICssValue Convert(StringSource source)
{ {

Просмотреть файл

@ -62,7 +62,7 @@ namespace AngleSharp
/// <param name="configuration">The configuration to extend.</param> /// <param name="configuration">The configuration to extend.</param>
/// <param name="renderDevice">The custom device to register, if any.</param> /// <param name="renderDevice">The custom device to register, if any.</param>
/// <returns>The new instance with the render device.</returns> /// <returns>The new instance with the render device.</returns>
public static IConfiguration WithRenderDevice(this IConfiguration configuration, IRenderDevice renderDevice = null) => public static IConfiguration WithRenderDevice(this IConfiguration configuration, IRenderDevice? renderDevice = null) =>
configuration.WithOnly<IRenderDevice>(renderDevice ?? new DefaultRenderDevice()); configuration.WithOnly<IRenderDevice>(renderDevice ?? new DefaultRenderDevice());
} }
} }

Просмотреть файл

@ -8,7 +8,7 @@ namespace AngleSharp.Css
{ {
#region Fields #region Fields
private ICssStyleSheet _default; private ICssStyleSheet? _default;
#endregion #endregion

Просмотреть файл

@ -33,13 +33,13 @@ namespace AngleSharp.Css
public async Task<IStyleSheet> ParseStylesheetAsync(IResponse response, StyleOptions options, CancellationToken cancel) public async Task<IStyleSheet> ParseStylesheetAsync(IResponse response, StyleOptions options, CancellationToken cancel)
{ {
var context = options.Document.Context; var context = options.Document.Context;
var parser = context.GetService<ICssParser>(); var parser = context.GetService<ICssParser>() ?? throw new InvalidOperationException("No parser found.");
var url = response.Address?.Href; var url = response.Address?.Href;
var source = new TextSource(response.Content); var source = new TextSource(response.Content);
var sheet = new CssStyleSheet(context, source) var sheet = new CssStyleSheet(context, source)
{ {
IsDisabled = options.IsDisabled, IsDisabled = options.IsDisabled,
Href = url Href = url!
}; };
sheet.SetOwner(options.Element); sheet.SetOwner(options.Element);
return await parser.ParseStyleSheetAsync(sheet, cancel).ConfigureAwait(false); return await parser.ParseStyleSheetAsync(sheet, cancel).ConfigureAwait(false);

Просмотреть файл

@ -7,61 +7,51 @@ namespace AngleSharp.Css
/// <summary> /// <summary>
/// A collection of useful information regarding a CSS declaration. /// A collection of useful information regarding a CSS declaration.
/// </summary> /// </summary>
public class DeclarationInfo /// <remarks>
/// Constructs a new declaration info.
/// </remarks>
/// <param name="name">The name of the declaration.</param>
/// <param name="converter">The value converter.</param>
/// <param name="flags">The property flags.</param>
/// <param name="initialValue">The initial value, if any.</param>
/// <param name="shorthands">The names of the associated shorthand declarations, if any.</param>
/// <param name="longhands">The names of the associated longhand declarations, if any.</param>
public class DeclarationInfo(String name, IValueConverter converter, PropertyFlags flags = PropertyFlags.None, ICssValue? initialValue = null, String[]? shorthands = null, String[]? longhands = null)
{ {
/// <summary>
/// Constructs a new declaration info.
/// </summary>
/// <param name="name">The name of the declaration.</param>
/// <param name="converter">The value converter.</param>
/// <param name="flags">The property flags.</param>
/// <param name="initialValue">The initial value, if any.</param>
/// <param name="shorthands">The names of the associated shorthand declarations, if any.</param>
/// <param name="longhands">The names of the associated longhand declarations, if any.</param>
public DeclarationInfo(String name, IValueConverter converter, PropertyFlags flags = PropertyFlags.None, ICssValue initialValue = null, String[] shorthands = null, String[] longhands = null)
{
Name = name;
Converter = initialValue != null ? Or(converter, AssignInitial(initialValue)) : converter;
Aggregator = converter as IValueAggregator;
Flags = flags;
InitialValue = initialValue;
Shorthands = shorthands ?? Array.Empty<String>();
Longhands = longhands ?? Array.Empty<String>();
}
/// <summary> /// <summary>
/// Gets the declaration name. /// Gets the declaration name.
/// </summary> /// </summary>
public String Name { get; } public String Name { get; } = name;
/// <summary> /// <summary>
/// Gets the initial value of the declaration, if any. /// Gets the initial value of the declaration, if any.
/// </summary> /// </summary>
public ICssValue InitialValue { get; } public ICssValue? InitialValue { get; } = initialValue;
/// <summary> /// <summary>
/// Gets the associated value converter. /// Gets the associated value converter.
/// </summary> /// </summary>
public IValueConverter Converter { get; } public IValueConverter Converter { get; } = initialValue != null ? Or(converter, AssignInitial(initialValue)) : converter;
/// <summary> /// <summary>
/// Gets the value aggregator, if any. /// Gets the value aggregator, if any.
/// </summary> /// </summary>
public IValueAggregator Aggregator { get; } public IValueAggregator? Aggregator { get; } = converter as IValueAggregator;
/// <summary> /// <summary>
/// Gets the flags of the declaration. /// Gets the flags of the declaration.
/// </summary> /// </summary>
public PropertyFlags Flags { get; } public PropertyFlags Flags { get; } = flags;
/// <summary> /// <summary>
/// Gets the names of related shorthand declarations. /// Gets the names of related shorthand declarations.
/// </summary> /// </summary>
public String[] Shorthands { get; } public String[] Shorthands { get; } = shorthands ?? [];
/// <summary> /// <summary>
/// Gets the names of related required longhand declarations. /// Gets the names of related required longhand declarations.
/// </summary> /// </summary>
public String[] Longhands { get; } public String[] Longhands { get; } = longhands ?? [];
} }
} }

Просмотреть файл

@ -14,12 +14,12 @@ namespace AngleSharp.Css.Declarations
public static IValueConverter Converter = new AnimationAggregator(); public static IValueConverter Converter = new AnimationAggregator();
public static ICssValue InitialValue = null; public static ICssValue? InitialValue = null;
public static PropertyFlags Flags = PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.AnimationDuration, PropertyNames.AnimationDuration,
PropertyNames.AnimationTimingFunction, PropertyNames.AnimationTimingFunction,
PropertyNames.AnimationDelay, PropertyNames.AnimationDelay,
@ -28,7 +28,7 @@ namespace AngleSharp.Css.Declarations
PropertyNames.AnimationFillMode, PropertyNames.AnimationFillMode,
PropertyNames.AnimationPlayState, PropertyNames.AnimationPlayState,
PropertyNames.AnimationName, PropertyNames.AnimationName,
}; ];
sealed class AnimationAggregator : IValueAggregator, IValueConverter sealed class AnimationAggregator : IValueAggregator, IValueConverter
{ {
@ -42,9 +42,9 @@ namespace AngleSharp.Css.Declarations
PlayStateConverter.Option(InitialValues.AnimationPlayStateDecl), PlayStateConverter.Option(InitialValues.AnimationPlayStateDecl),
IdentifierConverter.Option(InitialValues.AnimationNameDecl)).FromList(); IdentifierConverter.Option(InitialValues.AnimationNameDecl)).FromList();
public ICssValue Convert(StringSource source) => ListConverter.Convert(source); public ICssValue? Convert(StringSource source) => ListConverter.Convert(source);
public ICssValue Merge(ICssValue[] values) public ICssValue? Merge(ICssValue[] values)
{ {
var duration = values[0] as CssListValue; var duration = values[0] as CssListValue;
var timing = values[1] as CssListValue; var timing = values[1] as CssListValue;
@ -63,12 +63,12 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
public ICssValue[] Split(ICssValue value) public ICssValue?[]? Split(ICssValue value)
{ {
if (value is CssListValue list) if (value is CssListValue list)
{ {
return new[] return
{ [
CreateMultiple(list, 0), CreateMultiple(list, 0),
CreateMultiple(list, 1), CreateMultiple(list, 1),
CreateMultiple(list, 2), CreateMultiple(list, 2),
@ -77,13 +77,13 @@ namespace AngleSharp.Css.Declarations
CreateMultiple(list, 5), CreateMultiple(list, 5),
CreateMultiple(list, 6), CreateMultiple(list, 6),
CreateMultiple(list, 7), CreateMultiple(list, 7),
}; ];
} }
return null; return null;
} }
private static ICssValue CreateMultiple(CssListValue animation, Int32 index) private static ICssValue? CreateMultiple(CssListValue animation, Int32 index)
{ {
var values = animation.Items.OfType<CssTupleValue>().Select(m => m.Items[index]); var values = animation.Items.OfType<CssTupleValue>().Select(m => m.Items[index]);
@ -95,15 +95,15 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
private static ICssValue CreateValue(CssListValue duration, CssListValue timing, CssListValue delay, CssListValue iterationCount, CssListValue direction, CssListValue fillMode, CssListValue playState, CssListValue name) private static ICssValue CreateValue(CssListValue? duration, CssListValue? timing, CssListValue? delay, CssListValue? iterationCount, CssListValue? direction, CssListValue? fillMode, CssListValue? playState, CssListValue? name)
{ {
var items = (duration ?? timing ?? delay ?? iterationCount ?? direction ?? fillMode ?? playState ?? name).Items; var items = (duration ?? timing ?? delay ?? iterationCount ?? direction ?? fillMode ?? playState ?? name)?.Items;
var layers = new ICssValue[items.Length]; var layers = new ICssValue[items?.Length ?? 0];
for (var i = 0; i < items.Length; i++) for (var i = 0; i < layers.Length; i++)
{ {
layers[i] = new CssTupleValue(new[] layers[i] = new CssTupleValue(
{ [
GetValue(duration, i), GetValue(duration, i),
GetValue(timing, i), GetValue(timing, i),
GetValue(delay, i), GetValue(delay, i),
@ -112,13 +112,13 @@ namespace AngleSharp.Css.Declarations
GetValue(fillMode, i), GetValue(fillMode, i),
GetValue(playState, i), GetValue(playState, i),
GetValue(name, i), GetValue(name, i),
}); ]);
} }
return new CssListValue(layers); return new CssListValue(layers);
} }
private static ICssValue GetValue(CssListValue container, Int32 index) private static ICssValue? GetValue(CssListValue? container, Int32 index)
{ {
if (container != null && index < container.Items.Length) if (container != null && index < container.Items.Length)
{ {

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationDelay; public static String Name = PropertyNames.AnimationDelay;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = TimeConverter.FromList(); public static IValueConverter Converter = TimeConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationDirection; public static String Name = PropertyNames.AnimationDirection;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = AnimationDirectionConverter.FromList(); public static IValueConverter Converter = AnimationDirectionConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationDuration; public static String Name = PropertyNames.AnimationDuration;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = TimeConverter.FromList(); public static IValueConverter Converter = TimeConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationFillMode; public static String Name = PropertyNames.AnimationFillMode;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = AnimationFillStyleConverter.FromList(); public static IValueConverter Converter = AnimationFillStyleConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationIterationCount; public static String Name = PropertyNames.AnimationIterationCount;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = PositiveOrInfiniteNumberConverter.FromList(); public static IValueConverter Converter = PositiveOrInfiniteNumberConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationName; public static String Name = PropertyNames.AnimationName;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = Or(IdentifierConverter.FromList(), None); public static IValueConverter Converter = Or(IdentifierConverter.FromList(), None);

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationPlayState; public static String Name = PropertyNames.AnimationPlayState;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = PlayStateConverter.FromList(); public static IValueConverter Converter = PlayStateConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.AnimationTimingFunction; public static String Name = PropertyNames.AnimationTimingFunction;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Animation, PropertyNames.Animation,
}; ];
public static IValueConverter Converter = TransitionConverter.FromList(); public static IValueConverter Converter = TransitionConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundAttachment; public static String Name = PropertyNames.BackgroundAttachment;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = BackgroundAttachmentConverter.FromList(); public static IValueConverter Converter = BackgroundAttachmentConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundClip; public static String Name = PropertyNames.BackgroundClip;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = BoxModelConverter.FromList(); public static IValueConverter Converter = BoxModelConverter.FromList();

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundColor; public static String Name = PropertyNames.BackgroundColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = CurrentColorConverter; public static IValueConverter Converter = CurrentColorConverter;

Просмотреть файл

@ -14,12 +14,12 @@ namespace AngleSharp.Css.Declarations
public static IValueConverter Converter = new BackgroundAggregator(); public static IValueConverter Converter = new BackgroundAggregator();
public static ICssValue InitialValue = null; public static ICssValue? InitialValue = null;
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BackgroundImage, PropertyNames.BackgroundImage,
PropertyNames.BackgroundPosition, PropertyNames.BackgroundPosition,
PropertyNames.BackgroundSize, PropertyNames.BackgroundSize,
@ -28,11 +28,11 @@ namespace AngleSharp.Css.Declarations
PropertyNames.BackgroundOrigin, PropertyNames.BackgroundOrigin,
PropertyNames.BackgroundClip, PropertyNames.BackgroundClip,
PropertyNames.BackgroundColor, PropertyNames.BackgroundColor,
}; ];
sealed class BackgroundAggregator : IValueAggregator, IValueConverter sealed class BackgroundAggregator : IValueAggregator, IValueConverter
{ {
public ICssValue Convert(StringSource source) public ICssValue? Convert(StringSource source)
{ {
// [ <bg-layer> , ]* <final-bg-layer> // [ <bg-layer> , ]* <final-bg-layer>
// where: // where:
@ -177,7 +177,7 @@ namespace AngleSharp.Css.Declarations
return new CssBackgroundValue(new CssListValue(layers.OfType<ICssValue>().ToArray()), color ?? new CssInitialValue(InitialValues.BackgroundColorDecl)); return new CssBackgroundValue(new CssListValue(layers.OfType<ICssValue>().ToArray()), color ?? new CssInitialValue(InitialValues.BackgroundColorDecl));
} }
public ICssValue Merge(ICssValue[] values) public ICssValue? Merge(ICssValue[] values)
{ {
var image = GetList(values[0]); var image = GetList(values[0]);
var position = GetList(values[1]); var position = GetList(values[1]);
@ -197,7 +197,7 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
private static CssListValue GetList(ICssValue value) private static CssListValue? GetList(ICssValue value)
{ {
if (value is CssListValue list) if (value is CssListValue list)
{ {
@ -211,12 +211,12 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
public ICssValue[] Split(ICssValue value) public ICssValue?[]? Split(ICssValue value)
{ {
if (value is CssBackgroundValue background) if (value is CssBackgroundValue background)
{ {
return new[] return
{ [
CreateMultiple(background, m => m.Image, InitialValues.BackgroundImageDecl), CreateMultiple(background, m => m.Image, InitialValues.BackgroundImageDecl),
CreateMultiple(background, m => m.Position, InitialValues.BackgroundPositionDecl), CreateMultiple(background, m => m.Position, InitialValues.BackgroundPositionDecl),
CreateMultiple(background, m => m.Size, InitialValues.BackgroundSizeDecl), CreateMultiple(background, m => m.Size, InitialValues.BackgroundSizeDecl),
@ -225,13 +225,13 @@ namespace AngleSharp.Css.Declarations
CreateMultiple(background, m => m.Origin, InitialValues.BackgroundOriginDecl), CreateMultiple(background, m => m.Origin, InitialValues.BackgroundOriginDecl),
CreateMultiple(background, m => m.Clip, InitialValues.BackgroundClipDecl), CreateMultiple(background, m => m.Clip, InitialValues.BackgroundClipDecl),
background.Color, background.Color,
}; ];
} }
return null; return null;
} }
private static ICssValue CreateLayers(CssListValue image, CssListValue attachment, CssListValue clip, CssListValue position, CssListValue origin, CssListValue repeat, CssListValue size) private static ICssValue? CreateLayers(CssListValue? image, CssListValue? attachment, CssListValue? clip, CssListValue? position, CssListValue? origin, CssListValue? repeat, CssListValue? size)
{ {
var count = GetCount(image, attachment, clip, position, size, repeat, origin); var count = GetCount(image, attachment, clip, position, size, repeat, origin);
@ -257,7 +257,7 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
private static Int32 GetCount(params CssListValue[] lists) private static Int32 GetCount(params CssListValue?[] lists)
{ {
var count = 0; var count = 0;
@ -269,7 +269,7 @@ namespace AngleSharp.Css.Declarations
return count; return count;
} }
private static ICssValue GetValue(CssListValue container, Int32 index) private static ICssValue? GetValue(CssListValue? container, Int32 index)
{ {
if (container != null && index < container.Items.Length) if (container != null && index < container.Items.Length)
{ {
@ -279,7 +279,7 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
private static ICssValue CreateMultiple(CssBackgroundValue background, Func<CssBackgroundLayerValue, ICssValue> getValue, ICssValue initialValue) private static ICssValue? CreateMultiple(CssBackgroundValue background, Func<CssBackgroundLayerValue, ICssValue> getValue, ICssValue initialValue)
{ {
if (background.Layers is CssListValue layers) if (background.Layers is CssListValue layers)
{ {

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundImage; public static String Name = PropertyNames.BackgroundImage;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = MultipleImageSourceConverter; public static IValueConverter Converter = MultipleImageSourceConverter;

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundOrigin; public static String Name = PropertyNames.BackgroundOrigin;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = BoxModelConverter.FromList(); public static IValueConverter Converter = BoxModelConverter.FromList();

Просмотреть файл

@ -12,16 +12,16 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundPosition; public static String Name = PropertyNames.BackgroundPosition;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BackgroundPositionX, PropertyNames.BackgroundPositionX,
PropertyNames.BackgroundPositionY, PropertyNames.BackgroundPositionY,
}; ];
public static IValueConverter Converter = new BackgroundPositionAggregator(); public static IValueConverter Converter = new BackgroundPositionAggregator();
@ -63,11 +63,11 @@ namespace AngleSharp.Css.Declarations
var points = list.Items.OfType<CssPoint2D>(); var points = list.Items.OfType<CssPoint2D>();
var x = points.Select(m => m.X).ToArray(); var x = points.Select(m => m.X).ToArray();
var y = points.Select(m => m.Y).ToArray(); var y = points.Select(m => m.Y).ToArray();
return new ICssValue[] return
{ [
new CssListValue(x), new CssListValue(x),
new CssListValue(y), new CssListValue(y),
}; ];
} }
return null; return null;

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundPositionX; public static String Name = PropertyNames.BackgroundPositionX;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BackgroundPosition, PropertyNames.BackgroundPosition,
}; ];
public static IValueConverter Converter = PointXConverter.FromList(); public static IValueConverter Converter = PointXConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundPositionY; public static String Name = PropertyNames.BackgroundPositionY;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BackgroundPosition, PropertyNames.BackgroundPosition,
}; ];
public static IValueConverter Converter = PointYConverter.FromList(); public static IValueConverter Converter = PointYConverter.FromList();

Просмотреть файл

@ -12,16 +12,16 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundRepeat; public static String Name = PropertyNames.BackgroundRepeat;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BackgroundRepeatX, PropertyNames.BackgroundRepeatX,
PropertyNames.BackgroundRepeatY, PropertyNames.BackgroundRepeatY,
}; ];
public static IValueConverter Converter = new BackgroundRepeatAggregator(); public static IValueConverter Converter = new BackgroundRepeatAggregator();
@ -63,11 +63,11 @@ namespace AngleSharp.Css.Declarations
var repeats = list.Items.OfType<CssImageRepeatsValue>(); var repeats = list.Items.OfType<CssImageRepeatsValue>();
var h = repeats.Select(m => m.Horizontal).ToArray(); var h = repeats.Select(m => m.Horizontal).ToArray();
var v = repeats.Select(m => m.Vertical).ToArray(); var v = repeats.Select(m => m.Vertical).ToArray();
return new ICssValue[] return
{ [
new CssListValue(h), new CssListValue(h),
new CssListValue(v), new CssListValue(v),
}; ];
} }
return null; return null;

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundRepeatX; public static String Name = PropertyNames.BackgroundRepeatX;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BackgroundRepeat, PropertyNames.BackgroundRepeat,
}; ];
public static IValueConverter Converter = BackgroundRepeatConverter.FromList(); public static IValueConverter Converter = BackgroundRepeatConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundRepeatY; public static String Name = PropertyNames.BackgroundRepeatY;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BackgroundRepeat, PropertyNames.BackgroundRepeat,
}; ];
public static IValueConverter Converter = BackgroundRepeatConverter.FromList(); public static IValueConverter Converter = BackgroundRepeatConverter.FromList();

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BackgroundSize; public static String Name = PropertyNames.BackgroundSize;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Background, PropertyNames.Background,
}; ];
public static IValueConverter Converter = BackgroundSizeConverter.FromList(); public static IValueConverter Converter = BackgroundSizeConverter.FromList();

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottomColor; public static String Name = PropertyNames.BorderBottomColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderBottom, PropertyNames.BorderBottom,
PropertyNames.BorderColor, PropertyNames.BorderColor,
}; ];
public static IValueConverter Converter = CurrentColorConverter; public static IValueConverter Converter = CurrentColorConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottom; public static String Name = PropertyNames.BorderBottom;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = WithBorderSide( public static IValueConverter Converter = WithBorderSide(
InitialValues.BorderBottomWidthDecl, InitialValues.BorderBottomWidthDecl,
@ -22,11 +22,11 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderBottomWidth, PropertyNames.BorderBottomWidth,
PropertyNames.BorderBottomStyle, PropertyNames.BorderBottomStyle,
PropertyNames.BorderBottomColor, PropertyNames.BorderBottomColor,
}; ];
} }
} }

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottomLeftRadius; public static String Name = PropertyNames.BorderBottomLeftRadius;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderRadius, PropertyNames.BorderRadius,
}; ];
public static IValueConverter Converter = BorderRadiusLonghandConverter; public static IValueConverter Converter = BorderRadiusLonghandConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottomRightRadius; public static String Name = PropertyNames.BorderBottomRightRadius;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderRadius, PropertyNames.BorderRadius,
}; ];
public static IValueConverter Converter = BorderRadiusLonghandConverter; public static IValueConverter Converter = BorderRadiusLonghandConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottomStyle; public static String Name = PropertyNames.BorderBottomStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderBottom, PropertyNames.BorderBottom,
PropertyNames.BorderStyle, PropertyNames.BorderStyle,
}; ];
public static IValueConverter Converter = LineStyleConverter; public static IValueConverter Converter = LineStyleConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderBottomWidth; public static String Name = PropertyNames.BorderBottomWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderBottom, PropertyNames.BorderBottom,
PropertyNames.BorderWidth, PropertyNames.BorderWidth,
}; ];
public static IValueConverter Converter = LineWidthConverter; public static IValueConverter Converter = LineWidthConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderColor; public static String Name = PropertyNames.BorderColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = AggregatePeriodic(CurrentColorConverter); public static IValueConverter Converter = AggregatePeriodic(CurrentColorConverter);
@ -19,12 +19,12 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Hashless | PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Hashless | PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderTopColor, PropertyNames.BorderTopColor,
PropertyNames.BorderRightColor, PropertyNames.BorderRightColor,
PropertyNames.BorderBottomColor, PropertyNames.BorderBottomColor,
PropertyNames.BorderLeftColor, PropertyNames.BorderLeftColor,
}; ];
} }
} }

Просмотреть файл

@ -18,12 +18,12 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderWidth, PropertyNames.BorderWidth,
PropertyNames.BorderStyle, PropertyNames.BorderStyle,
PropertyNames.BorderColor, PropertyNames.BorderColor,
}; ];
sealed class BorderAggregator : IValueAggregator, IValueConverter sealed class BorderAggregator : IValueAggregator, IValueConverter
{ {
@ -48,7 +48,7 @@ namespace AngleSharp.Css.Declarations
{ {
if (value is CssTupleValue options) if (value is CssTupleValue options)
{ {
return options.ToArray(); return [.. options];
} }
return null; return null;

Просмотреть файл

@ -17,14 +17,14 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderImageOutset, PropertyNames.BorderImageOutset,
PropertyNames.BorderImageRepeat, PropertyNames.BorderImageRepeat,
PropertyNames.BorderImageSlice, PropertyNames.BorderImageSlice,
PropertyNames.BorderImageSource, PropertyNames.BorderImageSource,
PropertyNames.BorderImageWidth, PropertyNames.BorderImageWidth,
}; ];
sealed class BorderImageValueConverter : IValueConverter sealed class BorderImageValueConverter : IValueConverter
{ {
@ -103,7 +103,7 @@ namespace AngleSharp.Css.Declarations
} }
else else
{ {
return new CssTupleValue(new[] { repeatX, repeatY }); return new CssTupleValue([repeatX, repeatY]);
} }
} }
} }
@ -137,25 +137,25 @@ namespace AngleSharp.Css.Declarations
{ {
if (value is CssBorderImageValue img) if (value is CssBorderImageValue img)
{ {
return new ICssValue[] return
{ [
img.Outsets, img.Outsets,
img.Repeat, img.Repeat,
img.Slice, img.Slice,
img.Image, img.Image,
img.Widths, img.Widths,
}; ];
} }
else if (value is CssConstantValue<Object> constant) else if (value is CssConstantValue<Object> constant)
{ {
return new ICssValue[] return
{ [
null, null,
null, null,
null, null,
constant, constant,
null, null,
}; ];
} }
return null; return null;

Просмотреть файл

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderImageOutset; public static String Name = PropertyNames.BorderImageOutset;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderImage, PropertyNames.BorderImage,
}; ];
public static IValueConverter Converter = LengthOrPercentConverter.Periodic(); public static IValueConverter Converter = LengthOrPercentConverter.Periodic();

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderImageRepeat; public static String Name = PropertyNames.BorderImageRepeat;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderImage, PropertyNames.BorderImage,
}; ];
public static IValueConverter Converter = BorderImageRepeatConverter; public static IValueConverter Converter = BorderImageRepeatConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderImageSlice; public static String Name = PropertyNames.BorderImageSlice;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderImage, PropertyNames.BorderImage,
}; ];
public static IValueConverter Converter = BorderImageSliceConverter; public static IValueConverter Converter = BorderImageSliceConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderImageSource; public static String Name = PropertyNames.BorderImageSource;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderImage, PropertyNames.BorderImage,
}; ];
public static IValueConverter Converter = OptionalImageSourceConverter; public static IValueConverter Converter = OptionalImageSourceConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderImageWidth; public static String Name = PropertyNames.BorderImageWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderImage, PropertyNames.BorderImage,
}; ];
public static IValueConverter Converter = BorderImageWidthConverter; public static IValueConverter Converter = BorderImageWidthConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderLeftColor; public static String Name = PropertyNames.BorderLeftColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderLeft, PropertyNames.BorderLeft,
PropertyNames.BorderColor, PropertyNames.BorderColor,
}; ];
public static IValueConverter Converter = CurrentColorConverter; public static IValueConverter Converter = CurrentColorConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderLeft; public static String Name = PropertyNames.BorderLeft;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = WithBorderSide( public static IValueConverter Converter = WithBorderSide(
InitialValues.BorderLeftWidthDecl, InitialValues.BorderLeftWidthDecl,
@ -22,11 +22,11 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderLeftWidth, PropertyNames.BorderLeftWidth,
PropertyNames.BorderLeftStyle, PropertyNames.BorderLeftStyle,
PropertyNames.BorderLeftColor, PropertyNames.BorderLeftColor,
}; ];
} }
} }

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderLeftStyle; public static String Name = PropertyNames.BorderLeftStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderLeft, PropertyNames.BorderLeft,
PropertyNames.BorderStyle, PropertyNames.BorderStyle,
}; ];
public static IValueConverter Converter = LineStyleConverter; public static IValueConverter Converter = LineStyleConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderLeftWidth; public static String Name = PropertyNames.BorderLeftWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderLeft, PropertyNames.BorderLeft,
PropertyNames.BorderWidth, PropertyNames.BorderWidth,
}; ];
public static IValueConverter Converter = LineWidthConverter; public static IValueConverter Converter = LineWidthConverter;

Просмотреть файл

@ -18,13 +18,13 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderTopLeftRadius, PropertyNames.BorderTopLeftRadius,
PropertyNames.BorderTopRightRadius, PropertyNames.BorderTopRightRadius,
PropertyNames.BorderBottomRightRadius, PropertyNames.BorderBottomRightRadius,
PropertyNames.BorderBottomLeftRadius, PropertyNames.BorderBottomLeftRadius,
}; ];
sealed class BorderRadiusAggregator : IValueAggregator, IValueConverter sealed class BorderRadiusAggregator : IValueAggregator, IValueConverter
{ {
@ -57,8 +57,8 @@ namespace AngleSharp.Css.Declarations
if (topLeft != null && topRight != null && bottomRight != null && bottomLeft != null) if (topLeft != null && topRight != null && bottomRight != null && bottomLeft != null)
{ {
var horizontal = new CssPeriodicValue(new[] { topLeft.Width, topRight.Width, bottomRight.Width, bottomLeft.Width }); var horizontal = new CssPeriodicValue([topLeft.Width, topRight.Width, bottomRight.Width, bottomLeft.Width]);
var vertical = new CssPeriodicValue(new[] { topLeft.Height, topRight.Height, bottomRight.Height, bottomLeft.Height }); var vertical = new CssPeriodicValue([topLeft.Height, topRight.Height, bottomRight.Height, bottomLeft.Height]);
return new CssBorderRadiusValue(horizontal, vertical); return new CssBorderRadiusValue(horizontal, vertical);
} }
@ -69,13 +69,13 @@ namespace AngleSharp.Css.Declarations
{ {
if (value is CssBorderRadiusValue radius) if (value is CssBorderRadiusValue radius)
{ {
return new[] return
{ [
Both(radius.Horizontal.Top, radius.Vertical.Top), Both(radius.Horizontal.Top, radius.Vertical.Top),
Both(radius.Horizontal.Right, radius.Vertical.Right), Both(radius.Horizontal.Right, radius.Vertical.Right),
Both(radius.Horizontal.Bottom, radius.Vertical.Bottom), Both(radius.Horizontal.Bottom, radius.Vertical.Bottom),
Both(radius.Horizontal.Left, radius.Vertical.Left), Both(radius.Horizontal.Left, radius.Vertical.Left),
}; ];
} }
return null; return null;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderRightColor; public static String Name = PropertyNames.BorderRightColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderRight, PropertyNames.BorderRight,
PropertyNames.BorderColor, PropertyNames.BorderColor,
}; ];
public static IValueConverter Converter = CurrentColorConverter; public static IValueConverter Converter = CurrentColorConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderRight; public static String Name = PropertyNames.BorderRight;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = WithBorderSide( public static IValueConverter Converter = WithBorderSide(
InitialValues.BorderRightWidthDecl, InitialValues.BorderRightWidthDecl,
@ -22,11 +22,11 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderRightWidth, PropertyNames.BorderRightWidth,
PropertyNames.BorderRightStyle, PropertyNames.BorderRightStyle,
PropertyNames.BorderRightColor, PropertyNames.BorderRightColor,
}; ];
} }
} }

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderRightStyle; public static String Name = PropertyNames.BorderRightStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderRight, PropertyNames.BorderRight,
PropertyNames.BorderStyle, PropertyNames.BorderStyle,
}; ];
public static IValueConverter Converter = LineStyleConverter; public static IValueConverter Converter = LineStyleConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderRightWidth; public static String Name = PropertyNames.BorderRightWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderRight, PropertyNames.BorderRight,
PropertyNames.BorderWidth, PropertyNames.BorderWidth,
}; ];
public static IValueConverter Converter = LineWidthConverter; public static IValueConverter Converter = LineWidthConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderStyle; public static String Name = PropertyNames.BorderStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = AggregatePeriodic(LineStyleConverter); public static IValueConverter Converter = AggregatePeriodic(LineStyleConverter);
@ -19,12 +19,12 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderTopStyle, PropertyNames.BorderTopStyle,
PropertyNames.BorderRightStyle, PropertyNames.BorderRightStyle,
PropertyNames.BorderBottomStyle, PropertyNames.BorderBottomStyle,
PropertyNames.BorderLeftStyle, PropertyNames.BorderLeftStyle,
}; ];
} }
} }

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTopColor; public static String Name = PropertyNames.BorderTopColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderTop, PropertyNames.BorderTop,
PropertyNames.BorderColor, PropertyNames.BorderColor,
}; ];
public static IValueConverter Converter = CurrentColorConverter; public static IValueConverter Converter = CurrentColorConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTop; public static String Name = PropertyNames.BorderTop;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = WithBorderSide( public static IValueConverter Converter = WithBorderSide(
InitialValues.BorderTopWidthDecl, InitialValues.BorderTopWidthDecl,
@ -22,11 +22,11 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderTopWidth, PropertyNames.BorderTopWidth,
PropertyNames.BorderTopStyle, PropertyNames.BorderTopStyle,
PropertyNames.BorderTopColor, PropertyNames.BorderTopColor,
}; ];
} }
} }

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTopLeftRadius; public static String Name = PropertyNames.BorderTopLeftRadius;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderRadius, PropertyNames.BorderRadius,
}; ];
public static IValueConverter Converter = BorderRadiusLonghandConverter; public static IValueConverter Converter = BorderRadiusLonghandConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTopRightRadius; public static String Name = PropertyNames.BorderTopRightRadius;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.BorderRadius, PropertyNames.BorderRadius,
}; ];
public static IValueConverter Converter = BorderRadiusLonghandConverter; public static IValueConverter Converter = BorderRadiusLonghandConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTopStyle; public static String Name = PropertyNames.BorderTopStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderTop, PropertyNames.BorderTop,
PropertyNames.BorderStyle, PropertyNames.BorderStyle,
}; ];
public static IValueConverter Converter = LineStyleConverter; public static IValueConverter Converter = LineStyleConverter;

Просмотреть файл

@ -8,12 +8,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderTopWidth; public static String Name = PropertyNames.BorderTopWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
PropertyNames.BorderTop, PropertyNames.BorderTop,
PropertyNames.BorderWidth, PropertyNames.BorderWidth,
}; ];
public static IValueConverter Converter = LineWidthConverter; public static IValueConverter Converter = LineWidthConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.BorderWidth; public static String Name = PropertyNames.BorderWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Border, PropertyNames.Border,
}; ];
public static IValueConverter Converter = AggregatePeriodic(LineWidthConverter); public static IValueConverter Converter = AggregatePeriodic(LineWidthConverter);
@ -19,12 +19,12 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.BorderTopWidth, PropertyNames.BorderTopWidth,
PropertyNames.BorderRightWidth, PropertyNames.BorderRightWidth,
PropertyNames.BorderBottomWidth, PropertyNames.BorderBottomWidth,
PropertyNames.BorderLeftWidth, PropertyNames.BorderLeftWidth,
}; ];
} }
} }

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnCount; public static String Name = PropertyNames.ColumnCount;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Columns, PropertyNames.Columns,
}; ];
public static IValueConverter Converter = OptionalIntegerConverter; public static IValueConverter Converter = OptionalIntegerConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnGap; public static String Name = PropertyNames.ColumnGap;
public static readonly String[] Shorthands = new[] public static readonly String[] Shorthands =
{ [
PropertyNames.Gap, PropertyNames.Gap,
}; ];
public static IValueConverter Converter = GapConverter; public static IValueConverter Converter = GapConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnRuleColor; public static String Name = PropertyNames.ColumnRuleColor;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.ColumnRule, PropertyNames.ColumnRule,
}; ];
public static IValueConverter Converter = ColorConverter; public static IValueConverter Converter = ColorConverter;

Просмотреть файл

@ -16,12 +16,12 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.ColumnRuleColor, PropertyNames.ColumnRuleColor,
PropertyNames.ColumnRuleWidth, PropertyNames.ColumnRuleWidth,
PropertyNames.ColumnRuleStyle, PropertyNames.ColumnRuleStyle,
}; ];
sealed class ColumnRuleValueConverter : IValueConverter sealed class ColumnRuleValueConverter : IValueConverter
{ {
@ -87,12 +87,12 @@ namespace AngleSharp.Css.Declarations
{ {
if (value is CssTupleValue options) if (value is CssTupleValue options)
{ {
return new[] return
{ [
options.Items[0], options.Items[0],
options.Items[1], options.Items[1],
options.Items[2], options.Items[2],
}; ];
} }
return null; return null;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnRuleStyle; public static String Name = PropertyNames.ColumnRuleStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.ColumnRule, PropertyNames.ColumnRule,
}; ];
public static IValueConverter Converter = LineStyleConverter; public static IValueConverter Converter = LineStyleConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnRuleWidth; public static String Name = PropertyNames.ColumnRuleWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.ColumnRule, PropertyNames.ColumnRule,
}; ];
public static IValueConverter Converter = LineWidthConverter; public static IValueConverter Converter = LineWidthConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.ColumnWidth; public static String Name = PropertyNames.ColumnWidth;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Columns, PropertyNames.Columns,
}; ];
public static IValueConverter Converter = AutoLengthConverter; public static IValueConverter Converter = AutoLengthConverter;

Просмотреть файл

@ -16,11 +16,11 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.ColumnWidth, PropertyNames.ColumnWidth,
PropertyNames.ColumnCount, PropertyNames.ColumnCount,
}; ];
sealed class ColumnsValueConverter : IValueConverter sealed class ColumnsValueConverter : IValueConverter
{ {
@ -57,11 +57,11 @@ namespace AngleSharp.Css.Declarations
{ {
if (value is CssTupleValue options) if (value is CssTupleValue options)
{ {
return new[] return
{ [
options.Items[0], options.Items[0],
options.Items[1], options.Items[1],
}; ];
} }
return null; return null;

Просмотреть файл

@ -36,11 +36,11 @@ namespace AngleSharp.Css.Declarations
if (source.IsIdentifier(CssKeywords.Normal)) if (source.IsIdentifier(CssKeywords.Normal))
{ {
modes = new ICssValue[] { new NormalContentMode() }; modes = [new NormalContentMode()];
} }
else if (source.IsIdentifier(CssKeywords.None)) else if (source.IsIdentifier(CssKeywords.None))
{ {
modes = new ICssValue[] { }; modes = [];
} }
else else
{ {
@ -97,7 +97,7 @@ namespace AngleSharp.Css.Declarations
} }
modes = ms.ToArray(); modes = [.. ms];
} }
if (modes != null) if (modes != null)
@ -108,14 +108,9 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
private sealed class ContentValue : ICssValue, IEquatable<ContentValue> private sealed class ContentValue(ICssValue[] modes) : ICssValue, IEquatable<ContentValue>
{ {
private readonly ICssValue[] _modes; private readonly ICssValue[] _modes = modes;
public ContentValue(ICssValue[] modes)
{
_modes = modes;
}
public String CssText => _modes.Length == 0 ? CssKeywords.None : _modes.Join(" "); public String CssText => _modes.Length == 0 ? CssKeywords.None : _modes.Join(" ");
@ -220,14 +215,9 @@ namespace AngleSharp.Css.Declarations
/// <summary> /// <summary>
/// Text content. /// Text content.
/// </summary> /// </summary>
private sealed class TextContentMode : ContentMode private sealed class TextContentMode(String text) : ContentMode
{ {
private readonly String _text; private readonly String _text = text;
public TextContentMode(String text)
{
_text = text;
}
public override String GetCssText() => _text.CssString(); public override String GetCssText() => _text.CssString();
@ -249,14 +239,9 @@ namespace AngleSharp.Css.Declarations
/// in scope at this pseudo-element, from outermost to innermost /// in scope at this pseudo-element, from outermost to innermost
/// separated by the specified string. /// separated by the specified string.
/// </summary> /// </summary>
private sealed class CounterContentMode : ContentMode private sealed class CounterContentMode(CssCounterDefinitionValue counter) : ContentMode
{ {
private readonly CssCounterDefinitionValue _counter; private readonly CssCounterDefinitionValue _counter = counter;
public CounterContentMode(CssCounterDefinitionValue counter)
{
_counter = counter;
}
public override String GetCssText() => _counter.CssText; public override String GetCssText() => _counter.CssText;
@ -277,14 +262,9 @@ namespace AngleSharp.Css.Declarations
/// Returns the value of the element's attribute X as a string. If /// Returns the value of the element's attribute X as a string. If
/// there is no attribute X, an empty string is returned. /// there is no attribute X, an empty string is returned.
/// </summary> /// </summary>
private sealed class AttributeContentMode : ContentMode private sealed class AttributeContentMode(String attribute) : ContentMode
{ {
private readonly String _attribute; private readonly String _attribute = attribute;
public AttributeContentMode(String attribute)
{
_attribute = attribute;
}
public override String GetCssText() => FunctionNames.Attr.CssFunction(_attribute); public override String GetCssText() => FunctionNames.Attr.CssFunction(_attribute);
@ -306,14 +286,9 @@ namespace AngleSharp.Css.Declarations
/// image). If the resource or image can't be displayed, it is either /// image). If the resource or image can't be displayed, it is either
/// ignored or some placeholder shows up. /// ignored or some placeholder shows up.
/// </summary> /// </summary>
private sealed class UrlContentMode : ContentMode private sealed class UrlContentMode(CssUrlValue url) : ContentMode
{ {
private readonly CssUrlValue _url; private readonly CssUrlValue _url = url;
public UrlContentMode(CssUrlValue url)
{
_url = url;
}
public override String GetCssText() => _url.CssText; public override String GetCssText() => _url.CssText;

Просмотреть файл

@ -54,7 +54,7 @@ namespace AngleSharp.Css.Declarations
if (cursor != null) if (cursor != null)
{ {
return new CssCursorValue(definitions.ToArray(), cursor); return new CssCursorValue([.. definitions], cursor);
} }
break; break;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexBasis; public static String Name = PropertyNames.FlexBasis;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Flex, PropertyNames.Flex,
}; ];
public static IValueConverter Converter = Or(Content, AutoLengthOrPercentConverter); public static IValueConverter Converter = Or(Content, AutoLengthOrPercentConverter);

Просмотреть файл

@ -10,12 +10,12 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.Flex; public static String Name = PropertyNames.Flex;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.FlexGrow, PropertyNames.FlexGrow,
PropertyNames.FlexShrink, PropertyNames.FlexShrink,
PropertyNames.FlexBasis, PropertyNames.FlexBasis,
}; ];
public static IValueConverter Converter = new FlexAggregator(); public static IValueConverter Converter = new FlexAggregator();
@ -55,12 +55,12 @@ namespace AngleSharp.Css.Declarations
if (options != null) if (options != null)
{ {
return new[] return
{ [
options.Items[0], options.Items[0],
options.Items[1], options.Items[1],
options.Items[2], options.Items[2],
}; ];
} }
return null; return null;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexDirection; public static String Name = PropertyNames.FlexDirection;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.FlexFlow, PropertyNames.FlexFlow,
}; ];
public static IValueConverter Converter = FlexDirectionConverter; public static IValueConverter Converter = FlexDirectionConverter;

Просмотреть файл

@ -10,11 +10,11 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexFlow; public static String Name = PropertyNames.FlexFlow;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.FlexDirection, PropertyNames.FlexDirection,
PropertyNames.FlexWrap, PropertyNames.FlexWrap,
}; ];
public static IValueConverter Converter = new FlexFlowAggregator(); public static IValueConverter Converter = new FlexFlowAggregator();
@ -52,11 +52,11 @@ namespace AngleSharp.Css.Declarations
if (options != null) if (options != null)
{ {
return new[] return
{ [
options.Items[0], options.Items[0],
options.Items[1], options.Items[1],
}; ];
} }
return null; return null;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexGrow; public static String Name = PropertyNames.FlexGrow;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Flex, PropertyNames.Flex,
}; ];
public static IValueConverter Converter = NumberConverter; public static IValueConverter Converter = NumberConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexShrink; public static String Name = PropertyNames.FlexShrink;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Flex, PropertyNames.Flex,
}; ];
public static IValueConverter Converter = NumberConverter; public static IValueConverter Converter = NumberConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FlexWrap; public static String Name = PropertyNames.FlexWrap;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.FlexFlow, PropertyNames.FlexFlow,
}; ];
public static IValueConverter Converter = FlexWrapConverter; public static IValueConverter Converter = FlexWrapConverter;

Просмотреть файл

@ -17,8 +17,8 @@ namespace AngleSharp.Css.Declarations
public static PropertyFlags Flags = PropertyFlags.Inherited | PropertyFlags.Animatable | PropertyFlags.Shorthand; public static PropertyFlags Flags = PropertyFlags.Inherited | PropertyFlags.Animatable | PropertyFlags.Shorthand;
public static String[] Longhands = new[] public static String[] Longhands =
{ [
PropertyNames.FontFamily, PropertyNames.FontFamily,
PropertyNames.FontSize, PropertyNames.FontSize,
PropertyNames.FontVariant, PropertyNames.FontVariant,
@ -26,7 +26,7 @@ namespace AngleSharp.Css.Declarations
PropertyNames.FontStretch, PropertyNames.FontStretch,
PropertyNames.FontStyle, PropertyNames.FontStyle,
PropertyNames.LineHeight, PropertyNames.LineHeight,
}; ];
sealed class FontValueConverter : IValueConverter sealed class FontValueConverter : IValueConverter
{ {
@ -139,10 +139,10 @@ namespace AngleSharp.Css.Declarations
return null; return null;
} }
return new ICssValue[] { systemFont, null, null, null, null, null, null }; return [systemFont, null, null, null, null, null, null];
} }
return new ICssValue[] { font.FontFamilies, font.Size, font.Variant, font.Weight, font.Stretch, font.Style, font.LineHeight }; return [font.FontFamilies, font.Size, font.Variant, font.Weight, font.Stretch, font.Style, font.LineHeight];
} }
} }
} }

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FontFamily; public static String Name = PropertyNames.FontFamily;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Font, PropertyNames.Font,
}; ];
public static IValueConverter Converter = FontFamiliesConverter; public static IValueConverter Converter = FontFamiliesConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FontSize; public static String Name = PropertyNames.FontSize;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Font, PropertyNames.Font,
}; ];
public static IValueConverter Converter = FontSizeConverter; public static IValueConverter Converter = FontSizeConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FontStyle; public static String Name = PropertyNames.FontStyle;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Font, PropertyNames.Font,
}; ];
public static IValueConverter Converter = FontStyleConverter; public static IValueConverter Converter = FontStyleConverter;

Просмотреть файл

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{ {
public static String Name = PropertyNames.FontVariant; public static String Name = PropertyNames.FontVariant;
public static String[] Shorthands = new[] public static String[] Shorthands =
{ [
PropertyNames.Font, PropertyNames.Font,
}; ];
public static IValueConverter Converter = FontVariantConverter; public static IValueConverter Converter = FontVariantConverter;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше