Skip to content

Commit

Permalink
Add references to computing table measures spec
Browse files Browse the repository at this point in the history
  • Loading branch information
kygoh committed May 31, 2023
1 parent 16f8410 commit bb382b5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions weasyprint/layout/preferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [])
Expand All @@ -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:
Expand Down

0 comments on commit bb382b5

Please sign in to comment.