This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve performance for tabs, include intersectionObserver
fix #10611 fix #10582 fix #10544 fix #10509 fix #10123 fix #9998 fix #9398 fix #8414 fix #7925 fix #7730 fix #7301 fix #6957
- Loading branch information
1 parent
661ef90
commit 7660913
Showing
29 changed files
with
961 additions
and
707 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* 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 {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil') | ||
const {getFrameByKey} = require('../../../../js/state/frameStateUtil') | ||
|
||
module.exports.canPlayAudio = (state, frameKey) => { | ||
const frame = getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return false | ||
} | ||
|
||
return frame.get('audioPlaybackActive') || frame.get('audioMuted') | ||
} | ||
|
||
module.exports.isAudioMuted = (state, frameKey) => { | ||
const frame = 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 = 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 = getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return false | ||
} | ||
|
||
return ( | ||
module.exports.canPlayAudio(state, frameKey) && | ||
(isEntryIntersected(state, 'tabs') || isPinned) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* 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 frameStateUtil = require('../../../../js/state/frameStateUtil') | ||
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil') | ||
const {isSourceAboutUrl} = require('../../../../js/lib/appUrlUtil') | ||
|
||
// 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 = frame.get('location') === 'about:newtab' | ||
|
||
if (isEntryIntersected(state, 'tabs', intersection.at35)) { | ||
// when almost all tab content is covered, | ||
// only show favicon for the non-active tab | ||
return !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 | ||
} | ||
|
||
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.at20) | ||
} | ||
|
||
module.exports.showFaviconAtReducedSize = (state, frameKey) => { | ||
const frame = frameStateUtil.getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return false | ||
} | ||
|
||
return isEntryIntersected(state, 'tabs', intersection.at15) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* 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 | ||
const frameStateUtil = require('../../../../js/state/frameStateUtil') | ||
|
||
// Constants | ||
const {tabs} = require('../../../../js/constants/config') | ||
|
||
module.exports.isPartitionTab = (state, frameKey) => { | ||
const frame = frameStateUtil.getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return false | ||
} | ||
|
||
return !!frame.get('partitionNumber') | ||
} | ||
|
||
module.exports.getPartitionNumber = (state, frameKey) => { | ||
const frame = frameStateUtil.getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return 0 | ||
} | ||
|
||
if (typeof frame.get('partitionNumber') === 'string') { | ||
return frame.get('partitionNumber').replace(/^partition-/i, '') | ||
} | ||
return frame.get('partitionNumber') | ||
} | ||
|
||
module.exports.getMaxAllowedPartitionNumber = (state, frameKey) => { | ||
const frame = frameStateUtil.getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return 0 | ||
} | ||
|
||
const partitionNumber = module.exports.getPartitionNumber(state, frameKey) | ||
|
||
if (partitionNumber > tabs.maxAllowedNewSessions) { | ||
return tabs.maxAllowedNewSessions | ||
} | ||
return partitionNumber | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* 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 | ||
const frameStateUtil = require('../../../../js/state/frameStateUtil') | ||
|
||
module.exports.isPrivateTab = (state, frameKey) => { | ||
const frame = frameStateUtil.getFrameByKey(state, frameKey) | ||
|
||
if (frame == null) { | ||
return false | ||
} | ||
|
||
return !!frame.get('isPrivate') | ||
} |
Oops, something went wrong.