LayoutText.cpp 637 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <LibHTML/Layout/LayoutText.h>
  2. #include <ctype.h>
  3. LayoutText::LayoutText(const Text& text)
  4. : LayoutNode(&text)
  5. {
  6. }
  7. LayoutText::~LayoutText()
  8. {
  9. }
  10. static bool is_all_whitespace(const String& string)
  11. {
  12. for (int i = 0; i < string.length(); ++i) {
  13. if (!isspace(string[i]))
  14. return false;
  15. }
  16. return true;
  17. }
  18. const String& LayoutText::text() const
  19. {
  20. static String one_space = " ";
  21. if (is_all_whitespace(node().data()))
  22. return one_space;
  23. return node().data();
  24. }
  25. void LayoutText::compute_runs()
  26. {
  27. }
  28. void LayoutText::layout()
  29. {
  30. ASSERT(!has_children());
  31. compute_runs();
  32. }