Title: [253739] trunk/Source
Revision
253739
Author
[email protected]
Date
2019-12-18 23:35:28 -0800 (Wed, 18 Dec 2019)

Log Message

Web Inspector: Elements: restrict showing paint flashing and compositing borders to the Web Inspector session
https://bugs.webkit.org/show_bug.cgi?id=205201

Reviewed by Timothy Hatcher.

We often get bugs from users who turn on paint flashing or compositing borders, close Web
Inspector, reopen Web Inspector, and are then surprised when the page flashes red or these
borders exist all over the page.

Given that the dark mode and print styles toggles are limited to the Web Inspector session,
we should make these have the same behavior.

Source/_javascript_Core:

* inspector/protocol/Page.json:
Allow Web Inspector to override the `showDebugBorders` and `showRepaintCounter` settings via
the `inspectorOverride` key, rather than setting them manually via a special `Page` command.

Source/WebCore:

* page/Settings.yaml:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::getCompositingBordersVisible): Deleted.
(WebCore::InspectorPageAgent::setCompositingBordersVisible): Deleted.
Allow Web Inspector to override the `showDebugBorders` and `showRepaintCounter` settings via
the `inspectorOverride` key, rather than setting them manually via a special `Page` command.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI.initializeTarget):
* UserInterface/Base/Setting.js:
* UserInterface/Controllers/LayerTreeManager.js:
(WI.LayerTreeManager): Added.
(WI.LayerTreeManager.prototype.initializeTarget):
(WI.LayerTreeManager.supportsShowingPaintRects): Added.
(WI.LayerTreeManager.supportsVisibleCompositingBorders): Added.
(WI.LayerTreeManager.prototype.get showPaintRects): Added.
(WI.LayerTreeManager.prototype.set showPaintRects): Added.
(WI.LayerTreeManager.prototype.get compositingBordersVisible): Added.
(WI.LayerTreeManager.prototype.set compositingBordersVisible): Added.
(WI.LayerTreeManager.prototype.updateCompositingBordersVisibleFromPageIfNeeded): Added.
Use `WI.LayerTreeManager` to control the state of paint flashing and compositing borders, as
they're both related to the concept of layers.

* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView):
(WI.DOMTreeContentView.prototype.shown):
(WI.DOMTreeContentView.prototype.closed):
(WI.DOMTreeContentView.prototype.attached): Added.
(WI.DOMTreeContentView.prototype.detached): Added.
(WI.DOMTreeContentView.prototype._handleCompositingBordersVisibleChanged): Added.
(WI.DOMTreeContentView.prototype._handleCompositingBordersButtonClicked): Added.
(WI.DOMTreeContentView.prototype._handleShowPaintRectsChanged): Added.
(WI.DOMTreeContentView.prototype._handlePaingFlashingButtonClicked): Added.
(WI.DOMTreeContentView.prototype._toggleCompositingBorders): Deleted.
(WI.DOMTreeContentView.prototype._togglePaintFlashing): Deleted.
(WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings): Deleted.
(WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged): Deleted.

* UserInterface/Views/Layers3DContentView.js:
(WI.Layers3DContentView):
(WI.Layers3DContentView.prototype.shown):
(WI.Layers3DContentView.prototype.hidden):
(WI.Layers3DContentView.prototype.attached): Added.
(WI.Layers3DContentView.prototype.detached): Added.
(WI.Layers3DContentView.prototype._handleCompositingBordersVisibleChanged): Added.
(WI.Layers3DContentView.prototype._handleCompositingBordersButtonClicked): Added.
(WI.Layers3DContentView.prototype._handleShowPaintRectsChanged): Added.
(WI.Layers3DContentView.prototype._handlePaingFlashingButtonClicked): Added.
(WI.Layers3DContentView.prototype.closed): Deleted.
(WI.Layers3DContentView.prototype._showPaintRectsSettingChanged): Deleted.
(WI.Layers3DContentView.prototype._togglePaintFlashing): Deleted.
(WI.Layers3DContentView.prototype._updateCompositingBordersButtonState): Deleted.
(WI.Layers3DContentView.prototype._toggleCompositingBorders): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (253738 => 253739)


--- trunk/Source/_javascript_Core/ChangeLog	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-12-19 07:35:28 UTC (rev 253739)
@@ -1,3 +1,21 @@
+2019-12-18  Devin Rousso  <[email protected]>
+
+        Web Inspector: Elements: restrict showing paint flashing and compositing borders to the Web Inspector session
+        https://bugs.webkit.org/show_bug.cgi?id=205201
+
+        Reviewed by Timothy Hatcher.
+
+        We often get bugs from users who turn on paint flashing or compositing borders, close Web
+        Inspector, reopen Web Inspector, and are then surprised when the page flashes red or these
+        borders exist all over the page.
+
+        Given that the dark mode and print styles toggles are limited to the Web Inspector session,
+        we should make these have the same behavior.
+
+        * inspector/protocol/Page.json:
+        Allow Web Inspector to override the `showDebugBorders` and `showRepaintCounter` settings via
+        the `inspectorOverride` key, rather than setting them manually via a special `Page` command.
+
 2019-12-17  Yusuke Suzuki  <[email protected]>
 
         [JSC] 8Bit JSRopeString can contain 16Bit string in its rope

Modified: trunk/Source/_javascript_Core/inspector/protocol/Page.json (253738 => 253739)


--- trunk/Source/_javascript_Core/inspector/protocol/Page.json	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/_javascript_Core/inspector/protocol/Page.json	2019-12-19 07:35:28 UTC (rev 253739)
@@ -16,6 +16,8 @@
                 "MockCaptureDevicesEnabled",
                 "NeedsSiteSpecificQuirks",
                 "ScriptEnabled",
+                "ShowDebugBorders",
+                "ShowRepaintCounter",
                 "WebRTCEncryptionEnabled",
                 "WebSecurityEnabled"
             ]
@@ -245,20 +247,6 @@
             ]
         },
         {
-            "name": "getCompositingBordersVisible",
-            "description": "Indicates the visibility of compositing borders.",
-            "returns": [
-                { "name": "result", "type": "boolean", "description": "If true, compositing borders are visible." }
-            ]
-        },
-        {
-            "name": "setCompositingBordersVisible",
-            "description": "Controls the visibility of compositing borders.",
-            "parameters": [
-                { "name": "visible", "type": "boolean", "description": "True for showing compositing borders." }
-            ]
-        },
-        {
             "name": "snapshotNode",
             "description": "Capture a snapshot of the specified node that does not include unrelated layers.",
             "parameters": [

Modified: trunk/Source/WebCore/ChangeLog (253738 => 253739)


--- trunk/Source/WebCore/ChangeLog	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebCore/ChangeLog	2019-12-19 07:35:28 UTC (rev 253739)
@@ -1,3 +1,25 @@
+2019-12-18  Devin Rousso  <[email protected]>
+
+        Web Inspector: Elements: restrict showing paint flashing and compositing borders to the Web Inspector session
+        https://bugs.webkit.org/show_bug.cgi?id=205201
+
+        Reviewed by Timothy Hatcher.
+
+        We often get bugs from users who turn on paint flashing or compositing borders, close Web
+        Inspector, reopen Web Inspector, and are then surprised when the page flashes red or these
+        borders exist all over the page.
+
+        Given that the dark mode and print styles toggles are limited to the Web Inspector session,
+        we should make these have the same behavior.
+
+        * page/Settings.yaml:
+        * inspector/agents/InspectorPageAgent.h:
+        * inspector/agents/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::getCompositingBordersVisible): Deleted.
+        (WebCore::InspectorPageAgent::setCompositingBordersVisible): Deleted.
+        Allow Web Inspector to override the `showDebugBorders` and `showRepaintCounter` settings via
+        the `inspectorOverride` key, rather than setting them manually via a special `Page` command.
+
 2019-12-18  Tim Horton  <[email protected]>
 
         macCatalyst: Cursor should update when the platform deems it necessary

Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (253738 => 253739)


--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2019-12-19 07:35:28 UTC (rev 253739)
@@ -94,6 +94,8 @@
     macro(MockCaptureDevicesEnabled) \
     macro(NeedsSiteSpecificQuirks) \
     macro(ScriptEnabled) \
+    macro(ShowDebugBorders) \
+    macro(ShowRepaintCounter) \
     macro(WebRTCEncryptionEnabled) \
     macro(WebSecurityEnabled)
 
@@ -926,17 +928,6 @@
         media = m_emulatedMedia;
 }
 
-void InspectorPageAgent::getCompositingBordersVisible(ErrorString&, bool* outParam)
-{
-    *outParam = m_inspectedPage.settings().showDebugBorders() || m_inspectedPage.settings().showRepaintCounter();
-}
-
-void InspectorPageAgent::setCompositingBordersVisible(ErrorString&, bool visible)
-{
-    m_inspectedPage.settings().setShowDebugBorders(visible);
-    m_inspectedPage.settings().setShowRepaintCounter(visible);
-}
-
 void InspectorPageAgent::snapshotNode(ErrorString& errorString, int nodeId, String* outDataURL)
 {
     InspectorDOMAgent* domAgent = m_instrumentingAgents.inspectorDOMAgent();

Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h (253738 => 253739)


--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h	2019-12-19 07:35:28 UTC (rev 253739)
@@ -110,8 +110,6 @@
     void setShowPaintRects(ErrorString&, bool show) override;
     void setEmulatedMedia(ErrorString&, const String&) override;
     void setForcedAppearance(ErrorString&, const String&) override;
-    void getCompositingBordersVisible(ErrorString&, bool* out_param) override;
-    void setCompositingBordersVisible(ErrorString&, bool) override;
     void snapshotNode(ErrorString&, int nodeId, String* outDataURL) override;
     void snapshotRect(ErrorString&, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL) override;
     void archive(ErrorString&, String* data) override;

Modified: trunk/Source/WebCore/page/Settings.yaml (253738 => 253739)


--- trunk/Source/WebCore/page/Settings.yaml	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebCore/page/Settings.yaml	2019-12-19 07:35:28 UTC (rev 253739)
@@ -144,9 +144,11 @@
 showDebugBorders:
   initial: false
   onChange: setNeedsRecalcStyleInAllFrames
+  inspectorOverride: true
 showRepaintCounter:
   initial: false
   onChange: setNeedsRecalcStyleInAllFrames
+  inspectorOverride: true
 visibleDebugOverlayRegions:
   type: DebugOverlayRegions
   initial: 0

Modified: trunk/Source/WebInspectorUI/ChangeLog (253738 => 253739)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-12-19 07:35:28 UTC (rev 253739)
@@ -1,3 +1,64 @@
+2019-12-18  Devin Rousso  <[email protected]>
+
+        Web Inspector: Elements: restrict showing paint flashing and compositing borders to the Web Inspector session
+        https://bugs.webkit.org/show_bug.cgi?id=205201
+
+        Reviewed by Timothy Hatcher.
+
+        We often get bugs from users who turn on paint flashing or compositing borders, close Web
+        Inspector, reopen Web Inspector, and are then surprised when the page flashes red or these
+        borders exist all over the page.
+
+        Given that the dark mode and print styles toggles are limited to the Web Inspector session,
+        we should make these have the same behavior.
+
+        * UserInterface/Base/Main.js:
+        (WI.initializeTarget):
+        * UserInterface/Base/Setting.js:
+        * UserInterface/Controllers/LayerTreeManager.js:
+        (WI.LayerTreeManager): Added.
+        (WI.LayerTreeManager.prototype.initializeTarget):
+        (WI.LayerTreeManager.supportsShowingPaintRects): Added.
+        (WI.LayerTreeManager.supportsVisibleCompositingBorders): Added.
+        (WI.LayerTreeManager.prototype.get showPaintRects): Added.
+        (WI.LayerTreeManager.prototype.set showPaintRects): Added.
+        (WI.LayerTreeManager.prototype.get compositingBordersVisible): Added.
+        (WI.LayerTreeManager.prototype.set compositingBordersVisible): Added.
+        (WI.LayerTreeManager.prototype.updateCompositingBordersVisibleFromPageIfNeeded): Added.
+        Use `WI.LayerTreeManager` to control the state of paint flashing and compositing borders, as
+        they're both related to the concept of layers.
+
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WI.DOMTreeContentView):
+        (WI.DOMTreeContentView.prototype.shown):
+        (WI.DOMTreeContentView.prototype.closed):
+        (WI.DOMTreeContentView.prototype.attached): Added.
+        (WI.DOMTreeContentView.prototype.detached): Added.
+        (WI.DOMTreeContentView.prototype._handleCompositingBordersVisibleChanged): Added.
+        (WI.DOMTreeContentView.prototype._handleCompositingBordersButtonClicked): Added.
+        (WI.DOMTreeContentView.prototype._handleShowPaintRectsChanged): Added.
+        (WI.DOMTreeContentView.prototype._handlePaingFlashingButtonClicked): Added.
+        (WI.DOMTreeContentView.prototype._toggleCompositingBorders): Deleted.
+        (WI.DOMTreeContentView.prototype._togglePaintFlashing): Deleted.
+        (WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings): Deleted.
+        (WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged): Deleted.
+
+        * UserInterface/Views/Layers3DContentView.js:
+        (WI.Layers3DContentView):
+        (WI.Layers3DContentView.prototype.shown):
+        (WI.Layers3DContentView.prototype.hidden):
+        (WI.Layers3DContentView.prototype.attached): Added.
+        (WI.Layers3DContentView.prototype.detached): Added.
+        (WI.Layers3DContentView.prototype._handleCompositingBordersVisibleChanged): Added.
+        (WI.Layers3DContentView.prototype._handleCompositingBordersButtonClicked): Added.
+        (WI.Layers3DContentView.prototype._handleShowPaintRectsChanged): Added.
+        (WI.Layers3DContentView.prototype._handlePaingFlashingButtonClicked): Added.
+        (WI.Layers3DContentView.prototype.closed): Deleted.
+        (WI.Layers3DContentView.prototype._showPaintRectsSettingChanged): Deleted.
+        (WI.Layers3DContentView.prototype._togglePaintFlashing): Deleted.
+        (WI.Layers3DContentView.prototype._updateCompositingBordersButtonState): Deleted.
+        (WI.Layers3DContentView.prototype._toggleCompositingBorders): Deleted.
+
 2019-12-18  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: Runtime.enable reports duplicates (non existent) contexts

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (253738 => 253739)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-12-19 07:35:28 UTC (rev 253739)
@@ -583,13 +583,9 @@
                 target.PageAgent.overrideSetting(setting, value);
         }
 
-        // COMPATIBILITY (iOS 11.3)
+        // COMPATIBILITY (iOS 11.3): Page.setShowRuleers did not exist yet.
         if (target.hasCommand("Page.setShowRulers") && WI.settings.showRulers.value)
             target.PageAgent.setShowRulers(true);
-
-        // COMPATIBILITY (iOS 8): Page.setShowPaintRects did not exist.
-        if (target.hasCommand("Page.setShowPaintRects") && WI.settings.showPaintRects.value)
-            target.PageAgent.setShowPaintRects(true);
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (253738 => 253739)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2019-12-19 07:35:28 UTC (rev 253739)
@@ -206,7 +206,6 @@
     showImageGrid: new WI.Setting("show-image-grid", true),
     showInvisibleCharacters: new WI.Setting("show-invisible-characters", !!WI.Setting.migrateValue("show-invalid-characters")),
     showJavaScriptTypeInformation: new WI.Setting("show-_javascript_-type-information", false),
-    showPaintRects: new WI.Setting("show-paint-rects", false),
     showRulers: new WI.Setting("show-rulers", false),
     showRulersDuringElementSelection: new WI.Setting("show-rulers-during-element-selection", true),
     showScopeChainOnPause: new WI.Setting("show-scope-chain-sidebar", true),

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js (253738 => 253739)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js	2019-12-19 07:35:28 UTC (rev 253739)
@@ -27,6 +27,14 @@
 
 WI.LayerTreeManager = class LayerTreeManager extends WI.Object
 {
+    constructor()
+    {
+        super();
+
+        this._showPaintRects = false;
+        this._compositingBordersVisible = false;
+    }
+
     // Target
 
     initializeTarget(target)
@@ -33,8 +41,35 @@
     {
         if (target.hasDomain("LayerTree"))
             target.LayerTreeAgent.enable();
+
+        if (target.hasDomain("Page")) {
+            if (target.hasCommand("Page.setShowPaintRects") && this._showPaintRects)
+                target.PageAgent.setShowPaintRects(this._showPaintRects);
+
+            if (this._compositingBordersVisible) {
+                // COMPATIBILITY(iOS 13.1): Page.setCompositingBordersVisible was replaced by Page.Setting.ShowDebugBorders and Page.Setting.ShowRepaintCounter.
+                if (target.hasCommand("Page.overrideSetting") && InspectorBackend.Enum.Page.Setting.ShowDebugBorders && InspectorBackend.Enum.Page.Setting.ShowRepaintCounter) {
+                    target.PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.ShowDebugBorders, this._compositingBordersVisible);
+                    target.PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.ShowRepaintCounter, this._compositingBordersVisible);
+                } else if (target.hasCommand("Page.setCompositingBordersVisible"))
+                    target.PageAgent.setCompositingBordersVisible(this._compositingBordersVisible);
+            }
+        }
     }
 
+    // Static
+
+    static supportsShowingPaintRects()
+    {
+        return InspectorBackend.hasCommand("Page.setShowPaintRects");
+    }
+
+    static supportsVisibleCompositingBorders()
+    {
+        return InspectorBackend.hasCommand("Page.setCompositingBordersVisible")
+            || (InspectorBackend.Enum.Page.Setting.ShowDebugBorders && InspectorBackend.Enum.Page.Setting.ShowRepaintCounter);
+    }
+
     // Public
 
     get supported()
@@ -42,6 +77,76 @@
         return InspectorBackend.hasDomain("LayerTree");
     }
 
+    get showPaintRects()
+    {
+        return this._showPaintRects;
+    }
+
+    set showPaintRects(showPaintRects)
+    {
+        if (this._showPaintRects === showPaintRects)
+            return;
+
+        this._showPaintRects = showPaintRects;
+
+        for (let target of WI.targets) {
+            // COMPATIBILITY (iOS 9): Page.setCompositingBordersVisible did not exist yet.
+            if (target.hasCommand("Page.setShowPaintRects"))
+                target.PageAgent.setShowPaintRects(this._showPaintRects);
+        }
+
+        this.dispatchEventToListeners(LayerTreeManager.Event.ShowPaintRectsChanged);
+    }
+
+    get compositingBordersVisible()
+    {
+        return this._compositingBordersVisible;
+    }
+
+    set compositingBordersVisible(compositingBordersVisible)
+    {
+        if (this._compositingBordersVisible === compositingBordersVisible)
+            return;
+
+        this._compositingBordersVisible = compositingBordersVisible;
+
+        for (let target of WI.targets) {
+            // COMPATIBILITY(iOS 13.1): Page.setCompositingBordersVisible was replaced by Page.Setting.ShowDebugBorders and Page.Setting.ShowRepaintCounter.
+            if (target.hasCommand("Page.overrideSetting") && InspectorBackend.Enum.Page.Setting.ShowDebugBorders && InspectorBackend.Enum.Page.Setting.ShowRepaintCounter) {
+                target.PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.ShowDebugBorders, this._compositingBordersVisible);
+                target.PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.ShowRepaintCounter, this._compositingBordersVisible);
+            } else if (target.hasCommand("Page.setCompositingBordersVisible"))
+                target.PageAgent.setCompositingBordersVisible(this._compositingBordersVisible);
+        }
+
+        this.dispatchEventToListeners(LayerTreeManager.Event.CompositingBordersVisibleChanged);
+    }
+
+    updateCompositingBordersVisibleFromPageIfNeeded()
+    {
+        if (!WI.targetsAvailable()) {
+            WI.whenTargetsAvailable().then(() => {
+                this.updateCompositingBordersVisibleFromPageIfNeeded();
+            });
+            return;
+        }
+
+        let target = WI.assumingMainTarget();
+
+        // COMPATIBILITY(iOS 13.1): Page.getCompositingBordersVisible was replaced by Page.Setting.ShowDebugBorders and Page.Setting.ShowRepaintCounter.
+        if (!target.hasCommand("Page.getCompositingBordersVisible"))
+            return;
+
+        target.PageAgent.getCompositingBordersVisible((error, compositingBordersVisible) => {
+            if (error) {
+                WI.reportInternalError(error);
+                return;
+            }
+
+            this.compositingBordersVisible = compositingBordersVisible;
+        });
+    }
+
     layerTreeMutations(previousLayers, newLayers)
     {
         console.assert(this.supported);
@@ -101,5 +206,7 @@
 };
 
 WI.LayerTreeManager.Event = {
-    LayerTreeDidChange: "layer-tree-did-change"
+    ShowPaintRectsChanged: "show-paint-rects-changed",
+    CompositingBordersVisibleChanged: "compositing-borders-visible-changed",
+    LayerTreeDidChange: "layer-tree-did-change",
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (253738 => 253739)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2019-12-19 07:35:28 UTC (rev 253739)
@@ -51,16 +51,13 @@
         this._forceAppearanceButtonNavigationItem.enabled = WI.cssManager.canForceAppearance();
 
         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.hasDomain("Page");
+        this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleCompositingBordersButtonClicked, this);
+        this._compositingBordersButtonNavigationItem.enabled = WI.LayerTreeManager.supportsVisibleCompositingBorders();
         this._compositingBordersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
-        // COMPATIBILITY (iOS 9)
-        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 = InspectorBackend.hasCommand("Page.setShowPaintRects");
-        this._paintFlashingButtonNavigationItem.activated = this._paintFlashingButtonNavigationItem.enabled && WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handlePaingFlashingButtonClicked, this);
+        this._paintFlashingButtonNavigationItem.enabled = WI.LayerTreeManager.supportsShowingPaintRects();
         this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         this.element.classList.add("dom-tree");
@@ -147,7 +144,6 @@
         super.shown();
 
         this._domTreeOutline.setVisible(true, WI.isConsoleFocused());
-        this._updateCompositingBordersButtonToMatchPageSettings();
 
         if (!this._domTreeOutline.rootDOMNode)
             return;
@@ -167,7 +163,6 @@
     {
         super.closed();
 
-        WI.settings.showPaintRects.removeEventListener(null, null, this);
         WI.settings.showRulers.removeEventListener(null, null, this);
         WI.debuggerManager.removeEventListener(null, null, this);
         WI.domManager.removeEventListener(null, null, this);
@@ -383,6 +378,27 @@
 
     // Protected
 
+    attached()
+    {
+        super.attached();
+
+        WI.layerTreeManager.updateCompositingBordersVisibleFromPageIfNeeded();
+
+        WI.layerTreeManager.addEventListener(WI.LayerTreeManager.Event.CompositingBordersVisibleChanged, this._handleCompositingBordersVisibleChanged, this);
+        this._handleCompositingBordersVisibleChanged();
+
+        WI.layerTreeManager.addEventListener(WI.LayerTreeManager.Event.ShowPaintRectsChanged, this._handleShowPaintRectsChanged, this);
+        this._handleShowPaintRectsChanged();
+    }
+
+    detached()
+    {
+        WI.layerTreeManager.removeEventListener(WI.LayerTreeManager.Event.ShowPaintRectsChanged, this._handleShowPaintRectsChanged, this);
+        WI.layerTreeManager.removeEventListener(WI.LayerTreeManager.Event.CompositingBordersVisibleChanged, this._handleCompositingBordersVisibleChanged, this);
+
+        super.detached();
+    }
+
     sizeDidChange()
     {
         super.sizeDidChange();
@@ -579,51 +595,24 @@
         this._followLinkTimeoutIdentifier = setTimeout(followLink.bind(this), 333);
     }
 
-    _toggleCompositingBorders(event)
+    _handleCompositingBordersVisibleChanged(event)
     {
-        var activated = !this._compositingBordersButtonNavigationItem.activated;
-        this._compositingBordersButtonNavigationItem.activated = activated;
-
-        for (let target of WI.targets) {
-            if (target.hasDomain("Page"))
-                target.PageAgent.setCompositingBordersVisible(activated);
-        }
+        this._compositingBordersButtonNavigationItem.activated = WI.layerTreeManager.compositingBordersVisible;
     }
 
-    _togglePaintFlashing(event)
+    _handleCompositingBordersButtonClicked(event)
     {
-        WI.settings.showPaintRects.value = !WI.settings.showPaintRects.value;
+        WI.layerTreeManager.compositingBordersVisible = !WI.layerTreeManager.compositingBordersVisible;
     }
 
-    _updateCompositingBordersButtonToMatchPageSettings()
+    _handleShowPaintRectsChanged(event)
     {
-        if (!WI.targetsAvailable()) {
-            WI.whenTargetsAvailable().then(() => {
-                this._updateCompositingBordersButtonToMatchPageSettings();
-            });
-            return;
-        }
-
-        var button = this._compositingBordersButtonNavigationItem;
-
-        // We need to sync with the page settings since these can be controlled
-        // in a different way than just using the navigation bar button.
-        let target = WI.assumingMainTarget();
-        target.PageAgent.getCompositingBordersVisible(function(error, compositingBordersVisible) {
-            button.activated = error ? false : compositingBordersVisible;
-            button.enabled = error !== "unsupported";
-        });
+        this._paintFlashingButtonNavigationItem.activated = WI.layerTreeManager.showPaintRects;
     }
 
-    _showPaintRectsSettingChanged(event)
+    _handlePaingFlashingButtonClicked(event)
     {
-        let activated = WI.settings.showPaintRects.value;
-        this._paintFlashingButtonNavigationItem.activated = activated;
-
-        for (let target of WI.targets) {
-            if (target.hasCommand("Page.setShowPaintRects"))
-                target.PageAgent.setShowPaintRects(activated);
-        }
+        WI.layerTreeManager.showPaintRects = !WI.layerTreeManager.showPaintRects;
     }
 
     _showPrintStylesChanged()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js (253738 => 253739)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js	2019-12-19 06:35:37 UTC (rev 253738)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js	2019-12-19 07:35:28 UTC (rev 253739)
@@ -32,15 +32,13 @@
         this.element.classList.add("layers-3d");
 
         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.hasDomain("Page");
+        this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleCompositingBordersButtonClicked, this);
+        this._compositingBordersButtonNavigationItem.enabled = WI.LayerTreeManager.supportsVisibleCompositingBorders();
         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 = InspectorBackend.hasCommand("Page.setShowPaintRects");
-        this._paintFlashingButtonNavigationItem.activated = this._paintFlashingButtonNavigationItem.enabled && WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handlePaingFlashingButtonClicked, this);
+        this._paintFlashingButtonNavigationItem.enabled = WI.LayerTreeManager.supportsShowingPaintRects();
         this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         this._layers = [];
@@ -80,8 +78,6 @@
     {
         super.shown();
 
-        this._updateCompositingBordersButtonState();
-
         this.updateLayout();
         WI.layerTreeManager.addEventListener(WI.LayerTreeManager.Event.LayerTreeDidChange, this._layerTreeDidChange, this);
 
@@ -92,18 +88,12 @@
     hidden()
     {
         WI.layerTreeManager.removeEventListener(WI.LayerTreeManager.Event.LayerTreeDidChange, this._layerTreeDidChange, this);
+
         this._stopAnimation();
 
         super.hidden();
     }
 
-    closed()
-    {
-        WI.settings.showPaintRects.removeEventListener(WI.Setting.Event.Changed, this._showPaintRectsSettingChanged, this);
-
-        super.closed();
-    }
-
     selectLayerById(layerId)
     {
         let layerGroup = this._layerGroupsById.get(layerId);
@@ -139,6 +129,27 @@
 
     // Protected
 
+    attached()
+    {
+        super.attached();
+
+        WI.layerTreeManager.updateCompositingBordersVisibleFromPageIfNeeded();
+
+        WI.layerTreeManager.addEventListener(WI.LayerTreeManager.Event.CompositingBordersVisibleChanged, this._handleCompositingBordersVisibleChanged, this);
+        this._handleCompositingBordersVisibleChanged();
+
+        WI.layerTreeManager.addEventListener(WI.LayerTreeManager.Event.ShowPaintRectsChanged, this._handleShowPaintRectsChanged, this);
+        this._handleShowPaintRectsChanged();
+    }
+
+    detached()
+    {
+        WI.layerTreeManager.removeEventListener(WI.LayerTreeManager.Event.ShowPaintRectsChanged, this._handleShowPaintRectsChanged, this);
+        WI.layerTreeManager.removeEventListener(WI.LayerTreeManager.Event.CompositingBordersVisibleChanged, this._handleCompositingBordersVisibleChanged, this);
+
+        super.detached();
+    }
+
     initialLayout()
     {
         super.initialLayout();
@@ -395,49 +406,24 @@
         this._camera.position.add(delta);
     }
 
-    _showPaintRectsSettingChanged(event)
+    _handleCompositingBordersVisibleChanged(event)
     {
-        let activated = WI.settings.showPaintRects.value;
-        this._paintFlashingButtonNavigationItem.activated = activated;
-
-        for (let target of WI.targets) {
-            if (target.hasCommand("Page.setShowPaintRects"))
-                target.PageAgent.setShowPaintRects(activated);
-        }
+        this._compositingBordersButtonNavigationItem.activated = WI.layerTreeManager.compositingBordersVisible;
     }
 
-    _togglePaintFlashing(event)
+    _handleCompositingBordersButtonClicked(event)
     {
-        WI.settings.showPaintRects.value = !WI.settings.showPaintRects.value;
+        WI.layerTreeManager.compositingBordersVisible = !WI.layerTreeManager.compositingBordersVisible;
     }
 
-    _updateCompositingBordersButtonState()
+    _handleShowPaintRectsChanged(event)
     {
-        if (!WI.targetsAvailable()) {
-            WI.whenTargetsAvailable().then(() => {
-                this._updateCompositingBordersButtonState();
-            });
-            return;
-        }
-
-        // This value can be changed outside of Web Inspector.
-        // FIXME: Have PageAgent dispatch a change event instead?
-        let target = WI.assumingMainTarget();
-        target.PageAgent.getCompositingBordersVisible((error, compositingBordersVisible) => {
-            this._compositingBordersButtonNavigationItem.activated = error ? false : compositingBordersVisible;
-            this._compositingBordersButtonNavigationItem.enabled = error !== "unsupported";
-        });
+        this._paintFlashingButtonNavigationItem.activated = WI.layerTreeManager.showPaintRects;
     }
 
-    _toggleCompositingBorders(event)
+    _handlePaingFlashingButtonClicked(event)
     {
-        let activated = !this._compositingBordersButtonNavigationItem.activated;
-        this._compositingBordersButtonNavigationItem.activated = activated;
-
-        for (let target of WI.targets) {
-            if (target.hasDomain("Page"))
-                target.PageAgent.setCompositingBordersVisible(activated);
-        }
+        WI.layerTreeManager.showPaintRects = !WI.layerTreeManager.showPaintRects;
     }
 
     _buildLayerInfoElement()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to