Title: [247356] trunk/Source/WebInspectorUI
Revision
247356
Author
drou...@apple.com
Date
2019-07-11 11:36:57 -0700 (Thu, 11 Jul 2019)

Log Message

Web Inspector: Layers: Uncaught Exception: Request with id = 2 failed. {"code":-32601,"message":"'Page' domain was not found","data":[{"code":-32601,"message":"'Page' domain was not found"}]}
https://bugs.webkit.org/show_bug.cgi?id=199555

Reviewed by Joseph Pecoraro.

Use modern inspected target support checking, and defer agent commands until a target is
available.

* UserInterface/Views/Layers3DContentView.js:
(WI.Layers3DContentView):
(WI.Layers3DContentView.prototype._showPaintRectsSettingChanged):
(WI.Layers3DContentView.prototype._updateCompositingBordersButtonState):
(WI.Layers3DContentView.prototype._toggleCompositingBorders):

* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView):
(WI.DOMTreeContentView.prototype._toggleCompositingBorders):
(WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings):
(WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged):
(WI.DOMTreeContentView.prototype._showPrintStylesChanged):
(WI.DOMTreeContentView.prototype._showRulersChanged):
Drive-by: apply the same changes to the Elements tab for when the Layers tab isn't enabled.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (247355 => 247356)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-07-11 17:17:58 UTC (rev 247355)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-07-11 18:36:57 UTC (rev 247356)
@@ -1,3 +1,28 @@
+2019-07-11  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Layers: Uncaught Exception: Request with id = 2 failed. {"code":-32601,"message":"'Page' domain was not found","data":[{"code":-32601,"message":"'Page' domain was not found"}]}
+        https://bugs.webkit.org/show_bug.cgi?id=199555
+
+        Reviewed by Joseph Pecoraro.
+
+        Use modern inspected target support checking, and defer agent commands until a target is
+        available.
+
+        * UserInterface/Views/Layers3DContentView.js:
+        (WI.Layers3DContentView):
+        (WI.Layers3DContentView.prototype._showPaintRectsSettingChanged):
+        (WI.Layers3DContentView.prototype._updateCompositingBordersButtonState):
+        (WI.Layers3DContentView.prototype._toggleCompositingBorders):
+
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WI.DOMTreeContentView):
+        (WI.DOMTreeContentView.prototype._toggleCompositingBorders):
+        (WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings):
+        (WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged):
+        (WI.DOMTreeContentView.prototype._showPrintStylesChanged):
+        (WI.DOMTreeContentView.prototype._showRulersChanged):
+        Drive-by: apply the same changes to the Elements tab for when the Layers tab isn't enabled.
+
 2019-07-09  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: Canvas: replace WTF::Vector with std::initializer_list in CallTracer to avoid dynamic allocations

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (247355 => 247356)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2019-07-11 17:17:58 UTC (rev 247355)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2019-07-11 18:36:57 UTC (rev 247356)
@@ -34,7 +34,7 @@
         if (InspectorBackend.domains.Page) {
             this._compositingBordersButtonNavigationItem = new WI.ActivateButtonNavigationItem("layer-borders", WI.UIString("Show compositing borders"), WI.UIString("Hide compositing borders"), "Images/LayerBorders.svg", 13, 13);
             this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleCompositingBorders, this);
-            this._compositingBordersButtonNavigationItem.enabled = !!PageAgent.getCompositingBordersVisible;
+            this._compositingBordersButtonNavigationItem.enabled = !!InspectorBackend.domains.Page.getCompositingBordersVisible;
             this._compositingBordersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
         }
 
@@ -42,8 +42,8 @@
             WI.settings.showPaintRects.addEventListener(WI.Setting.Event.Changed, this._showPaintRectsSettingChanged, this);
             this._paintFlashingButtonNavigationItem = new WI.ActivateButtonNavigationItem("paint-flashing", WI.UIString("Enable paint flashing"), WI.UIString("Disable paint flashing"), "Images/Paint.svg", 16, 16);
             this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._togglePaintFlashing, this);
-            this._paintFlashingButtonNavigationItem.enabled = !!PageAgent.setShowPaintRects;
-            this._paintFlashingButtonNavigationItem.activated = PageAgent.setShowPaintRects && WI.settings.showPaintRects.value;
+            this._paintFlashingButtonNavigationItem.enabled = !!InspectorBackend.domains.Page.setShowPaintRects;
+            this._paintFlashingButtonNavigationItem.activated = InspectorBackend.domains.Page.setShowPaintRects && WI.settings.showPaintRects.value;
             this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
         }
 
@@ -590,11 +590,13 @@
 
     _toggleCompositingBorders(event)
     {
-        console.assert(PageAgent.setCompositingBordersVisible);
-
         var activated = !this._compositingBordersButtonNavigationItem.activated;
         this._compositingBordersButtonNavigationItem.activated = activated;
-        PageAgent.setCompositingBordersVisible(activated);
+
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setCompositingBordersVisible(activated);
+        }
     }
 
     _togglePaintFlashing(event)
@@ -604,6 +606,16 @@
 
     _updateCompositingBordersButtonToMatchPageSettings()
     {
+        if (!WI.targetsAvailable()) {
+            WI.whenTargetsAvailable().then(() => {
+                this._updateCompositingBordersButtonToMatchPageSettings();
+            });
+            return;
+        }
+
+        if (!window.PageAgent)
+            return;
+
         var button = this._compositingBordersButtonNavigationItem;
 
         // We need to sync with the page settings since these can be controlled
@@ -616,11 +628,13 @@
 
     _showPaintRectsSettingChanged(event)
     {
-        console.assert(PageAgent.setShowPaintRects);
+        let activated = WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.activated = activated;
 
-        this._paintFlashingButtonNavigationItem.activated = WI.settings.showPaintRects.value;
-
-        PageAgent.setShowPaintRects(this._paintFlashingButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowPaintRects)
+                target.PageAgent.setShowPaintRects(activated);
+        }
     }
 
     _showShadowDOMSettingChanged(event)
@@ -638,7 +652,10 @@
         this._showPrintStylesButtonNavigationItem.activated = WI.printStylesEnabled;
 
         let mediaType = WI.printStylesEnabled ? "print" : "";
-        PageAgent.setEmulatedMedia(mediaType);
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setEmulatedMedia(mediaType);
+        }
 
         WI.cssManager.mediaTypeChanged();
     }
@@ -716,11 +733,13 @@
 
     _showRulersChanged()
     {
-        console.assert(PageAgent.setShowRulers);
+        let activated = WI.settings.showRulers.value;
+        this._showRulersButtonNavigationItem.activated = activated;
 
-        this._showRulersButtonNavigationItem.activated = WI.settings.showRulers.value;
-
-        PageAgent.setShowRulers(this._showRulersButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowRulers)
+                target.PageAgent.setShowRulers(activated);
+        }
     }
 
     _toggleShowRulers(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js (247355 => 247356)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js	2019-07-11 17:17:58 UTC (rev 247355)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js	2019-07-11 18:36:57 UTC (rev 247356)
@@ -33,13 +33,14 @@
 
         this._compositingBordersButtonNavigationItem = new WI.ActivateButtonNavigationItem("layer-borders", WI.UIString("Show compositing borders"), WI.UIString("Hide compositing borders"), "Images/LayerBorders.svg", 13, 13);
         this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleCompositingBorders, this);
+        this._compositingBordersButtonNavigationItem.enabled = !!InspectorBackend.domains.Page;
         this._compositingBordersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         WI.settings.showPaintRects.addEventListener(WI.Setting.Event.Changed, this._showPaintRectsSettingChanged, this);
         this._paintFlashingButtonNavigationItem = new WI.ActivateButtonNavigationItem("paint-flashing", WI.UIString("Enable paint flashing"), WI.UIString("Disable paint flashing"), "Images/Paint.svg", 16, 16);
         this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._togglePaintFlashing, this);
-        this._paintFlashingButtonNavigationItem.enabled = !!PageAgent.setShowPaintRects;
-        this._paintFlashingButtonNavigationItem.activated = PageAgent.setShowPaintRects && WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.enabled = InspectorBackend.domains.Page && !!InspectorBackend.domains.Page.setShowPaintRects;
+        this._paintFlashingButtonNavigationItem.activated = InspectorBackend.domains.Page.setShowPaintRects && WI.settings.showPaintRects.value;
         this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         this._layers = [];
@@ -392,10 +393,13 @@
 
     _showPaintRectsSettingChanged(event)
     {
-        console.assert(PageAgent.setShowPaintRects);
+        let activated = WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.activated = activated;
 
-        this._paintFlashingButtonNavigationItem.activated = WI.settings.showPaintRects.value;
-        PageAgent.setShowPaintRects(this._paintFlashingButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowPaintRects)
+                target.PageAgent.setShowPaintRects(activated);
+        }
     }
 
     _togglePaintFlashing(event)
@@ -405,6 +409,16 @@
 
     _updateCompositingBordersButtonState()
     {
+        if (!WI.targetsAvailable()) {
+            WI.whenTargetsAvailable().then(() => {
+                this._updateCompositingBordersButtonState();
+            });
+            return;
+        }
+
+        if (!window.PageAgent)
+            return;
+
         // This value can be changed outside of Web Inspector.
         // FIXME: Have PageAgent dispatch a change event instead?
         PageAgent.getCompositingBordersVisible((error, compositingBordersVisible) => {
@@ -415,8 +429,13 @@
 
     _toggleCompositingBorders(event)
     {
-        this._compositingBordersButtonNavigationItem.activated = !this._compositingBordersButtonNavigationItem.activated;
-        PageAgent.setCompositingBordersVisible(this._compositingBordersButtonNavigationItem.activated);
+        let activated = !this._compositingBordersButtonNavigationItem.activated;
+        this._compositingBordersButtonNavigationItem.activated = activated;
+
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setCompositingBordersVisible(activated);
+        }
     }
 
     _buildLayerInfoElement()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to