Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
reliably activate titleMode based on mouse state
Browse files Browse the repository at this point in the history
Auditors: @bbondy
fix #9410
  • Loading branch information
cezaraugusto committed Jun 15, 2017
1 parent 20d570b commit d152013
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
2 changes: 0 additions & 2 deletions app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,6 @@ class Frame extends React.Component {
if (!this.frame.isEmpty()) {
windowActions.setNavigated(e.url, this.props.frameKey, false, this.props.tabId)
}
// force temporary url display for tabnapping protection
windowActions.setMouseInTitlebar(true)
})
this.webview.addEventListener('crashed', (e) => {
if (this.frame.isEmpty()) {
Expand Down
29 changes: 5 additions & 24 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const _ = require('underscore')
const cx = require('../../../../js/lib/classSet')
const eventUtil = require('../../../../js/lib/eventUtil')
const siteSettings = require('../../../../js/state/siteSettings')
const debounce = require('../../../../js/lib/debounce')
const {isSourceAboutUrl} = require('../../../../js/lib/appUrlUtil')
const {getCurrentWindowId, isMaximized, isFocused, isFullScreen} = require('../../currentWindow')
const {isDarwin, isWindows} = require('../../../common/lib/platformUtil')
Expand All @@ -88,7 +87,6 @@ class Main extends ImmutableComponent {
this.onTabContextMenu = this.onTabContextMenu.bind(this)
this.onFind = this.onFind.bind(this)
this.onFindHide = this.onFindHide.bind(this)
this.checkForTitleMode = debounce(this.checkForTitleMode.bind(this), 20)
this.resetAltMenuProcessing()
}
registerWindowLevelShortcuts () {
Expand Down Expand Up @@ -460,12 +458,6 @@ class Main extends ImmutableComponent {

this.loadSearchProviders()

window.addEventListener('mousemove', (e) => {
if (e.pageY !== this.pageY) {
this.pageY = e.pageY
this.checkForTitleMode()
}
})
window.addEventListener('focus', () => {
const activeFrame = frameStateUtil.getActiveFrame(self.props.windowState)
windowActions.setFocusedFrame(activeFrame)
Expand Down Expand Up @@ -508,21 +500,6 @@ class Main extends ImmutableComponent {
}
}

checkForTitleMode () {
const navigator = document.querySelector('.top')
// Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null
if (!navigator) {
return
}

const height = navigator.getBoundingClientRect().bottom
if (this.pageY < height && this.props.windowState.getIn(['ui', 'mouseInTitlebar']) !== true) {
windowActions.setMouseInTitlebar(true)
} else if (this.pageY === undefined || (this.pageY >= height && this.props.windowState.getIn(['ui', 'mouseInTitlebar']) !== false)) {
windowActions.setMouseInTitlebar(false)
}
}

onBraveMenu () {
const activeFrame = frameStateUtil.getActiveFrame(this.props.windowState)
if (shieldState.braveShieldsEnabled(activeFrame)) {
Expand Down Expand Up @@ -717,7 +694,11 @@ class Main extends ImmutableComponent {
detail={this.props.windowState.get('popupWindowDetail')} />
: null
}
<div className='top'>
<div
className='top'
onMouseEnter={windowActions.setMouseInTitlebar.bind(null, true)}
onMouseLeave={windowActions.setMouseInTitlebar.bind(null, false)}
>
<Navigator />
{
siteInfoIsVisible
Expand Down

0 comments on commit d152013

Please sign in to comment.