Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/Vector.h>
10#include <LibWeb/Layout/LineBoxFragment.h>
11
12namespace Web::Layout {
13
14class LineBox {
15public:
16 LineBox() = default;
17
18 CSSPixels width() const { return m_width; }
19 CSSPixels height() const { return m_height; }
20 CSSPixels bottom() const { return m_bottom; }
21 CSSPixels baseline() const { return m_baseline; }
22
23 void add_fragment(Node const& layout_node, int start, int 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, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
24
25 Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
26 Vector<LineBoxFragment>& fragments() { return m_fragments; }
27
28 void trim_trailing_whitespace();
29
30 bool is_empty_or_ends_in_whitespace() const;
31 bool is_empty() const { return m_fragments.is_empty(); }
32
33private:
34 friend class BlockContainer;
35 friend class InlineFormattingContext;
36 friend class LineBuilder;
37
38 Vector<LineBoxFragment> m_fragments;
39 CSSPixels m_width { 0 };
40 CSSPixels m_height { 0 };
41 CSSPixels m_bottom { 0 };
42 CSSPixels m_baseline { 0 };
43};
44
45}