Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dfl 3356 maintenance #102

Open
wants to merge 32 commits into
base: DFL-3356_maintenance_reviewed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7ce75f8
DFL-3226 Lots of info messages "getting readyState has failed in runt…
Jul 19, 2012
345b282
DFL-1360 Remeber selected element in DOM view between reloads.
Jul 20, 2012
95ab36e
DFL-3358 The tooltip in Scripts must take the runtime of the script t…
Jul 20, 2012
1a05029
Code cleanup.
Jul 24, 2012
27245e8
Code cleanup and select the runtime on selecting a script.
Jul 25, 2012
882f570
Added new method to find specific tokens.
Jul 26, 2012
dd59a2a
DFL-3360 Stylesheet is missing when debugging certain testcase.
Jul 26, 2012
e64a13d
DFL-3216 Getting the execution context must be smarter.
Jul 27, 2012
d2bec3e
Run cleanrepo.
Aug 8, 2012
263f01b
Synced with master.
Aug 8, 2012
0769f67
Run cleanrepo.
Aug 13, 2012
a69c05a
Merge branch 'master' into DFL-3356_maintenance
Aug 13, 2012
c0ece04
Working on DFL-3159.
Aug 17, 2012
96fe64d
Adjusting tooltips according to DFL-3159.
Aug 22, 2012
b41252d
Set the correct flag.
Aug 22, 2012
0723518
Working on copy action.
Aug 23, 2012
1892324
Added more copy actions.
Aug 29, 2012
361dc12
Added 'Copy CSS path' action.
Aug 29, 2012
4fbf526
Cleanup serialze to string of a DOM node.
Aug 30, 2012
4e76486
Fixd some issues with markup edit.
Aug 30, 2012
689eb92
Added SELECTION menu type.
Aug 30, 2012
2958762
Copy script source.
Aug 30, 2012
3205245
Updated message definitions and made them collapsible.
Sep 4, 2012
f7db753
Added missing default method.
Sep 13, 2012
f9fe9b9
Removed the clipboard API hack.
Sep 18, 2012
6bdb240
Log action handlers with missing get_selection_string method.
Sep 18, 2012
0ef4161
Removed empty line.
Sep 18, 2012
efb22c8
Fixed syntax error.
Sep 18, 2012
15f63e3
Fixed merge conflicts with master.
Sep 20, 2012
99ab7b1
Fixed merge conflicts with cutting-edge.
Oct 2, 2012
fb562f2
Merge branch 'DFL-3356_maintenance_reviewed' into DFL-3356_maintenance
Oct 3, 2012
58b4171
Run clean repo.
Oct 3, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/build-application/build_ecmascript_debugger_6_0.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ window.app.builders.EcmascriptDebugger["6.0"] = function(service)
window.runtime_onload_handler = new namespace.RuntimeOnloadHandler();

/* commandline */
cls.CommandLineRuntimeSelect.prototype = new CstSelect();
new cls.CommandLineRuntimeSelect('cmd-runtime-select', 'cmd-line-runtimes');

cls.ReplView.create_ui_widgets();
Expand Down
2 changes: 1 addition & 1 deletion src/client-en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ window.load_screen_timeout = window.setTimeout(function()
<script src="./lib/stylesheetlistprototype.js"/>
<script src="./lib/xmlhttprequestprototype.js"/>
<script src="./lib/storageprototype.js"/>
<script src="./lib/clipboard.js"/>
<script src="./lib/dict.js"/>


Expand Down Expand Up @@ -414,7 +415,6 @@ window.load_screen_timeout = window.setTimeout(function()
<script src="./ecma-debugger/scriptselect.js"/>

<script src="./ecma-debugger/dominspection/templates.js"/>
<script src="./ecma-debugger/dominspection/domserializer.js"/>
<script src="./ecma-debugger/dominspection/domview.js"/>
<script src="./ecma-debugger/dominspection/actions.js"/>
<script src="./ecma-debugger/dominspection/attrandtextditor.js"/>
Expand Down
59 changes: 0 additions & 59 deletions src/ecma-debugger/action_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,65 +101,6 @@ window.eventHandlers.click['examine-object-2'] = function(event, target)
}
};

window.eventHandlers.click['show-scripts'] = function(event)
{
var runtime_id = event.target.getAttribute('runtime_id');
var scripts = runtimes.getScripts(runtime_id);
var scripts_container = event.target.parentNode.getElementsByTagName('ul')[0];
var script = null, i = 0;

if (scripts_container)
{
event.target.parentNode.removeChild(scripts_container);
event.target.style.removeProperty('background-position');
runtimes.setUnfolded(runtime_id, 'script', false);
}
else
{
scripts_container = ['ul'];
for ( ; script = scripts[i]; i++)
{
scripts_container.push(templates.scriptLink(script));
}
scripts_container.splice(scripts_container.length, 0, 'runtime-id', runtime_id);
event.target.parentNode.render(scripts_container);
event.target.style.backgroundPosition = '0 -11px';
runtimes.setUnfolded(runtime_id, 'script', true);
}
};

window.eventHandlers.click['show-stylesheets'] = function(event, target)
{
var rt_id = target.getAttribute('runtime_id');
// stylesheets.get_stylesheets will call this function again if data is not avaible
// handleGetAllStylesheets in stylesheets will
// set for this reason __call_count on the event object
var sheets = cls.Stylesheets.get_instance().get_stylesheets(rt_id, arguments);
if (sheets)
{
var container = event.target.parentNode.getElementsByTagName('ul')[0];
var sheet = null, i = 0;
if (container)
{
target.parentNode.removeChild(container);
target.style.removeProperty('background-position');
runtimes.setUnfolded(rt_id, 'css', false);
}
else
{
container = ['ul'];
for ( ; sheet = sheets[i]; i++)
{
container.push(templates.sheetLink(sheet, i));
}
container.splice(container.length, 0, 'runtime-id', rt_id);
event.target.parentNode.render(container);
event.target.style.backgroundPosition = '0 -11px';
runtimes.setUnfolded(rt_id, 'css', true);
}
}
};

window.eventHandlers.click['continue'] = function(event)
{
this.broker.dispatch_action('global', event.target.id);
Expand Down
82 changes: 58 additions & 24 deletions src/ecma-debugger/dominspection/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

cls.DOMInspectorActions = function(id)
{
ActionHandlerInterface.apply(this);
this.view_id = id;
this.id = id;

const
SCROLL_IN_PADDING = 30,
MODE_DEFAULT = "default",
MODE_EDIT_ATTR_TEXT = "edit-attributes-and-text",
MODE_EDIT_MARKUP = "edit-markup";
var SCROLL_IN_PADDING = 30;
var MODE_DEFAULT = "default";
var MODE_EDIT_ATTR_TEXT = "edit-attributes-and-text";
var MODE_EDIT_MARKUP = "edit-markup";
var LEFT_CLICK = 1;
var SUCCESS = 0;

this.mode_labels =
{
Expand All @@ -33,8 +35,6 @@ cls.DOMInspectorActions = function(id)

var broker = ActionBroker.get_instance();

this.serializer = new cls.DOMSerializer();

this._handlers = {};
this._mode = MODE_DEFAULT;
this.__defineSetter__("mode", function(mode)
Expand Down Expand Up @@ -368,10 +368,10 @@ cls.DOMInspectorActions = function(id)
}
}
if (!nav_target)
{
nav_target = this.getFirstTarget();
}
this.setSelected(nav_target);

if (event.which == LEFT_CLICK)
this.setSelected(nav_target);
}
}

Expand Down Expand Up @@ -478,9 +478,11 @@ cls.DOMInspectorActions = function(id)
{
var target = event.target;
var is_in_container = view_container && view_container.contains(target);
if(is_in_container)
if (is_in_container)
{
if(target != nav_target && /^input|node|key|value|text$/i.test(target.nodeName))
if (event.which == LEFT_CLICK &&
target != nav_target &&
/^input|node|key|value|text$/i.test(target.nodeName))
{
this.setSelected(target);
}
Expand All @@ -497,9 +499,10 @@ cls.DOMInspectorActions = function(id)

this.blur = function(event)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline

if (this.mode != MODE_DEFAULT && this.editor)
this.editor.submit();
if (selection)
if (selection && !selection.isCollapsed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline before

selection.removeAllRanges();
view_container = null;
view_container_first_child = null;
Expand Down Expand Up @@ -610,12 +613,6 @@ cls.DOMInspectorActions = function(id)
}
}.bind(this);

this._handlers["export-markup"] = function(event, target)
{
var data = this.serializer.serialize(window.dom_data);
window.open("data:text/plain;charset=utf-8," + encodeURIComponent(data));
}.bind(this);

this._handlers["expand-whole-dom"] = function(event, target)
{
window.dom_data.get_snapshot();
Expand Down Expand Up @@ -892,6 +889,48 @@ cls.DOMInspectorActions = function(id)
}
}.bind(this);

this._handlers["copy-xpath"] = function(event, target)
{
var model = window.dominspections[target.get_ancestor_attr("data-model-id")];
var obj_id = parseInt(target.get_ancestor_attr("ref-id"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we mostly use Number when getting values form attributes, in the following functions too.

if (model && obj_id)
{
var force_lower_case = window.settings.dom.get("force-lowercase");
model.get_xpath(obj_id, force_lower_case, function(path)
{
if (path)
Clipboard.set_string(path);
});
}
}.bind(this);

this._handlers["copy-css-path"] = function(event, target)
{
var model = window.dominspections[target.get_ancestor_attr("data-model-id")];
var obj_id = parseInt(target.get_ancestor_attr("ref-id"));
if (model && obj_id)
{
var force_lower_case = window.settings.dom.get("force-lowercase");
var path = model.get_unique_css_path(obj_id, force_lower_case);
if (path)
Clipboard.set_string(path);
}
}.bind(this);

this._handlers["copy-markup"] = function(event, target)
{
var model = window.dominspections[target.get_ancestor_attr("data-model-id")];
var obj_id = parseInt(target.get_ancestor_attr("ref-id"));
if (model && obj_id)
{
model.serialize_to_string(obj_id, function(markup)
{
if (markup)
Clipboard.set_string(markup);
});
}
}.bind(this);

this.edit_onclick = function(event)
{
if( this.editor )
Expand Down Expand Up @@ -961,11 +1000,6 @@ window.event_handlers.mouseover['spotlight-node'] = function(event, target)
this.broker.dispatch_action("dom", "spotlight-node", event, target);
}

window.event_handlers.click['dom-inspection-export'] = function(event, target)
{
this.broker.dispatch_action("dom", "export-markup", event, target);
};

window.event_handlers.click['dom-inspection-snapshot'] = function(event, target)
{
this.broker.dispatch_action("dom", "expand-whole-dom", event, target);
Expand Down
50 changes: 41 additions & 9 deletions src/ecma-debugger/dominspection/domdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
this._reset_spotlight_timeouts = new Timeouts();
this._is_waiting = false;
this._editor_active = false;
this._last_selectors = {};

this._spotlight = function(event)
{
Expand Down Expand Up @@ -111,7 +112,14 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
{
if (!this._data.length && this._element_selected_state == CHECKED)
{
this._get_initial_view(this._data_runtime_id);
var rt_id = this._data_runtime_id;
if (runtime_onload_handler.is_loaded(rt_id))
this._get_initial_view(rt_id);
else
{
var cb = this._get_initial_view.bind(this, rt_id);
runtime_onload_handler.register(rt_id, cb, cb, 500);
}
}
else if (this._element_selected_state != CHECKED &&
this._element_selected_state != CHECK_AGAIN_NO_RUNTIME)
Expand Down Expand Up @@ -212,11 +220,11 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)

this._get_selected_element = function(rt_id)
{
var tag = tagManager.set_callback(this, this._on_element_selected, [rt_id, true]);
var tag = tagManager.set_callback(this, this._on_object_selected, [rt_id, true]);
window.services['ecmascript-debugger'].requestGetSelectedObject(tag);
}

this._on_element_selected = function(status, message, rt_id, show_initial_view)
this._on_object_selected = function(status, message, rt_id, show_initial_view)
{
// If the window ID is not the debug context, the runtime ID will not be set
const OBJECT_ID = 0, WINDOW_ID = 1, RUNTIME_ID = 2;
Expand All @@ -243,7 +251,6 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
{
if (message[WINDOW_ID] == window.window_manager_data.get_debug_context())
{
messages.post("runtime-selected", {id: this._data_runtime_id});
window['cst-selects']['document-select'].updateElement();
this._get_dom_sub(message[RUNTIME_ID], message[OBJECT_ID], true);
}
Expand Down Expand Up @@ -274,6 +281,7 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
this._current_target = 0;
this._active_window = [];
this.target = 0;
window.messages.post("element-selected", {obj_id: 0, rt_id: 0, model: null});
}

this._on_active_tab = function(msg)
Expand All @@ -291,7 +299,6 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
this._on_reset_state();
// the first field is the top runtime
this._data_runtime_id = msg.activeTab[0];
messages.post("runtime-selected", {id: this._data_runtime_id});
window['cst-selects']['document-select'].updateElement();
this._active_window = msg.activeTab.slice();
if (window.views[this._view_id].isvisible())
Expand Down Expand Up @@ -402,7 +409,6 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
if (rt_id != this._data_runtime_id)
{
this._data_runtime_id = rt_id;
messages.post("runtime-selected", {id: this._data_runtime_id});
window['cst-selects']['document-select'].updateElement();
}
if (obj_id)
Expand All @@ -419,8 +425,13 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)

this._get_initial_view = function(rt_id)
{
var last_selector = this._last_selectors[window.runtimes.getActiveWindowId()];
var query_last_selector = last_selector
? "document.querySelector(\"" + last_selector + "\") || "
: "";
var tag = tagManager.set_callback(this, this._handle_initial_view, [rt_id]);
var script_data = "return ( document.body || document.documentElement )";
var script_data = "return (" + query_last_selector +
"document.body || document.documentElement)";
services['ecmascript-debugger'].requestEval(tag, [rt_id, 0, 0, script_data]);
}

Expand Down Expand Up @@ -457,6 +468,22 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
'this._handle_snapshot in dom_data has failed');
}

this._on_element_selected = function(msg)
{
var win_id = window.runtimes.getActiveWindowId();
var css_path = this.get_css_path(msg.obj_id, null, true, false, true);
var is_first = false;
var selector = css_path.reduce(function(sel, ele)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline function should have { on the previous line

sel = sel + ele.name + (is_first ? ":first-child " : " ") +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sel +=?

(ele.combinator ? ele.combinator + " " : "");
is_first = ele.combinator == ">";
return sel;
}, "");
if (selector)
this._last_selectors[win_id] = selector;
};

/* implementation */


Expand All @@ -469,7 +496,10 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
if (runtime_onload_handler.is_loaded(rt_id))
this._get_initial_view(rt_id);
else
runtime_onload_handler.register(rt_id, this._get_initial_view.bind(this, rt_id));
{
var cb = this._get_initial_view.bind(this, rt_id);
runtime_onload_handler.register(rt_id, cb, cb);
}
}
this._is_waiting = true;
}).bind(this);
Expand All @@ -490,7 +520,7 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
{
ecma_debugger.onObjectSelected =
ecma_debugger.handleGetSelectedObject =
this._on_element_selected.bind(this);
this._on_object_selected.bind(this);
}

/* initialisation */
Expand All @@ -509,6 +539,7 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
this._set_reset_spotlight_bound = this._set_reset_spotlight.bind(this);
this._on_top_runtime_update_bound = this._on_top_runtime_update.bind(this);
this._on_dom_editor_active_bound = this._on_dom_editor_active.bind(this);
this._on_element_selected_bound = this._on_element_selected.bind(this);

this._init(0, 0);

Expand All @@ -522,6 +553,7 @@ cls.EcmascriptDebugger["6.0"].DOMData = function(view_id)
messages.addListener('top-runtime-updated', this._on_top_runtime_update_bound);
messages.addListener('dom-editor-active', this._on_dom_editor_active_bound);
messages.addListener('profile-disabled', this._on_profile_disabled_bound);
messages.addListener("element-selected", this._on_element_selected_bound);
};

cls.EcmascriptDebugger["6.0"].DOMData.prototype = cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype;
Expand Down
Loading