CssBorderImageSliceProperty
More information available at:
https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-slice
or even better:
http://dev.w3.org/csswg/css-backgrounds/#border-image-slice
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
namespace AngleSharp.Dom.Css
{
internal sealed class CssBorderImageSliceProperty : CssProperty, ICssBorderImageSliceProperty, ICssProperty
{
internal static readonly Length Default = new Length(100, Length.Unit.Percent);
internal static readonly IValueConverter<Tuple<Length, Length?, Length?, Length?, bool>> Converter = Converters.WithAny(Converters.BorderSliceConverter.Option(Default), Converters.BorderSliceConverter.ToNullable().Option(null), Converters.BorderSliceConverter.ToNullable().Option(null), Converters.BorderSliceConverter.ToNullable().Option(null), Converters.Assign(Keywords.Fill, true).Option(false));
private Length _top;
private Length _right;
private Length _bottom;
private Length _left;
private bool _fill;
public Length SliceTop => _top;
public Length SliceRight => _right;
public Length SliceBottom => _bottom;
public Length SliceLeft => _left;
public bool IsFilled => _fill;
internal CssBorderImageSliceProperty(CssStyleDeclaration rule)
: base(PropertyNames.BorderImageSlice, rule, PropertyFlags.None)
{
Reset();
}
private void SetSlice(Length top, Length? right, Length? bottom, Length? left, bool fill)
{
_top = top;
_right = (right ?? _top);
_bottom = (bottom ?? _top);
_left = (left ?? _right);
_fill = fill;
}
internal override void Reset()
{
_top = Default;
_right = Default;
_bottom = Default;
_left = Default;
_fill = false;
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<Length, Length?, Length?, Length?, bool> m) {
SetSlice(m.Item1, m.Item2, m.Item3, m.Item4, m.Item5);
});
}
}
}