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>
<readme>README.md</readme>
<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>
<copyright>Copyright 2016-2024, AngleSharp</copyright>
<tags>html html5 css css3 dom styling library anglesharp angle</tags>

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

@ -4,10 +4,8 @@
<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;net461;net472;net6.0;net7.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Css</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>

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

@ -20,7 +20,7 @@ namespace AngleSharp.Css
/// <param name="address">The address of the resource.</param>
/// <param name="element">The hosting element.</param>
/// <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);
/// <summary>
@ -31,22 +31,21 @@ namespace AngleSharp.Css
/// <param name="element">The hosting element.</param>
/// <param name="cancel">The cancellation token.</param>
/// <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 service = context.GetCssStyling();
if (loader != null && service != null)
if (loader is not null && service is not null)
{
var request = element.CreateRequestFor(address);
var download = loader.FetchAsync(request);
using (var response = await download.Task.ConfigureAwait(false))
{
var options = new StyleOptions(element?.Owner ?? context.Active) { Element = element };
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(document) { Element = element };
return await service.ParseStylesheetAsync(response, options, cancel).ConfigureAwait(false);
}
}
return null;
}
@ -57,7 +56,7 @@ namespace AngleSharp.Css
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 info = factory.Create(name);
@ -79,7 +78,7 @@ namespace AngleSharp.Css
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);
@ -102,7 +101,7 @@ namespace AngleSharp.Css
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];
@ -115,7 +114,7 @@ namespace AngleSharp.Css
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 BackgroundPositionXDecl = 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 BackgroundOriginDecl = new CssConstantValue<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox);
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 WidthDecl = CssLengthValue.Auto;
public static readonly ICssValue HeightDecl = CssLengthValue.Auto;
public static readonly ICssValue ScrollbarTrackColorDecl = CssColors.GetColor("scrollbar");
public static readonly ICssValue ScrollbarShadowColorDecl = CssColors.GetColor("threeddarkshadow");
public static readonly ICssValue ScrollbarHighlightColorDecl = CssColors.GetColor("threedhighlight");
public static readonly ICssValue ScrollbarFaceColorDecl = CssColors.GetColor("threedface");
public static readonly ICssValue ScrollbarDarkshadowColorDecl = CssColors.GetColor("threeddarkshadow");
public static readonly ICssValue ScrollbarTrackColorDecl = CssColors.GetColor("scrollbar")!;
public static readonly ICssValue ScrollbarShadowColorDecl = CssColors.GetColor("threeddarkshadow")!;
public static readonly ICssValue ScrollbarHighlightColorDecl = CssColors.GetColor("threedhighlight")!;
public static readonly ICssValue ScrollbarFaceColorDecl = CssColors.GetColor("threedface")!;
public static readonly ICssValue ScrollbarDarkshadowColorDecl = CssColors.GetColor("threeddarkshadow")!;
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 LetterSpacingDecl = CssLengthValue.Normal;
public static readonly ICssValue FontSizeAdjustDecl = new CssLengthValue(1.0, CssLengthValue.Unit.Em);

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

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

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

@ -4,23 +4,17 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Parser;
using AngleSharp.Css.Values;
using AngleSharp.Text;
using System;
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;
}
public ICssValue Convert(StringSource source)
{
var counters = new List<CssCounterValue>();
var counters = new List<ICssValue>();
if (!source.IsIdentifier(CssKeywords.None))
{
@ -39,7 +33,7 @@ namespace AngleSharp.Css.Converters
counters.Add(new CssCounterValue(name, value));
}
return new CssTupleValue<CssCounterValue>(counters.ToArray());
return new CssTupleValue([.. counters]);
}
return new CssConstantValue<CssCounterValue[]>(CssKeywords.None, NoneValue);

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

@ -7,22 +7,16 @@ namespace AngleSharp.Css.Converters
using System;
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)
{
_values = values;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var pos = source.Index;
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);
}

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

@ -6,28 +6,23 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text;
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)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var options = new ICssValue[2];
var length = 0;
for (var i = 0; i < options.Length; i++)
{
options[i] = _converter.Convert(source);
var option = _converter.Convert(source);
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 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)
{
_check = check;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var result = _check.Invoke(source);
if (result != null)
if (result is not null)
{
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 T _result;
private readonly String _identifier = identifier;
private readonly T _result = result;
public IdentifierValueConverter(String identifier, T result)
{
_identifier = identifier;
_result = result;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
if (source.IsIdentifier(_identifier))
{

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

@ -6,16 +6,11 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text;
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)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var values = new List<ICssValue>();
@ -33,7 +28,7 @@ namespace AngleSharp.Css.Converters
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.Collections.Generic;
sealed class OneOrMoreValueConverter : IValueConverter
sealed class OneOrMoreValueConverter(IValueConverter converter, Int32 minimum, Int32 maximum, String separator) : IValueConverter
{
private readonly IValueConverter _converter;
private readonly Int32 _minimum;
private readonly Int32 _maximum;
private readonly String _separator;
private readonly IValueConverter _converter = converter;
private readonly Int32 _minimum = minimum;
private readonly Int32 _maximum = maximum;
private readonly String _separator = separator;
public OneOrMoreValueConverter(IValueConverter converter, Int32 minimum, Int32 maximum, String separator)
{
_converter = converter;
_minimum = minimum;
_maximum = maximum;
_separator = separator;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var values = new List<ICssValue>();
@ -37,7 +29,7 @@ namespace AngleSharp.Css.Converters
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.Text;
sealed class OptionValueConverter : IValueConverter
sealed class OptionValueConverter(IValueConverter converter, ICssValue defaultValue) : IValueConverter
{
private readonly IValueConverter _converter;
private readonly ICssValue _defaultValue;
private readonly IValueConverter _converter = converter;
private readonly ICssValue _defaultValue = defaultValue;
public OptionValueConverter(IValueConverter converter, ICssValue defaultValue)
{
_converter = converter;
_defaultValue = defaultValue;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
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.Parser;
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)
{
_converters = converters;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var start = source.Index;

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

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

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

@ -6,28 +6,23 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Text;
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)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var options = new ICssValue[4];
var length = 0;
for (var i = 0; i < options.Length; i++)
{
options[i] = _converter.Convert(source);
var option = _converter.Convert(source);
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 System;
sealed class RadiusValueConverter : IValueConverter
sealed class RadiusValueConverter(IValueConverter converter) : IValueConverter
{
private readonly IValueConverter _converter;
private readonly IValueConverter _converter = converter;
public RadiusValueConverter(IValueConverter converter)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var options = new ICssValue[2];
var length = 0;
for (var i = 0; i < options.Length; i++)
{
options[i] = _converter.Convert(source);
var option = _converter.Convert(source);
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 System;
sealed class SeparatedEnumsConverter : IValueConverter
sealed class SeparatedEnumsConverter(IValueConverter[] converters, Char seperator) : IValueConverter
{
private readonly IValueConverter[] _converters;
private readonly Char _seperator;
private readonly IValueConverter[] _converters = converters;
private readonly Char _seperator = seperator;
public SeparatedEnumsConverter(IValueConverter[] converters, Char seperator)
{
_converters = converters;
_seperator = seperator;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var value = _converters[0].Convert(source);

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

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

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

@ -5,16 +5,11 @@ namespace AngleSharp.Css.Converters
using AngleSharp.Css.Values;
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)
{
_defaultValue = defaultValue;
}
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
var ident = source.ParseIdent();

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

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

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

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

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

@ -62,7 +62,7 @@ namespace AngleSharp
/// <param name="configuration">The configuration to extend.</param>
/// <param name="renderDevice">The custom device to register, if any.</param>
/// <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());
}
}

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

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

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

@ -33,13 +33,13 @@ namespace AngleSharp.Css
public async Task<IStyleSheet> ParseStylesheetAsync(IResponse response, StyleOptions options, CancellationToken cancel)
{
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 source = new TextSource(response.Content);
var sheet = new CssStyleSheet(context, source)
{
IsDisabled = options.IsDisabled,
Href = url
Href = url!
};
sheet.SetOwner(options.Element);
return await parser.ParseStyleSheetAsync(sheet, cancel).ConfigureAwait(false);

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

@ -7,61 +7,51 @@ namespace AngleSharp.Css
/// <summary>
/// A collection of useful information regarding a CSS declaration.
/// </summary>
public class DeclarationInfo
{
/// <summary>
/// <remarks>
/// Constructs a new declaration info.
/// </summary>
/// </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 DeclarationInfo(String name, IValueConverter converter, PropertyFlags flags = PropertyFlags.None, ICssValue initialValue = null, String[] shorthands = null, String[] longhands = null)
public class 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>
/// Gets the declaration name.
/// </summary>
public String Name { get; }
public String Name { get; } = name;
/// <summary>
/// Gets the initial value of the declaration, if any.
/// </summary>
public ICssValue InitialValue { get; }
public ICssValue? InitialValue { get; } = initialValue;
/// <summary>
/// Gets the associated value converter.
/// </summary>
public IValueConverter Converter { get; }
public IValueConverter Converter { get; } = initialValue != null ? Or(converter, AssignInitial(initialValue)) : converter;
/// <summary>
/// Gets the value aggregator, if any.
/// </summary>
public IValueAggregator Aggregator { get; }
public IValueAggregator? Aggregator { get; } = converter as IValueAggregator;
/// <summary>
/// Gets the flags of the declaration.
/// </summary>
public PropertyFlags Flags { get; }
public PropertyFlags Flags { get; } = flags;
/// <summary>
/// Gets the names of related shorthand declarations.
/// </summary>
public String[] Shorthands { get; }
public String[] Shorthands { get; } = shorthands ?? [];
/// <summary>
/// Gets the names of related required longhand declarations.
/// </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 ICssValue InitialValue = null;
public static ICssValue? InitialValue = null;
public static PropertyFlags Flags = PropertyFlags.Shorthand;
public static String[] Longhands = new[]
{
public static String[] Longhands =
[
PropertyNames.AnimationDuration,
PropertyNames.AnimationTimingFunction,
PropertyNames.AnimationDelay,
@ -28,7 +28,7 @@ namespace AngleSharp.Css.Declarations
PropertyNames.AnimationFillMode,
PropertyNames.AnimationPlayState,
PropertyNames.AnimationName,
};
];
sealed class AnimationAggregator : IValueAggregator, IValueConverter
{
@ -42,9 +42,9 @@ namespace AngleSharp.Css.Declarations
PlayStateConverter.Option(InitialValues.AnimationPlayStateDecl),
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 timing = values[1] as CssListValue;
@ -63,12 +63,12 @@ namespace AngleSharp.Css.Declarations
return null;
}
public ICssValue[] Split(ICssValue value)
public ICssValue?[]? Split(ICssValue value)
{
if (value is CssListValue list)
{
return new[]
{
return
[
CreateMultiple(list, 0),
CreateMultiple(list, 1),
CreateMultiple(list, 2),
@ -77,13 +77,13 @@ namespace AngleSharp.Css.Declarations
CreateMultiple(list, 5),
CreateMultiple(list, 6),
CreateMultiple(list, 7),
};
];
}
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]);
@ -95,15 +95,15 @@ namespace AngleSharp.Css.Declarations
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 layers = new ICssValue[items.Length];
var items = (duration ?? timing ?? delay ?? iterationCount ?? direction ?? fillMode ?? playState ?? name)?.Items;
var layers = new ICssValue[items?.Length ?? 0];
for (var i = 0; i < items.Length; i++)
{
layers[i] = new CssTupleValue(new[]
for (var i = 0; i < layers.Length; i++)
{
layers[i] = new CssTupleValue(
[
GetValue(duration, i),
GetValue(timing, i),
GetValue(delay, i),
@ -112,13 +112,13 @@ namespace AngleSharp.Css.Declarations
GetValue(fillMode, i),
GetValue(playState, i),
GetValue(name, i),
});
]);
}
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)
{

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

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

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

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

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

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

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

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

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

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

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

@ -9,10 +9,10 @@ namespace AngleSharp.Css.Declarations
{
public static String Name = PropertyNames.AnimationName;
public static String[] Shorthands = new[]
{
public static String[] Shorthands =
[
PropertyNames.Animation,
};
];
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[] Shorthands = new[]
{
public static String[] Shorthands =
[
PropertyNames.Animation,
};
];
public static IValueConverter Converter = PlayStateConverter.FromList();

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

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

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

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

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

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

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

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

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

@ -14,12 +14,12 @@ namespace AngleSharp.Css.Declarations
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 String[] Longhands = new[]
{
public static String[] Longhands =
[
PropertyNames.BackgroundImage,
PropertyNames.BackgroundPosition,
PropertyNames.BackgroundSize,
@ -28,11 +28,11 @@ namespace AngleSharp.Css.Declarations
PropertyNames.BackgroundOrigin,
PropertyNames.BackgroundClip,
PropertyNames.BackgroundColor,
};
];
sealed class BackgroundAggregator : IValueAggregator, IValueConverter
{
public ICssValue Convert(StringSource source)
public ICssValue? Convert(StringSource source)
{
// [ <bg-layer> , ]* <final-bg-layer>
// where:
@ -177,7 +177,7 @@ namespace AngleSharp.Css.Declarations
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 position = GetList(values[1]);
@ -197,7 +197,7 @@ namespace AngleSharp.Css.Declarations
return null;
}
private static CssListValue GetList(ICssValue value)
private static CssListValue? GetList(ICssValue value)
{
if (value is CssListValue list)
{
@ -211,12 +211,12 @@ namespace AngleSharp.Css.Declarations
return null;
}
public ICssValue[] Split(ICssValue value)
public ICssValue?[]? Split(ICssValue value)
{
if (value is CssBackgroundValue background)
{
return new[]
{
return
[
CreateMultiple(background, m => m.Image, InitialValues.BackgroundImageDecl),
CreateMultiple(background, m => m.Position, InitialValues.BackgroundPositionDecl),
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.Clip, InitialValues.BackgroundClipDecl),
background.Color,
};
];
}
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);
@ -257,7 +257,7 @@ namespace AngleSharp.Css.Declarations
return null;
}
private static Int32 GetCount(params CssListValue[] lists)
private static Int32 GetCount(params CssListValue?[] lists)
{
var count = 0;
@ -269,7 +269,7 @@ namespace AngleSharp.Css.Declarations
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)
{
@ -279,7 +279,7 @@ namespace AngleSharp.Css.Declarations
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)
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{
public static String Name = PropertyNames.BorderColor;
public static String[] Shorthands = new[]
{
public static String[] Shorthands =
[
PropertyNames.Border,
};
];
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 String[] Longhands = new[]
{
public static String[] Longhands =
[
PropertyNames.BorderTopColor,
PropertyNames.BorderRightColor,
PropertyNames.BorderBottomColor,
PropertyNames.BorderLeftColor,
};
];
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -8,10 +8,10 @@ namespace AngleSharp.Css.Declarations
{
public static String Name = PropertyNames.FlexWrap;
public static String[] Shorthands = new[]
{
public static String[] Shorthands =
[
PropertyNames.FlexFlow,
};
];
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 String[] Longhands = new[]
{
public static String[] Longhands =
[
PropertyNames.FontFamily,
PropertyNames.FontSize,
PropertyNames.FontVariant,
@ -26,7 +26,7 @@ namespace AngleSharp.Css.Declarations
PropertyNames.FontStretch,
PropertyNames.FontStyle,
PropertyNames.LineHeight,
};
];
sealed class FontValueConverter : IValueConverter
{
@ -139,10 +139,10 @@ namespace AngleSharp.Css.Declarations
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[] Shorthands = new[]
{
public static String[] Shorthands =
[
PropertyNames.Font,
};
];
public static IValueConverter Converter = FontFamiliesConverter;

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

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

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

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

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

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

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