1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

Sanitize simplified line breaking

The special case that an already broken child must be split again confronts
us with two skip stacks: The initial (absolute) and the adjusted (partial)
stack. Often the new stack is a relative one and (carefully) adding both
stacks is ok. But the following must be observed:

- The first number of the combined stack has to be the index of the child
  we broke twice.
- A child index bigger than the starting index of the initial stack denotes
  that the new skip stack is an absolute stack. Don't add nothing.

Should fix #953
This commit is contained in:
Tontyna 2019-10-03 17:50:05 +02:00
parent 0a403d9d16
commit ecbacef14f

View File

@ -858,11 +858,27 @@ def split_inline_box(context, box, position_x, max_x, skip_stack,
# add the original skip stack to the partial
# skip stack we get after the new rendering.
# We have to do:
# resume_at + initial_skip_stack
# but adding skip stacks is a bit complicated
current_skip_stack = initial_skip_stack
current_resume_at = (child_index, child_resume_at)
# Combining skip stacks is a bit complicated
# We have to:
# - set `child_index` as the first number
# - append the new stack if it's an absolute one
# - otherwise append the combined stacks
# (resume_at + initial_skip_stack)
# extract the initial index
if initial_skip_stack is None:
current_skip_stack = None
initial_index = 0
else:
initial_index, current_skip_stack = (
initial_skip_stack)
# child_resume_at is an absolute skip stack
if child_index > initial_index:
resume_at = (child_index, child_resume_at)
break
# combine the stacks
current_resume_at = child_resume_at
stack = []
while current_skip_stack and current_resume_at:
skip, current_skip_stack = (
@ -875,6 +891,8 @@ def split_inline_box(context, box, position_x, max_x, skip_stack,
resume_at = current_resume_at
while stack:
resume_at = (stack.pop(), resume_at)
# insert the child index
resume_at = (child_index, resume_at)
break
if break_found:
break