<commit_before>/****************************************************************************
**
** Copyright (C) 2013 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.0
import Sailfish.Silica 1.0
import Sailfish.Browser 1.0
import "components" as Browser


Page {
    id: browserPage

    property Item firstUseOverlay
    property Item debug
    property alias firstUseFullscreen: webView.firstUseFullscreen
    property Component tabPageComponent

    property alias tabs: webView.tabModel
    property alias favorites: favoriteModel
    property alias history: historyModel
    property alias viewLoading: webView.loading
    property alias url: webView.url
    property alias title: webView.title
    property alias thumbnailPath: webView.thumbnailPath

    property alias imageLoader: imageLoader
    property alias desktopBookmarkWriter: desktopBookmarkWriter
    property alias webView: webView

    function load(url, title) {
        webView.load(url, title)
    }

    // Safety clipping. There is clipping in ApplicationWindow that should react upon focus changes.
    // This clipping can handle also clipping of QmlMozView. When this page is active we do not need to clip
    // if input method is not visible.
    clip: status != PageStatus.Active || webView.inputPanelVisible

    orientationTransitions: Transition {
        to: 'Portrait,Landscape,LandscapeInverted'
        from: 'Portrait,Landscape,LandscapeInverted'
        SequentialAnimation {
            PropertyAction {
                target: browserPage
                property: 'orientationTransitionRunning'
                value: true
            }
            ParallelAnimation {
                FadeAnimation {
                    target: webView.contentItem
                    to: 0
                    duration: 150
                }
                FadeAnimation {
                    target: !webView.fullscreenMode ? controlArea : null
                    to: 0
                    duration: 150
                }
            }
            PropertyAction {
                target: browserPage
                properties: 'width,height,rotation,orientation'
            }
            ScriptAction {
                script: {
                    // Restores the Bindings to width, height and rotation
                    _defaultTransition = false
                    webView.resetHeight()
                    _defaultTransition = true
                }
            }
            FadeAnimation {
                target: !webView.fullscreenMode ? controlArea : null
                to: 1
                duration: 150
            }
            // End-2-end implementation for OnUpdateDisplayPort should
            // give better solution and reduce visible relayoutting.
            FadeAnimation {
                target: webView.contentItem
                to: 1
                duration: 850
            }
            PropertyAction {
                target: browserPage
                property: 'orientationTransitionRunning'
                value: false
            }
        }
    }

    onStatusChanged: {
        if (status === PageStatus.Inactive) {
            MozContext.sendObserve("memory-pressure", null)
        }
    }

    HistoryModel {
        id: historyModel
    }

    Browser.DownloadRemorsePopup { id: downloadPopup }
    Browser.WebView {
        id: webView

        visible: WebUtils.firstUseDone
        active: browserPage.status === PageStatus.Active
        toolbarHeight: toolBarContainer.height
        fullscreenHeight: portrait ? Screen.height : Screen.width
        portrait: browserPage.isPortrait
        maxLiveTabCount: 3

        tabModel.onCountChanged: {
            if (tabModel.count === 0 && browserPage.status === PageStatus.Active) {
                pageStack.push(tabPageComponent ? tabPageComponent : Qt.resolvedUrl("TabPage.qml"), {"browserPage" : browserPage, "initialSearchFocus": true })
            }
        }

        clip: true
        // TODO: once we get rid of bad rendering loop, check if we could use here parent.height
        // instead of fullscreenHeight. Currently with parent.height binding we skip
        // frames when returning back from tab page so that virtual keyboard was open.
        height: fullscreenHeight - (fullscreenMode ? 0 : toolBarContainer.height)

        Behavior on height {
            enabled: !browserPage.orientationTransitionRunning
            NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
        }
    }

    // TODO: This will change once toolbar can be pulled up.
    Column {
        id: controlArea

        z: 1
        y: webView.height
        width: parent.width
        visible: !webView.popupActive

        function openTabPage(focus, newTab, operationType) {
            if (browserPage.status === PageStatus.Active) {
                webView.captureScreen()
                pageStack.push(tabPageComponent ? tabPageComponent : Qt.resolvedUrl("TabPage.qml"),
                                                  {
                                                      "browserPage" : browserPage,
                                                      "initialSearchFocus": focus,
                                                      "newTab": newTab
                                                  }, operationType)
            }
        }

        Browser.ToolBarContainer {
            id: toolBarContainer
            width: parent.width
            enabled: !webView.fullscreenMode

            Browser.ProgressBar {
                id: progressBar
                anchors.fill: parent
                visible: !firstUseOverlay
                opacity: webView.loading ? 1.0 : 0.0<commit_msg>Make toolbar invisible when in fullscreen mode.<commit_after>/****************************************************************************
**
** Copyright (C) 2013 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.0
import Sailfish.Silica 1.0
import Sailfish.Browser 1.0
import "components" as Browser


Page {
    id: browserPage

    property Item firstUseOverlay
    property Item debug
    property alias firstUseFullscreen: webView.firstUseFullscreen
    property Component tabPageComponent

    property alias tabs: webView.tabModel
    property alias favorites: favoriteModel
    property alias history: historyModel
    property alias viewLoading: webView.loading
    property alias url: webView.url
    property alias title: webView.title
    property alias thumbnailPath: webView.thumbnailPath

    property alias imageLoader: imageLoader
    property alias desktopBookmarkWriter: desktopBookmarkWriter
    property alias webView: webView

    function load(url, title) {
        webView.load(url, title)
    }

    // Safety clipping. There is clipping in ApplicationWindow that should react upon focus changes.
    // This clipping can handle also clipping of QmlMozView. When this page is active we do not need to clip
    // if input method is not visible.
    clip: status != PageStatus.Active || webView.inputPanelVisible

    orientationTransitions: Transition {
        to: 'Portrait,Landscape,LandscapeInverted'
        from: 'Portrait,Landscape,LandscapeInverted'
        SequentialAnimation {
            PropertyAction {
                target: browserPage
                property: 'orientationTransitionRunning'
                value: true
            }
            ParallelAnimation {
                FadeAnimation {
                    target: webView.contentItem
                    to: 0
                    duration: 150
                }
                FadeAnimation {
                    target: !webView.fullscreenMode ? controlArea : null
                    to: 0
                    duration: 150
                }
            }
            PropertyAction {
                target: browserPage
                properties: 'width,height,rotation,orientation'
            }
            ScriptAction {
                script: {
                    // Restores the Bindings to width, height and rotation
                    _defaultTransition = false
                    webView.resetHeight()
                    _defaultTransition = true
                }
            }
            FadeAnimation {
                target: !webView.fullscreenMode ? controlArea : null
                to: 1
                duration: 150
            }
            // End-2-end implementation for OnUpdateDisplayPort should
            // give better solution and reduce visible relayoutting.
            FadeAnimation {
                target: webView.contentItem
                to: 1
                duration: 850
            }
            PropertyAction {
                target: browserPage
                property: 'orientationTransitionRunning'
                value: false
            }
        }
    }

    onStatusChanged: {
        if (status === PageStatus.Inactive) {
            MozContext.sendObserve("memory-pressure", null)
        }
    }

    HistoryModel {
        id: historyModel
    }

    Browser.DownloadRemorsePopup { id: downloadPopup }
    Browser.WebView {
        id: webView

        visible: WebUtils.firstUseDone
        active: browserPage.status === PageStatus.Active
        toolbarHeight: toolBarContainer.height
        fullscreenHeight: portrait ? Screen.height : Screen.width
        portrait: browserPage.isPortrait
        maxLiveTabCount: 3

        tabModel.onCountChanged: {
            if (tabModel.count === 0 && browserPage.status === PageStatus.Active) {
                pageStack.push(tabPageComponent ? tabPageComponent : Qt.resolvedUrl("TabPage.qml"), {"browserPage" : browserPage, "initialSearchFocus": true })
            }
        }

        clip: true
        // TODO: once we get rid of bad rendering loop, check if we could use here parent.height
        // instead of fullscreenHeight. Currently with parent.height binding we skip
        // frames when returning back from tab page so that virtual keyboard was open.
        height: fullscreenHeight - (fullscreenMode ? 0 : toolBarContainer.height)

        Behavior on height {
            enabled: !browserPage.orientationTransitionRunning
            NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
        }
    }

    // TODO: This will change once toolbar can be pulled up.
    Column {
        id: controlArea

        z: 1
        y: webView.height
        width: parent.width
        visible: !webView.popupActive && y < webView.fullscreenHeight

        function openTabPage(focus, newTab, operationType) {
            if (browserPage.status === PageStatus.Active) {
                webView.captureScreen()
                pageStack.push(tabPageComponent ? tabPageComponent : Qt.resolvedUrl("TabPage.qml"),
                                                  {
                                                      "browserPage" : browserPage,
                                                      "initialSearchFocus": focus,
                                                      "newTab": newTab
                                                  }, operationType)
            }
        }

        Browser.ToolBarContainer {
            id: toolBarContainer
            width: parent.width
            enabled: !webView.fullscreenMode

            Browser.ProgressBar {
                id: progressBar
                anchors.fill: parent
                visible: !firstUseOverlay
                opacity: webView.loading ? 1.0 : 0.0
{'fraction_non_alphanumeric': 0.08890175322527291, 'fraction_numerical': 0.006946741647370162, 'mean_word_length': 1.6975239794780281, 'pattern_counts': {'":': 6, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1520866', 'n_tokens_mistral': 2900, 'n_tokens_neox': 2676, 'n_words': 807}