summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-08-15 18:40:52 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-10-17 20:38:16 +0200
commitc11d213a1436d7d20b1e6805a509f7c3d2dd8f09 (patch)
treee28331e150df39bb22ffa82119b2fb3adf59a742
parent63213042ea782c76b26e1b5a9d948030d3fe9c9c (diff)
Set the viewport width as initial width value
When the initial width is -1, the contrainsts of min-width and max-width are not applied. If we set the viewport width after calcFinalWidth() it may exceed max-width. It is guaranteed to return a value different from -1 when the initial width is positive.
-rw-r--r--dw/widget.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/dw/widget.cc b/dw/widget.cc
index 1a8743ee..8824baeb 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -662,11 +662,9 @@ int Widget::getAvailWidth (bool forceValue)
int viewportWidth =
layout->viewportWidth - (layout->canvasHeightGreater ?
layout->vScrollbarThickness : 0);
- width = -1;
+ width = viewportWidth;
calcFinalWidth (getStyle (), viewportWidth, NULL, 0, forceValue, &width);
- if (width == -1)
- width = viewportWidth;
-
+ assert(width != -1);
DBG_OBJ_MSG_END ();
} else if (parent) {
DBG_OBJ_MSG ("resize", 1, "delegated to parent");