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

improve tabs performance and UI with this one simple trick #10691

Merged
merged 28 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fc67d61
remove tab styles file, move styles to their respective tab components
cezaraugusto Sep 11, 2017
49bfbdc
move AudioTabIcon visibility logic to its component
cezaraugusto Sep 11, 2017
7363665
move Favicon visibility logic to its component
cezaraugusto Sep 11, 2017
0b1e1fb
move TabTitle visibility logic to its component
cezaraugusto Sep 11, 2017
c516c70
move PrivateIcon visibility logic to its component
cezaraugusto Sep 11, 2017
46210dd
move NewSessionIcon visibility logic to its component
cezaraugusto Sep 11, 2017
7c240ee
change state helper name from tabContentState to tabUIState
cezaraugusto Sep 11, 2017
bbde7ac
split tabUIState helpers to its own state helper files
cezaraugusto Sep 11, 2017
43b404f
implements the observerUtil
cezaraugusto Sep 11, 2017
0cb7474
add new state helpers for the closeTabIcon
cezaraugusto Sep 11, 2017
22b9283
add new state helpers for the private tab
cezaraugusto Sep 11, 2017
83818cf
add new state helpers for the partition tab (new session)
cezaraugusto Sep 11, 2017
c4f89b8
add new state helpers for the audible tab (tabs w/ audio indicator)
cezaraugusto Sep 11, 2017
2c3168c
add new state helpers for the tab title
cezaraugusto Sep 11, 2017
faa87be
add new state helpers for the favicon
cezaraugusto Sep 11, 2017
23b57f4
add methods for tabUIState: handles helpers only for the UI state
cezaraugusto Sep 11, 2017
2de3e63
replace legacy logic with brand new TabTitle state logic
cezaraugusto Sep 12, 2017
1be528e
replace legacy logic with brand new Favicon state logic
cezaraugusto Sep 12, 2017
aeb3aee
add support for theme.js
cezaraugusto Sep 12, 2017
2c0f0dc
replace legacy logic with brand new CloseTabIcon state logic
cezaraugusto Sep 12, 2017
5c10031
replace legacy logic with brand new AudioTabIcon state logic
cezaraugusto Sep 12, 2017
4d300ac
replace legacy logic with brand new PrivateIcon state logic
cezaraugusto Sep 12, 2017
e7820d1
replace legacy logic with brand new NewSessionIcon state logic
cezaraugusto Sep 12, 2017
f17046d
clean-up: remove legacy/deprecated methods
cezaraugusto Sep 13, 2017
321281b
UI bug fixing
cezaraugusto Sep 13, 2017
80af744
add gradient layer to mimic current title gradient
cezaraugusto Sep 14, 2017
c3def82
do not allow previews if tab is being dragged
cezaraugusto Sep 15, 2017
33c5d10
add smooth animation transitions to tab content
cezaraugusto Sep 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 0 additions & 189 deletions app/common/state/tabContentState.js

This file was deleted.

56 changes: 56 additions & 0 deletions app/common/state/tabContentState/audioState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* 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/. */

// State helpers
const frameStateUtil = require('../../../../js/state/frameStateUtil')

// Utils
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil')

module.exports.canPlayAudio = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return frame.get('audioPlaybackActive') || frame.get('audioMuted')
}

module.exports.isAudioMuted = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

const tabCanPlayAudio = module.exports.canPlayAudio(state, frameKey)
return tabCanPlayAudio && frame.get('audioMuted')
}

module.exports.showAudioIcon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return (
!isEntryIntersected(state, 'tabs') &&
module.exports.canPlayAudio(state, frameKey)
)
}

module.exports.showAudioTopBorder = (state, frameKey, isPinned) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return (
module.exports.canPlayAudio(state, frameKey) &&
(isEntryIntersected(state, 'tabs') || isPinned)
)
}
52 changes: 52 additions & 0 deletions app/common/state/tabContentState/closeState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* 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/. */

// State helpers
const frameStateUtil = require('../../../../js/state/frameStateUtil')

// Utils
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil')

// Styles
const {intersection} = require('../../../renderer/components/styles/global')

module.exports.hasFixedCloseIcon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return (
frameStateUtil.isFrameKeyActive(state, frameKey) &&
isEntryIntersected(state, 'tabs', intersection.at75)
)
}

module.exports.hasRelativeCloseIcon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return (
frameStateUtil.getTabHoverState(state, frameKey) &&
!isEntryIntersected(state, 'tabs', intersection.at75)
)
}

module.exports.showCloseTabIcon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return !isEntryIntersected(state, 'tabs', intersection.at20) &&
(
module.exports.hasRelativeCloseIcon(state, frameKey) ||
module.exports.hasFixedCloseIcon(state, frameKey)
)
}
87 changes: 87 additions & 0 deletions app/common/state/tabContentState/faviconState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* 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/. */

// Utils
const {isSourceAboutUrl} = require('../../../../js/lib/appUrlUtil')
const frameStateUtil = require('../../../../js/state/frameStateUtil')
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil')

// Styles
const {intersection} = require('../../../renderer/components/styles/global')

module.exports.showFavicon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

const isNewTabPage = frameStateUtil.frameLocationMatch(frame, 'about:newtab')

if (isEntryIntersected(state, 'tabs', intersection.at40)) {
// do not show it at all at minimum ratio (intersection.at12)
if (isEntryIntersected(state, 'tabs', intersection.at12)) {
return false
}

return (
// when almost all tab content is covered,
// only show favicon if there's no closeIcon (intersection.at20)
// or otherwise only for the non-active tab
isEntryIntersected(state, 'tabs', intersection.at20) ||
!frameStateUtil.isFrameKeyActive(state, frameKey)
)
}

// new tab page is the only tab we do not show favicon
return !isNewTabPage
}

module.exports.getFavicon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)
const isLoadingVisible = module.exports.showLoadingIcon(state, frameKey)

if (frame == null) {
return ''
}

return !isLoadingVisible && frame.get('icon')
}

module.exports.showLoadingIcon = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

if (frame.get('loading') == null) {
return false
}

return (
!isSourceAboutUrl(frame.get('location')) &&
frame.get('loading')
)
}

module.exports.showIconWithLessMargin = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return isEntryIntersected(state, 'tabs', intersection.at30)
}

module.exports.showFaviconAtReducedSize = (state, frameKey) => {
const frame = frameStateUtil.getFrameByKey(state, frameKey)

if (frame == null) {
return false
}

return isEntryIntersected(state, 'tabs', intersection.at20)
}
Loading