mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 16:07:57 +03:00
Add a keywoard to translate boxes ignoring floating children
This commit is contained in:
parent
ce70354488
commit
878cc41c51
@ -111,7 +111,7 @@ class Box(object):
|
||||
new_box.style = self.style
|
||||
return new_box
|
||||
|
||||
def translate(self, dx=0, dy=0):
|
||||
def translate(self, dx=0, dy=0, ignore_floats=False):
|
||||
"""Change the box’s position.
|
||||
|
||||
Also update the children’s positions accordingly.
|
||||
@ -123,7 +123,8 @@ class Box(object):
|
||||
self.position_x += dx
|
||||
self.position_y += dy
|
||||
for child in self.all_children():
|
||||
child.translate(dx, dy)
|
||||
if not (ignore_floats and child.is_floated()):
|
||||
child.translate(dx, dy, ignore_floats)
|
||||
|
||||
# Heights and widths
|
||||
|
||||
@ -540,12 +541,12 @@ class TableBox(BlockLevelBox, ParentBox):
|
||||
def all_children(self):
|
||||
return itertools.chain(self.children, self.column_groups)
|
||||
|
||||
def translate(self, dx=0, dy=0):
|
||||
def translate(self, dx=0, dy=0, ignore_floats=False):
|
||||
if dx == 0 and dy == 0:
|
||||
return
|
||||
self.column_positions = [
|
||||
position + dx for position in self.column_positions]
|
||||
return super(TableBox, self).translate(dx, dy)
|
||||
return super(TableBox, self).translate(dx, dy, ignore_floats)
|
||||
|
||||
def page_values(self):
|
||||
return (self.style['page'], self.style['page'])
|
||||
|
@ -30,11 +30,11 @@ class AbsolutePlaceholder(object):
|
||||
object.__setattr__(self, '_box', new_box)
|
||||
object.__setattr__(self, '_layout_done', True)
|
||||
|
||||
def translate(self, dx=0, dy=0):
|
||||
def translate(self, dx=0, dy=0, ignore_floats=False):
|
||||
if dx == 0 and dy == 0:
|
||||
return
|
||||
if self._layout_done:
|
||||
self._box.translate(dx, dy)
|
||||
self._box.translate(dx, dy, ignore_floats)
|
||||
else:
|
||||
# Descendants do not have a position yet.
|
||||
self._box.position_x += dx
|
||||
|
Loading…
Reference in New Issue
Block a user