mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibGUI: Try use layout's preferred size for the content size
Previously this was only done if the widget had shrink_to_fit property enabled.
This commit is contained in:
parent
9156614de3
commit
f505f1ab5e
Notes:
sideshowbarker
2024-07-17 21:26:19 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/f505f1ab5e Pull-request: https://github.com/SerenityOS/serenity/pull/13945 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -38,12 +38,20 @@ void ScrollableContainerWidget::update_widget_size()
|
||||
return;
|
||||
m_widget->do_layout();
|
||||
auto new_size = Widget::content_size();
|
||||
if (m_widget->is_shrink_to_fit() && m_widget->layout()) {
|
||||
|
||||
if (m_widget->layout()) {
|
||||
auto preferred_size = m_widget->layout()->preferred_size();
|
||||
if (m_widget->is_shrink_to_fit()) {
|
||||
if (preferred_size.width() != -1)
|
||||
new_size.set_width(preferred_size.width());
|
||||
if (preferred_size.height() != -1)
|
||||
new_size.set_height(preferred_size.height());
|
||||
} else {
|
||||
new_size = Gfx::Size {
|
||||
max(new_size.width(), preferred_size.width()),
|
||||
max(new_size.height(), preferred_size.height())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
auto min_size = m_widget->min_size();
|
||||
|
Loading…
Reference in New Issue
Block a user