+2012-02-02 Pavel Feldman <pfeldman@google.com>
+
+ Web Inspector: add experiment for single click styles editing.
+ https://bugs.webkit.org/show_bug.cgi?id=77624
+
+ Reviewed by Vsevolod Vlasov.
+
+ * inspector/front-end/Settings.js:
+ (WebInspector.ExperimentsSettings):
+ * inspector/front-end/StylesSidebarPane.js:
+ (WebInspector.StylePropertiesSection):
+ (WebInspector.StylePropertyTreeElement.prototype.onattach):
+ (WebInspector.StylePropertyTreeElement.prototype._mouseDown):
+ (WebInspector.StylePropertyTreeElement.prototype._resetMouseDownElement):
+ (WebInspector.StylePropertyTreeElement.prototype):
+ (WebInspector.StylePropertyTreeElement.prototype.selectElement.context):
+
2012-02-02 Kenneth Rohde Christiansen <kenneth@webkit.org>
Make the tap highlighting work for all test cases
closeBrace.textContent = "}";
this.element.appendChild(closeBrace);
- this._selectorElement.addEventListener("dblclick", this._handleSelectorDoubleClick.bind(this), false);
- this.element.addEventListener("dblclick", this._handleEmptySpaceDoubleClick.bind(this), false);
+ var eventName = WebInspector.experimentsSettings.singleClickEditing.isEnabled() ? "click" : "dblclick";
+ this._selectorElement.addEventListener(eventName, this._handleSelectorDoubleClick.bind(this), false);
+ this.element.addEventListener(eventName, this._handleEmptySpaceDoubleClick.bind(this), false);
this._parentPane = parentPane;
this.styleRule = styleRule;
onattach: function()
{
this.updateTitle();
+ var eventName;
+ if (WebInspector.experimentsSettings.singleClickEditing.isEnabled()) {
+ this.listItemElement.addEventListener("mousedown", this._mouseDown.bind(this));
+ this.listItemElement.addEventListener("mouseup", this._resetMouseDownElement.bind(this));
+ eventName = "click";
+ } else
+ eventName = "dblclick";
+ this.listItemElement.addEventListener(eventName, this._startEditing.bind(this));
+ },
+
+ _mouseDown: function(event)
+ {
+ this._parentPane._mouseDownTreeElement = this;
+ this._parentPane._mouseDownTreeElementIsName = this._isNameElement(event.target);
+ this._parentPane._mouseDownTreeElementIsValue = this._isValueElement(event.target);
+ },
+
+ _resetMouseDownElement: function()
+ {
+ delete this._parentPane._mouseDownTreeElement;
+ delete this._parentPane._mouseDownTreeElementIsName;
+ delete this._parentPane._mouseDownTreeElementIsValue;
},
updateTitle: function()
}
},
- ondblclick: function(event)
- {
- this.startEditing(event.target);
- event.stopPropagation();
- },
-
restoreNameElement: function()
{
// Restore <span class="webkit-css-property"> if it doesn't yet exist or was accidentally deleted.
this.listItemElement.insertBefore(this.nameElement, this.listItemElement.firstChild);
},
+ _startEditing: function(event)
+ {
+ this.startEditing(event.target);
+ event.stopPropagation();
+ },
+
+ _isNameElement: function(element)
+ {
+ return element.enclosingNodeOrSelfWithClass("webkit-css-property") === this.nameElement;
+ },
+
+ _isValueElement: function(element)
+ {
+ return !!element.enclosingNodeOrSelfWithClass("value");
+ },
+
startEditing: function(selectElement)
{
// FIXME: we don't allow editing of longhand properties under a shorthand right now.
function blurListener(context, event)
{
- this.editingCommitted(null, event.target.textContent, context.previousContent, context, "");
+ var treeElement = this._parentPane._mouseDownTreeElement;
+ var moveDirection = "";
+ if (treeElement === this) {
+ if (isEditingName && this._parentPane._mouseDownTreeElementIsValue)
+ moveDirection = "forward";
+ if (!isEditingName && this._parentPane._mouseDownTreeElementIsName)
+ moveDirection = "backward";
+ }
+ this.editingCommitted(null, event.target.textContent, context.previousContent, context, moveDirection);
}
delete this.originalPropertyText;
editingEnded: function(context)
{
+ this._resetMouseDownElement();
if (this._applyFreeFlowStyleTextEditTimer)
clearTimeout(this._applyFreeFlowStyleTextEditTimer);