From bb382b55d7c5986a6018fb7b54c7d6296c0415e4 Mon Sep 17 00:00:00 2001 From: kygoh Date: Wed, 31 May 2023 14:36:11 +0000 Subject: [PATCH] Add references to computing table measures spec --- weasyprint/layout/preferred.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index dc28e7aa6..38deffa83 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -135,6 +135,10 @@ def margin_width(box, width, left=True, right=True): """Add box paddings, borders and margins to ``width``.""" percentages = 0 + # See https://drafts.csswg.org/css-tables-3/#cell-intrinsic-offsets + # It is a set of computed values for border-left-width, padding-left, + # padding-right, and border-right-width (along with zero values for + # margin-left and margin-right) for value in ( (['margin_left', 'padding_left'] if left else []) + (['margin_right', 'padding_right'] if right else []) @@ -150,13 +154,20 @@ def margin_width(box, width, left=True, right=True): collapse = box.style['border_collapse'] == 'collapse' if left: if collapse and hasattr(box, 'border_left_width'): + # In collapsed-borders mode: the computed horizontal padding of the + # cell and, for border values, the used border-width values of the + # cell (half the winning border-width) width += box.border_left_width else: + # In separated-borders mode: the computed horizontal padding and + # border of the table-cell width += box.style['border_left_width'] if right: if collapse and hasattr(box, 'border_right_width'): + # [...] the used border-width values of the cell width += box.border_right_width else: + # [...] the computed border of the table-cell width += box.style['border_right_width'] if percentages < 100: