Skip to content

Commit 7ce228e

Browse files
committed
Tighten color and fieldset defaults
Use `Math.Clamp` for channel bounds in `ColorParser` and `TryAdd` the default fieldset border in `HtmlParser` so existing borders are preserved.
1 parent cfabb0d commit 7ce228e

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/OpenXmlHtml/ColorParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static bool TryParseComponent(ReadOnlySpan<char> value, out int component)
270270
}
271271

272272
static int Clamp(int value) =>
273-
Math.Max(0, Math.Min(255, value));
273+
Math.Clamp(value, 0, 255);
274274

275275
static bool IsValidHex(ReadOnlySpan<char> hex)
276276
{

src/OpenXmlHtml/HtmlParser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ internal static void ApplyElementFormatting(IElement element, string tag, ref Fo
322322
if (tag == "fieldset")
323323
{
324324
declarations ??= new(StringComparer.OrdinalIgnoreCase);
325-
if (!declarations.ContainsKey("border"))
326-
{
327-
declarations["border"] = "1pt solid #808080";
328-
}
325+
declarations.TryAdd("border", "1pt solid #808080");
329326
}
330327
}
331328

0 commit comments

Comments
 (0)