LineBoxFragment.cpp 768 B

12345678910111213141516171819202122232425262728
  1. #include <LibGUI/GPainter.h>
  2. #include <LibHTML/Layout/LayoutText.h>
  3. #include <LibHTML/Layout/LineBoxFragment.h>
  4. #include <LibHTML/RenderingContext.h>
  5. void LineBoxFragment::render(RenderingContext& context)
  6. {
  7. for (auto* ancestor = layout_node().parent(); ancestor; ancestor = ancestor->parent()) {
  8. if (!ancestor->is_visible())
  9. return;
  10. }
  11. if (is<LayoutText>(layout_node())) {
  12. to<LayoutText>(layout_node()).render_fragment(context, *this);
  13. }
  14. }
  15. bool LineBoxFragment::is_justifiable_whitespace() const
  16. {
  17. return text() == " ";
  18. }
  19. StringView LineBoxFragment::text() const
  20. {
  21. if (!is<LayoutText>(layout_node()))
  22. return {};
  23. return to<LayoutText>(layout_node()).node().data().substring_view(m_start, m_length);
  24. }