void FullscreenController::willExitFullScreen()
{
    if (!m_fullScreenFrame)
        return;

    if (Document* doc = m_fullScreenFrame->document()) {
        FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(doc);
        if (!fullscreen)
            return;
        if (fullscreen->isFullScreen(doc)) {
            // When the client exits from full screen we have to call webkitCancelFullScreen to
            // notify the document. While doing that, suppress notifications back to the client.
            m_isCancelingFullScreen = true;
            fullscreen->webkitCancelFullScreen();
            m_isCancelingFullScreen = false;
            fullscreen->webkitWillExitFullScreenForElement(0);
        }
    }
}
void FullscreenController::willExitFullScreen()
{
    if (!m_fullScreenFrame)
        return;

    if (Document* doc = m_fullScreenFrame->document()) {
        FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(*doc);
        if (!fullscreen)
            return;
        if (fullscreen->isFullScreen(*doc)) {
            // When the client exits from full screen we have to call webkitCancelFullScreen to
            // notify the document. While doing that, suppress notifications back to the client.
            m_isCancelingFullScreen = true;
            fullscreen->webkitCancelFullScreen();
            m_isCancelingFullScreen = false;
            fullscreen->webkitWillExitFullScreenForElement(0);
            if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && m_webViewImpl->layerTreeView())
                m_webViewImpl->layerTreeView()->setHasTransparentBackground(m_webViewImpl->isTransparent());
        }
    }
}