mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: GTabWidget should not set children to have negative size
This could happen if a child was added to a GTabWidget before the GTabWidget had its first layout. Also add an assertion to catch this in GWidget::set_relative_rect() since it was not immediately obvious what was happening.
This commit is contained in:
parent
93dff5df34
commit
b916e34fed
Notes:
sideshowbarker
2024-07-19 11:34:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b916e34fed9
2 changed files with 10 additions and 3 deletions
|
@ -45,13 +45,18 @@ void GTabWidget::resize_event(GResizeEvent& event)
|
|||
|
||||
Rect GTabWidget::child_rect_for_size(const Size& size) const
|
||||
{
|
||||
Rect rect;
|
||||
switch (m_tab_position) {
|
||||
case TabPosition::Top:
|
||||
return { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||
rect = { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||
break;
|
||||
case TabPosition::Bottom:
|
||||
return { { container_padding(), container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||
rect = { { container_padding(), container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||
break;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
if (rect.is_empty())
|
||||
return {};
|
||||
return rect;
|
||||
}
|
||||
|
||||
void GTabWidget::child_event(CChildEvent& event)
|
||||
|
|
|
@ -44,6 +44,8 @@ void GWidget::child_event(CChildEvent& event)
|
|||
|
||||
void GWidget::set_relative_rect(const Rect& rect)
|
||||
{
|
||||
ASSERT(rect.width() >= 0 && rect.height() >= 0);
|
||||
|
||||
if (rect == m_relative_rect)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue