2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2020-03-07 06:32:51 -03:00
|
|
|
#include <LibWeb/Layout/LineBoxFragment.h>
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
namespace Web::Layout {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
class LineBox {
|
|
|
|
|
public:
|
2024-10-29 08:32:59 -03:00
|
|
|
LineBox(CSS::Direction direction, CSS::WritingMode writing_mode)
|
2024-08-18 13:58:05 -03:00
|
|
|
: m_direction(direction)
|
2024-10-29 08:32:59 -03:00
|
|
|
, m_writing_mode(writing_mode)
|
2024-08-18 13:58:05 -03:00
|
|
|
{
|
|
|
|
|
}
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2024-10-29 08:32:59 -03:00
|
|
|
CSSPixels width() const;
|
|
|
|
|
CSSPixels height() const;
|
|
|
|
|
CSSPixels bottom() const;
|
2024-10-29 08:32:59 -03:00
|
|
|
|
|
|
|
|
CSSPixels inline_length() const { return m_inline_length; }
|
|
|
|
|
CSSPixels block_length() const { return m_block_length; }
|
2022-11-04 14:19:11 -03:00
|
|
|
CSSPixels baseline() const { return m_baseline; }
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2025-06-11 04:07:16 -03:00
|
|
|
void add_fragment(Node const& layout_node, size_t start, size_t length, CSSPixels leading_size, CSSPixels trailing_size, CSSPixels leading_margin, CSSPixels trailing_margin, CSSPixels content_width, CSSPixels content_height, CSSPixels border_box_top, CSSPixels border_box_bottom, RefPtr<Gfx::GlyphRun> glyph_run = {});
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2022-02-27 06:32:00 -03:00
|
|
|
Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
|
|
|
|
|
Vector<LineBoxFragment>& fragments() { return m_fragments; }
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2025-03-26 13:11:50 -03:00
|
|
|
CSSPixels get_trailing_whitespace_width() const;
|
2019-10-20 12:18:28 -03:00
|
|
|
void trim_trailing_whitespace();
|
2020-06-10 05:42:29 -03:00
|
|
|
|
2020-12-17 16:17:29 -03:00
|
|
|
bool is_empty_or_ends_in_whitespace() const;
|
2023-03-15 17:11:38 -03:00
|
|
|
bool is_empty() const { return m_fragments.is_empty() && !m_has_break; }
|
2020-06-13 09:59:17 -03:00
|
|
|
|
2023-08-12 13:30:18 -03:00
|
|
|
AvailableSize original_available_width() const { return m_original_available_width; }
|
2023-05-16 04:51:33 -03:00
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
private:
|
2021-10-06 15:02:41 -03:00
|
|
|
friend class BlockContainer;
|
2020-11-22 11:53:01 -03:00
|
|
|
friend class InlineFormattingContext;
|
2022-01-19 07:57:58 -03:00
|
|
|
friend class LineBuilder;
|
|
|
|
|
|
2025-03-26 13:11:50 -03:00
|
|
|
enum class RemoveTrailingWhitespace : u8 {
|
|
|
|
|
Yes,
|
|
|
|
|
No,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CSSPixels calculate_or_trim_trailing_whitespace(RemoveTrailingWhitespace);
|
|
|
|
|
|
2022-02-27 06:32:00 -03:00
|
|
|
Vector<LineBoxFragment> m_fragments;
|
2024-10-29 08:32:59 -03:00
|
|
|
CSSPixels m_inline_length { 0 };
|
|
|
|
|
CSSPixels m_block_length { 0 };
|
2022-11-04 14:19:11 -03:00
|
|
|
CSSPixels m_bottom { 0 };
|
|
|
|
|
CSSPixels m_baseline { 0 };
|
2024-08-18 13:58:05 -03:00
|
|
|
CSS::Direction m_direction { CSS::Direction::Ltr };
|
2024-10-29 08:32:59 -03:00
|
|
|
CSS::WritingMode m_writing_mode { CSS::WritingMode::HorizontalTb };
|
2023-05-16 04:51:33 -03:00
|
|
|
|
|
|
|
|
// The amount of available width that was originally available when creating this line box. Used for text justification.
|
2023-08-12 13:30:18 -03:00
|
|
|
AvailableSize m_original_available_width { AvailableSize::make_indefinite() };
|
2023-05-16 04:51:33 -03:00
|
|
|
|
2023-03-15 17:11:38 -03:00
|
|
|
bool m_has_break { false };
|
2023-06-10 10:49:17 -03:00
|
|
|
bool m_has_forced_break { false };
|
2019-10-03 10:20:13 -03:00
|
|
|
};
|
2020-03-07 06:27:02 -03:00
|
|
|
|
|
|
|
|
}
|