Skip to content

Commit 0ce87a9

Browse files
author
Chris K
committed
Cleanup naming.
1 parent 44924f5 commit 0ce87a9

File tree

3 files changed

+88
-82
lines changed

3 files changed

+88
-82
lines changed

src/ecma-debugger/eventlisteners/evlisteners.js

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ window.cls || (window.cls = {});
55
* @extends ViewBase
66
*/
77

8-
cls.EventName = function(name)
8+
cls.EventType = function(type)
99
{
10-
this.name = name;
10+
this.type = type;
1111
this.rt_listeners = null;
1212
this.is_expanded = false;
1313
this.rt_id = 0;
1414
this.obj_id = 0;
1515
this._init();
1616
};
1717

18-
cls.EventNamePrototype = function()
18+
cls.EventTypePrototype = function()
1919
{
2020
var SEARCH_TYPE_EVENT = 5;
2121

22-
this.search_dom = function(rt_id, obj_id, ev_name, cb)
22+
this.search_listeners = function(rt_id, obj_id, type, cb)
2323
{
2424
this.rt_id = this._data_runtime_id = rt_id;
2525
this.obj_id = this._root_obj_id = obj_id;
26-
this.search(ev_name, SEARCH_TYPE_EVENT, 0, 0, cb);
26+
this.search(type, SEARCH_TYPE_EVENT, 0, 0, cb);
2727
};
2828

2929
this.collapse = function()
@@ -34,8 +34,8 @@ cls.EventNamePrototype = function()
3434
};
3535
};
3636

37-
cls.EventNamePrototype.prototype = cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype;
38-
cls.EventName.prototype = new cls.EventNamePrototype();
37+
cls.EventTypePrototype.prototype = cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype;
38+
cls.EventType.prototype = new cls.EventTypePrototype();
3939

4040
cls.RTListUpdateCTX = function(rt_id_list, cb)
4141
{
@@ -44,10 +44,10 @@ cls.RTListUpdateCTX = function(rt_id_list, cb)
4444

4545
cls.RTListUpdateCTX.prototype = new function()
4646
{
47-
this._handle_expand_listener = function(ev_name_obj)
47+
this._handle_expand_listener = function(ev_type)
4848
{
49-
var list = this.expanded_map[ev_name_obj.rt_id];
50-
var index = list.indexOf(ev_name_obj.name);
49+
var list = this.expanded_map[ev_type.rt_id];
50+
var index = list.indexOf(ev_type.type);
5151
if (index > -1)
5252
list.splice(index, 1);
5353
else
@@ -61,7 +61,7 @@ cls.RTListUpdateCTX.prototype = new function()
6161
{
6262
return this.rt_map.hasOwnProperty(rt_id) &&
6363
(!this.rt_map[rt_id] || (this.expanded_map[rt_id] &&
64-
this.expanded_map[rt_id].length === 0));
64+
this.expanded_map[rt_id].length === 0));
6565
};
6666

6767
this.check_is_updated = function()
@@ -94,9 +94,9 @@ cls.EvenetListeners.prototype = new function()
9494

9595
this.update = function() {};
9696
this.get_data = function() {};
97-
this.expand_listeners = function(rt_id, obj_id, ev_name, cb) {};
98-
this.collapse_listeners = function(rt_id, ev_name) {};
99-
this.is_expanded = function(rt_id, name) {};
97+
this.expand_listeners = function(rt_id, obj_id, type, cb) {};
98+
this.collapse_listeners = function(rt_id, type) {};
99+
this.is_expanded = function(rt_id, type) {};
100100

101101
var SUCCESS = 0;
102102
var SEARCH_TYPE_EVENT = 5;
@@ -108,7 +108,7 @@ cls.EvenetListeners.prototype = new function()
108108
109109
this._rts = [{rt_id: <rt-id>,
110110
obj_id: <obj-id>,
111-
event_names: [<EventName>, ...]}, ...]
111+
event_types: [<EventType>, ...]}, ...]
112112
*/
113113

114114
this._on_new_rts = function()
@@ -173,21 +173,21 @@ cls.EvenetListeners.prototype = new function()
173173
{
174174
this._win_id_map[rt_id] = ctx.win_id_map[rt_id] = message[OBJECT_VALUE][OBJECT_ID];
175175
if (ctx.rt_id_list.every(function(rt_id) { return ctx.win_id_map[rt_id]; }))
176-
ctx.rt_id_list.map(this._get_event_names.bind(this, ctx));
176+
ctx.rt_id_list.map(this._get_event_types.bind(this, ctx));
177177
}
178178
else
179179
opera.postError(ui_strings.S_DRAGONFLY_INFO_MESSAGE +
180180
"failed to get the window object in cls.EvenetListeners.")
181181
};
182182

183-
this._get_event_names = function(ctx, rt_id)
183+
this._get_event_types = function(ctx, rt_id)
184184
{
185-
var tag = this._tagman.set_callback(this, this._handle_get_event_names, [ctx]);
185+
var tag = this._tagman.set_callback(this, this._handle_get_event_types, [ctx]);
186186
var msg = [rt_id];
187187
this._esdb.requestGetEventNames(tag, msg);
188188
};
189189

190-
this._handle_get_event_names = function(status, message, ctx)
190+
this._handle_get_event_types = function(status, message, ctx)
191191
{
192192
if (status === SUCCESS)
193193
{
@@ -203,22 +203,21 @@ cls.EvenetListeners.prototype = new function()
203203
ctx.expanded_map[rt_id] = [];
204204
if (ev_list && ev_list.length)
205205
{
206-
rt_listeners.event_names = ev_list.map(function(name)
206+
rt_listeners.event_types = ev_list.map(function(type)
207207
{
208-
var ev_n_obj = new cls.EventName(name);
209-
if (this.is_expanded(rt_id, name))
208+
var ev_type = new cls.EventType(type);
209+
if (this.is_expanded(rt_id, type))
210210
{
211-
ctx.expanded_map[rt_id].push(name);
212-
var search_cb = this._handle_dom_search.bind(this,
213-
ev_n_obj,
214-
ctx.handle_expand_listener);
215-
ev_n_obj.search_dom(rt_id, obj_id, name, search_cb);
211+
ctx.expanded_map[rt_id].push(type);
212+
var cb = this._handle_dom_search.bind(this, ev_type,
213+
ctx.handle_expand_listener);
214+
ev_type.search_listeners(rt_id, obj_id, type, cb);
216215
}
217-
return ev_n_obj;
216+
return ev_type;
218217
}, this);
219218
}
220219
else
221-
rt_listeners.event_names = [];
220+
rt_listeners.event_types = [];
222221

223222
ctx.rt_map[rt_id] = rt_listeners;
224223
ctx.check_is_updated();
@@ -228,34 +227,34 @@ cls.EvenetListeners.prototype = new function()
228227
"failed to retrieve the event names in cls.EvenetListeners.")
229228
};
230229

231-
this._handle_dom_search = function(ev_name_obj, cb)
230+
this._handle_dom_search = function(ev_type, cb)
232231
{
233-
var tag = this._tagman.set_callback(this, this._handle_obj_search, [ev_name_obj, cb]);
234-
var msg = [ev_name_obj.rt_id, [this._win_id_map[ev_name_obj.rt_id]]];
232+
var tag = this._tagman.set_callback(this, this._handle_obj_search, [ev_type, cb]);
233+
var msg = [ev_type.rt_id, [this._win_id_map[ev_type.rt_id]]];
235234
this._esdb.requestGetEventListeners(tag, msg);
236235
};
237236

238-
this._handle_obj_search = function(status, message, ev_name_obj, cb)
237+
this._handle_obj_search = function(status, message, ev_type, cb)
239238
{
240239
if (status === SUCCESS)
241240
{
242241
var TARGET_LIST = 1;
243242
var OBJECT_ID = 0;
244243
var EVENT_LISTENERS = 1;
245244
var ev_target = message[TARGET_LIST] && message[TARGET_LIST][0];
246-
ev_name_obj.window_listeners = ev_target
247-
? {win_id: ev_target[OBJECT_ID],
248-
listeners: ev_target[EVENT_LISTENERS]}
249-
: null;
250-
ev_name_obj.is_expanded = true;
245+
ev_type.window_listeners = ev_target
246+
? {win_id: ev_target[OBJECT_ID],
247+
listeners: ev_target[EVENT_LISTENERS]}
248+
: null;
249+
ev_type.is_expanded = true;
251250

252-
if (!this._expand_tree[ev_name_obj.rt_id])
253-
this._expand_tree[ev_name_obj.rt_id] = {};
251+
if (!this._expand_tree[ev_type.rt_id])
252+
this._expand_tree[ev_type.rt_id] = {};
254253

255-
this._expand_tree[ev_name_obj.rt_id][ev_name_obj.name] = true;
254+
this._expand_tree[ev_type.rt_id][ev_type.type] = true;
256255

257256
if (cb)
258-
cb(ev_name_obj);
257+
cb(ev_type);
259258
else
260259
this._view.update();
261260

@@ -265,15 +264,15 @@ cls.EvenetListeners.prototype = new function()
265264
"requestGetEventListeners failed in cls.EvenetListeners.")
266265
};
267266

268-
this._get_ev_name_obj = function(rt_id, ev_name)
267+
this._get_ev_type = function(rt_id, type)
269268
{
270269
var rt = this._get_rt(rt_id);
271270
if (rt)
272271
{
273-
for (var i = 0, ev_n; ev_n = rt.event_names[i]; i++)
272+
for (var i = 0, ev_type; ev_type = rt.event_types[i]; i++)
274273
{
275-
if (ev_n.name == ev_name)
276-
return ev_n;
274+
if (ev_type.type == type)
275+
return ev_type;
277276
}
278277
}
279278
return null;
@@ -318,35 +317,35 @@ cls.EvenetListeners.prototype = new function()
318317
return null;
319318
};
320319

321-
this.expand_listeners = function(rt_id, obj_id, ev_name, cb)
320+
this.expand_listeners = function(rt_id, obj_id, type, cb)
322321
{
323-
var ev_n_obj = this._get_ev_name_obj(rt_id, ev_name);
324-
if (ev_n_obj)
322+
var ev_type = this._get_ev_type(rt_id, type);
323+
if (ev_type)
325324
{
326-
var search_cb = this._handle_dom_search.bind(this, ev_n_obj, cb);
327-
ev_n_obj.search_dom(rt_id, obj_id, ev_name, search_cb);
325+
var cb = this._handle_dom_search.bind(this, ev_type, cb);
326+
ev_type.search_listeners(rt_id, obj_id, type, cb);
328327
}
329328
else
330329
opera.postError(ui_strings.S_DRAGONFLY_INFO_MESSAGE +
331330
"failed to find event names object in cls.EvenetListeners.")
332331

333332
};
334333

335-
this.collapse_listeners = function(rt_id, ev_name)
334+
this.collapse_listeners = function(rt_id, type)
336335
{
337-
var ev_n_obj = this._get_ev_name_obj(rt_id, ev_name);
338-
if (ev_n_obj)
336+
var ev_type = this._get_ev_type(rt_id, type);
337+
if (ev_type)
339338
{
340-
ev_n_obj.collapse();
339+
ev_type.collapse();
341340
if (this._expand_tree[rt_id])
342-
this._expand_tree[rt_id][ev_name] = false;
341+
this._expand_tree[rt_id][type] = false;
343342
}
344343
};
345344

346-
this.is_expanded = function(rt_id, name)
345+
this.is_expanded = function(rt_id, type)
347346
{
348347
return this._expand_tree[rt_id]
349-
? Boolean(this._expand_tree[rt_id][name])
348+
? Boolean(this._expand_tree[rt_id][type])
350349
: false;
351350
};
352351

src/ecma-debugger/eventlisteners/evlistenertemplates.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function()
22
{
3-
var HAS_LISTENERS = function(rt_l) { return rt_l.event_names.length; };
3+
var HAS_LISTENERS = function(rt_l) { return rt_l.event_types.length; };
44

55
/* Event listener view */
66

@@ -16,71 +16,70 @@
1616
"unselectable", "on",
1717
"tabindex", "1",
1818
"handler", "update-ev-listeners"]],
19-
["ul", data_with_ls.map(this._ev_names_list, this), "class", "ev-all"],
19+
["ul", data_with_ls.map(this._ev_rt_view, this), "class", "ev-all"],
2020
"class", "main-ev-listener-view js-search-results-runtime padding"]);
2121
};
2222

23-
this._ev_names_list = function(ev_obj, index, ev_obj_list)
23+
this._ev_rt_view = function(ev_rt, index, ev_rt_list)
2424
{
25-
var rt = window.runtimes.getRuntime(ev_obj.rt_id);
25+
var rt = window.runtimes.getRuntime(ev_rt.rt_id);
2626
var ret = ["li"];
27-
if (ev_obj_list.length > 1)
27+
if (ev_rt_list.length > 1)
2828
{
2929
ret.push(["h2",
3030
["span", rt && (rt.title || rt.host),
3131
"data-tooltip", "url-tooltip",
3232
"data-tooltip-text", rt && rt.uri],
3333
"class", "ev-listener-rt-title"]);
3434
}
35-
ret.push(["ul", ev_obj.event_names.map(this._ev_name_item, this),
36-
"data-rt-id", String(ev_obj.rt_id),
37-
"data-obj-id", String(ev_obj.obj_id),
35+
ret.push(["ul", ev_rt.event_types.map(this._ev_type, this),
36+
"data-rt-id", String(ev_rt.rt_id),
37+
"data-obj-id", String(ev_rt.obj_id),
3838
"class", "ev-rt-list"]);
3939
return ret;
4040
};
4141

42-
this._ev_name_item = function(ev_name_obj)
42+
this._ev_type = function(ev_type)
4343
{
44-
var bg_pos = ev_name_obj.is_expanded ? "0 -11px" : "0 0";
45-
44+
var bg_pos = ev_type.is_expanded ? "0 -11px" : "0 0";
4645
return (
4746
["li",
4847
["h3",
4948
["input", "type", "button",
5049
"class", "folder-key",
5150
"style", "background-position: " + bg_pos],
52-
ev_name_obj.name,
51+
ev_type.type,
5352
"handler", "toggle-ev-listeners",
54-
"data-ev-name", ev_name_obj.name,
53+
"data-ev-name", ev_type.type,
5554
"class", "ev-listener-type"],
56-
ev_name_obj.is_expanded ? this.ev_all_listeners(ev_name_obj) : []]);
55+
ev_type.is_expanded ? this.ev_all_listeners(ev_type) : []]);
5756
};
5857

59-
this.ev_all_listeners = function(ev_name_obj)
58+
this.ev_all_listeners = function(ev_type)
6059
{
61-
var tmpl_obj_l = window.templates.ev_window_listeners(ev_name_obj);
62-
var tmpl_node_l = window.templates.dom_search(ev_name_obj);
60+
var tmpl_obj_l = window.templates.ev_window_listeners(ev_type);
61+
var tmpl_node_l = window.templates.dom_search(ev_type);
6362
return["div", tmpl_obj_l, [tmpl_node_l], "class", "ev-all-listeners"];
6463
};
6564

66-
this.ev_window_listeners = function(ev_name_object)
65+
this.ev_window_listeners = function(ev_type)
6766
{
6867
var EVENT_TYPE = 0;
69-
var win_listeners = ev_name_object && ev_name_object.window_listeners;
68+
var win_listeners = ev_type && ev_type.window_listeners;
7069
var ret = [];
7170
if (win_listeners && win_listeners.listeners.some(function(listener)
7271
{
73-
return listener[EVENT_TYPE] == ev_name_object.name;
72+
return listener[EVENT_TYPE] == ev_type.type;
7473
}))
7574
{
7675
ret =
7776
["div",
7877
"window",
7978
["span", "class", "node-with-ev-listener",
8079
"data-tooltip", "event-listener"],
81-
"data-model-id", String(ev_name_object.id),
80+
"data-model-id", String(ev_type.id),
8281
"data-window-id", String(win_listeners.win_id),
83-
"data-rt-id", String(ev_name_object.rt_id),
82+
"data-rt-id", String(ev_type.rt_id),
8483
"data-obj-id", String(win_listeners.win_id),
8584
"handler", "inspect-object-link",
8685
"class", "search-match"];
@@ -112,7 +111,9 @@
112111
var position = listener[POSITION];
113112

114113
ret.push(["dt", listener[EVENT_TYPE], "class", "ev-type"]);
115-
ret.push(["dd", listener[USE_CAPTURE] ? "capturing phase" : "bubbling phase",
114+
ret.push(["dd", listener[USE_CAPTURE]
115+
? ui_strings.S_LISTENER_CAPTURING_PHASE
116+
: ui_strings.S_LISTENER_BUBBLING_PHASE,
116117
"class", "ev-phase"]);
117118
if (listener[LISTENER_SCRIPT_DATA])
118119
{

src/ui-strings/ui_strings-en.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,4 +1501,10 @@ ui_strings.S_TOGGLE_PAUSED_UPDATING_NETWORK_VIEW = "Pause updating network activ
15011501
ui_strings.S_EVENT_LISTENER_ADDED_IN = "added in %s";
15021502

15031503
/* DESC: Info in an event listener tooltip that the according source file is missing. */
1504-
ui_strings.S_INFO_MISSING_JS_SOURCE_FILE = "<missing JavaScript source file>"
1504+
ui_strings.S_INFO_MISSING_JS_SOURCE_FILE = "<missing JavaScript source file>";
1505+
1506+
/* DESC: Info in an event listener tooltip that the according listener listens in the capturing phase. */
1507+
ui_strings.S_LISTENER_CAPTURING_PHASE = "capturing phase";
1508+
1509+
/* DESC: Info in an event listener tooltip that the according listener listens in the bubbling phase. */
1510+
ui_strings.S_LISTENER_BUBBLING_PHASE = "bubbling phase";

0 commit comments

Comments
 (0)