def set_viewport_overflow(root_box):
    """
    Set a ``viewport_overflow`` attribute on the box for the root element.

    Like backgrounds, ``overflow`` on the root element must be propagated
    to the viewport.

    See http://www.w3.org/TR/CSS21/visufx.html#overflow
    """
    chosen_box = root_box
    if root_box.element_tag.lower() == 'html' and root_box.style['overflow'
        ] == 'visible':
        for child in root_box.children:
            if child.element_tag.lower() == 'body':
                chosen_box = child
                break
    root_box.viewport_overflow = chosen_box.style['overflow']
    chosen_box.style['overflow'] = 'visible'
    return root_box
