diff options
author | Andreas Kling <kling@serenityos.org> | 2022-01-18 11:00:25 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-23 01:22:41 +0100 |
commit | 39b2046c427a5be11551cf7f430c8ae542390069 (patch) | |
tree | bede4c109fdcc6ebeb168bc3e1a57e5bb80e8d08 /Userland/Libraries/LibWeb | |
parent | 1f603c54ffe2a613a1e443a5974b6b4c43f0a3af (diff) | |
download | serenity-39b2046c427a5be11551cf7f430c8ae542390069.zip |
LibWeb: Move available_space_for_line() into InlineFormattingContext
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp | 21 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h | 7 |
2 files changed, 15 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index a1cf598434..454f91e732 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -25,23 +25,18 @@ InlineFormattingContext::~InlineFormattingContext() { } -struct AvailableSpaceForLineInfo { - float left { 0 }; - float right { 0 }; -}; - -static AvailableSpaceForLineInfo available_space_for_line(const InlineFormattingContext& context, size_t line_index) +InlineFormattingContext::AvailableSpaceForLineInfo InlineFormattingContext::available_space_for_line(size_t line_index) const { - if (!context.parent()->is_block_formatting_context()) - return { 0, context.context_box().width() }; + if (!parent()->is_block_formatting_context()) + return { 0, context_box().width() }; AvailableSpaceForLineInfo info; // FIXME: This is a total hack guess since we don't actually know the final y position of lines here! - float line_height = context.containing_block().line_height(); + float line_height = containing_block().line_height(); float y = (line_index * line_height); - auto& bfc = static_cast<const BlockFormattingContext&>(*context.parent()); + auto const& bfc = static_cast<BlockFormattingContext const&>(*parent()); for (ssize_t i = bfc.left_floating_boxes().size() - 1; i >= 0; --i) { auto& floating_box = *bfc.left_floating_boxes().at(i); @@ -52,7 +47,7 @@ static AvailableSpaceForLineInfo available_space_for_line(const InlineFormatting } } - info.right = context.containing_block().width(); + info.right = containing_block().width(); for (ssize_t i = bfc.right_floating_boxes().size() - 1; i >= 0; --i) { auto& floating_box = *bfc.right_floating_boxes().at(i); @@ -68,7 +63,7 @@ static AvailableSpaceForLineInfo available_space_for_line(const InlineFormatting float InlineFormattingContext::available_width_at_line(size_t line_index) const { - auto info = available_space_for_line(*this, line_index); + auto info = available_space_for_line(line_index); return info.right - info.left; } @@ -98,7 +93,7 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode) max_height = max(max_height, fragment.height()); } - float x_offset = available_space_for_line(*this, line_index).left; + float x_offset = available_space_for_line(line_index).left; float excess_horizontal_space = (float)containing_block().width() - line_box.width(); diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h index 43fdef047b..c82aa29dbd 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h @@ -28,6 +28,13 @@ public: void dimension_box_on_line(Box&, LayoutMode); private: + struct AvailableSpaceForLineInfo { + float left { 0 }; + float right { 0 }; + }; + + AvailableSpaceForLineInfo available_space_for_line(size_t line_index) const; + void generate_line_boxes(LayoutMode); }; |