CssVerticalAlignProperty
Information can be found on MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align
using AngleSharp.Css;
using AngleSharp.Extensions;
namespace AngleSharp.Dom.Css
{
internal sealed class CssVerticalAlignProperty : CssProperty, ICssVerticalAlignProperty, ICssProperty
{
internal static readonly VerticalAlignment Default = VerticalAlignment.Baseline;
internal static readonly IValueConverter<VerticalAlignment> Converter = Map.VerticalAlignments.ToConverter();
private VerticalAlignment _mode;
private Length _shift;
public Length Shift => _shift;
public VerticalAlignment State => _mode;
internal CssVerticalAlignProperty(CssStyleDeclaration rule)
: base(PropertyNames.VerticalAlign, rule, PropertyFlags.Animatable)
{
Reset();
}
public void SetAlignment(Length shift)
{
_shift = shift;
_mode = VerticalAlignment.Baseline;
}
public void SetAlignment(VerticalAlignment mode)
{
_mode = mode;
_shift = Length.Zero;
}
internal override void Reset()
{
_mode = Default;
_shift = Length.Zero;
}
protected override bool IsValid(ICssValue value)
{
if (!Converters.LengthOrPercentConverter.TryConvert(value, SetAlignment))
return Converter.TryConvert(value, SetAlignment);
return true;
}
}
}