Skip to content

Commit 11122f9

Browse files
committed
optimize
1 parent bcaad58 commit 11122f9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/textual/_resolve.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ def resolve_box_models(
203203
fraction_zero = Fraction(0)
204204
margin_size = size - margin
205205

206+
margins = [widget.styles.margin.totals for widget in widgets]
207+
206208
# Fixed box models
207209
box_models: list[BoxModel | None] = [
208210
(
@@ -211,11 +213,13 @@ def resolve_box_models(
211213
else widget._get_box_model(
212214
size,
213215
viewport_size,
214-
max(fraction_zero, fraction_width - widget.styles.margin.width),
215-
max(fraction_zero, fraction_height - widget.styles.margin.height),
216+
max(fraction_zero, fraction_width - margin_width),
217+
max(fraction_zero, fraction_height - margin_height),
216218
)
217219
)
218-
for (_dimension, widget) in zip(dimensions, widgets)
220+
for (_dimension, widget, (margin_width, margin_height)) in zip(
221+
dimensions, widgets, margins
222+
)
219223
]
220224

221225
if None not in box_models:

0 commit comments

Comments
 (0)