Skip to content

Commit

Permalink
Remove useless dots used for old float divisions
Browse files Browse the repository at this point in the history
liZe committed Feb 14, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cf06221 commit d814c2e
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions weasyprint/css/computed_values.py
Original file line number Diff line number Diff line change
@@ -580,7 +580,7 @@ def font_size(style, name, value):
else:
return parent_font_size * 0.8
elif value.unit == '%':
return value.value * parent_font_size / 100.
return value.value * parent_font_size / 100
else:
return length(
style, name, value, pixels_only=True,
@@ -612,7 +612,7 @@ def line_height(style, name, value):
elif not value.unit:
return ('NUMBER', value.value)
elif value.unit == '%':
factor = value.value / 100.
factor = value.value / 100
font_size_value = style['font_size']
pixels = factor * font_size_value
else:
2 changes: 1 addition & 1 deletion weasyprint/css/utils.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
'in': 96., # LENGTHS_TO_PIXELS['pt'] * 72
'cm': 96. / 2.54, # LENGTHS_TO_PIXELS['in'] / 2.54
'mm': 96. / 25.4, # LENGTHS_TO_PIXELS['in'] / 25.4
'q': 96. / 25.4 / 4., # LENGTHS_TO_PIXELS['mm'] / 4
'q': 96. / 25.4 / 4, # LENGTHS_TO_PIXELS['mm'] / 4
}

# http://dev.w3.org/csswg/css-values/#resolution
4 changes: 2 additions & 2 deletions weasyprint/layout/block.py
Original file line number Diff line number Diff line change
@@ -174,8 +174,8 @@ def block_level_width(box, containing_block):
paddings_plus_borders + margin_l + margin_r)
margin_sum = cb_width - paddings_plus_borders - width
if margin_l == 'auto' and margin_r == 'auto':
box.margin_left = margin_sum / 2.
box.margin_right = margin_sum / 2.
box.margin_left = margin_sum / 2
box.margin_right = margin_sum / 2
elif margin_l == 'auto' and margin_r != 'auto':
box.margin_left = margin_sum - margin_r
elif margin_l != 'auto' and margin_r == 'auto':
2 changes: 1 addition & 1 deletion weasyprint/layout/inline.py
Original file line number Diff line number Diff line change
@@ -1049,7 +1049,7 @@ def inline_box_verticality(box, top_bottom_subtrees, baseline_y):
child_baseline_y = baseline_y
elif vertical_align == 'middle':
one_ex = box.style['font_size'] * ex_ratio(box.style)
top = baseline_y - (one_ex + child.margin_height()) / 2.
top = baseline_y - (one_ex + child.margin_height()) / 2
child_baseline_y = top + child.baseline
elif vertical_align == 'text-top':
# align top with the top of the parent’s content area
2 changes: 1 addition & 1 deletion weasyprint/layout/percent.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ def percentage(value, refer_to):
return value.value
else:
assert value.unit == '%'
return refer_to * value.value / 100.
return refer_to * value.value / 100


def resolve_one_percentage(box, property_name, refer_to,
6 changes: 3 additions & 3 deletions weasyprint/layout/preferred.py
Original file line number Diff line number Diff line change
@@ -153,7 +153,7 @@ def margin_width(box, width, left=True, right=True):
width += box.style['border_right_width']

if percentages < 100:
return width / (1 - percentages / 100.)
return width / (1 - percentages / 100)
else:
# Pathological case, ignore
return 0
@@ -570,14 +570,14 @@ def table_and_columns_preferred_widths(context, box, outer=True):

# Calculate the max- and min-content widths of table and columns
small_percentage_contributions = [
max_content_widths[i] / (intrinsic_percentages[i] / 100.)
max_content_widths[i] / (intrinsic_percentages[i] / 100)
for i in range(grid_width)
if intrinsic_percentages[i]]
large_percentage_contribution_numerator = sum(
max_content_widths[i] for i in range(grid_width)
if intrinsic_percentages[i] == 0)
large_percentage_contribution_denominator = (
(100 - sum(intrinsic_percentages)) / 100.)
(100 - sum(intrinsic_percentages)) / 100)
if large_percentage_contribution_denominator == 0:
if large_percentage_contribution_numerator == 0:
large_percentage_contribution = 0
2 changes: 1 addition & 1 deletion weasyprint/layout/table.py
Original file line number Diff line number Diff line change
@@ -248,7 +248,7 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
if cell.vertical_align == 'bottom':
add_top_padding(cell, extra)
elif cell.vertical_align == 'middle':
extra /= 2.
extra /= 2
add_top_padding(cell, extra)
cell.padding_bottom += extra
else:
2 changes: 1 addition & 1 deletion weasyprint/svg/text.py
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ def text(svg, node, font_size):
# TODO: use real values
ascent, descent = font_size * .8, font_size * .2
if text_anchor == 'middle':
x_align = - (width / 2. + x_bearing)
x_align = - (width / 2 + x_bearing)
if letter_spacing and node.text:
x_align -= (len(node.text) - 1) * letter_spacing / 2
elif text_anchor == 'end':

0 comments on commit d814c2e

Please sign in to comment.