DevTools: [CodeMirror] show native copy/paste/cut items in editor context menu

Currently, if you select some text in text editor and then do a right-click
inside selection, the just-summoned context menu won't have a copy/paste/cut
items, as well as other native items natural for text area context menu.

This happens due to the way CodeMirror handles contextmenu event. It
focuses a small text area during the contextmenu bubbling phase, so the
upcoming ContextMenu gets populated with appropriate items. Unfortunately,
codemirror does all this textarea mess *after* firing its own "contextmenu"
event, and as we create menu in the listener, it doesn't have correct active
element.

This patch goes back to listening contextmenu event on element, which due to
bubbling nature happens after textarea was focused.

R=vsevik

Review URL: https://codereview.chromium.org/306023015

git-svn-id: svn://svn.chromium.org/blink/trunk@175286 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6369af7d
...@@ -139,7 +139,7 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate) ...@@ -139,7 +139,7 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bind(this)); this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bind(this));
this._codeMirror.on("scroll", this._scroll.bind(this)); this._codeMirror.on("scroll", this._scroll.bind(this));
this._codeMirror.on("focus", this._focus.bind(this)); this._codeMirror.on("focus", this._focus.bind(this));
this._codeMirror.on("contextmenu", this._contextMenu.bind(this)); this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false);
/** /**
* @this {WebInspector.CodeMirrorTextEditor} * @this {WebInspector.CodeMirrorTextEditor}
*/ */
...@@ -721,7 +721,7 @@ WebInspector.CodeMirrorTextEditor.prototype = { ...@@ -721,7 +721,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick, { lineNumber: lineNumber, event: event }); this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick, { lineNumber: lineNumber, event: event });
}, },
_contextMenu: function(codeMirror, event) _contextMenu: function(event)
{ {
var contextMenu = new WebInspector.ContextMenu(event); var contextMenu = new WebInspector.ContextMenu(event);
var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutter-elt"); var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutter-elt");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment