Changeset 219017 in webkit


Ignore:
Timestamp:
Jun 30, 2017, 2:57:09 PM (8 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Add small delay before showing the progress spinner when loading resources
https://bugs.webkit.org/show_bug.cgi?id=173437

Reviewed by Joseph Pecoraro.

  • UserInterface/Views/ResourceContentView.js:

(WebInspector.ResourceContentView):
(WebInspector.ResourceContentView.prototype.removeLoadingIndicator): Added.
(WebInspector.ResourceContentView.prototype._contentError):
(WebInspector.ResourceContentView.prototype._hasContent):
Delay the creation of the spinner for 100ms. If the content is available before then, just
clear the timeout and the spinner will never be created/shown.

We measured an average of 35ms to load and display images with slow cases being around 55ms.
100ms was chosen for the timeout to give some room to allow for abnormally slow loading
while not being too long as to be outright noticable.

  • UserInterface/Views/FontResourceContentView.js:

(WebInspector.FontResourceContentView.prototype.contentAvailable):

  • UserInterface/Views/ImageResourceContentView.js:

(WebInspector.ImageResourceContentView.prototype.contentAvailable):

  • UserInterface/Views/TextResourceContentView.js:

(WebInspector.TextResourceContentView.prototype._contentWillPopulate):
Calls the new protected function removeLoadingIndicator to ensure that the spinner (and any
other element) is removed.

This is necessary because TextResourceContentView effectively has two phases of loading its
content: getting the content and formatting it for display. The first follows the same path
as the other ResourceContentView subclasses, the second waits for the ContentWillPopulate
event on SourceCodeTextEditor before it actually adds the content as a subview. In this
case, the spinner should only be removed right before the content is actually added, not
once it's ready.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r219015 r219017  
     12017-06-30  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Add small delay before showing the progress spinner when loading resources
     4        https://bugs.webkit.org/show_bug.cgi?id=173437
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Views/ResourceContentView.js:
     9        (WebInspector.ResourceContentView):
     10        (WebInspector.ResourceContentView.prototype.removeLoadingIndicator): Added.
     11        (WebInspector.ResourceContentView.prototype._contentError):
     12        (WebInspector.ResourceContentView.prototype._hasContent):
     13        Delay the creation of the spinner for 100ms.  If the content is available before then, just
     14        clear the timeout and the spinner will never be created/shown.
     15
     16        We measured an average of 35ms to load and display images with slow cases being around 55ms.
     17        100ms was chosen for the timeout to give some room to allow for abnormally slow loading
     18        while not being too long as to be outright noticable.
     19
     20        * UserInterface/Views/FontResourceContentView.js:
     21        (WebInspector.FontResourceContentView.prototype.contentAvailable):
     22        * UserInterface/Views/ImageResourceContentView.js:
     23        (WebInspector.ImageResourceContentView.prototype.contentAvailable):
     24        * UserInterface/Views/TextResourceContentView.js:
     25        (WebInspector.TextResourceContentView.prototype._contentWillPopulate):
     26        Calls the new protected function removeLoadingIndicator to ensure that the spinner (and any
     27        other element) is removed.
     28
     29        This is necessary because TextResourceContentView effectively has two phases of loading its
     30        content: getting the content and formatting it for display.  The first follows the same path
     31        as the other ResourceContentView subclasses, the second waits for the ContentWillPopulate
     32        event on SourceCodeTextEditor before it actually adds the content as a subview.  In this
     33        case, the spinner should only be removed right before the content is actually added, not
     34        once it's ready.
     35
    1362017-06-30  Commit Queue  <commit-queue@webkit.org>
    237
  • trunk/Source/WebInspectorUI/UserInterface/Views/FontResourceContentView.js

    r216138 r219017  
    7373            this._styleElement.parentNode.removeChild(this._styleElement);
    7474
    75         this.element.removeChildren();
     75        this.removeLoadingIndicator();
    7676
    7777        this._styleElement = document.createElement("style");
  • trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js

    r218544 r219017  
    5454        }
    5555
    56         this.element.removeChildren();
     56        this.removeLoadingIndicator();
    5757
    5858        this._imageElement = document.createElement("img");
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js

    r217258 r219017  
    3737        this.element.classList.add(styleClassName, "resource");
    3838
    39         // Append a spinner while waiting for contentAvailable. The subclasses are responsible for removing
    40         // the spinner before showing the resource content.
    41         var spinner = new WebInspector.IndeterminateProgressSpinner;
    42         this.element.appendChild(spinner.element);
     39        this._spinnerTimeout = setTimeout(() => {
     40            // Append a spinner while waiting for contentAvailable. Subclasses are responsible for
     41            // removing the spinner before showing the resource content by calling removeLoadingIndicator.
     42            let spinner = new WebInspector.IndeterminateProgressSpinner;
     43            this.element.appendChild(spinner.element);
     44
     45            this._spinnerTimeout = undefined;
     46        }, 100);
    4347
    4448        this.element.addEventListener("click", this._mouseWasClicked.bind(this), false);
     
    98102    }
    99103
     104    // Protected
     105
     106    removeLoadingIndicator()
     107    {
     108        if (this._spinnerTimeout) {
     109            clearTimeout(this._spinnerTimeout);
     110            this._spinnerTimeout = undefined;
     111        }
     112
     113        this.element.removeChildren();
     114    }
     115
    100116    // Private
    101117
     
    118134            return;
    119135
    120         this.element.removeChildren();
     136        this.removeLoadingIndicator();
     137
    121138        this.element.appendChild(WebInspector.createMessageTextView(error, true));
    122139
     
    126143    _hasContent()
    127144    {
    128         return !this.element.querySelector(".indeterminate-progress-spinner");
     145        return this.element.hasChildNodes() && !this.element.querySelector(".indeterminate-progress-spinner");
    129146    }
    130147
  • trunk/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js

    r217258 r219017  
    192192            return;
    193193
    194         this.element.removeChildren();
     194        this.removeLoadingIndicator();
     195
    195196        this.addSubview(this._textEditor);
    196197    }
Note: See TracChangeset for help on using the changeset viewer.