Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
b5=(
Dimension(176, 'mm'),
Dimension(250, 'mm'),
),
b4=(
Dimension(250, 'mm'),
Dimension(353, 'mm'),
),
letter=(
Dimension(8.5, 'in'),
Dimension(11, 'in'),
),
legal=(
Dimension(8.5, 'in'),
Dimension(14, 'in'),
),
ledger=(
Dimension(11, 'in'),
Dimension(17, 'in'),
),
)
# In "portrait" orientation.
for w, h in PAGE_SIZES.values():
assert w.value < h.value
INITIAL_PAGE_SIZE = PAGE_SIZES['a4']
INITIAL_VALUES['size'] = tuple(
d.value * LENGTHS_TO_PIXELS[d.unit] for d in INITIAL_PAGE_SIZE)
def _computing_order():
def get_length(token, negative=True, percentage=False):
"""Parse a token."""
if percentage and token.type == 'percentage':
if negative or token.value >= 0:
return Dimension(token.value, '%')
if token.type == 'dimension' and token.unit in LENGTH_UNITS:
if negative or token.value >= 0:
return Dimension(token.value, token.unit)
if token.type == 'number' and token.value == 0:
return Dimension(0, None)
else:
main_flex_direction = None
resolve_percentages(child, containing_block, main_flex_direction)
child.position_x = parent_box.content_box_x()
child.position_y = parent_box.content_box_y()
if child.min_width == 'auto':
specified_size = (
child.width if child.width != 'auto' else float('inf'))
if isinstance(child, boxes.ParentBox):
new_child = child.copy_with_children(child.children)
else:
new_child = child.copy()
new_child.style = child.style.copy()
new_child.style['width'] = 'auto'
new_child.style['min_width'] = Dimension(0, 'px')
new_child.style['max_width'] = Dimension(float('inf'), 'px')
content_size = min_content_width(context, new_child, outer=False)
child.min_width = min(specified_size, content_size)
elif child.min_height == 'auto':
# TODO: find a way to get min-content-height
specified_size = (
child.height if child.height != 'auto' else float('inf'))
if isinstance(child, boxes.ParentBox):
new_child = child.copy_with_children(child.children)
else:
new_child = child.copy()
new_child.style = child.style.copy()
new_child.style['height'] = 'auto'
new_child.style['min_height'] = Dimension(0, 'px')
new_child.style['max_height'] = Dimension(float('inf'), 'px')
new_child = blocks.block_level_layout(
context, new_child, float('inf'), child_skip_stack,
def line_height(token):
"""``line-height`` property validation."""
if get_keyword(token) == 'normal':
return 'normal'
if token.type == 'number' and token.value >= 0:
return Dimension(token.value, None)
if token.type == 'percentage' and token.value >= 0:
return Dimension(token.value, '%')
elif token.type == 'dimension' and token.value >= 0:
return get_length(token)
)
# http://www.w3.org/TR/css3-page/#size
# name=(width in pixels, height in pixels)
PAGE_SIZES = dict(
a5=(
Dimension(148, 'mm'),
Dimension(210, 'mm'),
),
a4=(
Dimension(210, 'mm'),
Dimension(297, 'mm'),
),
a3=(
Dimension(297, 'mm'),
Dimension(420, 'mm'),
),
b5=(
Dimension(176, 'mm'),
Dimension(250, 'mm'),
),
b4=(
Dimension(250, 'mm'),
Dimension(353, 'mm'),
),
letter=(
Dimension(8.5, 'in'),
Dimension(11, 'in'),
),
legal=(
Dimension(8.5, 'in'),
Dimension(14, 'in'),
marker_text = counters.format_list_marker(
counter_value, style['list_style_type'])
box = boxes.TextBox.anonymous_from(box, marker_text)
box.style['white_space'] = 'pre-wrap'
children.append(box)
if not children:
return
if parent_style['list_style_position'] == 'outside':
marker_box = boxes.BlockBox.anonymous_from(box, children)
# We can safely edit everything that can't be changed by user style
# See https://drafts.csswg.org/css-pseudo-4/#marker-pseudo
marker_box.style['position'] = 'absolute'
if parent_style['direction'] == 'ltr':
translate_x = properties.Dimension(-100, '%')
else:
translate_x = properties.Dimension(100, '%')
translate_y = computed_values.ZERO_PIXELS
marker_box.style['transform'] = (
('translate', (translate_x, translate_y)),)
else:
marker_box = boxes.InlineBox.anonymous_from(box, children)
yield marker_box
),
b4=(
Dimension(250, 'mm'),
Dimension(353, 'mm'),
),
letter=(
Dimension(8.5, 'in'),
Dimension(11, 'in'),
),
legal=(
Dimension(8.5, 'in'),
Dimension(14, 'in'),
),
ledger=(
Dimension(11, 'in'),
Dimension(17, 'in'),
),
)
# In "portrait" orientation.
for w, h in PAGE_SIZES.values():
assert w.value < h.value
INITIAL_PAGE_SIZE = PAGE_SIZES['a4']
INITIAL_VALUES['size'] = tuple(
d.value * LENGTHS_TO_PIXELS[d.unit] for d in INITIAL_PAGE_SIZE)
def _computing_order():
"""Some computed values are required by others, so order matters."""
first = [
'font_stretch', 'font_weight', 'font_family', 'font_variant',
'font_style', 'font_size', 'line_height']
),
b4=(
Dimension(250, 'mm'),
Dimension(353, 'mm'),
),
letter=(
Dimension(8.5, 'in'),
Dimension(11, 'in'),
),
legal=(
Dimension(8.5, 'in'),
Dimension(14, 'in'),
),
ledger=(
Dimension(11, 'in'),
Dimension(17, 'in'),
),
)
# In "portrait" orientation.
for w, h in PAGE_SIZES.values():
assert w.value < h.value
INITIAL_PAGE_SIZE = PAGE_SIZES['a4']
INITIAL_VALUES['size'] = tuple(
d.value * LENGTHS_TO_PIXELS[d.unit] for d in INITIAL_PAGE_SIZE)
def _computing_order():
"""Some computed values are required by others, so order matters."""
first = [
'font_stretch', 'font_weight', 'font_family', 'font_variant',
'font_style', 'font_size', 'line_height', 'marks']
Dimension(250, 'mm'),
),
b4=(
Dimension(250, 'mm'),
Dimension(353, 'mm'),
),
letter=(
Dimension(8.5, 'in'),
Dimension(11, 'in'),
),
legal=(
Dimension(8.5, 'in'),
Dimension(14, 'in'),
),
ledger=(
Dimension(11, 'in'),
Dimension(17, 'in'),
),
)
# In "portrait" orientation.
for w, h in PAGE_SIZES.values():
assert w.value < h.value
INITIAL_PAGE_SIZE = PAGE_SIZES['a4']
INITIAL_VALUES['size'] = tuple(
d.value * LENGTHS_TO_PIXELS[d.unit] for d in INITIAL_PAGE_SIZE)
def _computing_order():
"""Some computed values are required by others, so order matters."""
first = [
'font_stretch', 'font_weight', 'font_family', 'font_variant',