#NEWLINE# def absolute_replaced( context , box , containing_block ) : #NEWLINE# #INDENT# from . inlines import inline_replaced_box_width_height #NEWLINE# inline_replaced_box_width_height ( box , device_size = None ) #NEWLINE# ( cb_x , cb_y , cb_width , cb_height ) = containing_block #NEWLINE# ltr = ( box . style . direction == 'ltr' ) #NEWLINE# if ( box . left == box . right == 'auto' ) : #NEWLINE# #INDENT# if ltr : #NEWLINE# #INDENT# box . left = ( box . position_x - cb_x ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# box . right = ( ( cb_x + cb_width ) - box . position_x ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'auto' in ( box . left , box . right ) ) : #NEWLINE# #INDENT# if ( box . margin_left == 'auto' ) : #NEWLINE# #INDENT# box . margin_left = 0 #NEWLINE# #UNINDENT# if ( box . margin_right == 'auto' ) : #NEWLINE# #INDENT# box . margin_right = 0 #NEWLINE# #UNINDENT# remaining = ( cb_width - box . margin_width ( ) ) #NEWLINE# if ( box . left == 'auto' ) : #NEWLINE# #INDENT# box . left = ( remaining - box . right ) #NEWLINE# #UNINDENT# if ( box . right == 'auto' ) : #NEWLINE# #INDENT# box . right = ( remaining - box . left ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'auto' in ( box . margin_left , box . margin_right ) ) : #NEWLINE# #INDENT# remaining = ( cb_width - ( ( box . border_width ( ) + box . left ) + box . right ) ) #NEWLINE# if ( box . margin_left == box . margin_right == 'auto' ) : #NEWLINE# #INDENT# if ( remaining >= 0 ) : #NEWLINE# #INDENT# box . margin_left = box . margin_right = ( remaining // 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ltr : #NEWLINE# #INDENT# box . margin_left = 0 #NEWLINE# box . margin_right = remaining #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# box . margin_left = remaining #NEWLINE# box . margin_right = 0 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( box . margin_left == 'auto' ) : #NEWLINE# #INDENT# box . margin_left = remaining #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# box . margin_right = remaining #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ltr : #NEWLINE# #INDENT# box . right = ( cb_width - ( box . margin_width ( ) + box . left ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# box . left = ( cb_width - ( box . margin_width ( ) + box . right ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( box . top == box . bottom == 'auto' ) : #NEWLINE# #INDENT# box . top = ( box . position_y - cb_y ) #NEWLINE# #UNINDENT# if ( 'auto' in ( box . top , box . bottom ) ) : #NEWLINE# #INDENT# if ( box . margin_top == 'auto' ) : #NEWLINE# #INDENT# box . margin_top = 0 #NEWLINE# #UNINDENT# if ( box . margin_bottom == 'auto' ) : #NEWLINE# #INDENT# box . margin_bottom = 0 #NEWLINE# #UNINDENT# remaining = ( cb_height - box . margin_height ( ) ) #NEWLINE# if ( box . top == 'auto' ) : #NEWLINE# #INDENT# box . top = remaining #NEWLINE# #UNINDENT# if ( box . bottom == 'auto' ) : #NEWLINE# #INDENT# box . bottom = remaining #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'auto' in ( box . margin_top , cb_y . margin_bottom ) ) : #NEWLINE# #INDENT# remaining = ( cb_height - ( ( box . border_height ( ) + box . top ) + box . bottom ) ) #NEWLINE# if ( box . margin_top == box . margin_bottom == 'auto' ) : #NEWLINE# #INDENT# box . margin_top = box . margin_bottom = ( remaining // 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( box . margin_top == 'auto' ) : #NEWLINE# #INDENT# box . margin_top = remaining #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# box . margin_bottom = remaining #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# box . bottom = ( cb_height - ( box . margin_height ( ) + box . top ) ) #NEWLINE# #UNINDENT# #UNINDENT# box . position_x = ( cb_x + box . left ) #NEWLINE# box . position_y = ( cb_y + box . top ) #NEWLINE# return box