1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibWeb: Rename the LayoutMode enum values and explain them

The old mode names, while mechanically accurate, didn't really reflect
their relationship to the CSS specifications.

This patch renames them as follows:

    Default => Normal
    AllPossibleLineBreaks => MinContent
    OnlyRequiredLineBreaks => MaxContent

There's also now an explainer comment with the LayoutMode enum about the
specific implications of layout in each mode.
This commit is contained in:
Andreas Kling 2022-03-19 15:44:02 +01:00
parent ceb055a75e
commit c1f0d21bbe
10 changed files with 43 additions and 32 deletions

View file

@ -141,7 +141,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
}
}
if (m_wrap_lines || m_layout_mode == LayoutMode::AllPossibleLineBreaks) {
if (m_wrap_lines || m_layout_mode == LayoutMode::MinContent) {
bool is_space = is_ascii_space(*m_iterator);
if (is_space != m_last_was_space) {
m_last_was_space = is_space;
@ -163,7 +163,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
Optional<TextNode::Chunk> TextNode::ChunkIterator::try_commit_chunk(Utf8View::Iterator const& start, Utf8View::Iterator const& end, bool has_breaking_newline, bool must_commit) const
{
if (m_layout_mode == LayoutMode::OnlyRequiredLineBreaks && !must_commit)
if (m_layout_mode == LayoutMode::MaxContent && !must_commit)
return {};
auto byte_offset = m_utf8_view.byte_offset_of(start);