Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1646)

Unified Diff: Source/devtools/front_end/ui/InplaceEditor.js

Issue 1200833006: DevTools: [Elements] F2 should commit changes in edit-as-html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeElement.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/InplaceEditor.js
diff --git a/Source/devtools/front_end/ui/InplaceEditor.js b/Source/devtools/front_end/ui/InplaceEditor.js
index c8c4620834c6f85b5699cc340704c5496432efa9..9bb9cb48a4cdee2c313c9c0694d0803f7fac8786 100644
--- a/Source/devtools/front_end/ui/InplaceEditor.js
+++ b/Source/devtools/front_end/ui/InplaceEditor.js
@@ -169,6 +169,10 @@ WebInspector.InplaceEditor.prototype = {
committedCallback(this, self.editorContent(editingContext), editingContext.oldText, context, moveDirection);
}
+ /**
+ * @param {!Event} event
+ * @return {string}
+ */
function defaultFinishHandler(event)
{
var isMetaOrCtrl = WebInspector.isMac() ?
@@ -180,6 +184,7 @@ WebInspector.InplaceEditor.prototype = {
return "cancel";
else if (!isMultiline && event.keyIdentifier === "U+0009") // Tab key
return "move-" + (event.shiftKey ? "backward" : "forward");
+ return "";
}
function handleEditingResult(result, event)
@@ -197,16 +202,23 @@ WebInspector.InplaceEditor.prototype = {
}
}
+ /**
+ * @param {!Event} event
+ */
function pasteEventListener(event)
{
var result = pasteCallback(event);
handleEditingResult(result, event);
}
+ /**
+ * @param {!Event} event
+ */
function keyDownEventListener(event)
{
- var handler = config.customFinishHandler || defaultFinishHandler;
- var result = handler(event);
+ var result = defaultFinishHandler(event);
+ if (!result && config.postKeydownFinishHandler)
+ result = config.postKeydownFinishHandler(event);
handleEditingResult(result, event);
}
@@ -241,22 +253,19 @@ WebInspector.InplaceEditor.Config = function(commitHandler, cancelHandler, conte
this.blurHandler = blurHandler;
/**
- * Handles the "paste" event, return values are the same as those for customFinishHandler
- * @type {function(!Element)|undefined}
+ * @type {function(!Event):string|undefined}
*/
this.pasteHandler;
/**
- * Whether the edited element is multiline
* @type {boolean|undefined}
*/
this.multiline;
/**
- * Custom finish handler for the editing session (invoked on keydown)
- * @type {function(!Element,*)|undefined}
+ * @type {function(!Event):string|undefined}
*/
- this.customFinishHandler;
+ this.postKeydownFinishHandler;
}
WebInspector.InplaceEditor.Config.prototype = {
@@ -282,8 +291,11 @@ WebInspector.InplaceEditor.Config.prototype = {
this.smartIndent = smartIndent;
},
- setCustomFinishHandler: function(customFinishHandler)
+ /**
+ * @param {function(!Event):string} postKeydownFinishHandler
+ */
+ setPostKeydownFinishHandler: function(postKeydownFinishHandler)
{
- this.customFinishHandler = customFinishHandler;
+ this.postKeydownFinishHandler = postKeydownFinishHandler;
}
}
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeElement.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698