aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-08-16 17:59:55 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-10-17 20:38:16 +0200
commite4fbfd6b62523fabb612aa55e20b568f44910bda (patch)
tree97b3ea8f63b56e72450122847a54b6dbc2017f77
parent7823c15c4dd68faa911d3807c8133f358854eb3e (diff)
Use maximum size for pathological CSS cases
When CSS min-{width,height} > max-{width,height} set the max-{width,heigh} to the maximum value min-{width,height}.
-rw-r--r--dw/widget.cc29
1 files changed, 25 insertions, 4 deletions
diff --git a/dw/widget.cc b/dw/widget.cc
index ef4d6b46..eaa9e985 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -788,11 +788,19 @@ void Widget::correctRequisitionViewport (Requisition *requisition,
int minHeight = calcHeight (getStyle()->minHeight, false,
layout->viewportHeight, NULL, false);
- adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent,
- requisition->descent);
int maxHeight = calcHeight (getStyle()->maxHeight, false,
layout->viewportHeight, NULL, false);
+
+ if (minHeight != -1 && maxHeight != -1) {
+ /* Prefer the maximum size for pathological cases (min > max) */
+ if (maxHeight < minHeight)
+ maxHeight = minHeight;
+ }
+
+ adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent,
+ requisition->descent);
+
adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent,
requisition->descent);
@@ -1005,6 +1013,12 @@ void Widget::calcFinalWidth (style::Style *style, int refWidth,
DBG_OBJ_MSGF ("resize", 1, "minWidth = %d, maxWidth = %d",
minWidth, maxWidth);
+ if (minWidth != -1 && maxWidth != -1) {
+ /* Prefer the maximum size for pathological cases (min > max) */
+ if (maxWidth < minWidth)
+ maxWidth = minWidth;
+ }
+
if (minWidth != -1 && w < minWidth)
w = minWidth;
@@ -2064,11 +2078,18 @@ void Widget::correctReqHeightOfChild (Widget *child, Requisition *requisition,
int minHeight = child->calcHeight (child->getStyle()->minHeight, true, -1,
this, false);
+ int maxHeight = child->calcHeight (child->getStyle()->maxHeight, true, -1,
+ this, false);
+
+ if (minHeight != -1 && maxHeight != -1) {
+ /* Prefer the maximum size for pathological cases (min > max) */
+ if (maxHeight < minHeight)
+ maxHeight = minHeight;
+ }
+
adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent,
requisition->descent);
- int maxHeight = child->calcHeight (child->getStyle()->maxHeight, true, -1,
- this, false);
adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent,
requisition->descent);