CssBackgroundRepeatProperty
More information available at:
https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat
Gets an enumeration with the horizontal repeat modes.
Gets an enumeration with the vertical repeat modes.
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
namespace AngleSharp.Dom.Css
{
internal sealed class CssBackgroundRepeatProperty : CssProperty
{
internal struct Repeat
{
public BackgroundRepeat Horizontal;
public BackgroundRepeat Vertical;
}
private static readonly Repeat Default;
internal static readonly IValueConverter<Repeat> SingleConverter;
private static readonly IValueConverter<Repeat[]> Converter;
internal CssBackgroundRepeatProperty(CssStyleDeclaration rule)
: base(PropertyNames.BackgroundRepeat, rule, PropertyFlags.None)
{
}
protected override object GetDefault(IElement element)
{
return Default;
}
protected override object Compute(IElement element)
{
return Converter.Convert(base.Value);
}
protected override bool IsValid(ICssValue value)
{
return Converter.Validate(value);
}
static CssBackgroundRepeatProperty()
{
Repeat repeat = new Repeat {
Horizontal = BackgroundRepeat.Repeat,
Vertical = BackgroundRepeat.Repeat
};
Default = repeat;
IValueConverter<Repeat> primary = Map.BackgroundRepeats.ToConverter().To(delegate(BackgroundRepeat m) {
Repeat result2 = default(Repeat);
result2.Horizontal = m;
result2.Vertical = m;
return result2;
});
string repeatX = Keywords.RepeatX;
repeat = new Repeat {
Horizontal = BackgroundRepeat.Repeat,
Vertical = BackgroundRepeat.NoRepeat
};
IValueConverter<Repeat> primary2 = primary.Or(repeatX, repeat);
string repeatY = Keywords.RepeatY;
repeat = new Repeat {
Horizontal = BackgroundRepeat.NoRepeat,
Vertical = BackgroundRepeat.Repeat
};
SingleConverter = primary2.Or(repeatY, repeat).Or(Converters.WithOrder(Map.BackgroundRepeats.ToConverter().Required(), Map.BackgroundRepeats.ToConverter().Required()).To(delegate(Tuple<BackgroundRepeat, BackgroundRepeat> m) {
Repeat result = default(Repeat);
result.Horizontal = m.Item1;
result.Vertical = m.Item2;
return result;
}));
Converter = SingleConverter.FromList();
}
}
}