Skip to content

Commit

Permalink
short circuit get_clearance
Browse files Browse the repository at this point in the history
  • Loading branch information
chancyk committed Jun 10, 2018
1 parent 3210ea8 commit 89e269a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion weasyprint/layout/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ def get_clearance(context, box, collapsed_margin=0):
hypothetical_position = box.position_y + collapsed_margin
# Hypothetical position is the position of the top border edge
for excluded_shape in context.excluded_shapes:
y = excluded_shape.position_y
# Skip expensive attribute lookups if there's already
# no possibility of clearance.
if hypothetical_position >= y:
continue
h = excluded_shape.margin_height()
if box.style['clear'] in (excluded_shape.style.float, 'both'):
y, h = excluded_shape.position_y, excluded_shape.margin_height()
if hypothetical_position < y + h:
clearance = max(
(clearance or 0), y + h - hypothetical_position)
Expand Down

0 comments on commit 89e269a

Please sign in to comment.