mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibWeb: Use the cached text-align value in LineBox::add_fragment()
This commit is contained in:
parent
f4ecb5362f
commit
26eef65017
2 changed files with 9 additions and 1 deletions
|
@ -191,6 +191,7 @@ public:
|
||||||
|
|
||||||
const StyleProperties& style() const;
|
const StyleProperties& style() const;
|
||||||
CSS::Position position() const;
|
CSS::Position position() const;
|
||||||
|
CSS::TextAlign text_align() const;
|
||||||
|
|
||||||
LayoutNodeWithStyle* parent();
|
LayoutNodeWithStyle* parent();
|
||||||
const LayoutNodeWithStyle* parent() const;
|
const LayoutNodeWithStyle* parent() const;
|
||||||
|
@ -299,6 +300,13 @@ inline CSS::Position LayoutNode::position() const
|
||||||
return parent()->position();
|
return parent()->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CSS::TextAlign LayoutNode::text_align() const
|
||||||
|
{
|
||||||
|
if (m_has_style)
|
||||||
|
return static_cast<const LayoutNodeWithStyle*>(this)->text_align();
|
||||||
|
return parent()->text_align();
|
||||||
|
}
|
||||||
|
|
||||||
inline const LayoutNodeWithStyle* LayoutNode::parent() const
|
inline const LayoutNodeWithStyle* LayoutNode::parent() const
|
||||||
{
|
{
|
||||||
return static_cast<const LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent());
|
return static_cast<const LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent());
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Web {
|
||||||
|
|
||||||
void LineBox::add_fragment(const LayoutNode& layout_node, int start, int length, int width, int height)
|
void LineBox::add_fragment(const LayoutNode& layout_node, int start, int length, int width, int height)
|
||||||
{
|
{
|
||||||
bool text_align_is_justify = layout_node.style().string_or_fallback(CSS::PropertyID::TextAlign, "left") == "justify";
|
bool text_align_is_justify = layout_node.text_align() == CSS::TextAlign::Justify;
|
||||||
if (!text_align_is_justify && !m_fragments.is_empty() && &m_fragments.last().layout_node() == &layout_node) {
|
if (!text_align_is_justify && !m_fragments.is_empty() && &m_fragments.last().layout_node() == &layout_node) {
|
||||||
// The fragment we're adding is from the last LayoutNode on the line.
|
// The fragment we're adding is from the last LayoutNode on the line.
|
||||||
// Expand the last fragment instead of adding a new one with the same LayoutNode.
|
// Expand the last fragment instead of adding a new one with the same LayoutNode.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue