2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
2021-09-19 13:16:00 -03:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
2024-10-13 16:29:47 -03:00
|
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
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
|
|
|
*/
|
|
|
|
|
|
2021-08-19 08:20:43 -03:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2020-03-07 06:32:51 -03:00
|
|
|
#include <LibWeb/DOM/Element.h>
|
2020-12-05 16:10:39 -03:00
|
|
|
#include <LibWeb/Layout/InlineFormattingContext.h>
|
2020-11-22 11:53:01 -03:00
|
|
|
#include <LibWeb/Layout/InlineNode.h>
|
2026-01-08 13:17:32 -03:00
|
|
|
#include <LibWeb/Painting/PaintableWithLines.h>
|
2019-10-17 18:09:41 -03:00
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
namespace Web::Layout {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(InlineNode);
|
2024-04-06 14:16:04 -03:00
|
|
|
|
2024-12-20 12:35:12 -03:00
|
|
|
InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, GC::Ref<CSS::ComputedProperties> style)
|
2022-02-23 17:25:35 -03:00
|
|
|
: Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style))
|
2019-10-17 18:09:41 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 16:21:51 -03:00
|
|
|
InlineNode::~InlineNode() = default;
|
2019-10-17 18:09:41 -03:00
|
|
|
|
2026-05-07 08:38:05 -03:00
|
|
|
NonnullRefPtr<Painting::PaintableWithLines> InlineNode::create_paintable_for_line_with_index(size_t line_index) const
|
2020-12-03 15:21:33 -03:00
|
|
|
{
|
2024-10-13 16:29:47 -03:00
|
|
|
for (auto const& paintable : paintables()) {
|
2026-05-07 08:38:05 -03:00
|
|
|
if (is<Painting::PaintableWithLines>(*paintable)) {
|
|
|
|
|
auto const& paintable_with_lines = static_cast<Painting::PaintableWithLines const&>(*paintable);
|
2024-10-13 16:29:47 -03:00
|
|
|
if (paintable_with_lines.line_index() == line_index) {
|
|
|
|
|
return const_cast<Painting::PaintableWithLines&>(paintable_with_lines);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Painting::PaintableWithLines::create(*this, line_index);
|
2021-09-19 13:16:00 -03:00
|
|
|
}
|
|
|
|
|
|
2020-03-07 06:27:02 -03:00
|
|
|
}
|