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 = new Repeat {
Horizontal = BackgroundRepeat.Repeat,
Vertical = BackgroundRepeat.Repeat
};
internal static readonly IValueConverter<Repeat> SingleConverter = Map.BackgroundRepeats.ToConverter().To(delegate(BackgroundRepeat m) {
Repeat result2 = default(Repeat);
result2.Horizontal = m;
result2.Vertical = m;
return result2;
}).Or(Keywords.RepeatX, new Repeat {
Horizontal = BackgroundRepeat.Repeat,
Vertical = BackgroundRepeat.NoRepeat
})
.Or(Keywords.RepeatY, new Repeat {
Horizontal = BackgroundRepeat.NoRepeat,
Vertical = BackgroundRepeat.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;
}));
private static readonly IValueConverter<Repeat[]> Converter = SingleConverter.FromList();
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(CssValue value)
{
return Converter.Validate(value);
}
}
}