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

Unified Diff: Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 650123002: DevTools: [SSP] fix live edit of property values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comment Created 6 years, 2 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 | « LayoutTests/inspector/elements/styles/edit-value-inside-property-expected.txt ('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/elements/StylesSidebarPane.js
diff --git a/Source/devtools/front_end/elements/StylesSidebarPane.js b/Source/devtools/front_end/elements/StylesSidebarPane.js
index 61ef8be74c9cd835149705f97a9f844141015fa3..4c3593ee5678ab56e6708e5ef77fcd36c6f99c2c 100644
--- a/Source/devtools/front_end/elements/StylesSidebarPane.js
+++ b/Source/devtools/front_end/elements/StylesSidebarPane.js
@@ -2679,6 +2679,9 @@ WebInspector.StylePropertyTreeElement = function(stylesPane, styleRule, style, p
this._applyStyleThrottler = new WebInspector.Throttler(0);
}
+/** @typedef {{expanded: boolean, hasChildren: boolean, isEditingName: boolean, previousContent: string}} */
+WebInspector.StylePropertyTreeElement.Context;
+
WebInspector.StylePropertyTreeElement.prototype = {
/**
* @return {?WebInspector.DOMNode}
@@ -2944,6 +2947,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
return splitFieldValue.join("");
}
+ /** @type {!WebInspector.StylePropertyTreeElement.Context} */
var context = {
expanded: this.expanded,
hasChildren: this.hasChildren,
@@ -2959,6 +2963,8 @@ WebInspector.StylePropertyTreeElement.prototype = {
selectElement.textContent = selectElement.textContent; // remove color swatch and the like
/**
+ * @param {!WebInspector.StylePropertyTreeElement.Context} context
+ * @param {!Event} event
* @this {WebInspector.StylePropertyTreeElement}
*/
function pasteHandler(context, event)
@@ -2989,6 +2995,8 @@ WebInspector.StylePropertyTreeElement.prototype = {
}
/**
+ * @param {!WebInspector.StylePropertyTreeElement.Context} context
+ * @param {!Event} event
* @this {WebInspector.StylePropertyTreeElement}
*/
function blurListener(context, event)
@@ -3019,20 +3027,24 @@ WebInspector.StylePropertyTreeElement.prototype = {
}
var proxyElement = this._prompt.attachAndStartEditing(selectElement, blurListener.bind(this, context));
- proxyElement.addEventListener("keydown", this.editingNameValueKeyDown.bind(this, context), false);
- proxyElement.addEventListener("keypress", this.editingNameValueKeyPress.bind(this, context), false);
+ proxyElement.addEventListener("keydown", this._editingNameValueKeyDown.bind(this, context), false);
+ proxyElement.addEventListener("keypress", this._editingNameValueKeyPress.bind(this, context), false);
+ proxyElement.addEventListener("input", this._editingNameValueInput.bind(this, context), false);
if (isEditingName)
proxyElement.addEventListener("paste", pasteHandler.bind(this, context), false);
window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1);
},
- editingNameValueKeyDown: function(context, event)
+ /**
+ * @param {!WebInspector.StylePropertyTreeElement.Context} context
+ * @param {!Event} event
+ */
+ _editingNameValueKeyDown: function(context, event)
{
if (event.handled)
return;
- var isEditingName = context.isEditingName;
var result;
if (isEnterKey(event)) {
@@ -3040,7 +3052,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
result = "forward";
} else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B")
result = "cancel";
- else if (!isEditingName && this._newProperty && event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code) {
+ else if (!context.isEditingName && this._newProperty && event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code) {
// For a new property, when Backspace is pressed at the beginning of new property value, move back to the property name.
var selection = window.getSelection();
if (selection.isCollapsed && !selection.focusOffset) {
@@ -3066,12 +3078,13 @@ WebInspector.StylePropertyTreeElement.prototype = {
event.consume();
return;
}
-
- if (!isEditingName)
- this._applyFreeFlowStyleTextEdit();
},
- editingNameValueKeyPress: function(context, event)
+ /**
+ * @param {!WebInspector.StylePropertyTreeElement.Context} context
+ * @param {!Event} event
+ */
+ _editingNameValueKeyPress: function(context, event)
{
function shouldCommitValueSemicolon(text, cursorPosition)
{
@@ -3099,6 +3112,16 @@ WebInspector.StylePropertyTreeElement.prototype = {
}
},
+ /**
+ * @param {!WebInspector.StylePropertyTreeElement.Context} context
+ * @param {!Event} event
+ */
+ _editingNameValueInput: function(context, event)
+ {
+ if (!context.isEditingName)
+ this._applyFreeFlowStyleTextEdit();
+ },
+
_applyFreeFlowStyleTextEdit: function()
{
var valueText = this.valueElement.textContent;
« no previous file with comments | « LayoutTests/inspector/elements/styles/edit-value-inside-property-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698