Improved background serialization
This commit is contained in:
Родитель
0ee93d6b1e
Коммит
20e091d414
|
@ -30,7 +30,7 @@ namespace AngleSharp.Css.Declarations
|
|||
PropertyNames.BackgroundColor,
|
||||
};
|
||||
|
||||
sealed class BackgroundValueConverter : IValueConverter
|
||||
sealed class BackgroundAggregator : IValueAggregator, IValueConverter
|
||||
{
|
||||
public ICssValue Convert(StringSource source)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace AngleSharp.Css.Declarations
|
|||
}
|
||||
}
|
||||
while (pos != source.Index);
|
||||
|
||||
|
||||
layers.Add(new CssBackgroundLayerValue(
|
||||
image,
|
||||
position,
|
||||
|
@ -126,13 +126,6 @@ namespace AngleSharp.Css.Declarations
|
|||
|
||||
return new CssBackgroundValue(new CssListValue(layers.OfType<ICssValue>().ToArray()), color);
|
||||
}
|
||||
}
|
||||
|
||||
sealed class BackgroundAggregator : IValueAggregator, IValueConverter
|
||||
{
|
||||
private static readonly IValueConverter converter = new BackgroundValueConverter();
|
||||
|
||||
public ICssValue Convert(StringSource source) => converter.Convert(source);
|
||||
|
||||
public ICssValue Merge(ICssValue[] values)
|
||||
{
|
||||
|
@ -144,7 +137,6 @@ namespace AngleSharp.Css.Declarations
|
|||
var origin = GetList(values[5]);
|
||||
var clip = GetList(values[6]);
|
||||
var color = values[7];
|
||||
|
||||
var layers = CreateLayers(image, attachment, clip, position, origin, repeat, size);
|
||||
|
||||
if (color != null || layers != null)
|
||||
|
|
|
@ -52,10 +52,6 @@ namespace AngleSharp.Css.Declarations
|
|||
|
||||
return new CssListValue(points);
|
||||
}
|
||||
else if (values[0] is CssInitialValue && values[1] is CssInitialValue)
|
||||
{
|
||||
return new CssInitialValue(InitialValues.BackgroundPositionDecl);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -73,14 +69,6 @@ namespace AngleSharp.Css.Declarations
|
|||
new CssListValue(y),
|
||||
};
|
||||
}
|
||||
else if (value is CssInitialValue)
|
||||
{
|
||||
return new ICssValue[]
|
||||
{
|
||||
new CssInitialValue(InitialValues.BackgroundPositionXDecl),
|
||||
new CssInitialValue(InitialValues.BackgroundPositionYDecl),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -52,10 +52,6 @@ namespace AngleSharp.Css.Declarations
|
|||
|
||||
return new CssListValue(repeats);
|
||||
}
|
||||
else if (values[0] is CssInitialValue && values[1] is CssInitialValue)
|
||||
{
|
||||
return new CssInitialValue(InitialValues.BackgroundRepeatDecl);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -73,14 +69,6 @@ namespace AngleSharp.Css.Declarations
|
|||
new CssListValue(v),
|
||||
};
|
||||
}
|
||||
else if (value is CssInitialValue)
|
||||
{
|
||||
return new ICssValue[]
|
||||
{
|
||||
new CssInitialValue(InitialValues.BackgroundRepeatHorizontalDecl),
|
||||
new CssInitialValue(InitialValues.BackgroundRepeatVerticalDecl),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -47,11 +47,16 @@ namespace AngleSharp.Css
|
|||
if (value is ICssRawValue || value is CssChildValue)
|
||||
{
|
||||
var child = new CssChildValue(value);
|
||||
return Enumerable.Repeat(child, longhands.Length).ToArray();
|
||||
return Enumerable
|
||||
.Repeat(child, longhands.Length)
|
||||
.ToArray();
|
||||
}
|
||||
else if (value is CssInitialValue)
|
||||
{
|
||||
return longhands.Select(name => factory.Create(name)?.InitialValue).ToArray();
|
||||
return longhands
|
||||
.Select(name => new CssInitialValue(factory.Create(name)?.InitialValue))
|
||||
.OfType<ICssValue>()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return info.Aggregator?.Split(value);
|
||||
|
|
Загрузка…
Ссылка в новой задаче