(node, context)
Implements S10.3.2
Implements S10.3.2
Implements S10 . 3 . 2
def calculate_inline_replaced_width(node, context):
    "Implements S10.3.2"
    if node.layout.margin_left == AUTO:  # P1
        node.layout.margin_left = 0

    if node.layout.margin_right == AUTO:  # P1
        node.layout.margin_right = 0

    if node.style.width is AUTO:
        content_width = None
        if node.style.height is AUTO:
            if node.intrinsic.width is not None:  # P2
                content_width = node.intrinsic.width
            elif node.intrinsic.height is not None and node.intrinsic.ratio is not None:  # P3
                content_width = round(node.intrinsic.height * node.intrinsic.ratio)
            elif node.intrinsic.ratio is not None:  # P4
                content_width = (
                    context['size']
                    - node.layout.margin_left
                    - node.layout.border_left_width
                    - node.layout.padding_left
                    - node.layout.padding_right
                    - node.layout.border_right_width
                    - node.layout.margin_right
                )

        if content_width is None:
            if node.intrinsic.width is not None:  # P5
                content_width = node.intrinsic.width
            else:  # P6
                content_width = 300
    else:
        content_width = node.style.width.px(**context)

    node.layout.content_width = content_width
    node.layout.content_left = node.layout.margin_left + node.layout.border_left_width + node.layout.padding_left
def calculate_inline_replaced_width ( node , context ) : if node . layout . margin_left == AUTO : # P1 node . layout . margin_left = 0 if node . layout . margin_right == AUTO : # P1 node . layout . margin_right = 0 if node . style . width is AUTO : content_width = None if node . style . height is AUTO : if node . intrinsic . width is not None : # P2 content_width = node . intrinsic . width elif node . intrinsic . height is not None and node . intrinsic . ratio is not None : # P3 content_width = round ( node . intrinsic . height * node . intrinsic . ratio ) elif node . intrinsic . ratio is not None : # P4 content_width = ( context [ 'size' ] - node . layout . margin_left - node . layout . border_left_width - node . layout . padding_left - node . layout . padding_right - node . layout . border_right_width - node . layout . margin_right ) if content_width is None : if node . intrinsic . width is not None : # P5 content_width = node . intrinsic . width else : # P6 content_width = 300 else : content_width = node . style . width . px ( * * context ) node . layout . content_width = content_width node . layout . content_left = node . layout . margin_left + node . layout . border_left_width + node . layout . padding_left