(node, context)
Implements S10.6.3
Implements S10.6.3
Implements S10 . 6 . 3
def calculate_block_non_replaced_normal_flow_height(node, context):
    "Implements S10.6.3"
    if node.layout.margin_top is AUTO:  # P2
        node.layout.margin_top = 0

    if node.layout.margin_bottom is AUTO:  # P2
        node.layout.margin_bottom = 0

    if node.style.height is AUTO:  # P3
        # if node.children and node.has_inline_formatting_content: # P4.1
        #     content_height = bottom edge of last line box
        # elif node.children and node.children[-1] non collapsing with bottom margin:
        if node.children and node.children[-1]:
            last_child = node.children[-1]
            content_height = last_child.layout.border_box_bottom

            # Merge the margin of the last child with
            # the margin of the last child.
            node.layout.collapse_bottom = last_child.layout.collapse_bottom

        # elif node.children and node.children[-1] top margin non collapsing with bottom margin:
        #     content_height = bottom border edge of bottom margin
        else:
            if node.style.min_height is not AUTO:  # 10.7 Minimum height
                content_height = node.style.min_height.px(**context)
            else:
                content_height = 0
    else:
        if node.parent is not None and node.parent.style.height is not AUTO:
            parent_height = node.parent.style.height.px(**context)
            content_height = node.style.height.px(
                display=context['display'], font=context['font'], size=parent_height
            )
        else:
            content_height = node.style.height.px(**context)
        if node.style.max_height is not None:  # 10.7 Maximum height
            content_max_height = node.style.max_height.px(**context)
            if content_height > content_max_height:
                content_height = content_max_height

    node.layout.content_height = content_height
    node.layout.content_top += node.layout.border_top_width + node.layout.padding_top
def calculate_block_non_replaced_normal_flow_height ( node , context ) : if node . layout . margin_top is AUTO : # P2 node . layout . margin_top = 0 if node . layout . margin_bottom is AUTO : # P2 node . layout . margin_bottom = 0 if node . style . height is AUTO : # P3 # if node.children and node.has_inline_formatting_content: # P4.1 #     content_height = bottom edge of last line box # elif node.children and node.children[-1] non collapsing with bottom margin: if node . children and node . children [ - 1 ] : last_child = node . children [ - 1 ] content_height = last_child . layout . border_box_bottom # Merge the margin of the last child with # the margin of the last child. node . layout . collapse_bottom = last_child . layout . collapse_bottom # elif node.children and node.children[-1] top margin non collapsing with bottom margin: #     content_height = bottom border edge of bottom margin else : if node . style . min_height is not AUTO : # 10.7 Minimum height content_height = node . style . min_height . px ( * * context ) else : content_height = 0 else : if node . parent is not None and node . parent . style . height is not AUTO : parent_height = node . parent . style . height . px ( * * context ) content_height = node . style . height . px ( display = context [ 'display' ] , font = context [ 'font' ] , size = parent_height ) else : content_height = node . style . height . px ( * * context ) if node . style . max_height is not None : # 10.7 Maximum height content_max_height = node . style . max_height . px ( * * context ) if content_height > content_max_height : content_height = content_max_height node . layout . content_height = content_height node . layout . content_top += node . layout . border_top_width + node . layout . padding_top