2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
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:
|
2022-03-14 16:21:51 -03:00
|
|
|
LineBox() = default;
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2019-10-20 07:30:25 -03:00
|
|
|
float width() const { return m_width; }
|
2022-03-24 18:45:51 -03:00
|
|
|
float height() const { return m_height; }
|
2022-02-27 09:34:34 -03:00
|
|
|
float bottom() const { return m_bottom; }
|
2022-03-03 06:09:10 -03:00
|
|
|
float baseline() const { return m_baseline; }
|
2019-10-03 10:20:13 -03:00
|
|
|
|
2022-03-09 14:46:07 -03:00
|
|
|
void add_fragment(Node const& layout_node, int start, int length, float leading_size, float trailing_size, float leading_margin, float trailing_margin, float content_width, float content_height, float border_box_top, float border_box_bottom, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
|
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
|
|
|
|
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;
|
2022-01-22 06:32:49 -03:00
|
|
|
bool is_empty() const { return m_fragments.is_empty(); }
|
2020-06-13 09:59:17 -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;
|
|
|
|
|
|
2022-02-27 06:32:00 -03:00
|
|
|
Vector<LineBoxFragment> m_fragments;
|
2019-10-20 07:30:25 -03:00
|
|
|
float m_width { 0 };
|
2022-03-24 18:45:51 -03:00
|
|
|
float m_height { 0 };
|
2022-02-27 09:34:34 -03:00
|
|
|
float m_bottom { 0 };
|
2022-03-03 06:09:10 -03:00
|
|
|
float m_baseline { 0 };
|
2019-10-03 10:20:13 -03:00
|
|
|
};
|
2020-03-07 06:27:02 -03:00
|
|
|
|
|
|
|
|
}
|