Web Inspector: Styles: inline swatches don't work when Multiple Properties Selection is enabled
https://bugs.webkit.org/show_bug.cgi?id=191165
<rdar://problem/45737972>
Reviewed by Devin Rousso.
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):
* UserInterface/Views/SpreadsheetTextField.js:
(WI.SpreadsheetTextField):
`click` is fired after `mouseup` and inline swatches are activated by `click` event.
Changing this to `click` allows swatches to activate before editing starts.
(WI.SpreadsheetTextField.prototype._handleMouseDown):
Clicking on the field that is being edited should't restart editing. It should move the text caret.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@238120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog
index 412c488..f715ebf 100644
--- a/Source/WebInspectorUI/ChangeLog
+++ b/Source/WebInspectorUI/ChangeLog
@@ -1,3 +1,21 @@
+2018-11-12 Nikita Vasilyev <nvasilyev@apple.com>
+
+ Web Inspector: Styles: inline swatches don't work when Multiple Properties Selection is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=191165
+ <rdar://problem/45737972>
+
+ Reviewed by Devin Rousso.
+
+ * UserInterface/Views/SpreadsheetStyleProperty.js:
+ (WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):
+ * UserInterface/Views/SpreadsheetTextField.js:
+ (WI.SpreadsheetTextField):
+ `click` is fired after `mouseup` and inline swatches are activated by `click` event.
+ Changing this to `click` allows swatches to activate before editing starts.
+
+ (WI.SpreadsheetTextField.prototype._handleMouseDown):
+ Clicking on the field that is being edited should't restart editing. It should move the text caret.
+
2018-11-12 Don Olmstead <don.olmstead@sony.com>
Shipped PNGs include bad profiles: iCCP: known incorrect sRGB profile
diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
index f4b35cb..dd418f5 100644
--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
@@ -452,12 +452,14 @@
if (typeof this._delegate.stylePropertyInlineSwatchActivated === "function") {
swatch.addEventListener(WI.InlineSwatch.Event.Activated, () => {
+ this._swatchActive = true;
this._delegate.stylePropertyInlineSwatchActivated();
});
}
if (typeof this._delegate.stylePropertyInlineSwatchDeactivated === "function") {
swatch.addEventListener(WI.InlineSwatch.Event.Deactivated, () => {
+ this._swatchActive = false;
this._delegate.stylePropertyInlineSwatchDeactivated();
});
}
@@ -465,7 +467,13 @@
tokenElement.append(swatch.element, innerElement);
// Prevent the value from editing when clicking on the swatch.
- swatch.element.addEventListener("mousedown", (event) => { event.stop(); });
+ if (WI.settings.experimentalEnableMultiplePropertiesSelection.value) {
+ swatch.element.addEventListener("click", (event) => {
+ if (this._swatchActive)
+ event.stop();
+ });
+ } else
+ swatch.element.addEventListener("mousedown", (event) => { event.stop(); });
return tokenElement;
}
diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js
index 9c9a9f30..ea432cda 100644
--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js
+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js
@@ -40,9 +40,10 @@
this._element.classList.add("spreadsheet-text-field");
- if (WI.settings.experimentalEnableMultiplePropertiesSelection.value)
- this._element.addEventListener("mouseup", this._handleMouseUp.bind(this));
- else
+ if (WI.settings.experimentalEnableMultiplePropertiesSelection.value) {
+ this._element.addEventListener("mousedown", this._handleMouseDown.bind(this), true);
+ this._element.addEventListener("click", this._handleClick.bind(this));
+ } else
this._element.addEventListener("focus", this._handleFocus.bind(this));
this._element.addEventListener("blur", this._handleBlur.bind(this));
@@ -201,11 +202,17 @@
}
}
- _handleMouseUp(event)
+ _handleClick(event)
{
this.startEditing();
}
+ _handleMouseDown(event)
+ {
+ if (this._editing)
+ event.stopPropagation();
+ }
+
_handleFocus(event)
{
this.startEditing();