Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ coverage
webpack.local-config.js
*.orig
*.rej
.idea/
26 changes: 9 additions & 17 deletions src/components/stack-chart/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { FastFillStyle } from '../../utils';
import TextMeasurement from '../../utils/text-measurement';
import { formatMilliseconds, formatBytes } from '../../utils/format-numbers';
import { bisectionLeft, bisectionRight } from '../../utils/bisect';
import type {
updatePreviewSelection,
changeMouseTimePosition,
} from '../../actions/profile-view';
import type { changeMouseTimePosition } from '../../actions/profile-view';

type ChangeMouseTimePosition = typeof changeMouseTimePosition;
import {
Expand Down Expand Up @@ -54,7 +51,6 @@ import type {
IndexIntoStackTiming,
SameWidthsIndexToTimestampMap,
} from '../../profile-logic/stack-timing';
import type { WrapFunctionInDispatch } from '../../utils/connect';

type OwnProps = {
readonly thread: Thread;
Expand All @@ -67,14 +63,12 @@ type OwnProps = {
readonly combinedTimingRows: CombinedTimingRows;
readonly sameWidthsIndexToTimestampMap: SameWidthsIndexToTimestampMap;
readonly stackFrameHeight: CssPixels;
readonly updatePreviewSelection: WrapFunctionInDispatch<
typeof updatePreviewSelection
>;
readonly changeMouseTimePosition: ChangeMouseTimePosition;
readonly getMarker: (param: MarkerIndex) => Marker;
readonly categories: CategoryList;
readonly callNodeInfo: CallNodeInfo;
readonly selectedCallNodeIndex: IndexIntoCallNodeTable | null;
readonly onDoubleClick: (param: IndexIntoCallNodeTable | null) => void;
readonly onSelectionChange: (param: IndexIntoCallNodeTable | null) => void;
readonly onRightClick: (param: IndexIntoCallNodeTable | null) => void;
readonly shouldDisplayTooltips: () => boolean;
Expand Down Expand Up @@ -648,16 +642,14 @@ class StackChartCanvasImpl extends React.PureComponent<Props> {
};

_onDoubleClickStack = (hoveredItem: HoveredStackTiming | null) => {
if (hoveredItem === null) {
return;
if (!hoveredItem) return;

const result =
this._getCallNodeIndexOrMarkerIndexFromHoveredItem(hoveredItem);

if (result && result.type === 'call-node') {
this.props.onDoubleClick(result.index);
}
const { depth, stackTimingIndex } = hoveredItem;
const { combinedTimingRows, updatePreviewSelection } = this.props;
updatePreviewSelection({
isModifying: false,
selectionStart: combinedTimingRows[depth].start[stackTimingIndex],
selectionEnd: combinedTimingRows[depth].end[stackTimingIndex],
});
};

_getCallNodeIndexOrMarkerIndexFromHoveredItem(
Expand Down
20 changes: 18 additions & 2 deletions src/components/stack-chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ class StackChartImpl extends React.PureComponent<Props> {
handleCallNodeTransformShortcut(event, threadsKey, nodeIndex);
};

_onDoubleClick = (callNodeIndex: IndexIntoCallNodeTable | null) => {
if (callNodeIndex === null) {
return;
}

const { thread, callNodeInfo, updateBottomBoxContentsAndMaybeOpen } =
this.props;

const bottomBoxInfo = getBottomBoxInfoForCallNode(
callNodeIndex,
callNodeInfo,
thread,
thread.samples
);
updateBottomBoxContentsAndMaybeOpen('stack-chart', bottomBoxInfo);
};

_onCopy = (event: ClipboardEvent) => {
if (document.activeElement === this._viewport) {
event.preventDefault();
Expand Down Expand Up @@ -214,7 +231,6 @@ class StackChartImpl extends React.PureComponent<Props> {
timeRange,
interval,
previewSelection,
updatePreviewSelection,
changeMouseTimePosition,
callNodeInfo,
categories,
Expand Down Expand Up @@ -271,14 +287,14 @@ class StackChartImpl extends React.PureComponent<Props> {
combinedTimingRows,
sameWidthsIndexToTimestampMap,
getMarker,
updatePreviewSelection,
changeMouseTimePosition,
rangeStart: timeRange.start,
rangeEnd: timeRange.end,
stackFrameHeight: STACK_FRAME_HEIGHT,
callNodeInfo,
categories,
selectedCallNodeIndex,
onDoubleClick: this._onDoubleClick,
onSelectionChange: this._onSelectedCallNodeChange,
// TODO: support right clicking user timing markers #2354.
onRightClick: this._onRightClickedCallNodeChange,
Expand Down