def transform_declaration(decl): decl = StyleDeclaration(decl) changed = False for prop, parent_prop in tuple(decl): if prop.name in page_break_properties: changed = True name = prop.name.partition('-')[2] for prefix in ('', '-webkit-column-'): # Note that Firefox does not support break-after at all # https://bugzil.la/549114 decl.set_property(prefix + name, prop.value, prop.priority) decl.remove_property(prop, parent_prop) elif prop.name == 'font-size': raw = prop.value afs = absolute_font_sizes.get(raw) if afs is not None: changed = True decl.change_property(prop, parent_prop, afs) continue l, unit = parse_css_length(raw) if unit in absolute_units: changed = True l = convert_fontsize(l, unit) decl.change_property(prop, parent_prop, unicode_type(l) + 'rem') return changed
def transform_declaration(decl): decl = StyleDeclaration(decl) changed = False for prop, parent_prop in tuple(decl): if prop.name in {'page-break-before', 'page-break-after', 'page-break-inside'}: changed = True name = prop.name.partition('-')[2] for prefix in ('', '-webkit-column-'): # Note that Firefox does not support break-after at all # https://bugzil.la/549114 decl.set_property(prefix + name, prop.value, prop.priority) decl.remove_property(prop, parent_prop) elif prop.name == 'font-size': l, unit = parse_css_length(prop.value) if unit in absolute_units: changed = True l = convert_fontsize(l, unit) decl.change_property(prop, parent_prop, str(l) + 'rem') return changed
def transform_declaration(decl): decl = StyleDeclaration(decl) changed = False nonstandard_writing_mode_props = {} standard_writing_mode_props = {} for prop, parent_prop in tuple(decl): if prop.name in page_break_properties: changed = True name = prop.name.partition('-')[2] for prefix in ('', '-webkit-column-'): # Note that Firefox does not support break-after at all # https://bugzil.la/549114 decl.set_property(prefix + name, prop.value, prop.priority) decl.remove_property(prop, parent_prop) elif prop.name == 'font-size': raw = prop.value afs = absolute_font_sizes.get(raw) if afs is not None: changed = True decl.change_property(prop, parent_prop, afs) continue l, unit = parse_css_length(raw) if unit in absolute_units: changed = True l = convert_fontsize(l, unit) decl.change_property(prop, parent_prop, unicode_type(l) + 'rem') elif prop.name in nonstandard_writing_mode_property_names: nonstandard_writing_mode_props[prop.value] = prop.priority elif prop.name == 'writing-mode': standard_writing_mode_props[prop.value] = True # Add standard writing-mode properties if they don't exist so that # all of the browsers supported by the viewer work in vertical modes for value, priority in nonstandard_writing_mode_props.items(): if value not in standard_writing_mode_props: decl.set_property('writing-mode', value, priority) changed = True return changed