Skip to content

Commit

Permalink
Fix a bug with handling infinities in the flex formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
alml committed Jan 2, 2024
1 parent 5307f10 commit eadbd44
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/Core/Layout/FlexFormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ UniquePtr<LayoutBox> FlexFormattingContext::Format(ContainerBox* parent_containe
}

Vector2f FlexFormattingContext::GetMaxContentSize(Element *element) {
RootBox root(Vector2f(FLT_MAX, FLT_MAX));
Vector2f containing_block(FLT_MAX, FLT_MAX);
// A large but finite number is used here, because the flexbox formatting algorithm
// needs to round numbers, and it doesn't support infinities.
Vector2f infinity(10000.0f, 10000.0f);
RootBox root(infinity);
auto flex_container_box = MakeUnique<FlexContainer>(element, &root);

FlexFormattingContext context;
context.flex_container_box = flex_container_box.get();
context.element_flex = element;
context.flex_available_content_size = Vector2f(-1, -1);
context.flex_content_containing_block = Vector2f(-1, -1);
context.flex_max_size = Vector2f(FLT_MAX, FLT_MAX);
context.flex_available_content_size = infinity;
context.flex_content_containing_block = infinity;
context.flex_max_size = infinity;

// Format the flexbox and all its children.
Vector2f flex_resulting_content_size, content_overflow_size;
Expand Down

0 comments on commit eadbd44

Please sign in to comment.