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

Clean and reorder the CSS properties

This commit is contained in:
Guillaume Ayoub 2016-08-24 16:57:00 +02:00
parent bdfb37d7c4
commit 42785bfbda

View File

@ -21,35 +21,11 @@ Dimension = collections.namedtuple('Dimension', ['value', 'unit'])
# See http://www.w3.org/TR/CSS21/propidx.html
INITIAL_VALUES = {
'background_attachment': ['scroll'],
'background_color': COLOR_KEYWORDS['transparent'],
'background_image': [('none', None)],
'background_position': [('left', Dimension(0, '%'),
'top', Dimension(0, '%'))],
'background_repeat': [('repeat', 'repeat')],
'background_clip': ['border-box'], # CSS3
'background_origin': ['padding-box'], # CSS3
'background_size': [('auto', 'auto')], # CSS3
'border_collapse': 'separate',
# http://www.w3.org/TR/css3-color/#currentcolor
'border_top_color': 'currentColor',
'border_right_color': 'currentColor',
'border_bottom_color': 'currentColor',
'border_left_color': 'currentColor',
'border_spacing': (0, 0),
'border_top_style': 'none',
'border_right_style': 'none',
'border_bottom_style': 'none',
'border_left_style': 'none',
'border_top_width': 3, # Computed value for 'medium'
'border_right_width': 3,
'border_bottom_width': 3,
'border_left_width': 3,
'bottom': 'auto',
'caption_side': 'top',
'clear': 'none',
'clip': (), # empty collection, computed value for 'auto'
'color': COLOR_KEYWORDS['black'], # chosen by the user agent
'clip': (), # computed value for 'auto'
'color': COLOR_KEYWORDS['black'], # chosen by the user agent
'content': 'normal',
# Means 'none', but allow `display: list-item` to increment the
# list-item counter. If we ever have a way for authors to query
@ -61,15 +37,8 @@ INITIAL_VALUES = {
'display': 'inline',
'empty_cells': 'show',
'float': 'none',
'font_family': ['serif'], # depends on user agent
'font_size': 16, # Actually medium, but we define medium from this.
'font_stretch': 'normal', # css3-fonts
'font_style': 'normal',
'font_variant': 'normal',
'font_weight': 400,
'height': 'auto',
'left': 'auto',
'letter_spacing': 'normal',
'line_height': 'normal',
'list_style_image': ('none', None),
'list_style_position': 'outside',
@ -78,92 +47,115 @@ INITIAL_VALUES = {
'margin_right': Dimension(0, 'px'),
'margin_bottom': Dimension(0, 'px'),
'margin_left': Dimension(0, 'px'),
'max_height': Dimension(float('inf'), 'px'), # Parsed value for 'none'
'max_height': Dimension(float('inf'), 'px'), # parsed value for 'none'
'max_width': Dimension(float('inf'), 'px'),
'min_height': Dimension(0, 'px'),
'min_width': Dimension(0, 'px'),
'orphans': 2,
'outline_color': 'currentColor', # invert is not supported
'outline_style': 'none',
'outline_width': 3, # Computed value for 'medium'
'overflow': 'visible',
'padding_top': Dimension(0, 'px'),
'padding_right': Dimension(0, 'px'),
'padding_bottom': Dimension(0, 'px'),
'padding_left': Dimension(0, 'px'),
'page_break_after': 'auto',
'page_break_before': 'auto',
'page_break_inside': 'auto',
'quotes': list('“”‘’'), # depends on user agent
'quotes': list('“”‘’'), # chosen by the user agent
'position': 'static',
'right': 'auto',
# http://dev.w3.org/csswg/css-gcpm/#named-strings
'string_set': 'none',
'table_layout': 'auto',
# Taken from CSS3 Text.
# The only other supported value form CSS3 is -weasy-end.
'text_align': '-weasy-start',
'text_decoration': 'none',
'text_indent': Dimension(0, 'px'),
'text_transform': 'none',
'top': 'auto',
'unicode_bidi': 'normal',
'vertical_align': 'baseline',
'visibility': 'visible',
'white_space': 'normal',
'widows': 2,
'width': 'auto',
'word_spacing': 0, # computed value for 'normal'
'z_index': 'auto',
# CSS3 Paged Media: http://www.w3.org/TR/css3-page/#page-size
'size': None, # XXX set to A4 in computed_values
# CSS3 User Interface: http://www.w3.org/TR/css3-ui/#box-sizing
'box_sizing': 'content-box',
'overflow_wrap': 'normal',
# CSS3 Backgrounds and Borders: http://www.w3.org/TR/css3-background/
'border_top_left_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
'border_top_right_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
# Backgrounds and Borders 3: https://www.w3.org/TR/css3-background/
'background_attachment': ['scroll'],
'background_clip': ['border-box'],
'background_color': COLOR_KEYWORDS['transparent'],
'background_image': [('none', None)],
'background_origin': ['padding-box'],
'background_position': [('left', Dimension(0, '%'),
'top', Dimension(0, '%'))],
'background_repeat': [('repeat', 'repeat')],
'background_size': [('auto', 'auto')],
'border_bottom_color': 'currentColor',
'border_bottom_left_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
'border_bottom_right_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
'border_bottom_style': 'none',
'border_bottom_width': 3,
'border_collapse': 'separate',
'border_left_color': 'currentColor',
'border_left_style': 'none',
'border_left_width': 3,
'border_right_color': 'currentColor',
'border_right_style': 'none',
'border_right_width': 3,
'border_spacing': (0, 0),
'border_top_color': 'currentColor',
'border_top_left_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
'border_top_right_radius': (Dimension(0, 'px'), Dimension(0, 'px')),
'border_top_style': 'none',
'border_top_width': 3, # computed value for 'medium'
# CSS3 Color: http://www.w3.org/TR/css3-color/#transparency
# Color 3: https://www.w3.org/TR/css3-color/
'opacity': 1,
# CSS3 2D Transforms: http://www.w3.org/TR/css3-2d-transforms
'transform_origin': (Dimension(50, '%'), Dimension(50, '%')),
'transform': (), # empty sequence: computed value for 'none'
# Fonts 3: https://www.w3.org/TR/css-fonts-3/
'font_family': ['serif'], # depends on user agent
'font_size': 16, # actually medium, but we define medium from this
'font_stretch': 'normal',
'font_style': 'normal',
'font_variant': 'normal',
'font_weight': 400,
# Taken from SVG:
# http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty
# Fragmentation 3: https://www.w3.org/TR/css-break-3/
'orphans': 2,
'page_break_after': 'auto',
'page_break_before': 'auto',
'page_break_inside': 'auto',
'widows': 2,
# Generated Content for Paged Media: https://www.w3.org/TR/css-gcpm-3/
'bookmark_label': [('content', 'text')],
'bookmark_level': 'none',
'string_set': 'none',
# Images 3/4: https://www.w3.org/TR/css4-images/
'image_resolution': 1, # dppx
'image_rendering': 'auto',
# http://www.w3.org/TR/css3-images/#the-image-resolution
'image_resolution': 1, # dppx
# Paged Media 3: https://www.w3.org/TR/css3-page/
'size': None, # XXX set to A4 in computed_values
# Text 3/4: https://www.w3.org/TR/css-text-4/
'hyphenate_character': '', # computed value chosen by the user agent
'hyphenate_limit_chars': (5, 2, 2),
'hyphenate_limit_zone': Dimension(0, 'px'),
'hyphens': 'manual',
'letter_spacing': 'normal',
'tab_size': 8,
'text_align': '-weasy-start',
'text_indent': Dimension(0, 'px'),
'text_transform': 'none',
'white_space': 'normal',
'word_spacing': 0, # computed value for 'normal'
# Transforms 1: https://www.w3.org/TR/css-transforms-1/
'transform_origin': (Dimension(50, '%'), Dimension(50, '%')),
'transform': (), # computed value for 'none'
# User Interface 3: https://www.w3.org/TR/css-ui-3/
'box_sizing': 'content-box',
'outline_color': 'currentColor', # invert is not supported
'outline_style': 'none',
'outline_width': 3, # computed value for 'medium'
'overflow_wrap': 'normal',
# Proprietary
'anchor': None, # computed value of 'none'
'link': None, # computed value of 'none'
'lang': None, # computed value of 'none'
# CSS3 Generated Content for Paged Media
# http://dev.w3.org/csswg/css3-gcpm/
'bookmark_label': [('content', 'text')],
'bookmark_level': 'none',
# CSS3 Text
# https://www.w3.org/TR/css-text-3/
'hyphens': 'manual',
'tab_size': 8,
# CSS4 Text
# http://dev.w3.org/csswg/css4-text/#hyphenation
'hyphenate_character': '',
'hyphenate_limit_chars': (5, 2, 2),
'hyphenate_limit_zone': Dimension(0, 'px'),
# Internal, to implement the "static position" for absolute boxes.
'_weasy_specified_display': 'inline',
}
@ -220,8 +212,16 @@ INHERITED = set("""
font_stretch
font_variant
font_weight
hyphens
hyphenate_character
hyphenate_limit_chars
hyphenate_limit_zone
image_rendering
image_resolution
lang
letter_spacing
line_height
link
list_style_image
list_style_position
list_style_type
@ -237,15 +237,6 @@ INHERITED = set("""
white_space
widows
word_spacing
hyphens
hyphenate_character
hyphenate_limit_chars
hyphenate_limit_zone
image_rendering
image_resolution
lang
link
""".split())
# Inherited but not applicable to print:
@ -269,24 +260,23 @@ INHERITED = set("""
# See also http://lists.w3.org/Archives/Public/www-style/2012Jun/0066.html
# Only non-inherited properties need to be included here.
TABLE_WRAPPER_BOX_PROPERTIES = set('''
position
bottom
clear
counter_increment
counter_reset
float
left
margin_top
margin_bottom
margin_left
margin_right
top
bottom
left
right
clear
counter_increment
counter_reset
opacity
page_break_before
page_break_after
page_break_before
page_break_inside
position
right
top
transform
transform_origin
vertical_align