Title: [194573] trunk/Source/WebInspectorUI
- Revision
- 194573
- Author
- [email protected]
- Date
- 2016-01-04 22:32:28 -0800 (Mon, 04 Jan 2016)
Log Message
Web Inspector: Add debounce to URL inputs in the Visual sidebar
https://bugs.webkit.org/show_bug.cgi?id=152655
Patch by Devin Rousso <[email protected]> on 2016-01-04
Reviewed by Joseph Pecoraro.
Adding a debounce to url() based Visual sidebar editors will prevent needless
errors from being thrown as the user types, since incomplete URL's will not
be able to be located.
* UserInterface/Base/Utilities.js:
(Function.prototype.debounce):
Prevents the given function from executing more than once in the specified amount of time.
* UserInterface/Views/VisualStyleBackgroundPicker.js:
(WebInspector.VisualStyleBackgroundPicker):
* UserInterface/Views/VisualStyleURLInput.js:
(WebInspector.VisualStyleURLInput):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (194572 => 194573)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-01-05 05:10:29 UTC (rev 194572)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-01-05 06:32:28 UTC (rev 194573)
@@ -1,3 +1,24 @@
+2016-01-04 Devin Rousso <[email protected]>
+
+ Web Inspector: Add debounce to URL inputs in the Visual sidebar
+ https://bugs.webkit.org/show_bug.cgi?id=152655
+
+ Reviewed by Joseph Pecoraro.
+
+ Adding a debounce to url() based Visual sidebar editors will prevent needless
+ errors from being thrown as the user types, since incomplete URL's will not
+ be able to be located.
+
+ * UserInterface/Base/Utilities.js:
+ (Function.prototype.debounce):
+ Prevents the given function from executing more than once in the specified amount of time.
+
+ * UserInterface/Views/VisualStyleBackgroundPicker.js:
+ (WebInspector.VisualStyleBackgroundPicker):
+
+ * UserInterface/Views/VisualStyleURLInput.js:
+ (WebInspector.VisualStyleURLInput):
+
2016-01-04 Joseph Pecoraro <[email protected]>
Web Inspector: Fix debug context menu string and reload without cache tooltip string
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (194572 => 194573)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-01-05 05:10:29 UTC (rev 194572)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-01-05 06:32:28 UTC (rev 194573)
@@ -1107,6 +1107,24 @@
}
});
+(function() {
+ const debounceSymbol = Symbol("function-debounce-timeout");
+ Object.defineProperty(Function.prototype, "debounce",
+ {
+ value: function(delay, thisObject)
+ {
+ let callback = this.bind(thisObject);
+ return function() {
+ clearTimeout(callback[debounceSymbol]);
+ let args = arguments;
+ callback[debounceSymbol] = setTimeout(() => {
+ callback.apply(null, args);
+ }, delay);
+ };
+ }
+ });
+})();
+
function appendWebInspectorSourceURL(string)
{
return string + "\n//# sourceURL=__WebInspectorInternal__\n";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleBackgroundPicker.js (194572 => 194573)
--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleBackgroundPicker.js 2016-01-05 05:10:29 UTC (rev 194572)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleBackgroundPicker.js 2016-01-05 06:32:28 UTC (rev 194573)
@@ -43,7 +43,7 @@
this._valueInputElement.classList.add("value-input");
this._valueInputElement.type = "url";
this._valueInputElement.placeholder = WebInspector.UIString("Enter a URL");
- this._valueInputElement.addEventListener("input", this._valueInputValueChanged.bind(this));
+ this._valueInputElement.addEventListener("input", this._valueInputValueChanged.debounce(250, this));
this.contentElement.appendChild(this._valueInputElement);
this._valueTypePickerElement = document.createElement("select");
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleURLInput.js (194572 => 194573)
--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleURLInput.js 2016-01-05 05:10:29 UTC (rev 194572)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleURLInput.js 2016-01-05 06:32:28 UTC (rev 194573)
@@ -32,7 +32,7 @@
this._urlInputElement = document.createElement("input");
this._urlInputElement.type = "url";
this._urlInputElement.placeholder = WebInspector.UIString("Enter a URL");
- this._urlInputElement.addEventListener("keyup", this._valueDidChange.bind(this));
+ this._urlInputElement.addEventListener("keyup", this._valueDidChange.debounce(250, this));
this.contentElement.appendChild(this._urlInputElement);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes