From 58fbf816d454f4005aabb93aac62141852a3b6b3 Mon Sep 17 00:00:00 2001 From: bridiver Date: Fri, 26 Aug 2016 15:34:41 -0700 Subject: [PATCH] give webview focus on fullscreen fixes #3464 don't show findbar in webview fullscreen exit webview fullscreen on tab change auditors: @bbondy --- js/components/frame.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/js/components/frame.js b/js/components/frame.js index 071ce54b8eb..401620f7dee 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -20,6 +20,7 @@ const clipboard = global.require('electron').clipboard const FullScreenWarning = require('./fullScreenWarning') const debounce = require('../lib/debounce.js') const getSetting = require('../settings').getSetting +const config = require('../constants/config') const settings = require('../constants/settings') const FindBar = require('./findbar.js') const { aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isNavigatableAboutPage } = require('../lib/appUrlUtil') @@ -324,6 +325,19 @@ class Frame extends ImmutableComponent { } } + enterHtmlFullScreen () { + if (this.webview) { + this.webview.executeScriptInTab(config.braveExtensionId, 'document.documentElement.webkitRequestFullScreen()', {}) + this.webview.focus() + } + } + + exitHtmlFullScreen () { + if (this.webview) { + this.webview.executeScriptInTab(config.braveExtensionId, 'document.webkitExitFullscreen()', {}) + } + } + componentDidUpdate (prevProps, prevState) { const cb = () => { if (this.webRTCPolicy !== this.getWebRTCPolicy()) { @@ -337,11 +351,12 @@ class Frame extends ImmutableComponent { } // make sure the webview content updates to // match the fullscreen state of the frame - if (prevProps.isFullScreen !== this.props.isFullScreen) { - if (this.props.isFullScreen) { - this.webview.executeJavaScript('document.webkitRequestFullscreen()') + if (prevProps.isFullScreen !== this.props.isFullScreen || + (this.props.isFullScreen && !this.props.isActive)) { + if (this.props.isFullScreen && this.props.isActive) { + this.enterHtmlFullScreen() } else { - this.webview.executeJavaScript('document.webkitExitFullscreen()') + this.exitHtmlFullScreen() } } this.webview.setAudioMuted(this.props.audioMuted || false) @@ -1048,7 +1063,7 @@ class Frame extends ImmutableComponent { : null } { - this.props.findbarShown + this.props.findbarShown && !this.props.isFullScreen ?