2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2021-04-17 23:10:10 +02:00
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
#include <LibWeb/Layout/ListItemBox.h>
|
|
|
|
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
2019-10-11 23:16:53 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
namespace Web::Layout {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
ListItemBox::ListItemBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
|
|
|
|
: Layout::BlockBox(document, &element, move(style))
|
2019-10-11 23:16:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
ListItemBox::~ListItemBox()
|
2019-10-11 23:16:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
void ListItemBox::layout_marker()
|
2019-10-11 23:16:53 +02:00
|
|
|
{
|
2020-05-08 22:40:20 +02:00
|
|
|
if (m_marker) {
|
|
|
|
remove_child(*m_marker);
|
|
|
|
m_marker = nullptr;
|
|
|
|
}
|
|
|
|
|
2021-01-06 10:34:31 +01:00
|
|
|
if (computed_values().list_style_type() == CSS::ListStyleType::None)
|
2020-05-30 12:04:15 +02:00
|
|
|
return;
|
|
|
|
|
2019-10-11 23:16:53 +02:00
|
|
|
if (!m_marker) {
|
2021-04-17 23:10:10 +02:00
|
|
|
int child_index = parent()->index_of_child<ListItemBox>(*this).value();
|
|
|
|
m_marker = adopt(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1));
|
2019-10-11 23:25:45 +02:00
|
|
|
if (first_child())
|
|
|
|
m_marker->set_inline(first_child()->is_inline());
|
|
|
|
append_child(*m_marker);
|
2019-10-11 23:16:53 +02:00
|
|
|
}
|
|
|
|
|
2020-06-10 10:42:29 +02:00
|
|
|
m_marker->set_offset(-8, 0);
|
2021-04-17 00:03:17 +02:00
|
|
|
m_marker->set_size(4, line_height());
|
2019-10-11 23:16:53 +02:00
|
|
|
}
|
2020-03-07 10:27:02 +01:00
|
|
|
|
|
|
|
}
|