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
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
#include <LibGC/Ptr.h>
|
2020-09-18 04:49:51 -03:00
|
|
|
#include <LibGfx/Rect.h>
|
2023-12-02 14:38:05 -03:00
|
|
|
#include <LibGfx/TextLayout.h>
|
2025-07-25 11:05:24 -03:00
|
|
|
#include <LibWeb/CSS/Enums.h>
|
2022-10-31 16:46:55 -03:00
|
|
|
#include <LibWeb/PixelUnits.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
|
|
|
|
2022-02-27 06:26:38 -03:00
|
|
|
class LineBoxFragment {
|
2019-10-03 10:20:13 -03:00
|
|
|
friend class LineBox;
|
2020-06-10 05:42:29 -03:00
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
public:
|
2025-06-11 04:07:16 -03:00
|
|
|
LineBoxFragment(Node const& layout_node, size_t start, size_t length, CSSPixels inline_offset, CSSPixels block_offset, CSSPixels inline_length, CSSPixels block_length, CSSPixels border_box_top, CSS::Direction, CSS::WritingMode, RefPtr<Gfx::GlyphRun>);
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2022-02-20 11:51:24 -03:00
|
|
|
Node const& layout_node() const { return m_layout_node; }
|
2025-06-11 04:07:16 -03:00
|
|
|
size_t start() const { return m_start; }
|
2025-09-12 05:06:27 -03:00
|
|
|
size_t length_in_code_units() const { return m_length_in_code_units; }
|
2020-06-10 05:42:29 -03:00
|
|
|
|
2024-10-29 08:32:59 -03:00
|
|
|
CSSPixelPoint offset() const;
|
|
|
|
|
CSSPixels inline_offset() const { return m_inline_offset; }
|
|
|
|
|
CSSPixels block_offset() const { return m_block_offset; }
|
|
|
|
|
void set_inline_offset(CSSPixels inline_offset) { m_inline_offset = inline_offset; }
|
|
|
|
|
void set_block_offset(CSSPixels block_offset) { m_block_offset = block_offset; }
|
2020-06-10 05:42:29 -03:00
|
|
|
|
2022-03-28 16:05:51 -03:00
|
|
|
// The baseline of a fragment is the number of pixels from the top to the text baseline.
|
2022-10-31 16:46:55 -03:00
|
|
|
void set_baseline(CSSPixels y) { m_baseline = y; }
|
|
|
|
|
CSSPixels baseline() const { return m_baseline; }
|
2022-03-28 16:05:51 -03:00
|
|
|
|
2024-10-29 08:32:59 -03:00
|
|
|
CSSPixelSize size() const;
|
|
|
|
|
CSSPixels width() const { return size().width(); }
|
|
|
|
|
CSSPixels height() const { return size().height(); }
|
|
|
|
|
CSSPixels inline_length() const { return m_inline_length; }
|
|
|
|
|
CSSPixels block_length() const { return m_block_length; }
|
|
|
|
|
void set_inline_length(CSSPixels inline_length) { m_inline_length = inline_length; }
|
|
|
|
|
void set_block_length(CSSPixels block_length) { m_block_length = block_length; }
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2022-10-31 16:46:55 -03:00
|
|
|
CSSPixels border_box_top() const { return m_border_box_top; }
|
2019-10-20 12:18:28 -03:00
|
|
|
|
2020-06-13 09:59:17 -03:00
|
|
|
bool ends_in_whitespace() const;
|
2019-10-20 07:30:25 -03:00
|
|
|
bool is_justifiable_whitespace() const;
|
2025-07-25 10:34:41 -03:00
|
|
|
Utf16View text() const;
|
2019-10-20 07:30:25 -03:00
|
|
|
|
2023-03-14 06:28:01 -03:00
|
|
|
bool is_atomic_inline() const;
|
|
|
|
|
|
2024-06-29 12:14:23 -03:00
|
|
|
RefPtr<Gfx::GlyphRun> glyph_run() const { return m_glyph_run; }
|
2024-10-29 11:29:00 -03:00
|
|
|
CSS::WritingMode writing_mode() const { return m_writing_mode; }
|
2024-08-18 13:58:05 -03:00
|
|
|
void append_glyph_run(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width);
|
2023-12-02 14:38:05 -03:00
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
private:
|
2024-08-18 13:58:05 -03:00
|
|
|
CSS::Direction resolve_glyph_run_direction(Gfx::GlyphRun::TextType) const;
|
|
|
|
|
void append_glyph_run_ltr(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width);
|
|
|
|
|
void append_glyph_run_rtl(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width);
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<Node const> m_layout_node;
|
2025-06-11 04:07:16 -03:00
|
|
|
size_t m_start { 0 };
|
2025-09-12 05:06:27 -03:00
|
|
|
size_t m_length_in_code_units { 0 };
|
2024-10-29 08:32:59 -03:00
|
|
|
CSSPixels m_inline_offset;
|
|
|
|
|
CSSPixels m_block_offset;
|
|
|
|
|
CSSPixels m_inline_length;
|
|
|
|
|
CSSPixels m_block_length;
|
2022-10-31 16:46:55 -03:00
|
|
|
CSSPixels m_border_box_top { 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 };
|
2024-08-18 13:58:05 -03:00
|
|
|
|
2024-06-29 12:14:23 -03:00
|
|
|
RefPtr<Gfx::GlyphRun> m_glyph_run;
|
2024-08-18 13:58:05 -03:00
|
|
|
float m_insert_position { 0 };
|
|
|
|
|
CSS::Direction m_current_insert_direction { CSS::Direction::Ltr };
|
2019-10-03 10:20:13 -03:00
|
|
|
};
|
2020-03-07 06:27:02 -03:00
|
|
|
|
|
|
|
|
}
|