2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2023-01-11 15:48:53 -03:00
|
|
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.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
|
|
|
*/
|
|
|
|
|
|
2020-02-14 20:27:50 -03:00
|
|
|
#include <AK/Utf8View.h>
|
2023-01-11 15:48:53 -03:00
|
|
|
#include <LibWeb/DOM/Range.h>
|
2022-07-16 18:30:32 -03:00
|
|
|
#include <LibWeb/Layout/LayoutState.h>
|
2023-02-25 07:04:29 -03:00
|
|
|
#include <LibWeb/Layout/Viewport.h>
|
2020-06-13 09:59:17 -03:00
|
|
|
#include <ctype.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
|
|
|
|
2020-06-13 09:59:17 -03:00
|
|
|
bool LineBoxFragment::ends_in_whitespace() const
|
|
|
|
|
{
|
|
|
|
|
auto text = this->text();
|
|
|
|
|
if (text.is_empty())
|
|
|
|
|
return false;
|
|
|
|
|
return isspace(text[text.length() - 1]);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 07:30:25 -03:00
|
|
|
bool LineBoxFragment::is_justifiable_whitespace() const
|
2019-10-20 12:18:28 -03:00
|
|
|
{
|
|
|
|
|
return text() == " ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringView LineBoxFragment::text() const
|
2019-10-20 07:30:25 -03:00
|
|
|
{
|
2020-11-22 11:53:01 -03:00
|
|
|
if (!is<TextNode>(layout_node()))
|
2019-10-20 12:18:28 -03:00
|
|
|
return {};
|
2023-11-20 18:56:29 -03:00
|
|
|
return verify_cast<TextNode>(layout_node()).text_for_rendering().bytes_as_string_view().substring_view(m_start, m_length);
|
2019-10-20 07:30:25 -03:00
|
|
|
}
|
2019-11-05 18:13:26 -03:00
|
|
|
|
2022-10-31 16:46:55 -03:00
|
|
|
CSSPixelRect const LineBoxFragment::absolute_rect() const
|
2020-06-10 05:42:29 -03:00
|
|
|
{
|
2022-10-31 16:46:55 -03:00
|
|
|
CSSPixelRect rect { {}, size() };
|
2023-04-20 12:00:42 -03:00
|
|
|
rect.set_location(m_layout_node->containing_block()->paintable_box()->absolute_position());
|
2021-04-12 15:47:09 -03:00
|
|
|
rect.translate_by(offset());
|
2020-06-10 05:42:29 -03:00
|
|
|
return rect;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 06:28:01 -03:00
|
|
|
bool LineBoxFragment::is_atomic_inline() const
|
|
|
|
|
{
|
|
|
|
|
return layout_node().is_replaced_box() || (layout_node().display().is_inline_outside() && !layout_node().display().is_flow_inside());
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-07 06:27:02 -03:00
|
|
|
}
|