mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 17:48:12 +00:00
LibHTML: LayoutText should always use parent's style properties
This patch makes StyleProperties heap-allocated and ref-counted so that a LayoutNode can be without one. The ref-counting also allows anonymous blocks to share style with their parent block. LayoutText never needs a StyleProperties, since text always inherits style from its parent element. This is handled by style_properties().
This commit is contained in:
parent
79d8b9ae75
commit
4e35bbffdd
14 changed files with 45 additions and 39 deletions
|
@ -7,8 +7,8 @@
|
|||
#include <LibHTML/Layout/LayoutText.h>
|
||||
#include <ctype.h>
|
||||
|
||||
LayoutText::LayoutText(const Text& text, StyleProperties&& style_properties)
|
||||
: LayoutInline(text, move(style_properties))
|
||||
LayoutText::LayoutText(const Text& text)
|
||||
: LayoutInline(text, {})
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -78,12 +78,13 @@ static bool is_all_whitespace(const String& string)
|
|||
return true;
|
||||
}
|
||||
|
||||
const String& LayoutText::text() const
|
||||
const String& LayoutText::text_for_style(const StyleProperties& style_properties) const
|
||||
{
|
||||
static String one_space = " ";
|
||||
if (is_all_whitespace(node().data()))
|
||||
if (style_properties().string_or_fallback("white-space", "normal") == "normal")
|
||||
if (is_all_whitespace(node().data())) {
|
||||
if (style_properties.string_or_fallback("white-space", "normal") == "normal")
|
||||
return one_space;
|
||||
}
|
||||
return node().data();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue