Skip to content

Commit 9ea64a8

Browse files
committed
Remove panelLayoutGeneration.
We originally introduced this to resolve #1205 and #736, but these days it's not needed anymore because we have ResizeObservers in the relevant places.
1 parent 3448088 commit 9ea64a8

12 files changed

Lines changed: 10 additions & 128 deletions

File tree

src/actions/app.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ export function changeSidebarOpenState(tab: TabSlug, isOpen: boolean): Action {
109109
return { type: 'CHANGE_SIDEBAR_OPEN_STATE', tab, isOpen };
110110
}
111111

112-
export function invalidatePanelLayout(): Action {
113-
return { type: 'INCREMENT_PANEL_LAYOUT_GENERATION' as const };
114-
}
115-
116112
/**
117113
* The viewport component provides a hint to use shift to zoom scroll. The first
118114
* time a user does this, the hint goes away.

src/components/app/DetailsContainer.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import SplitterLayout from 'react-splitter-layout';
77
import { Details } from './Details';
88
import { selectSidebar } from 'firefox-profiler/components/sidebar';
99

10-
import { invalidatePanelLayout } from 'firefox-profiler/actions/app';
1110
import { getSelectedTab } from 'firefox-profiler/selectors/url-state';
1211
import { getIsSidebarOpen } from 'firefox-profiler/selectors/app';
1312
import explicitConnect from 'firefox-profiler/utils/connect';
@@ -22,39 +21,28 @@ type StateProps = {
2221
readonly isSidebarOpen: boolean;
2322
};
2423

25-
type DispatchProps = {
26-
readonly invalidatePanelLayout: typeof invalidatePanelLayout;
27-
};
28-
29-
type Props = ConnectedProps<{}, StateProps, DispatchProps>;
24+
type Props = ConnectedProps<{}, StateProps, {}>;
3025

31-
function DetailsContainerImpl({
32-
selectedTab,
33-
isSidebarOpen,
34-
invalidatePanelLayout,
35-
}: Props) {
26+
function DetailsContainerImpl({ selectedTab, isSidebarOpen }: Props) {
3627
const Sidebar = selectSidebar(selectedTab);
3728

3829
return (
3930
<SplitterLayout
4031
customClassName="DetailsContainer"
4132
percentage
4233
secondaryInitialSize={20}
43-
onDragEnd={invalidatePanelLayout}
4434
>
4535
<Details />
4636
{Sidebar && isSidebarOpen ? <Sidebar /> : null}
4737
</SplitterLayout>
4838
);
4939
}
5040

51-
export const DetailsContainer = explicitConnect<{}, StateProps, DispatchProps>({
41+
export const DetailsContainer = explicitConnect<{}, StateProps, {}>({
5242
mapStateToProps: (state) => ({
5343
selectedTab: getSelectedTab(state),
5444
isSidebarOpen: getIsSidebarOpen(state),
5545
}),
56-
mapDispatchToProps: {
57-
invalidatePanelLayout,
58-
},
46+
mapDispatchToProps: {},
5947
component: DetailsContainerImpl,
6048
});

src/components/app/ProfileViewer.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { returnToZipFileList } from 'firefox-profiler/actions/zipped-profiles';
2121
import { Timeline } from 'firefox-profiler/components/timeline';
2222
import { getHasZipFile } from 'firefox-profiler/selectors/zipped-profiles';
2323
import SplitterLayout from 'react-splitter-layout';
24-
import { invalidatePanelLayout } from 'firefox-profiler/actions/app';
2524
import { getTimelineHeight } from 'firefox-profiler/selectors/app';
2625
import { getIsBottomBoxOpen } from 'firefox-profiler/selectors/url-state';
2726
import {
@@ -54,7 +53,6 @@ type StateProps = {
5453

5554
type DispatchProps = {
5655
readonly returnToZipFileList: typeof returnToZipFileList;
57-
readonly invalidatePanelLayout: typeof invalidatePanelLayout;
5856
};
5957

6058
type Props = ConnectedProps<{}, StateProps, DispatchProps>;
@@ -64,7 +62,6 @@ class ProfileViewerImpl extends PureComponent<Props> {
6462
const {
6563
hasZipFile,
6664
returnToZipFileList,
67-
invalidatePanelLayout,
6865
timelineHeight,
6966
isUploading,
7067
uploadProgress,
@@ -136,7 +133,6 @@ class ProfileViewerImpl extends PureComponent<Props> {
136133
primaryIndex={1}
137134
// The Timeline is secondary.
138135
secondaryInitialSize={270}
139-
onDragEnd={invalidatePanelLayout}
140136
>
141137
<Timeline />
142138
<SplitterLayout
@@ -146,7 +142,6 @@ class ProfileViewerImpl extends PureComponent<Props> {
146142
primaryIndex={0}
147143
// The BottomBox is secondary.
148144
secondaryInitialSize={40}
149-
onDragEnd={invalidatePanelLayout}
150145
>
151146
<DetailsContainer />
152147
{isBottomBoxOpen ? <BottomBox /> : null}
@@ -178,7 +173,6 @@ export const ProfileViewer = explicitConnect<{}, StateProps, DispatchProps>({
178173
}),
179174
mapDispatchToProps: {
180175
returnToZipFileList,
181-
invalidatePanelLayout,
182176
},
183177
component: ProfileViewerImpl,
184178
});

src/components/shared/chart/Viewport.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import * as React from 'react';
66
import classNames from 'classnames';
77
import explicitConnect from 'firefox-profiler/utils/connect';
88
import { getResizeObserverWrapper } from 'firefox-profiler/utils/resize-observer-wrapper';
9-
import {
10-
getHasZoomedViaMousewheel,
11-
getPanelLayoutGeneration,
12-
} from 'firefox-profiler/selectors/app';
9+
import { getHasZoomedViaMousewheel } from 'firefox-profiler/selectors/app';
1310
import { setHasZoomedViaMousewheel } from 'firefox-profiler/actions/app';
1411
import { updatePreviewSelection } from 'firefox-profiler/actions/profile-view';
1512

@@ -132,7 +129,6 @@ export type Viewport = {
132129
};
133130

134131
type ChartViewportImplStateProps = {
135-
readonly panelLayoutGeneration: number;
136132
readonly hasZoomedViaMousewheel?: boolean;
137133
};
138134

@@ -316,10 +312,6 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
316312
this.setState({
317313
horizontalViewport,
318314
});
319-
} else if (
320-
this.props.panelLayoutGeneration !== newProps.panelLayoutGeneration
321-
) {
322-
this._setSizeNextFrame();
323315
}
324316
}
325317

@@ -871,7 +863,6 @@ export function withChartViewport<ChartProps>(
871863
ChartViewportImplDispatchProps
872864
>({
873865
mapStateToProps: (state) => ({
874-
panelLayoutGeneration: getPanelLayoutGeneration(state),
875866
hasZoomedViaMousewheel: getHasZoomedViaMousewheel(state),
876867
}),
877868
mapDispatchToProps: { setHasZoomedViaMousewheel, updatePreviewSelection },

src/components/timeline/FullTimeline.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
getGlobalTrackReferences,
2222
getTrackCount,
2323
getGlobalTrackOrder,
24-
getPanelLayoutGeneration,
2524
} from 'firefox-profiler/selectors';
2625
import { TimelineTrackContextMenu } from './TrackContextMenu';
2726

@@ -57,7 +56,6 @@ type StateProps = {
5756
readonly globalTracks: GlobalTrack[];
5857
readonly globalTrackOrder: TrackIndex[];
5958
readonly globalTrackReferences: GlobalTrackReference[];
60-
readonly panelLayoutGeneration: number;
6159
readonly zeroAt: Milliseconds;
6260
readonly profileTimelineUnit: TimelineUnit;
6361
readonly trackCount: TrackCount;
@@ -145,7 +143,6 @@ class FullTimelineImpl extends React.PureComponent<Props, State> {
145143
profileTimelineUnit,
146144
width,
147145
globalTrackReferences,
148-
panelLayoutGeneration,
149146
trackCount,
150147
changeRightClickedTrack,
151148
innerElementRef,
@@ -173,7 +170,6 @@ class FullTimelineImpl extends React.PureComponent<Props, State> {
173170
</div>
174171
<OverflowEdgeIndicator
175172
className="tracksContainer timelineOverflowEdgeIndicator"
176-
panelLayoutGeneration={panelLayoutGeneration}
177173
initialSelected={this.state.initialSelected}
178174
>
179175
<Reorderable
@@ -214,7 +210,6 @@ export const FullTimeline = explicitConnect<
214210
committedRange: getCommittedRange(state),
215211
zeroAt: getZeroAt(state),
216212
profileTimelineUnit: getProfileTimelineUnit(state),
217-
panelLayoutGeneration: getPanelLayoutGeneration(state),
218213
trackCount: getTrackCount(state),
219214
}),
220215
mapDispatchToProps: {

src/components/timeline/OverflowEdgeIndicator.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import './OverflowEdgeIndicator.css';
1111
type Props = {
1212
className: string;
1313
children: React.ReactNode;
14-
panelLayoutGeneration: number;
1514
initialSelected: InitialSelectedTrackReference | null;
1615
forceLayoutGeneration?: number;
1716
};

src/reducers/app.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -110,47 +110,6 @@ const isSidebarOpenPerPanel: Reducer<IsOpenPerPanelState> = (
110110
}
111111
};
112112

113-
/**
114-
* The panels that make up the timeline, details view, and sidebar can all change
115-
* their sizes depending on the state that is fed to them. In order to control
116-
* the invalidations of this sizing information, provide a "generation" value that
117-
* increases monotonically for any change that potentially changes the sizing of
118-
* any of the panels. This provides a mechanism for subscribing components to
119-
* deterministically update their sizing correctly.
120-
*/
121-
const panelLayoutGeneration: Reducer<number> = (state = 0, action) => {
122-
switch (action.type) {
123-
case 'INCREMENT_PANEL_LAYOUT_GENERATION':
124-
// Sidebar: (fallthrough)
125-
case 'CHANGE_SIDEBAR_OPEN_STATE':
126-
// Timeline: (fallthrough)
127-
case 'HIDE_GLOBAL_TRACK':
128-
case 'SHOW_ALL_TRACKS':
129-
case 'SHOW_PROVIDED_TRACKS':
130-
case 'HIDE_PROVIDED_TRACKS':
131-
case 'SHOW_GLOBAL_TRACK':
132-
case 'SHOW_GLOBAL_TRACK_INCLUDING_LOCAL_TRACKS':
133-
case 'ISOLATE_PROCESS':
134-
case 'ISOLATE_PROCESS_MAIN_THREAD':
135-
case 'HIDE_LOCAL_TRACK':
136-
case 'SHOW_LOCAL_TRACK':
137-
case 'ISOLATE_LOCAL_TRACK':
138-
case 'TOGGLE_RESOURCES_PANEL':
139-
case 'ENABLE_EXPERIMENTAL_CPU_GRAPHS':
140-
case 'ENABLE_EXPERIMENTAL_PROCESS_CPU_TRACKS':
141-
case 'CHANGE_TAB_FILTER':
142-
// Committed range changes: (fallthrough)
143-
case 'COMMIT_RANGE':
144-
case 'POP_COMMITTED_RANGES':
145-
// Bottom box: (fallthrough)
146-
case 'UPDATE_BOTTOM_BOX':
147-
case 'CLOSE_BOTTOM_BOX_FOR_TAB':
148-
return state + 1;
149-
default:
150-
return state;
151-
}
152-
};
153-
154113
/**
155114
* Clicking on tracks can switch between different tabs. This piece of state holds
156115
* on to the last relevant thread-based tab that was viewed. This makes the UX nicer
@@ -365,7 +324,6 @@ const appStateReducer: Reducer<AppState> = combineReducers({
365324
urlSetupPhase,
366325
hasZoomedViaMousewheel,
367326
isSidebarOpenPerPanel,
368-
panelLayoutGeneration,
369327
lastVisibleThreadTabSlug,
370328
trackThreadHeights,
371329
isNewlyPublished,

src/selectors/app.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export const getHasZoomedViaMousewheel: Selector<boolean> = (state) => {
5555
};
5656
export const getIsSidebarOpen: Selector<boolean> = (state) =>
5757
getApp(state).isSidebarOpenPerPanel[getSelectedTab(state)];
58-
export const getPanelLayoutGeneration: Selector<number> = (state) =>
59-
getApp(state).panelLayoutGeneration;
6058
export const getLastVisibleThreadTabSlug: Selector<TabSlug> = (state) =>
6159
getApp(state).lastVisibleThreadTabSlug;
6260
export const getTrackThreadHeights: Selector<{

src/test/components/Viewport.test.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import {
1717
getPreviewSelection,
1818
} from '../../selectors/profile';
1919

20-
import { changeSidebarOpenState } from '../../actions/app';
21-
2220
import explicitConnect from '../../utils/connect';
2321
import { ensureExists } from '../../utils/types';
2422

@@ -27,6 +25,7 @@ import {
2725
autoMockElementSize,
2826
setMockedElementSize,
2927
} from '../fixtures/mocks/element-size';
28+
import { triggerResizeObservers } from '../fixtures/mocks/resize-observer';
3029
import { mockRaf } from '../fixtures/mocks/request-animation-frame';
3130
import { storeWithProfile } from '../fixtures/stores';
3231
import { getProfileFromTextSamples } from '../fixtures/profiles/processed-profile';
@@ -589,8 +588,8 @@ describe('Viewport', function () {
589588
});
590589
});
591590

592-
it('reacts to changes to the panel layout generation', function () {
593-
const { dispatch, getChartViewport, flushRafCalls } = setup();
591+
it('reacts to container size changes', function () {
592+
const { getChartViewport } = setup();
594593

595594
expect(getChartViewport()).toMatchObject({
596595
containerWidth: BOUNDING_BOX_WIDTH,
@@ -606,10 +605,7 @@ describe('Viewport', function () {
606605
...INITIAL_ELEMENT_SIZE,
607606
width: BOUNDING_BOX_WIDTH - boundingWidthDiff,
608607
});
609-
act(() => {
610-
dispatch(changeSidebarOpenState('calltree', true));
611-
});
612-
flushRafCalls();
608+
triggerResizeObservers();
613609

614610
expect(getChartViewport()).toMatchObject({
615611
containerWidth: BOUNDING_BOX_WIDTH - boundingWidthDiff,

src/test/store/app.test.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4-
import { storeWithSimpleProfile, storeWithProfile } from '../fixtures/stores';
4+
import { storeWithSimpleProfile } from '../fixtures/stores';
55
import * as UrlStateSelectors from '../../selectors/url-state';
66
import * as AppSelectors from '../../selectors/app';
77
import createStore from '../../app-logic/create-store';
88
import { withAnalyticsMock } from '../fixtures/mocks/analytics';
9-
import { isolateProcess } from '../../actions/profile-view';
10-
import { getProfileWithNiceTracks } from '../fixtures/profiles/tracks';
119

1210
import * as AppActions from '../../actions/app';
1311

@@ -148,31 +146,4 @@ describe('app actions', function () {
148146
expect(UrlStateSelectors.getSelectedTab(getState())).toEqual('calltree');
149147
});
150148
});
151-
152-
describe('panelLayoutGeneration', function () {
153-
it('can be manually updated using an action', function () {
154-
const { dispatch, getState } = storeWithSimpleProfile();
155-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(0);
156-
dispatch(AppActions.invalidatePanelLayout());
157-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(1);
158-
dispatch(AppActions.invalidatePanelLayout());
159-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(2);
160-
});
161-
162-
it('will be updated when working with the sidebar', function () {
163-
const { dispatch, getState } = storeWithSimpleProfile();
164-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(0);
165-
dispatch(AppActions.changeSidebarOpenState('flame-graph', false));
166-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(1);
167-
});
168-
169-
it('will be updated when working with the timeline', function () {
170-
const { dispatch, getState } = storeWithProfile(
171-
getProfileWithNiceTracks()
172-
);
173-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(0);
174-
dispatch(isolateProcess(0));
175-
expect(AppSelectors.getPanelLayoutGeneration(getState())).toBe(1);
176-
});
177-
});
178149
});

0 commit comments

Comments
 (0)