#include "third_party/blink/renderer/core/layout/length_utils.h"
#include <algorithm>
#include <optional>
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/layout/block_node.h"
#include "third_party/blink/renderer/core/layout/constraint_space.h"
#include "third_party/blink/renderer/core/layout/constraint_space_builder.h"
#include "third_party/blink/renderer/core/layout/fragmentation_utils.h"
#include "third_party/blink/renderer/core/layout/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/space_utils.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/geometry/length.h"
#include "third_party/blink/renderer/platform/geometry/length_functions.h"
namespace blink {
LayoutUnit ResolveInlineLengthInternal(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func,
const Length& original_length,
const Length* auto_length,
LengthTypeInternal length_type,
LayoutUnit override_available_size,
CalcSizeKeywordBehavior calc_size_keyword_behavior) { … }
LayoutUnit ResolveBlockLengthInternal(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& original_length,
const Length* auto_length,
LengthTypeInternal length_type,
LayoutUnit override_available_size,
const LayoutUnit* override_percentage_resolution_size,
BlockSizeFunctionRef block_size_func) { … }
LayoutUnit InlineSizeFromAspectRatio(const BoxStrut& border_padding,
const LogicalSize& aspect_ratio,
EBoxSizing box_sizing,
LayoutUnit block_size) { … }
LayoutUnit BlockSizeFromAspectRatio(const BoxStrut& border_padding,
const LogicalSize& aspect_ratio,
EBoxSizing box_sizing,
LayoutUnit inline_size) { … }
namespace {
MinMaxSizesResult ComputeMinAndMaxContentContributionForReplaced(
const BlockNode& child,
const ConstraintSpace& space) { … }
}
MinMaxSizesResult ComputeMinAndMaxContentContributionInternal(
WritingMode parent_writing_mode,
const BlockNode& child,
const ConstraintSpace& space,
MinMaxSizesFunctionRef original_min_max_sizes_func) { … }
MinMaxSizesResult ComputeMinAndMaxContentContribution(
const ComputedStyle& parent_style,
const BlockNode& child,
const ConstraintSpace& space,
const MinMaxSizesFloatInput float_input) { … }
MinMaxSizesResult ComputeMinAndMaxContentContributionForSelf(
const BlockNode& child,
const ConstraintSpace& space) { … }
MinMaxSizes ComputeMinAndMaxContentContributionForTest(
WritingMode parent_writing_mode,
const BlockNode& child,
const ConstraintSpace& space,
const MinMaxSizes& min_max_sizes) { … }
LayoutUnit ComputeInlineSizeForFragmentInternal(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func) { … }
LayoutUnit ComputeInlineSizeForFragment(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func) { … }
LayoutUnit ComputeUsedInlineSizeForTableFragment(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
const MinMaxSizes& table_grid_min_max_sizes) { … }
MinMaxSizes ComputeInitialMinMaxBlockSizes(const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding) { … }
MinMaxSizes ComputeMinMaxBlockSizes(const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
const Length* auto_min_length,
BlockSizeFunctionRef block_size_func,
LayoutUnit override_available_size) { … }
MinMaxSizes ComputeTransferredMinMaxInlineSizes(
const LogicalSize& ratio,
const MinMaxSizes& block_min_max,
const BoxStrut& border_padding,
const EBoxSizing sizing) { … }
MinMaxSizes ComputeTransferredMinMaxBlockSizes(
const LogicalSize& ratio,
const MinMaxSizes& inline_min_max,
const BoxStrut& border_padding,
const EBoxSizing sizing) { … }
MinMaxSizes ComputeMinMaxInlineSizesFromAspectRatio(
const ConstraintSpace& constraint_space,
const BlockNode& node,
const BoxStrut& border_padding) { … }
MinMaxSizes ComputeMinMaxInlineSizes(const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
const Length* auto_min_length,
MinMaxSizesFunctionRef min_max_sizes_func,
LayoutUnit override_available_size) { … }
namespace {
LayoutUnit ComputeBlockSizeForFragmentInternal(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
LayoutUnit intrinsic_size,
LayoutUnit inline_size,
LayoutUnit override_available_size = kIndefiniteSize) { … }
}
LayoutUnit ComputeBlockSizeForFragment(const ConstraintSpace& constraint_space,
const BlockNode& node,
const BoxStrut& border_padding,
LayoutUnit intrinsic_size,
LayoutUnit inline_size,
LayoutUnit override_available_size) { … }
LayoutUnit ComputeInitialBlockSizeForFragment(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
LayoutUnit intrinsic_size,
LayoutUnit inline_size,
LayoutUnit override_available_size) { … }
namespace {
LogicalSize ComputeDefaultNaturalSize(const BlockNode& node) { … }
std::optional<LogicalSize> ComputeNormalizedNaturalSize(
const BlockNode& node,
const BoxStrut& border_padding,
const EBoxSizing box_sizing,
const LogicalSize& aspect_ratio) { … }
LogicalSize ComputeReplacedSizeInternal(const BlockNode& node,
const ConstraintSpace& space,
const BoxStrut& border_padding,
ReplacedSizeMode mode) { … }
}
LogicalSize ComputeReplacedSize(const BlockNode& node,
const ConstraintSpace& space,
const BoxStrut& border_padding,
ReplacedSizeMode mode) { … }
int ResolveUsedColumnCount(int computed_count,
LayoutUnit computed_size,
LayoutUnit used_gap,
LayoutUnit available_size) { … }
int ResolveUsedColumnCount(LayoutUnit available_size,
const ComputedStyle& style) { … }
LayoutUnit ResolveUsedColumnInlineSize(int computed_count,
LayoutUnit computed_size,
LayoutUnit used_gap,
LayoutUnit available_size) { … }
LayoutUnit ResolveUsedColumnInlineSize(LayoutUnit available_size,
const ComputedStyle& style) { … }
LayoutUnit ResolveUsedColumnGap(LayoutUnit available_size,
const ComputedStyle& style) { … }
LayoutUnit ColumnInlineProgression(LayoutUnit available_size,
const ComputedStyle& style) { … }
PhysicalBoxStrut ComputePhysicalMargins(
const ComputedStyle& style,
PhysicalSize percentage_resolution_size) { … }
BoxStrut ComputeMarginsFor(const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const ConstraintSpace& compute_for) { … }
namespace {
BoxStrut ComputeBordersInternal(const ComputedStyle& style) { … }
}
BoxStrut ComputeBorders(const ConstraintSpace& constraint_space,
const BlockNode& node) { … }
BoxStrut ComputeBordersForInline(const ComputedStyle& style) { … }
BoxStrut ComputeNonCollapsedTableBorders(const ComputedStyle& style) { … }
BoxStrut ComputeBordersForTest(const ComputedStyle& style) { … }
BoxStrut ComputePadding(const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
BoxStrut ComputeScrollbarsForNonAnonymous(const BlockNode& node) { … }
void ResolveInlineAutoMargins(const ComputedStyle& style,
const ComputedStyle& container_style,
LayoutUnit available_inline_size,
LayoutUnit inline_size,
BoxStrut* margins) { … }
void ResolveAutoMargins(Length start_length,
Length end_length,
LayoutUnit additional_space,
LayoutUnit* start_result,
LayoutUnit* end_result) { … }
void ResolveAutoMargins(Length inline_start_length,
Length inline_end_length,
Length block_start_length,
Length block_end_length,
LayoutUnit additional_inline_space,
LayoutUnit additional_block_space,
BoxStrut* margins) { … }
LayoutUnit LineOffsetForTextAlign(ETextAlign text_align,
TextDirection direction,
LayoutUnit space_left) { … }
LayoutUnit CalculateDefaultBlockSize(const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
const BoxStrut& border_scrollbar_padding) { … }
FragmentGeometry CalculateInitialFragmentGeometry(
const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
MinMaxSizesFunctionRef min_max_sizes_func,
bool is_intrinsic) { … }
FragmentGeometry CalculateInitialFragmentGeometry(
const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
bool is_intrinsic) { … }
LogicalSize ShrinkLogicalSize(LogicalSize size, const BoxStrut& insets) { … }
LogicalSize CalculateChildAvailableSize(
const ConstraintSpace& space,
const BlockNode& node,
const LogicalSize border_box_size,
const BoxStrut& border_scrollbar_padding) { … }
namespace {
LogicalSize AdjustChildPercentageSize(const ConstraintSpace& space,
const BlockNode node,
LogicalSize child_percentage_size,
LayoutUnit parent_percentage_block_size) { … }
}
LogicalSize CalculateChildPercentageSize(
const ConstraintSpace& space,
const BlockNode node,
const LogicalSize child_available_size) { … }
LogicalSize CalculateReplacedChildPercentageSize(
const ConstraintSpace& space,
const BlockNode node,
const LogicalSize child_available_size,
const BoxStrut& border_scrollbar_padding,
const BoxStrut& border_padding) { … }
LayoutUnit ClampIntrinsicBlockSize(
const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
const BoxStrut& border_scrollbar_padding,
LayoutUnit current_intrinsic_block_size,
std::optional<LayoutUnit> body_margin_block_sum) { … }
std::optional<MinMaxSizesResult> CalculateMinMaxSizesIgnoringChildren(
const BlockNode& node,
const BoxStrut& border_scrollbar_padding) { … }
void AddScrollbarFreeze(const BoxStrut& scrollbars_before,
const BoxStrut& scrollbars_after,
WritingDirectionMode writing_direction,
bool* freeze_horizontal,
bool* freeze_vertical) { … }
}