public static ICssValue Collapse(this DeclarationInfo info, IDeclarationFactory factory, ICssValue[] longhands) { var initial = true; var unset = true; var child = true; foreach (var longhand in longhands) { initial = initial && longhand is CssInitialValue; unset = unset && longhand is CssUnsetValue; child = child && longhand is CssChildValue; } if (initial) { return(new CssInitialValue(info.InitialValue)); } else if (unset) { return(new CssUnsetValue(info.InitialValue)); } else if (child) { return(((CssChildValue)longhands[0]).Parent); } return(info.Aggregator?.Merge(longhands)); }
public static ICssProperty[] CreateLonghands(this DeclarationInfo info, ICssValue value, Func <String, ICssValue, ICssProperty> createProperty) { var aggregator = info.Converter as IValueAggregator; var longhands = info.Longhands; if (value is ICssRawValue) { var child = new CssChildValue(value); var values = Enumerable.Repeat(child, longhands.Length).ToArray(); return(CreateProperties(longhands, values, createProperty)); } return(CreateProperties(longhands, aggregator?.Split(value), createProperty)); }
public static ICssValue[] Expand(this DeclarationInfo info, IDeclarationFactory factory, ICssValue value) { var longhands = info.Longhands; if (value is ICssRawValue || value is CssChildValue) { var child = new CssChildValue(value); return(Enumerable .Repeat(child, longhands.Length) .ToArray()); } else if (value is CssInitialValue) { return(longhands .Select(name => new CssInitialValue(factory.Create(name)?.InitialValue)) .OfType <ICssValue>() .ToArray()); } return(info.Aggregator?.Split(value)); }
public static IEnumerable <String> GetMappings(this DeclarationInfo info) { return(info.Longhands.Length > 0 ? info.Longhands : Enumerable.Repeat(info.Name, 1)); }
private static Boolean AllowsDeclaration(this IBrowsingContext context, DeclarationInfo info) => info.Flags != PropertyFlags.Unknown || context.IsAllowingUnknownDeclarations();