mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibHTML: Implement "text-align: justify"
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. :^)
This commit is contained in:
parent
ea5da0f9b5
commit
eb77e680ed
9 changed files with 72 additions and 25 deletions
|
@ -82,7 +82,7 @@ void LayoutNode::set_needs_display()
|
|||
if (auto* block = containing_block()) {
|
||||
block->for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
const_cast<Frame*>(frame)->set_needs_display(fragment.rect());
|
||||
const_cast<Frame*>(frame)->set_needs_display(enclosing_int_rect(fragment.rect()));
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ Point LayoutNode::box_type_agnostic_position() const
|
|||
if (auto* block = containing_block()) {
|
||||
block->for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
position = fragment.rect().location();
|
||||
position = enclosing_int_rect(fragment.rect()).location();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue