Changeset 194573 in webkit


Ignore:
Timestamp:
Jan 4, 2016 10:32:28 PM (8 years ago)
Author:
commit-queue@webkit.org
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 <Devin Rousso> 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):

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r194572 r194573  
     12016-01-04  Devin Rousso  <dcrousso+webkit@gmail.com>
     2
     3        Web Inspector: Add debounce to URL inputs in the Visual sidebar
     4        https://bugs.webkit.org/show_bug.cgi?id=152655
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Adding a debounce to url() based Visual sidebar editors will prevent needless
     9        errors from being thrown as the user types, since incomplete URL's will not
     10        be able to be located.
     11
     12        * UserInterface/Base/Utilities.js:
     13        (Function.prototype.debounce):
     14        Prevents the given function from executing more than once in the specified amount of time.
     15
     16        * UserInterface/Views/VisualStyleBackgroundPicker.js:
     17        (WebInspector.VisualStyleBackgroundPicker):
     18
     19        * UserInterface/Views/VisualStyleURLInput.js:
     20        (WebInspector.VisualStyleURLInput):
     21
    1222016-01-04  Joseph Pecoraro  <pecoraro@apple.com>
    223
  • trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r194311 r194573  
    11081108});
    11091109
     1110(function() {
     1111    const debounceSymbol = Symbol("function-debounce-timeout");
     1112    Object.defineProperty(Function.prototype, "debounce",
     1113    {
     1114        value: function(delay, thisObject)
     1115        {
     1116            let callback = this.bind(thisObject);
     1117            return function() {
     1118                clearTimeout(callback[debounceSymbol]);
     1119                let args = arguments;
     1120                callback[debounceSymbol] = setTimeout(() => {
     1121                    callback.apply(null, args);
     1122                }, delay);
     1123            };
     1124        }
     1125    });
     1126})();
     1127
    11101128function appendWebInspectorSourceURL(string)
    11111129{
  • trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleBackgroundPicker.js

    r192705 r194573  
    4444        this._valueInputElement.type = "url";
    4545        this._valueInputElement.placeholder = WebInspector.UIString("Enter a URL");
    46         this._valueInputElement.addEventListener("input", this._valueInputValueChanged.bind(this));
     46        this._valueInputElement.addEventListener("input", this._valueInputValueChanged.debounce(250, this));
    4747        this.contentElement.appendChild(this._valueInputElement);
    4848
  • trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleURLInput.js

    r194504 r194573  
    3333        this._urlInputElement.type = "url";
    3434        this._urlInputElement.placeholder = WebInspector.UIString("Enter a URL");
    35         this._urlInputElement.addEventListener("keyup", this._valueDidChange.bind(this));
     35        this._urlInputElement.addEventListener("keyup", this._valueDidChange.debounce(250, this));
    3636        this.contentElement.appendChild(this._urlInputElement);
    3737    }
Note: See TracChangeset for help on using the changeset viewer.