Skip to content

Commit cd33ace

Browse files
author
Chris K
committed
Template for the event listener tooltip.
1 parent a406e47 commit cd33ace

File tree

3 files changed

+57
-58
lines changed

3 files changed

+57
-58
lines changed

src/ecma-debugger/evlistenertooltip/evlistenertemplates.js

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,78 +18,59 @@
1818
var USE_CAPTURE = 3;
1919
var LISTENER_OBJECT_ID = 4;
2020
var LISTENER_SCRIPT_DATA = 5;
21-
22-
/*
23-
matchReason: TRAVERSAL (1)
24-
pseudoElementList:
25-
eventListenerList:
26-
eventener:
27-
eventType: "click"
28-
origin: EVENT_TARGET (1)
29-
position:
30-
scriptID: 2544
31-
lineNumber: 19
32-
useCapture: 0
33-
listenerObjectID: 17
34-
*/
35-
3621
var ret = [];
3722
ret.push(["dt", listener[EVENT_TYPE], "class", "ev-type"]);
3823
ret.push(["dd", listener[USE_CAPTURE] ? "capturing phase" : "bubbling phase",
3924
"class", "ev-phase"]);
40-
ret.push(["dd", listener[ORIGIN] == ORIGIN_EVENT_TARGET
41-
? "event target handler"
42-
: "attribute handler",
43-
"data-tooltip", "js-inspection",
44-
"data-rt-id", String(rt_id),
45-
"data-obj-id", String(listener[LISTENER_OBJECT_ID]),
46-
"data-class-name", "Function",
47-
"class", "ev-origin"]);
25+
ret.push(["dd",
26+
["span", listener[ORIGIN] == ORIGIN_EVENT_TARGET
27+
? "event target handler"
28+
: "attribute handler",
29+
"data-tooltip", "js-inspection",
30+
"data-rt-id", String(rt_id),
31+
"data-obj-id", String(listener[LISTENER_OBJECT_ID]),
32+
"data-class-name", "Function",
33+
"class", "ev-origin"]]);
4834
var position = listener[POSITION];
4935
var script_id = position && position[SCRIPT_ID];
5036
var script = window.runtimes.getScript(script_id);
5137
if (script)
5238
{
53-
ret.push(["dd", "added in ",
54-
this.ev_script_link(script, position[LINE_NUMBER]),
55-
"handler", "show-log-entry-source",
56-
"data-scriptid", String(script_id),
57-
"data-scriptline", String(position[LINE_NUMBER]),
58-
"class", "ev-added"]);
59-
}
60-
else
61-
{
62-
// TODO missing script
63-
}
64-
return ret;
65-
};
39+
var script_type = this._script_type_map[script.script_type] ||
40+
script.script_type;
41+
var ctx = [];
42+
if (script.uri)
43+
{
44+
var is_linked = script.script_type == "linked";
45+
ctx.push("span", "added in " + script.filename + ":" + position[LINE_NUMBER], // TODO ui string
46+
"data-tooltip", is_linked && "url-tooltip",
47+
"data-tooltip-text", is_linked && script.uri);
48+
}
49+
else
50+
{
51+
var rt = window.runtimes.getRuntime(script.runtime_id);
52+
if (rt)
53+
ctx.push("span", "added in " + rt.filename, // TODO ui string
54+
"data-tooltip", "url-tooltip",
55+
"data-tooltip-text", rt.uri);
56+
else
57+
opera.postError(ui_strings.S_DRAGONFLY_INFO_MESSAGE +
58+
" missing runtime in _ev_listener template.");
59+
}
6660

67-
this.ev_script_link = function(script, line_number)
68-
{
69-
var script_type = this._script_type_map[script.script_type] ||
70-
script.script_type;
71-
if (script.uri)
72-
{
73-
var is_linked = script.script_type == "linked";
74-
var ret = ["span", script.filename + ":" + line_number,
75-
"data-tooltip", is_linked && "js-script-select",
76-
"data-tooltip-text", is_linked && script.uri,
77-
"class", "file-line"];
78-
}
79-
else
80-
{
81-
var rt = window.runtimes.getRuntime(script.runtime_id);
82-
if (rt)
61+
if (ctx.length)
8362
{
84-
var ret = ["span", rt.filename, // line_number is relative to the inline script
85-
"data-tooltip", "js-script-select",
86-
"data-tooltip-text", rt.uri,
87-
"class", "file-line"];
63+
ctx.push("handler", "show-log-entry-source",
64+
"data-scriptid", String(script_id),
65+
"data-scriptline", String(position[LINE_NUMBER]),
66+
"class", "ev-added");
67+
ret.push(["dd", ctx]);
8868
}
8969
}
70+
else
71+
ret.push(["dd", "<missing JavaScript source file>"]); // TODO ui string
9072

91-
ret.push("script-id", String(script.script_id));
9273
return ret;
9374
};
9475

95-
}).apply(window.templates || (window.templates = {}));
76+
}).apply(window.templates || (window.templates = {}));

src/ecma-debugger/evlistenertooltip/evlistenertooltip.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cls.EvListenerTooltip = function()
77

88

99
var _tooltip = null;
10+
var _url_tooltip = null;
1011

1112

1213

@@ -71,6 +72,7 @@ cls.EvListenerTooltip = function()
7172
var _init = function(view)
7273
{
7374
_tooltip = Tooltips.register(cls.EvListenerTooltip.tooltip_name, true);
75+
_url_tooltip = Tooltips.register("url-tooltip", true);
7476

7577
_tooltip.ontooltip = _ontooltip;
7678
_tooltip.onhide = _hide_tooltip;

src/ui-style/debugger_style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,3 +1615,19 @@ d
16151615
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
16161616
}
16171617

1618+
.ev-added,
1619+
.ev-origin
1620+
{
1621+
border-radius: 2px;
1622+
}
1623+
1624+
.tooltip-function-source
1625+
{
1626+
position: relative;
1627+
}
1628+
1629+
.tooltip-function-source .js-source-content
1630+
{
1631+
margin-left: 40px;
1632+
}
1633+

0 commit comments

Comments
 (0)