Web Inspector: changes to CSS resources only take affect once editing stops
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2019 16:28:16 +0000 (16:28 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2019 16:28:16 +0000 (16:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195774
<rdar://problem/48905413>

Reviewed by Timothy Hatcher.

* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype._resourceContentDidChange.applyStyleSheetChanges.styleSheetFound):
(WI.CSSManager.prototype._resourceContentDidChange):
(WI.CSSManager.prototype._updateResourceContent.fetchedStyleSheetContent):
(WI.CSSManager.prototype._updateResourceContent):
Use a `Throttler` instead of a 500ms debounce.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243208 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js

index 4c1fd6b..8d58393 100644 (file)
@@ -1,5 +1,20 @@
 2019-03-20  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: changes to CSS resources only take affect once editing stops
+        https://bugs.webkit.org/show_bug.cgi?id=195774
+        <rdar://problem/48905413>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/CSSManager.js:
+        (WI.CSSManager.prototype._resourceContentDidChange.applyStyleSheetChanges.styleSheetFound):
+        (WI.CSSManager.prototype._resourceContentDidChange):
+        (WI.CSSManager.prototype._updateResourceContent.fetchedStyleSheetContent):
+        (WI.CSSManager.prototype._updateResourceContent):
+        Use a `Throttler` instead of a 500ms debounce.
+
+2019-03-20  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Search: allow DOM searches to be case sensitive
         https://bugs.webkit.org/show_bug.cgi?id=194673
         <rdar://problem/48087577>
index 199f3d9..a622d0e 100644 (file)
@@ -641,7 +641,7 @@ WI.CSSManager = class CSSManager extends WI.Object
         {
             function styleSheetFound(styleSheet)
             {
-                resource.__pendingChangeTimeout = undefined;
+                resource.__pendingChangeTimeout.cancel();
 
                 console.assert(styleSheet);
                 if (!styleSheet)
@@ -657,9 +657,9 @@ WI.CSSManager = class CSSManager extends WI.Object
             this._lookupStyleSheetForResource(resource, styleSheetFound.bind(this));
         }
 
-        if (resource.__pendingChangeTimeout)
-            clearTimeout(resource.__pendingChangeTimeout);
-        resource.__pendingChangeTimeout = setTimeout(applyStyleSheetChanges.bind(this), 500);
+        if (!resource.__pendingChangeTimeout)
+            resource.__pendingChangeTimeout = new Throttler(applyStyleSheetChanges.bind(this), 100);
+        resource.__pendingChangeTimeout.fire();
     }
 
     _updateResourceContent(styleSheet)
@@ -668,8 +668,9 @@ WI.CSSManager = class CSSManager extends WI.Object
 
         function fetchedStyleSheetContent(parameters)
         {
+            styleSheet.__pendingChangeTimeout.cancel();
+
             let representedObject = parameters.sourceCode;
-            representedObject.__pendingChangeTimeout = undefined;
 
             console.assert(representedObject.url);
             if (!representedObject.url)
@@ -716,9 +717,9 @@ WI.CSSManager = class CSSManager extends WI.Object
                 this._fetchInfoForAllStyleSheets(styleSheetReady.bind(this));
         }
 
-        if (styleSheet.__pendingChangeTimeout)
-            clearTimeout(styleSheet.__pendingChangeTimeout);
-        styleSheet.__pendingChangeTimeout = setTimeout(applyStyleSheetChanges.bind(this), 500);
+        if (!styleSheet.__pendingChangeTimeout)
+            styleSheet.__pendingChangeTimeout = new Throttler(applyStyleSheetChanges.bind(this), 100);
+        styleSheet.__pendingChangeTimeout.fire();
     }
 };