From 329f06d59a8713b644fad120460b6509be09ac53 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 24 Mar 2022 17:37:24 +0100 Subject: LibWeb: Add Layout::Node::line_height() This allows you to call line_height() on any layout node, even if it's a text node (in which case we'll ask the parent node for its line-height.) --- Userland/Libraries/LibWeb/Layout/Node.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Userland/Libraries/LibWeb') diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 95910180e4..0c7bccfbab 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -108,6 +108,7 @@ public: const Gfx::Font& font() const; const CSS::ImmutableComputedValues& computed_values() const; + float line_height() const; NodeWithStyle* parent(); const NodeWithStyle* parent() const; @@ -227,6 +228,13 @@ inline const CSS::ImmutableComputedValues& Node::computed_values() const return parent()->computed_values(); } +inline float Node::line_height() const +{ + if (m_has_style) + return static_cast(this)->line_height(); + return parent()->line_height(); +} + inline const NodeWithStyle* Node::parent() const { return static_cast(TreeNode::parent()); -- cgit v1.2.3