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

Commit 633ab0a

Browse files
committed
clean-up: remove legacy/deprecated methods
Auditors: @bsclifton Test plan: `npm run unittest`
1 parent cb2cfa1 commit 633ab0a

File tree

12 files changed

+4
-343
lines changed

12 files changed

+4
-343
lines changed

app/common/state/tabContentState/closeState.js

-34
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,10 @@ const frameStateUtil = require('../../../../js/state/frameStateUtil')
77

88
// Utils
99
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil')
10-
const {hasBreakpoint} = require('../../../renderer/lib/tabUtil')
1110

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

15-
/**
16-
* Check whether or not closeTab icon is always visible (fixed) in tab
17-
*/
18-
module.exports.deprecatedHasFixedCloseIcon = (state, frameKey) => {
19-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
20-
const isActive = frameStateUtil.isFrameKeyActive(state, frameKey)
21-
22-
if (frame == null) {
23-
return false
24-
}
25-
26-
return (
27-
isActive &&
28-
// Larger sizes still have a relative closeIcon
29-
// We don't resize closeIcon as we do with favicon so don't show it (smallest)
30-
!hasBreakpoint(frame.get('breakpoint'), ['dynamic', 'default', 'large', 'smallest'])
31-
)
32-
}
33-
34-
/**
35-
* Check whether or not closeTab icon is relative to hover state
36-
*/
37-
module.exports.deprecatedHasRelativeCloseIcon = (state, frameKey) => {
38-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
39-
40-
if (frame == null) {
41-
return false
42-
}
43-
44-
return frameStateUtil.getTabHoverState(state, frameKey) &&
45-
hasBreakpoint(frame.get('breakpoint'), ['dynamic', 'default', 'large'])
46-
}
47-
4814
module.exports.hasFixedCloseIcon = (state, frameKey) => {
4915
const frame = frameStateUtil.getFrameByKey(state, frameKey)
5016

app/common/state/tabContentState/faviconState.js

-21
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,9 @@ const {isSourceAboutUrl} = require('../../../../js/lib/appUrlUtil')
77
const frameStateUtil = require('../../../../js/state/frameStateUtil')
88
const {isEntryIntersected} = require('../../../../app/renderer/lib/observerUtil')
99

10-
// TODO deprecate
11-
const {braveExtensionId} = require('../../../../js/constants/config')
12-
1310
// Styles
1411
const {intersection} = require('../../../renderer/components/styles/global')
1512

16-
// TODO deprecate
17-
module.exports.deprecatedIsTabLoading = (state, frameKey) => {
18-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
19-
20-
if (frame == null) {
21-
return false
22-
}
23-
24-
return (
25-
frame.get('loading') ||
26-
frame.get('location') === 'about:blank'
27-
) &&
28-
(
29-
!frame.get('provisionalLocation') ||
30-
!frame.get('provisionalLocation').startsWith(`chrome-extension://${braveExtensionId}/`)
31-
)
32-
}
33-
3413
module.exports.showFavicon = (state, frameKey) => {
3514
const frame = frameStateUtil.getFrameByKey(state, frameKey)
3615

app/common/state/tabUIState.js

-58
Original file line numberDiff line numberDiff line change
@@ -12,70 +12,12 @@ const frameStateUtil = require('../../../js/state/frameStateUtil')
1212
// Utils
1313
const {isEntryIntersected} = require('../../../app/renderer/lib/observerUtil')
1414
const {getTextColorForBackground} = require('../../../js/lib/color')
15-
const {hasBreakpoint} = require('../../renderer/lib/tabUtil') // TODO deprecate
1615

1716
// Settings
1817
const {getSetting} = require('../../../js/settings')
1918

2019
// Styles
2120
const {intersection} = require('../../renderer/components/styles/global')
22-
// const {theme} = require('../../renderer/components/styles/theme')
23-
24-
// ///////////////////////////////////////////
25-
// methods to deprecate after the observer
26-
// ///////////////////////////////////////////
27-
28-
module.exports.hasTabInFullScreen = (state) => {
29-
return state.get('frames')
30-
.map((frame) => frame.get('isFullScreen'))
31-
.some(fullScreenMode => fullScreenMode === true)
32-
}
33-
34-
module.exports.isMediumView = (state, frameKey) => {
35-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
36-
return frame
37-
? ['large', 'largeMedium'].includes(frame.get('breakpoint'))
38-
: false
39-
}
40-
41-
module.exports.isNarrowView = (state, frameKey) => {
42-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
43-
return frame
44-
? ['medium', 'mediumSmall', 'small', 'extraSmall', 'smallest'].includes(frame.get('breakpoint'))
45-
: false
46-
}
47-
48-
module.exports.isNarrowestView = (state, frameKey) => {
49-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
50-
return frame
51-
? ['extraSmall', 'smallest'].includes(frame.get('breakpoint'))
52-
: false
53-
}
54-
55-
/**
56-
* Check whether or not private or newSession icon should be visible
57-
*/
58-
module.exports.hasVisibleSecondaryIcon = (state, frameKey) => {
59-
const frame = frameStateUtil.getFrameByKey(state, frameKey)
60-
61-
if (frame == null) {
62-
return false
63-
}
64-
65-
return (
66-
// Hide icon on hover
67-
!closeState.deprecatedHasRelativeCloseIcon(state, frameKey) &&
68-
// If closeIcon is fixed then there's no room for another icon
69-
!closeState.deprecatedHasFixedCloseIcon(state, frameKey) &&
70-
// completely hide it for small sizes
71-
!hasBreakpoint(frame.get('breakpoint'),
72-
['medium', 'mediumSmall', 'small', 'extraSmall', 'smallest'])
73-
)
74-
}
75-
76-
// ///////////////////////////////////////////
77-
// end of methods to deprecate
78-
// ///////////////////////////////////////////
7921

8022
module.exports.getThemeColor = (state, frameKey) => {
8123
const frame = frameStateUtil.getFrameByKey(state, frameKey)

app/renderer/components/styles/global.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,7 @@ const globalStyles = {
2525
breakpointExtensionButtonPadding: '720px',
2626
breakpointSmallWin32: '650px',
2727
breakpointTinyWin32: '500px',
28-
breakpointNewPrivateTab: '890px',
29-
tab: {
30-
dynamic: '99999px', // add a large number as new spec will set tab width based on window size
31-
default: '184px', // match tabArea max-width
32-
large: '120px',
33-
largeMedium: '83px',
34-
medium: '66px',
35-
mediumSmall: '53px',
36-
small: '46px',
37-
extraSmall: '40px',
38-
smallest: '19px'
39-
}
28+
breakpointNewPrivateTab: '890px'
4029
},
4130
intersection: {
4231
// whereas 1 === 100%

app/renderer/components/tabs/tab.js

+3-106
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ const {getTextColorForBackground} = require('../../../../js/lib/color')
4040
const {isIntermediateAboutPage} = require('../../../../js/lib/appUrlUtil')
4141
const contextMenus = require('../../../../js/contextMenus')
4242
const dnd = require('../../../../js/dnd')
43-
const throttle = require('../../../../js/lib/throttle')
4443
const frameStateUtil = require('../../../../js/state/frameStateUtil')
45-
const {
46-
getTabBreakpoint,
47-
tabUpdateFrameRate,
48-
hasTabAsRelatedTarget
49-
} = require('../../lib/tabUtil')
44+
const {hasTabAsRelatedTarget} = require('../../lib/tabUtil')
5045
const isWindows = require('../../../common/lib/platformUtil').isWindows()
5146
const {getCurrentWindowId} = require('../../currentWindow')
5247
const {setObserver} = require('../../lib/observerUtil')
@@ -58,7 +53,6 @@ class Tab extends React.Component {
5853
this.onMouseMove = this.onMouseMove.bind(this)
5954
this.onMouseEnter = this.onMouseEnter.bind(this)
6055
this.onMouseLeave = this.onMouseLeave.bind(this)
61-
this.onUpdateTabSize = this.onUpdateTabSize.bind(this)
6256
this.onDragStart = this.onDragStart.bind(this)
6357
this.onDragEnd = this.onDragEnd.bind(this)
6458
this.onDragOver = this.onDragOver.bind(this)
@@ -191,22 +185,6 @@ class Tab extends React.Component {
191185
}
192186
}
193187

194-
get tabSize () {
195-
const tab = this.tabNode
196-
// Avoid TypeError keeping it null until component is mounted
197-
return tab && !this.props.isPinnedTab ? tab.getBoundingClientRect().width : null
198-
}
199-
200-
onUpdateTabSize () {
201-
const currentSize = getTabBreakpoint(this.tabSize)
202-
// Avoid updating breakpoint when user enters fullscreen (see #7301)
203-
// Also there can be a race condition for pinned tabs if we update when not needed
204-
// since a new tab component with the same key gets created which is not pinned.
205-
if (this.props.breakpoint !== currentSize && !this.props.hasTabInFullScreen) {
206-
windowActions.setTabBreakpoint(this.props.frameKey, currentSize)
207-
}
208-
}
209-
210188
componentDidMount () {
211189
// do not observe pinned tabs
212190
if (this.props.isPinned) {
@@ -219,9 +197,7 @@ class Tab extends React.Component {
219197
this.observer = setObserver(this.tabSentinel, threshold, margin, this.onObserve)
220198
this.observer.observe(this.tabSentinel)
221199

222-
this.onUpdateTabSize() // TODO: this will be depreacated
223200
this.tabNode.addEventListener('auxclick', this.onAuxClick.bind(this))
224-
window.addEventListener('resize', throttle(this.onUpdateTabSize, tabUpdateFrameRate), { passive: true })
225201
}
226202

227203
componentDidUpdate () {
@@ -230,12 +206,10 @@ class Tab extends React.Component {
230206
if (this.props.isPinnedTab) {
231207
this.observer.unobserve(this.tabSentinel)
232208
}
233-
this.onUpdateTabSize() // TODO: deprecate
234209
}
235210

236211
componentWillUnmount () {
237212
this.observer.unobserve(this.tabSentinel)
238-
window.removeEventListener('resize', this.onUpdateTabSize)
239213
}
240214

241215
onObserve (entries) {
@@ -270,23 +244,18 @@ class Tab extends React.Component {
270244
// used in renderer
271245
props.frameKey = ownProps.frameKey
272246
props.isPrivateTab = frame.get('isPrivate')
273-
props.breakpoint = frame.get('breakpoint')
274247
props.notificationBarActive = notificationBarActive
275248
props.isActive = frameStateUtil.isFrameKeyActive(currentWindow, props.frameKey)
276249
props.tabWidth = currentWindow.getIn(['ui', 'tabs', 'fixTabWidth'])
277250
props.isPinnedTab = tabState.isTabPinned(state, tabId)
278251
props.canPlayAudio = audioState.canPlayAudio(currentWindow, props.frameKey)
279252
props.themeColor = tabUIState.getThemeColor(currentWindow, props.frameKey)
280-
props.isNarrowView = tabUIState.isNarrowView(currentWindow, props.frameKey)
281-
props.isNarrowestView = tabUIState.isNarrowestView(currentWindow, props.frameKey)
282-
props.isPlayIndicatorBreakpoint = tabUIState.isMediumView(currentWindow, props.frameKey) || props.isNarrowView
283253
props.title = frame.get('title')
284254
props.partOfFullPageSet = ownProps.partOfFullPageSet
285255

286256
// used in other functions
287257
props.totalTabs = state.get('tabs').size
288258
props.dragData = state.getIn(['dragData', 'type']) === dragTypes.TAB && state.get('dragData')
289-
props.hasTabInFullScreen = tabUIState.hasTabInFullScreen(currentWindow)
290259
props.tabId = tabId
291260
props.previewMode = currentWindow.getIn(['ui', 'tabs', 'previewMode'])
292261

@@ -335,19 +304,12 @@ class Tab extends React.Component {
335304
isWindows && styles.tabForWindows,
336305
this.props.isPinnedTab && styles.isPinned,
337306
this.props.isActive && styles.active,
338-
this.props.isPlayIndicatorBreakpoint && this.props.canPlayAudio && styles.narrowViewPlayIndicator,
339307
this.props.isActive && this.props.themeColor && perPageStyles.themeColor,
340308
// Private color should override themeColor
341309
this.props.isPrivateTab && styles.private,
342-
this.props.isActive && this.props.isPrivateTab && styles.activePrivateTab,
343-
!this.props.isPinnedTab && this.props.isNarrowView && styles.tabNarrowView,
344-
!this.props.isPinnedTab && this.props.isNarrowestView && styles.tabNarrowestView,
345-
!this.props.isPinnedTab && this.props.breakpoint === 'smallest' && styles.tabMinAllowedSize
310+
this.props.isActive && this.props.isPrivateTab && styles.activePrivateTab
346311
)}
347312
data-test-id='tab'
348-
data-test-active-tab={this.props.isActive}
349-
data-test-pinned-tab={this.props.isPinnedTab}
350-
data-test-private-tab={this.props.isPrivateTab}
351313
data-frame-key={this.props.frameKey}
352314
draggable
353315
title={this.props.title}
@@ -361,11 +323,7 @@ class Tab extends React.Component {
361323
ref={(node) => { this.tabSentinel = node }}
362324
className={css(styles.tab__sentinel)}
363325
/>
364-
<div className={css(
365-
styles.tabId,
366-
this.props.isNarrowView && styles.tabIdNarrowView,
367-
this.props.breakpoint === 'smallest' && styles.tabIdMinAllowedSize
368-
)}>
326+
<div className={css(styles.tabId)}>
369327
<Favicon tabId={this.props.tabId} />
370328
<AudioTabIcon tabId={this.props.tabId} />
371329
<TabTitle tabId={this.props.tabId} />
@@ -422,44 +380,6 @@ const styles = StyleSheet.create({
422380
width: globalStyles.spacing.sentinelSize
423381
},
424382

425-
// Custom classes based on tab's width and behaviour
426-
tabNarrowView: {
427-
padding: '0 2px'
428-
},
429-
430-
narrowViewPlayIndicator: {
431-
'::before': {
432-
content: `''`,
433-
display: 'block',
434-
position: 'absolute',
435-
top: 0,
436-
left: 0,
437-
right: 0,
438-
height: '2px',
439-
background: 'lightskyblue'
440-
}
441-
},
442-
443-
tabNarrowestView: {
444-
justifyContent: 'center'
445-
},
446-
447-
tabMinAllowedSize: {
448-
padding: 0
449-
},
450-
451-
tabIdNarrowView: {
452-
flex: 'inherit'
453-
},
454-
455-
tabIdMinAllowedSize: {
456-
overflow: 'hidden'
457-
},
458-
459-
alternativePlayIndicator: {
460-
borderTop: '2px solid lightskyblue'
461-
},
462-
463383
tabId: {
464384
justifyContent: 'center',
465385
alignItems: 'center',
@@ -514,29 +434,6 @@ const styles = StyleSheet.create({
514434
opacity: '0'
515435
}
516436
}
517-
},
518-
519-
icon: {
520-
width: globalStyles.spacing.iconSize,
521-
minWidth: globalStyles.spacing.iconSize,
522-
height: globalStyles.spacing.iconSize,
523-
backgroundSize: globalStyles.spacing.iconSize,
524-
fontSize: globalStyles.fontSize.tabIcon,
525-
backgroundPosition: 'center',
526-
backgroundRepeat: 'no-repeat',
527-
paddingLeft: globalStyles.spacing.defaultIconPadding,
528-
paddingRight: globalStyles.spacing.defaultIconPadding
529-
},
530-
531-
icon_audio: {
532-
color: globalStyles.color.highlightBlue,
533-
534-
// 16px
535-
fontSize: `calc(${globalStyles.fontSize.tabIcon} + 2px)`,
536-
537-
// equal spacing around audio icon (favicon and tabTitle)
538-
padding: globalStyles.spacing.defaultTabPadding,
539-
paddingRight: '0 !important'
540437
}
541438
})
542439

0 commit comments

Comments
 (0)