InlineNode.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
  3. * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
  4. * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/DOM/Element.h>
  10. #include <LibWeb/Layout/BlockContainer.h>
  11. #include <LibWeb/Layout/InlineFormattingContext.h>
  12. #include <LibWeb/Layout/InlineNode.h>
  13. namespace Web::Layout {
  14. JS_DEFINE_ALLOCATOR(InlineNode);
  15. InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, CSS::StyleProperties style)
  16. : Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style))
  17. {
  18. }
  19. InlineNode::~InlineNode() = default;
  20. JS::GCPtr<Painting::PaintableWithLines> InlineNode::create_paintable_for_line_with_index(size_t line_index) const
  21. {
  22. for (auto const& paintable : paintables()) {
  23. if (is<Painting::PaintableWithLines>(paintable)) {
  24. auto const& paintable_with_lines = static_cast<Painting::PaintableWithLines const&>(paintable);
  25. if (paintable_with_lines.line_index() == line_index) {
  26. return const_cast<Painting::PaintableWithLines&>(paintable_with_lines);
  27. }
  28. }
  29. }
  30. return Painting::PaintableWithLines::create(*this, line_index);
  31. }
  32. }