This commit is contained in:
Florian Rappl 2024-01-16 14:45:20 +01:00
Родитель 7a96a5587f
Коммит dba9069d70
5 изменённых файлов: 99 добавлений и 7 удалений

Просмотреть файл

@ -10,6 +10,7 @@ Released on tbd.
- Fixed integer serialization of keyframe stops (#128)
- Fixed ordering of rows and columns in `grid` and `grid-gap` (#137)
- Fixed inclusion of CSS from stylesheets (#116, #140)
- Fixed style empty if `text-align` is `start` (#151)
- Added further compactification of CSS tuples (#89, #93)
- Added support for 8-digit hex color codes (#132)
- Added more CSSOM possibilities and helpers (#6)

Просмотреть файл

@ -690,6 +690,39 @@ namespace AngleSharp.Css.Tests.Declarations
Assert.IsFalse(property.IsInherited);
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.HasValue);
}
}
}
[Test]
public void CssTextAlignLegalStart_Issue151()
{
var snippet = "text-align:start";
var property = ParseDeclaration(snippet);
Assert.AreEqual("text-align", property.Name);
Assert.IsTrue(property.HasValue);
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.AreEqual("start", property.Value);
}
[Test]
public void CssTextAlignLegalJustifyAll_Issue151()
{
var snippet = "text-align:justify-all";
var property = ParseDeclaration(snippet);
Assert.AreEqual("text-align", property.Name);
Assert.IsTrue(property.HasValue);
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.AreEqual("justify-all", property.Value);
}
[Test]
public void CssTextAlignIllegalJustifyNone_Issue151()
{
var snippet = "text-align:justify-none";
var property = ParseDeclaration(snippet);
Assert.AreEqual("text-align", property.Name);
Assert.IsFalse(property.HasValue);
}
}
}

Просмотреть файл

@ -702,6 +702,11 @@ namespace AngleSharp.Css
/// </summary>
public static readonly String Justify = "justify";
/// <summary>
/// The justify-all keyword.
/// </summary>
public static readonly String JustifyAll = "justify-all";
/// <summary>
/// The underline keyword.
/// </summary>
@ -1422,6 +1427,11 @@ namespace AngleSharp.Css
/// </summary>
public static readonly String Separate = "separate";
/// <summary>
/// The match-parent keyword.
/// </summary>
public static readonly String MatchParent = "match-parent";
/// <summary>
/// The start keyword.
/// </summary>

Просмотреть файл

@ -93,12 +93,16 @@ namespace AngleSharp.Css
/// <summary>
/// Contains the string-HorizontalAlignment mapping.
/// </summary>
public static readonly Dictionary<String, HorizontalAlignment> HorizontalAlignments = new(StringComparer.OrdinalIgnoreCase)
public static readonly Dictionary<String, TextAlign> HorizontalAlignments = new(StringComparer.OrdinalIgnoreCase)
{
{ CssKeywords.Left, HorizontalAlignment.Left },
{ CssKeywords.Right, HorizontalAlignment.Right },
{ CssKeywords.Center, HorizontalAlignment.Center },
{ CssKeywords.Justify, HorizontalAlignment.Justify },
{ CssKeywords.Left, TextAlign.Left },
{ CssKeywords.Right, TextAlign.Right },
{ CssKeywords.Center, TextAlign.Center },
{ CssKeywords.Justify, TextAlign.Justify },
{ CssKeywords.Start, TextAlign.Start },
{ CssKeywords.End, TextAlign.End },
{ CssKeywords.JustifyAll, TextAlign.JustifyAll },
{ CssKeywords.MatchParent, TextAlign.MatchParent },
};
/// <summary>

Просмотреть файл

@ -0,0 +1,44 @@
namespace AngleSharp.Css.Dom
{
/// <summary>
/// An enumeration with all possible text alignments.
/// </summary>
public enum TextAlign: byte
{
/// <summary>
/// The inline contents are aligned to the left edge of the line box.
/// This is the default value for table data.
/// </summary>
Left,
/// <summary>
/// The inline contents are centered within the line box. This is
/// the default value for table headers.
/// </summary>
Center,
/// <summary>
/// The inline contents are aligned to the right edge of the line box.
/// </summary>
Right,
/// <summary>
/// The text is justified. Text should line up their left and right
/// edges to the left and right content edges of the paragraph.
/// </summary>
Justify,
/// <summary>
/// The same as left if direction is left-to-right and right if direction is right-to-left.
/// </summary>
Start,
/// <summary>
/// The same as right if direction is left-to-right and left if direction is right-to-left.
/// </summary>
End,
/// <summary>
/// Same as justify, but also forces the last line to be justified.
/// </summary>
JustifyAll,
/// <summary>
/// Similar to inherit, but the values start and end are calculated according to the parent's direction and are replaced by the appropriate left or right value.
/// </summary>
MatchParent,
}
}