-
Notifications
You must be signed in to change notification settings - Fork 47
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
base: DFL-3356_maintenance_reviewed
Are you sure you want to change the base?
Dfl 3356 maintenance #102
Changes from all commits
7ce75f8
345b282
95ab36e
1a05029
27245e8
882f570
dd59a2a
e64a13d
d2bec3e
263f01b
0769f67
a69c05a
c0ece04
96fe64d
b41252d
0723518
1892324
361dc12
4fbf526
4e76486
689eb92
2958762
3205245
f7db753
f9fe9b9
6bdb240
0ef4161
efb22c8
15f63e3
99ab7b1
fb562f2
58b4171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = | ||
{ | ||
|
@@ -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) | ||
|
@@ -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); | ||
} | ||
} | ||
|
||
|
@@ -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); | ||
} | ||
|
@@ -497,9 +499,10 @@ cls.DOMInspectorActions = function(id) | |
|
||
this.blur = function(event) | ||
{ | ||
|
||
if (this.mode != MODE_DEFAULT && this.editor) | ||
this.editor.submit(); | ||
if (selection) | ||
if (selection && !selection.isCollapsed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline before |
||
selection.removeAllRanges(); | ||
view_container = null; | ||
view_container_first_child = null; | ||
|
@@ -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(); | ||
|
@@ -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")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ) | ||
|
@@ -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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
{ | ||
|
@@ -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) | ||
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
|
@@ -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) | ||
|
@@ -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()) | ||
|
@@ -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) | ||
|
@@ -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]); | ||
} | ||
|
||
|
@@ -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) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inline function should have |
||
sel = sel + ele.name + (is_first ? ":first-child " : " ") + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(ele.combinator ? ele.combinator + " " : ""); | ||
is_first = ele.combinator == ">"; | ||
return sel; | ||
}, ""); | ||
if (selector) | ||
this._last_selectors[win_id] = selector; | ||
}; | ||
|
||
/* implementation */ | ||
|
||
|
||
|
@@ -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); | ||
|
@@ -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 */ | ||
|
@@ -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); | ||
|
||
|
@@ -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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline