<commit_before>/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

import QtQuick 2.2

Item {
    id: animator

    property Item overlay
    property QtObject webView
    property bool portrait
    property bool atTop
    property bool atMiddle
    property bool atBottom: true
    property int transitionDuration: !_immediate ? 400 : 0
    property real openYPosition: portrait ? overlay.toolBar.toolsHeight : 0

    property bool active
    readonly property bool allowContentUse: state === "chromeVisible" || state === "fullscreenWebPage" || state === "doubleToolBar"
    readonly property bool dragging: state === "draggingOverlay"
    readonly property bool secondaryTools: state === "doubleToolBar"

    property bool _immediate

    function showSecondaryTools() {
        updateState("doubleToolBar")
    }

    function showChrome(immediate) {
        updateState("chromeVisible", immediate || false)
    }

    function showOverlay(immediate) {
        updateState("fullscreenOverlay", immediate || false)
    }

    function drag() {
        updateState("draggingOverlay")
    }

    function hide() {
        updateState("noOverlay")
    }

    // Wrapper from updating the state. Handy for debugging.
    function updateState(newState, immediate) {
        _immediate = immediate || false
        if (newState !== "fullscreenWebPage") {
            overlay.visible = true
        }

        state = newState
    }

    state: "chromeVisible"

    // TODO: Fix real cover. Once that is fixed, we should remove this block.
    onActiveChanged: {
        // When activating and state already changed to something else than
        // "fullscreenWebPage" we should not alter the state.
        // For instance "new-tab" cover action triggers this state change.
        if (active && (state !== "fullscreenWebPage" || webView.contentItem && webView.contentItem.fullscreen)) {
            return
        }

        if (active) {
            if (webView.completed && !webView.tabModel.waitingForNewTab && webView.tabModel.count === 0) {
                updateState("fullscreenOverlay", true)
            } else {
                updateState("chromeVisible", true)
            }
        } else if (webView.tabModel.count > 0) {
            updateState("fullscreenWebPage", true)
        }
    }

    onStateChanged: {
        // Animation end changes to true state. Hence not like atTop = state !== "fullscreenOverlay"
        if (state !== "fullscreenOverlay") {
            atTop = false
        } if (state !== "chromeVisible" && state !== "fullscreenWebPage" && state !== "doubleToolBar") {
            atBottom = false
        } if (state !== "loadProgressOverlay") {
            atMiddle = false
        }
    }

    Connections {
        target: webView
        ignoreUnknownSignals: true

        onFullscreenModeChanged: {
            if (!active) {<commit_msg>Remove unused atMiddle<commit_after>/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

import QtQuick 2.2

Item {
    id: animator

    property Item overlay
    property QtObject webView
    property bool portrait
    property bool atTop
    property bool atBottom: true
    property int transitionDuration: !_immediate ? 400 : 0
    property real openYPosition: portrait ? overlay.toolBar.toolsHeight : 0

    property bool active
    readonly property bool allowContentUse: state === "chromeVisible" || state === "fullscreenWebPage" || state === "doubleToolBar"
    readonly property bool dragging: state === "draggingOverlay"
    readonly property bool secondaryTools: state === "doubleToolBar"

    property bool _immediate

    function showSecondaryTools() {
        updateState("doubleToolBar")
    }

    function showChrome(immediate) {
        updateState("chromeVisible", immediate || false)
    }

    function showOverlay(immediate) {
        updateState("fullscreenOverlay", immediate || false)
    }

    function drag() {
        updateState("draggingOverlay")
    }

    function hide() {
        updateState("noOverlay")
    }

    // Wrapper from updating the state. Handy for debugging.
    function updateState(newState, immediate) {
        _immediate = immediate || false
        if (newState !== "fullscreenWebPage") {
            overlay.visible = true
        }

        state = newState
    }

    state: "chromeVisible"

    // TODO: Fix real cover. Once that is fixed, we should remove this block.
    onActiveChanged: {
        // When activating and state already changed to something else than
        // "fullscreenWebPage" we should not alter the state.
        // For instance "new-tab" cover action triggers this state change.
        if (active && (state !== "fullscreenWebPage" || webView.contentItem && webView.contentItem.fullscreen)) {
            return
        }

        if (active) {
            if (webView.completed && !webView.tabModel.waitingForNewTab && webView.tabModel.count === 0) {
                updateState("fullscreenOverlay", true)
            } else {
                updateState("chromeVisible", true)
            }
        } else if (webView.tabModel.count > 0) {
            updateState("fullscreenWebPage", true)
        }
    }

    onStateChanged: {
        // Animation end changes to true state. Hence not like atTop = state !== "fullscreenOverlay"
        if (state !== "fullscreenOverlay") {
            atTop = false
        } if (state !== "chromeVisible" && state !== "fullscreenWebPage" && state !== "doubleToolBar") {
            atBottom = false
        }
    }

    Connections {
        target: webView
        ignoreUnknownSignals: true

        onFullscreenModeChanged: {
            if (!active) {
{'fraction_non_alphanumeric': 0.14343623323978796, 'fraction_numerical': 0.005300904271905207, 'mean_word_length': 2.6140845070422536, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6875386', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1599, 'n_words': 504}