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