#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LENGTH_UTILS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LENGTH_UTILS_H_
#include <optional>
#include "base/functional/function_ref.h"
#include "third_party/blink/renderer/core/core_export.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/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/geometry/fragment_geometry.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_size.h"
#include "third_party/blink/renderer/core/layout/min_max_sizes.h"
#include "third_party/blink/renderer/core/layout/table/table_node.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h"
namespace blink {
class ComputedStyle;
class ConstraintSpace;
class Length;
enum class SizeType { … };
MinMaxSizesFunctionRef;
BlockSizeFunctionRef;
inline bool NeedMinMaxSize(const ComputedStyle& style) { … }
CORE_EXPORT 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);
enum class LengthTypeInternal { … };
CORE_EXPORT LayoutUnit
ResolveInlineLengthInternal(const ConstraintSpace&,
const ComputedStyle&,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef,
const Length&,
const Length* auto_length,
LengthTypeInternal length_type,
LayoutUnit override_available_size,
CalcSizeKeywordBehavior calc_size_keyword_behavior);
CORE_EXPORT LayoutUnit ResolveBlockLengthInternal(
const ConstraintSpace&,
const ComputedStyle&,
const BoxStrut& border_padding,
const Length&,
const Length* auto_length,
LengthTypeInternal length_type,
LayoutUnit override_available_size,
const LayoutUnit* override_percentage_resolution_size,
BlockSizeFunctionRef block_size_func);
inline LayoutUnit ResolveMinInlineLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func,
const Length& length,
const Length* auto_length = nullptr,
LayoutUnit override_available_size = kIndefiniteSize) { … }
inline LayoutUnit ResolveMaxInlineLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func,
const Length& length,
LayoutUnit override_available_size = kIndefiniteSize) { … }
inline LayoutUnit ResolveMainInlineLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func,
const Length& length,
const Length* auto_length,
LayoutUnit override_available_size = kIndefiniteSize,
CalcSizeKeywordBehavior calc_size_keyword_behavior =
CalcSizeKeywordBehavior::kAsSpecified) { … }
inline LayoutUnit ResolveInitialMinBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& length,
LayoutUnit override_available_size = kIndefiniteSize) { … }
inline LayoutUnit ResolveMinBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
BlockSizeFunctionRef block_size_func,
const Length& length,
const Length* auto_length = nullptr,
LayoutUnit override_available_size = kIndefiniteSize,
const LayoutUnit* override_percentage_resolution_size = nullptr) { … }
inline LayoutUnit ResolveInitialMaxBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& length) { … }
inline LayoutUnit ResolveMaxBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& length,
BlockSizeFunctionRef block_size_func,
LayoutUnit override_available_size = kIndefiniteSize,
const LayoutUnit* override_percentage_resolution_size = nullptr) { … }
inline LayoutUnit ResolveMainBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& length,
const Length* auto_length,
LayoutUnit intrinsic_size,
LayoutUnit override_available_size = kIndefiniteSize,
const LayoutUnit* override_percentage_resolution_size = nullptr) { … }
inline LayoutUnit ResolveMainBlockLength(
const ConstraintSpace& constraint_space,
const ComputedStyle& style,
const BoxStrut& border_padding,
const Length& length,
const Length* auto_length,
BlockSizeFunctionRef block_size_func,
LayoutUnit override_available_size = kIndefiniteSize) { … }
MinMaxSizes ComputeInitialMinMaxBlockSizes(const ConstraintSpace&,
const BlockNode&,
const BoxStrut& border_padding);
MinMaxSizes ComputeMinMaxBlockSizes(
const ConstraintSpace&,
const BlockNode&,
const BoxStrut& border_padding,
const Length* auto_min_length,
BlockSizeFunctionRef,
LayoutUnit override_available_size = kIndefiniteSize);
MinMaxSizes ComputeTransferredMinMaxInlineSizes(
const LogicalSize& ratio,
const MinMaxSizes& block_min_max,
const BoxStrut& border_padding,
const EBoxSizing sizing);
MinMaxSizes ComputeTransferredMinMaxBlockSizes(const LogicalSize& ratio,
const MinMaxSizes& block_min_max,
const BoxStrut& border_padding,
const EBoxSizing sizing);
CORE_EXPORT MinMaxSizes
ComputeMinMaxInlineSizesFromAspectRatio(const ConstraintSpace&,
const BlockNode&,
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 = kIndefiniteSize);
CORE_EXPORT LayoutUnit ComputeBlockSizeForFragment(
const ConstraintSpace&,
const BlockNode&,
const BoxStrut& border_padding,
LayoutUnit intrinsic_size,
LayoutUnit inline_size,
LayoutUnit override_available_size = kIndefiniteSize);
LayoutUnit ComputeInlineSizeForFragmentInternal(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func);
CORE_EXPORT LayoutUnit
ComputeInlineSizeForFragment(const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
MinMaxSizesFunctionRef min_max_sizes_func);
inline LayoutUnit ComputeInlineSizeForFragment(
const ConstraintSpace& space,
const BlockNode& node,
const BoxStrut& border_padding,
const MinMaxSizes* override_min_max_sizes_for_test = nullptr) { … }
CORE_EXPORT LayoutUnit ComputeUsedInlineSizeForTableFragment(
const ConstraintSpace& space,
const BlockNode&,
const BoxStrut& border_padding,
const MinMaxSizes& table_grid_min_max_sizes);
LayoutUnit ComputeInitialBlockSizeForFragment(
const ConstraintSpace&,
const BlockNode&,
const BoxStrut& border_padding,
LayoutUnit intrinsic_size,
LayoutUnit inline_size,
LayoutUnit override_available_size = kIndefiniteSize);
CORE_EXPORT LayoutUnit
CalculateDefaultBlockSize(const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
const BoxStrut& border_scrollbar_padding);
enum class ReplacedSizeMode { … };
CORE_EXPORT LogicalSize
ComputeReplacedSize(const BlockNode&,
const ConstraintSpace&,
const BoxStrut& border_padding,
ReplacedSizeMode = ReplacedSizeMode::kNormal);
CORE_EXPORT int ResolveUsedColumnCount(int computed_count,
LayoutUnit computed_size,
LayoutUnit used_gap,
LayoutUnit available_size);
CORE_EXPORT int ResolveUsedColumnCount(LayoutUnit available_size,
const ComputedStyle&);
CORE_EXPORT LayoutUnit ResolveUsedColumnInlineSize(int computed_count,
LayoutUnit computed_size,
LayoutUnit used_gap,
LayoutUnit available_size);
CORE_EXPORT LayoutUnit ResolveUsedColumnInlineSize(LayoutUnit available_size,
const ComputedStyle&);
CORE_EXPORT LayoutUnit ResolveUsedColumnGap(LayoutUnit available_size,
const ComputedStyle&);
CORE_EXPORT LayoutUnit ColumnInlineProgression(LayoutUnit available_size,
const ComputedStyle&);
CORE_EXPORT PhysicalBoxStrut
ComputePhysicalMargins(const ComputedStyle&,
PhysicalSize percentage_resolution_size);
inline PhysicalBoxStrut ComputePhysicalMargins(
const ComputedStyle& style,
LogicalSize percentage_resolution_size) { … }
inline PhysicalBoxStrut ComputePhysicalMargins(
const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
CORE_EXPORT BoxStrut ComputeMarginsFor(const ConstraintSpace&,
const ComputedStyle&,
const ConstraintSpace& compute_for);
inline BoxStrut ComputeMarginsFor(
const ComputedStyle& style,
LogicalSize percentage_resolution_size,
WritingDirectionMode container_writing_direction) { … }
inline BoxStrut ComputeMarginsFor(
const ComputedStyle& style,
LayoutUnit percentage_resolution_inline_size,
WritingDirectionMode container_writing_direction) { … }
inline BoxStrut ComputeMarginsFor(
const ConstraintSpace& space,
const ComputedStyle& style,
WritingDirectionMode container_writing_direction) { … }
inline BoxStrut ComputeMarginsForSelf(const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
inline LineBoxStrut ComputeLineMarginsForSelf(
const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
inline LineBoxStrut ComputeLineMarginsForVisualContainer(
const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
CORE_EXPORT BoxStrut ComputeBorders(const ConstraintSpace&, const BlockNode&);
CORE_EXPORT BoxStrut ComputeBordersForInline(const ComputedStyle&);
CORE_EXPORT BoxStrut ComputeNonCollapsedTableBorders(const ComputedStyle&);
inline LineBoxStrut ComputeLineBorders(const ComputedStyle& style) { … }
CORE_EXPORT BoxStrut ComputeBordersForTest(const ComputedStyle& style);
CORE_EXPORT BoxStrut ComputePadding(const ConstraintSpace&,
const ComputedStyle&);
inline LineBoxStrut ComputeLinePadding(const ConstraintSpace& constraint_space,
const ComputedStyle& style) { … }
CORE_EXPORT BoxStrut ComputeScrollbarsForNonAnonymous(const BlockNode&);
inline BoxStrut ComputeScrollbars(const ConstraintSpace& space,
const BlockNode& node) { … }
CORE_EXPORT void ResolveInlineAutoMargins(
const ComputedStyle& child_style,
const ComputedStyle& containing_block_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);
CORE_EXPORT LayoutUnit LineOffsetForTextAlign(ETextAlign,
TextDirection,
LayoutUnit space_left);
inline LayoutUnit ConstrainByMinMax(LayoutUnit length,
LayoutUnit min,
LayoutUnit max) { … }
CORE_EXPORT FragmentGeometry
CalculateInitialFragmentGeometry(const ConstraintSpace& space,
const BlockNode& node,
const BlockBreakToken* break_token,
MinMaxSizesFunctionRef min_max_sizes_func,
bool is_intrinsic = false);
CORE_EXPORT FragmentGeometry
CalculateInitialFragmentGeometry(const ConstraintSpace&,
const BlockNode&,
const BlockBreakToken*,
bool is_intrinsic = false);
LogicalSize ShrinkLogicalSize(LogicalSize size, const BoxStrut& insets);
LogicalSize CalculateChildAvailableSize(
const ConstraintSpace&,
const BlockNode& node,
const LogicalSize border_box_size,
const BoxStrut& border_scrollbar_padding);
LogicalSize CalculateChildPercentageSize(
const ConstraintSpace&,
const BlockNode node,
const LogicalSize child_available_size);
LogicalSize CalculateReplacedChildPercentageSize(
const ConstraintSpace&,
const BlockNode node,
const LogicalSize child_available_size,
const BoxStrut& border_scrollbar_padding,
const BoxStrut& border_padding);
LayoutUnit ClampIntrinsicBlockSize(
const ConstraintSpace&,
const BlockNode&,
const BlockBreakToken* break_token,
const BoxStrut& border_scrollbar_padding,
LayoutUnit current_intrinsic_block_size,
std::optional<LayoutUnit> body_margin_block_sum = std::nullopt);
MinMaxSizesResult ComputeMinAndMaxContentContributionInternal(
WritingMode parent_writing_mode,
const BlockNode& child,
const ConstraintSpace& space,
MinMaxSizesFunctionRef min_max_sizes_func);
MinMaxSizesResult ComputeMinAndMaxContentContribution(
const ComputedStyle& parent_style,
const BlockNode& child,
const ConstraintSpace& space,
const MinMaxSizesFloatInput float_input = MinMaxSizesFloatInput());
MinMaxSizesResult ComputeMinAndMaxContentContributionForSelf(
const BlockNode& child,
const ConstraintSpace& space);
inline MinMaxSizesResult ComputeMinAndMaxContentContributionForSelf(
const BlockNode& child,
const ConstraintSpace& space,
MinMaxSizesFunctionRef min_max_sizes_func) { … }
CORE_EXPORT MinMaxSizes
ComputeMinAndMaxContentContributionForTest(WritingMode writing_mode,
const BlockNode&,
const ConstraintSpace&,
const MinMaxSizes&);
std::optional<MinMaxSizesResult> CalculateMinMaxSizesIgnoringChildren(
const BlockNode&,
const BoxStrut& border_scrollbar_padding);
void AddScrollbarFreeze(const BoxStrut& scrollbars_before,
const BoxStrut& scrollbars_after,
WritingDirectionMode,
bool* freeze_horizontal,
bool* freeze_vertical);
}
#endif