mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Create "empty" line box fragments for inline elements
In order for inline elements (e.g <span>) to contribute padding etc. to line boxes, we now create special "leading" and "trailing" fragments for Layout::InlineNode and size them according to the horizontal padding values. The height of these fragments is taken from the tallest fragment on the line. (Perhaps we should stop having per-fragment heights and just keep a single height per line box, but that's a separate issue.) In order to make things look nice, we now also adjust the height of all fragments on a line so that nobody is shorter than the CSS line-height.
This commit is contained in:
parent
311e1039b5
commit
d59ec3ab85
7 changed files with 56 additions and 4 deletions
|
@ -37,12 +37,19 @@ class LineBoxFragment : public Weakable<LineBoxFragment> {
|
|||
friend class LineBox;
|
||||
|
||||
public:
|
||||
LineBoxFragment(const Node& layout_node, int start, int length, const Gfx::FloatPoint& offset, const Gfx::FloatSize& size)
|
||||
enum class Type {
|
||||
Normal,
|
||||
Leading,
|
||||
Trailing,
|
||||
};
|
||||
|
||||
LineBoxFragment(const Node& layout_node, int start, int length, const Gfx::FloatPoint& offset, const Gfx::FloatSize& size, Type type)
|
||||
: m_layout_node(layout_node)
|
||||
, m_start(start)
|
||||
, m_length(length)
|
||||
, m_offset(offset)
|
||||
, m_size(size)
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -50,12 +57,14 @@ public:
|
|||
int start() const { return m_start; }
|
||||
int length() const { return m_length; }
|
||||
const Gfx::FloatRect absolute_rect() const;
|
||||
Type type() const { return m_type; }
|
||||
|
||||
const Gfx::FloatPoint& offset() const { return m_offset; }
|
||||
void set_offset(const Gfx::FloatPoint& offset) { m_offset = offset; }
|
||||
|
||||
const Gfx::FloatSize& size() const { return m_size; }
|
||||
void set_width(float width) { m_size.set_width(width); }
|
||||
void set_height(float height) { m_size.set_height(height); }
|
||||
float width() const { return m_size.width(); }
|
||||
float height() const { return m_size.height(); }
|
||||
|
||||
|
@ -77,6 +86,7 @@ private:
|
|||
int m_length { 0 };
|
||||
Gfx::FloatPoint m_offset;
|
||||
Gfx::FloatSize m_size;
|
||||
Type m_type { Type::Normal };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue