forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.js
More file actions
134 lines (116 loc) · 3.19 KB
/
Copy pathFrame.js
File metadata and controls
134 lines (116 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* 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/>. */
// @flow
import React, { Component } from "react";
import classNames from "classnames";
import Svg from "../../shared/Svg";
import { formatDisplayName } from "../../../utils/pause/frames";
import { getFilename } from "../../../utils/source";
import FrameMenu from "./FrameMenu";
import type { Frame } from "../../../types";
import type { LocalFrame } from "./types";
type FrameTitleProps = {
frame: Frame,
options: Object
};
function FrameTitle({ frame, options }: FrameTitleProps) {
const displayName = formatDisplayName(frame, options);
return <div className="title">{displayName}</div>;
}
type FrameLocationProps = { frame: LocalFrame };
function FrameLocation({ frame }: FrameLocationProps) {
if (!frame.source) {
return;
}
if (frame.library) {
return (
<div className="location">
{frame.library}
<Svg name={frame.library.toLowerCase()} className="annotation-logo" />
</div>
);
}
const filename = getFilename(frame.source);
return (
<div className="location">{`${filename}: ${frame.location.line}`}</div>
);
}
FrameLocation.displayName = "FrameLocation";
type FrameComponentProps = {
frame: LocalFrame,
selectedFrame: LocalFrame,
copyStackTrace: Function,
toggleFrameworkGrouping: Function,
selectFrame: Function,
frameworkGroupingOn: boolean,
hideLocation: boolean,
shouldMapDisplayName: boolean,
toggleBlackBox: Function
};
export default class FrameComponent extends Component<FrameComponentProps> {
static defaultProps = {
hideLocation: false,
shouldMapDisplayName: true
};
onContextMenu(event: SyntheticKeyboardEvent<HTMLElement>) {
const {
frame,
copyStackTrace,
toggleFrameworkGrouping,
toggleBlackBox,
frameworkGroupingOn
} = this.props;
FrameMenu(
frame,
frameworkGroupingOn,
{ copyStackTrace, toggleFrameworkGrouping, toggleBlackBox },
event
);
}
onMouseDown(
e: SyntheticKeyboardEvent<HTMLElement>,
frame: Frame,
selectedFrame: Frame
) {
if (e.which == 3) {
return;
}
this.props.selectFrame(frame);
}
onKeyUp(
event: SyntheticKeyboardEvent<HTMLElement>,
frame: Frame,
selectedFrame: Frame
) {
if (event.key != "Enter") {
return;
}
this.props.selectFrame(frame);
}
render() {
const {
frame,
selectedFrame,
hideLocation,
shouldMapDisplayName
} = this.props;
const className = classNames("frame", {
selected: selectedFrame && selectedFrame.id === frame.id
});
return (
<li
key={frame.id}
className={className}
onMouseDown={e => this.onMouseDown(e, frame, selectedFrame)}
onKeyUp={e => this.onKeyUp(e, frame, selectedFrame)}
onContextMenu={e => this.onContextMenu(e)}
tabIndex={0}
>
<FrameTitle frame={frame} options={{ shouldMapDisplayName }} />
{!hideLocation && <FrameLocation frame={frame} />}
</li>
);
}
}
FrameComponent.displayName = "Frame";