From 456112a39a5ea33d5902db1e6883887761ef3c01 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Thu, 31 Oct 2024 10:51:46 +0100 Subject: [PATCH] make intrinsic size func public --- src/vaev-layout/layout.cpp | 12 ++++++------ src/vaev-layout/layout.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vaev-layout/layout.cpp b/src/vaev-layout/layout.cpp index d05802e..d80c71f 100644 --- a/src/vaev-layout/layout.cpp +++ b/src/vaev-layout/layout.cpp @@ -99,7 +99,7 @@ static Math::Radii _computeRadii(Tree &tree, Box &box, Vec2Px size) { return res; } -static Vec2Px _computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock) { +Vec2Px computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock) { if (intrinsic == IntrinsicSize::AUTO) { panic("bad argument"); } @@ -121,15 +121,15 @@ static Vec2Px _computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsi static Opt _computeSpecifiedSize(Tree &tree, Box &box, Size size, Vec2Px containingBlock, bool isWidth) { if (size == Size::MIN_CONTENT) { - auto intrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock); + auto intrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock); return isWidth ? intrinsicSize.x : intrinsicSize.y; } else if (size == Size::MAX_CONTENT) { - auto intrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock); + auto intrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock); return isWidth ? intrinsicSize.x : intrinsicSize.y; } else if (size == Size::FIT_CONTENT) { - auto minIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock); - auto maxIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock); - auto stretchIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::STRETCH_TO_FIT, containingBlock); + auto minIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock); + auto maxIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock); + auto stretchIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::STRETCH_TO_FIT, containingBlock); if (isWidth) return clamp(stretchIntrinsicSize.x, minIntrinsicSize.x, maxIntrinsicSize.x); diff --git a/src/vaev-layout/layout.h b/src/vaev-layout/layout.h index 4c5751b..d274638 100644 --- a/src/vaev-layout/layout.h +++ b/src/vaev-layout/layout.h @@ -8,6 +8,8 @@ InsetsPx computeMargins(Tree &tree, Box &box, Input input); InsetsPx computeBorders(Tree &tree, Box &box); +Vec2Px computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock); + Output layout(Tree &tree, Box &box, Input input); } // namespace Vaev::Layout