mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
LibGfx: Remove aligned_within from Rect
The CenterRight and TopCenter alignment cases were mistakenly identical due to a copy-paste error, causing the function to behave unexpectedly. Rather than attempting to fix it, remove aligned_within entirely.
This commit is contained in:
parent
4c6cb13f7f
commit
116e7baead
Notes:
github-actions[bot]
2024-12-08 13:33:00 +00:00
Author: https://github.com/shlyakpavel
Commit: 116e7baead
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2829
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 0 additions and 42 deletions
|
@ -606,48 +606,6 @@ public:
|
|||
return rect;
|
||||
}
|
||||
|
||||
[[nodiscard]] Rect<T> aligned_within(Size<T> const& rect_size, Point<T> const& align_at, TextAlignment alignment = TextAlignment::Center) const
|
||||
{
|
||||
if (rect_size.is_empty())
|
||||
return {};
|
||||
if (!size().contains(rect_size))
|
||||
return {};
|
||||
if (!contains(align_at))
|
||||
return {};
|
||||
|
||||
Rect<T> rect;
|
||||
switch (alignment) {
|
||||
case TextAlignment::TopCenter:
|
||||
rect = { { align_at.x() - rect_size.width() / 2, align_at.y() }, rect_size };
|
||||
break;
|
||||
case TextAlignment::TopLeft:
|
||||
rect = { align_at, rect_size };
|
||||
break;
|
||||
case TextAlignment::TopRight:
|
||||
rect = { { align_at.x() - rect_size.width(), align_at.y() }, rect_size };
|
||||
break;
|
||||
case TextAlignment::CenterLeft:
|
||||
rect = { { align_at.x(), align_at.y() - rect_size.height() / 2 }, rect_size };
|
||||
break;
|
||||
case TextAlignment::Center:
|
||||
rect = { { align_at.x() - rect_size.width() / 2, align_at.y() - rect_size.height() / 2 }, rect_size };
|
||||
break;
|
||||
case TextAlignment::CenterRight:
|
||||
rect = { { align_at.x() - rect_size.width() / 2, align_at.y() }, rect_size };
|
||||
break;
|
||||
case TextAlignment::BottomCenter:
|
||||
rect = { { align_at.x() - rect_size.width() / 2, align_at.y() - rect_size.width() }, rect_size };
|
||||
break;
|
||||
case TextAlignment::BottomLeft:
|
||||
rect = { { align_at.x(), align_at.y() - rect_size.width() }, rect_size };
|
||||
break;
|
||||
case TextAlignment::BottomRight:
|
||||
rect = { { align_at.x() - rect_size.width(), align_at.y() - rect_size.width() }, rect_size };
|
||||
break;
|
||||
}
|
||||
return rect.constrained_to(*this);
|
||||
}
|
||||
|
||||
[[nodiscard]] Point<T> closest_to(Point<T> const& point) const
|
||||
{
|
||||
if (is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue