mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 03:09:08 +00:00
In order for this to work nicely, I made the line box classes use float instead of int for its geometry information. Justification works by distributing all of the whitespace on the line (including the trailing whitespace before the line break) evenly across the spaces in-between words. We should probably use floating point (or maybe fixed point?) for all the layout metrics stuff. But one thing at a time. :^)
35 lines
818 B
C++
35 lines
818 B
C++
#pragma once
|
|
|
|
#include <LibDraw/FloatRect.h>
|
|
|
|
class LayoutNode;
|
|
class RenderingContext;
|
|
|
|
class LineBoxFragment {
|
|
friend class LineBox;
|
|
public:
|
|
LineBoxFragment(const LayoutNode& layout_node, int start, int length, const FloatRect& rect)
|
|
: m_layout_node(layout_node)
|
|
, m_start(start)
|
|
, m_length(length)
|
|
, m_rect(rect)
|
|
{
|
|
}
|
|
|
|
const LayoutNode& layout_node() const { return m_layout_node; }
|
|
int start() const { return m_start; }
|
|
int length() const { return m_length; }
|
|
const FloatRect& rect() const { return m_rect; }
|
|
FloatRect& rect() { return m_rect; }
|
|
|
|
void render(RenderingContext&);
|
|
|
|
bool is_justifiable_whitespace() const;
|
|
|
|
private:
|
|
const LayoutNode& m_layout_node;
|
|
int m_start { 0 };
|
|
int m_length { 0 };
|
|
FloatRect m_rect;
|
|
};
|