Skip to content

Commit 4e50390

Browse files
committed
optimize / simplify
1 parent 2c822db commit 4e50390

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/textual/widget.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,33 +2212,34 @@ def _resolve_extrema(
22122212

22132213
styles = self.styles
22142214
margin = styles.margin
2215-
is_border_box = styles.box_sizing == "border-box"
2216-
gutter = styles.gutter
2215+
container -= margin.totals
2216+
if styles.box_sizing == "border-box":
2217+
gutter_width, gutter_height = styles.gutter.totals
2218+
else:
2219+
gutter_width = gutter_height = 0
22172220

22182221
if styles.min_width is not None:
2219-
min_width = styles.min_width.resolve(
2220-
container - margin.totals, viewport, width_fraction
2222+
min_width = (
2223+
styles.min_width.resolve(container, viewport, width_fraction)
2224+
- gutter_width
22212225
)
2222-
if is_border_box:
2223-
min_width -= gutter.width
2226+
22242227
if styles.max_width is not None:
2225-
max_width = styles.max_width.resolve(
2226-
container - margin.totals, viewport, width_fraction
2228+
max_width = (
2229+
styles.max_width.resolve(container, viewport, width_fraction)
2230+
- gutter_width
22272231
)
2228-
if is_border_box:
2229-
max_width -= gutter.width
22302232
if styles.min_height is not None:
2231-
min_height = styles.min_height.resolve(
2232-
container - margin.totals, viewport, height_fraction
2233+
min_height = (
2234+
styles.min_height.resolve(container, viewport, height_fraction)
2235+
- gutter_height
22332236
)
2234-
if is_border_box:
2235-
min_height -= gutter.height
2237+
22362238
if styles.max_height is not None:
2237-
max_height = styles.max_height.resolve(
2238-
container - margin.totals, viewport, height_fraction
2239+
max_height = (
2240+
styles.max_height.resolve(container, viewport, height_fraction)
2241+
- gutter_height
22392242
)
2240-
if is_border_box:
2241-
max_height -= gutter.height
22422243

22432244
extrema = Extrema(min_width, max_width, min_height, max_height)
22442245
return extrema

0 commit comments

Comments
 (0)