diff --git a/.gitignore b/.gitignore index 14f36789cc..7f04f29a05 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage webpack.local-config.js *.orig *.rej +.idea/ diff --git a/src/components/stack-chart/Canvas.tsx b/src/components/stack-chart/Canvas.tsx index 18716529c2..81fc837544 100644 --- a/src/components/stack-chart/Canvas.tsx +++ b/src/components/stack-chart/Canvas.tsx @@ -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 { @@ -54,7 +51,6 @@ import type { IndexIntoStackTiming, SameWidthsIndexToTimestampMap, } from '../../profile-logic/stack-timing'; -import type { WrapFunctionInDispatch } from '../../utils/connect'; type OwnProps = { readonly thread: Thread; @@ -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; @@ -648,16 +642,14 @@ class StackChartCanvasImpl extends React.PureComponent { }; _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( diff --git a/src/components/stack-chart/index.tsx b/src/components/stack-chart/index.tsx index d027f0b83c..ba98f87a9b 100644 --- a/src/components/stack-chart/index.tsx +++ b/src/components/stack-chart/index.tsx @@ -180,6 +180,23 @@ class StackChartImpl extends React.PureComponent { 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(); @@ -214,7 +231,6 @@ class StackChartImpl extends React.PureComponent { timeRange, interval, previewSelection, - updatePreviewSelection, changeMouseTimePosition, callNodeInfo, categories, @@ -271,7 +287,6 @@ class StackChartImpl extends React.PureComponent { combinedTimingRows, sameWidthsIndexToTimestampMap, getMarker, - updatePreviewSelection, changeMouseTimePosition, rangeStart: timeRange.start, rangeEnd: timeRange.end, @@ -279,6 +294,7 @@ class StackChartImpl extends React.PureComponent { callNodeInfo, categories, selectedCallNodeIndex, + onDoubleClick: this._onDoubleClick, onSelectionChange: this._onSelectedCallNodeChange, // TODO: support right clicking user timing markers #2354. onRightClick: this._onRightClickedCallNodeChange,