Skip to content

Commit 140ea7f

Browse files
author
Chris K
committed
Function tooltip for attribute handlers with script data.
1 parent 387bd59 commit 140ea7f

File tree

5 files changed

+72
-31
lines changed

5 files changed

+72
-31
lines changed

src/ecma-debugger/eventlisteners/evlistenertemplates.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
]);
5252
};
5353

54-
this.ev_listeners = function(listener_list, rt_id)
54+
this.ev_listeners_tooltip = function(listener_list, rt_id)
5555
{
56-
return ["dl", listener_list.map(this._ev_listener.bind(this, rt_id)),
56+
return ["dl", listener_list.map(this._ev_listener_tooltip.bind(this, rt_id)),
5757
"class", "ev-listener mono"];
5858
};
5959

@@ -77,8 +77,8 @@
7777
"data-window-id", String(win_listeners.win_id),
7878
"data-rt-id", String(ev_name_object.rt_id),
7979
"data-obj-id", String(win_listeners.win_id),
80-
"class", "search-match",
81-
"handler", "inspect-object-link"];
80+
"handler", "inspect-object-link",
81+
"class", "search-match"];
8282
}
8383
return ret;
8484
};
@@ -94,7 +94,7 @@
9494
"class", "ev-all-listeners"]);
9595
};
9696

97-
this._ev_listener = function(rt_id, listener)
97+
this._ev_listener_tooltip = function(rt_id, listener)
9898
{
9999
var EVENT_TYPE = 0;
100100
var ORIGIN = 1;
@@ -112,15 +112,28 @@
112112
ret.push(["dt", listener[EVENT_TYPE], "class", "ev-type"]);
113113
ret.push(["dd", listener[USE_CAPTURE] ? "capturing phase" : "bubbling phase",
114114
"class", "ev-phase"]);
115-
ret.push(["dd",
116-
["span", listener[ORIGIN] == ORIGIN_EVENT_TARGET
117-
? "event target handler"
118-
: "attribute handler",
119-
"data-tooltip", "js-inspection",
120-
"data-rt-id", String(rt_id),
121-
"data-obj-id", String(listener[LISTENER_OBJECT_ID]),
122-
"data-class-name", "Function",
123-
"class", "ev-origin"]]);
115+
if (listener[LISTENER_SCRIPT_DATA])
116+
{
117+
opera.postError("script data")
118+
ret.push(["dd",
119+
["span", "attribute handler",
120+
"data-tooltip", "js-inspection",
121+
"data-script-data", listener[LISTENER_SCRIPT_DATA],
122+
"data-class-name", "Function",
123+
"class", "ev-origin"]]);
124+
}
125+
else
126+
{
127+
ret.push(["dd",
128+
["span", listener[ORIGIN] == ORIGIN_EVENT_TARGET
129+
? "event target handler"
130+
: "attribute handler",
131+
"data-tooltip", "js-inspection",
132+
"data-rt-id", String(rt_id),
133+
"data-obj-id", String(listener[LISTENER_OBJECT_ID]),
134+
"data-class-name", "Function",
135+
"class", "ev-origin"]]);
136+
}
124137
var script_id = position && position[SCRIPT_ID];
125138
var script = window.runtimes.getScript(script_id);
126139
if (script)

src/ecma-debugger/eventlisteners/evlistenertooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cls.EvListenerTooltip = function()
6868
var listeners = node_id
6969
? model.get_ev_listeners(node_id)
7070
: model.window_listeners.listeners;
71-
var tmpl = window.templates.ev_listeners(listeners, rt_id);
71+
var tmpl = window.templates.ev_listeners_tooltip(listeners, rt_id);
7272
_tooltip.show(tmpl);
7373
}
7474
};

src/ecma-debugger/js-source-view.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,22 +1012,26 @@ cls.JsSourceView = function(id, name, container_class)
10121012

10131013
cls.JsSourceView.update_breakpoints = function(script, line_numbers, top_line)
10141014
{
1015-
var BP_IMAGE_LINE_HEIGHT = 24;
1016-
var lines = line_numbers && line_numbers.querySelectorAll(".break-point");
1017-
var bp_states = script && script.breakpoint_states;
1018-
if (typeof top_line != "number")
1015+
if (script && line_numbers)
10191016
{
1020-
var span = line_numbers.querySelector(".line-number");
1021-
top_line = span && Number(span.textContent);
1022-
}
1023-
if (lines && bp_states && typeof top_line == "number")
1024-
{
1025-
for (var i = 0, line; line = lines[i]; i++)
1017+
1018+
var BP_IMAGE_LINE_HEIGHT = 24;
1019+
var lines = line_numbers.querySelectorAll(".break-point");
1020+
var bp_states = script && script.breakpoint_states;
1021+
if (typeof top_line != "number")
10261022
{
1027-
var y = bp_states[top_line + i]
1028-
? this.default_y - 1 * bp_states[top_line + i] * BP_IMAGE_LINE_HEIGHT
1029-
: 0;
1030-
line.style.backgroundPosition = "0 " + y + "px";
1023+
var span = line_numbers.querySelector(".line-number");
1024+
top_line = span && Number(span.textContent);
1025+
}
1026+
if (lines && bp_states && typeof top_line == "number")
1027+
{
1028+
for (var i = 0, line; line = lines[i]; i++)
1029+
{
1030+
var y = bp_states[top_line + i]
1031+
? this.default_y - 1 * bp_states[top_line + i] * BP_IMAGE_LINE_HEIGHT
1032+
: 0;
1033+
line.style.backgroundPosition = "0 " + y + "px";
1034+
}
10311035
}
10321036
}
10331037
};

src/ecma-debugger/objectinspection.6.0/inspectiontooltip.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ cls.JSInspectionTooltip = function()
126126
callback: _handle_ontooltip});
127127

128128
}
129+
else
130+
{
131+
var script_data = target.get_ancestor_attr("data-script-data");
132+
if (script_data && class_name)
133+
{
134+
_cur_object = {script_data: script_data, class_name: class_name};
135+
_pretty_printer.print({target: target,
136+
script_data: script_data,
137+
class_name: class_name,
138+
object: _cur_object,
139+
callback: _handle_ontooltip});
140+
}
141+
}
129142
}
130143
};
131144

src/ecma-debugger/objectinspection.6.0/prettyprinter.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ cls.PrettyPrinter.types[cls.PrettyPrinter.FUNCTION] =
110110
template: function(message, ctx)
111111
{
112112
var tmpl = [];
113-
if (ctx.function_definition)
113+
if (ctx.script_data)
114+
{
115+
tmpl.push("div");
116+
window.templates.highlight_js_source(ctx.script_data, null, 0, tmpl);
117+
tmpl.push("class", "tooltip-function-source");
118+
}
119+
else if (ctx.function_definition)
114120
{
115121
var script = ctx.script;
116122
var start_line = ctx.function_definition.start_line;
@@ -299,7 +305,12 @@ cls.PrettyPrinter.prototype = new function()
299305

300306
this._print_function = function(ctx)
301307
{
302-
if (services["ecmascript-debugger"].requestGetFunctionPositions)
308+
if (ctx.script_data)
309+
{
310+
ctx.template = ctx.type.template(null, ctx);
311+
ctx.callback(ctx);
312+
}
313+
else if (services["ecmascript-debugger"].requestGetFunctionPositions)
303314
{
304315
var tag = tagManager.set_callback(this, this._handle_function, [ctx]);
305316
var msg = [ctx.rt_id, [ctx.obj_id]];

0 commit comments

Comments
 (0)