ladybird/Libraries/LibHTML/Layout/LayoutText.cpp
Sergey Bugaev fd0aa5dd43 LibHTML: Get rid of the style tree
We now create a layout tree directly from the DOM tree.
This way we don't actually lose text nodes ^)
2019-09-28 18:29:42 +02:00

38 lines
696 B
C++

#include <LibHTML/Layout/LayoutText.h>
#include <ctype.h>
LayoutText::LayoutText(const Text& text, StyleProperties&& style_properties)
: LayoutNode(&text, move(style_properties))
{
}
LayoutText::~LayoutText()
{
}
static bool is_all_whitespace(const String& string)
{
for (int i = 0; i < string.length(); ++i) {
if (!isspace(string[i]))
return false;
}
return true;
}
const String& LayoutText::text() const
{
static String one_space = " ";
if (is_all_whitespace(node().data()))
return one_space;
return node().data();
}
void LayoutText::compute_runs()
{
}
void LayoutText::layout()
{
ASSERT(!has_children());
compute_runs();
}