diff --git a/weasyprint/formatting_structure/boxes.py b/weasyprint/formatting_structure/boxes.py index c0bbe831..3daff6df 100644 --- a/weasyprint/formatting_structure/boxes.py +++ b/weasyprint/formatting_structure/boxes.py @@ -302,12 +302,14 @@ class ParentBox(Box): setattr(self, 'border_%s_width' % side, 0) def _remove_decoration(self, start, end): + if self.style['box_decoration_break'] == 'clone': + return if start: self._reset_spacing('top') if end: self._reset_spacing('bottom') - def copy_with_children(self, new_children, is_start=True, is_end=True): + def copy_with_children(self, new_children): """Create a new equivalent box with given ``new_children``.""" new_box = self.copy() new_box.children = tuple(new_children) @@ -315,8 +317,6 @@ class ParentBox(Box): # Clear and reset removed decorations as we don't want to keep the # previous data, for example when a box is split between two pages. self.remove_decoration_sides = set() - if self.style['box_decoration_break'] == 'slice': - new_box._remove_decoration(not is_start, not is_end) return new_box @@ -411,6 +411,8 @@ class InlineLevelBox(Box): """ def _remove_decoration(self, start, end): + if self.style['box_decoration_break'] == 'clone': + return ltr = self.style['direction'] == 'ltr' if start: self._reset_spacing('left' if ltr else 'right') diff --git a/weasyprint/formatting_structure/build.py b/weasyprint/formatting_structure/build.py index 7806db79..591038bf 100644 --- a/weasyprint/formatting_structure/build.py +++ b/weasyprint/formatting_structure/build.py @@ -1467,13 +1467,11 @@ def _inner_block_in_inline(box, skip_stack=None): new_children.append(new_child) if block_level_box is not None: resume_at = (index, resume_at) - box = box.copy_with_children( - new_children, is_start=is_start, is_end=False) + box = box.copy_with_children(new_children) break else: if changed or skip: - box = box.copy_with_children( - new_children, is_start=is_start, is_end=True) + box = box.copy_with_children(new_children) return box, block_level_box, resume_at diff --git a/weasyprint/layout/blocks.py b/weasyprint/layout/blocks.py index 3277bfba..ce85394e 100644 --- a/weasyprint/layout/blocks.py +++ b/weasyprint/layout/blocks.py @@ -275,9 +275,7 @@ def block_container_layout(context, box, max_position_y, skip_stack, context.create_block_formatting_context() is_start = skip_stack is None - if box.style['box_decoration_break'] == 'slice' and not is_start: - # Remove top margin, border and padding: - box._remove_decoration(start=True, end=False) + box._remove_decoration(start=not is_start, end=False) if adjoining_margins is None: adjoining_margins = [] @@ -640,8 +638,8 @@ def block_container_layout(context, box, max_position_y, skip_stack, position_y += collapse_margin(adjoining_margins) adjoining_margins = [] - new_box = box.copy_with_children( - new_children, is_start=is_start, is_end=resume_at is None) + new_box = box.copy_with_children(new_children) + new_box._remove_decoration(start=not is_start, end=resume_at is not None) # TODO: See corner cases in # http://www.w3.org/TR/CSS21/visudet.html#normal-block diff --git a/weasyprint/layout/inlines.py b/weasyprint/layout/inlines.py index 4d3f9fdb..a1ac9c2b 100644 --- a/weasyprint/layout/inlines.py +++ b/weasyprint/layout/inlines.py @@ -899,8 +899,8 @@ def split_inline_box(context, box, position_x, max_x, skip_stack, is_end = resume_at is None new_box = box.copy_with_children( - [box_child for index, box_child in children], - is_start=is_start, is_end=is_end) + [box_child for index, box_child in children]) + new_box._remove_decoration(start=not is_start, end=not is_end) if isinstance(box, boxes.LineBox): # We must reset line box width according to its new children in_flow_children = [ diff --git a/weasyprint/layout/tables.py b/weasyprint/layout/tables.py index 23a9f109..8def64f8 100644 --- a/weasyprint/layout/tables.py +++ b/weasyprint/layout/tables.py @@ -249,9 +249,9 @@ def table_layout(context, table, max_position_y, skip_stack, containing_block, not new_group_children): return None, None, next_page - group = group.copy_with_children( - new_group_children, - is_start=is_group_start, is_end=resume_at is None) + group = group.copy_with_children(new_group_children) + group._remove_decoration( + start=not is_group_start, end=resume_at is not None) # Set missing baselines in a second loop because of rowspan for row in group.children: @@ -442,8 +442,9 @@ def table_layout(context, table, max_position_y, skip_stack, containing_block, table = table.copy_with_children( ([header] if header is not None else []) + new_table_children + - ([footer] if footer is not None else []), - is_start=skip_stack is None, is_end=resume_at is None) + ([footer] if footer is not None else [])) + table._remove_decoration( + start=skip_stack is not None, end=resume_at is not None) if table.style['border_collapse'] == 'collapse': table.skipped_rows = skipped_rows