Title: [245730] trunk/Source
Revision
245730
Author
[email protected]
Date
2019-05-23 18:34:32 -0700 (Thu, 23 May 2019)

Log Message

Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
https://bugs.webkit.org/show_bug.cgi?id=198088

Reviewed by Timothy Hatcher.

When trying to "measure" the absolute position (to the viewport) or relative position (to
another element) of a given element, often the easiest way is to enable Element Selection
and Show Rulers at the same time.

This can have the undesired "side-effect" of having the rulers be always present, even when
not highlighting any nodes.

The ideal functionality is to allow the rulers/guides to be shown when element selection is
active and a node is hovered, regardless of whether "Show Rulers" is enabled.

Source/_javascript_Core:

* inspector/protocol/DOM.json:
Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
current value of `Page.setShowRulers` as to whether rulers/guides are shown.

Source/WebCore:

* inspector/InspectorOverlay.h:
(WebCore::InspectorOverlay::setShowRulersDuringElementSelection): Added.
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::paint):
(WebCore::InspectorOverlay::shouldShowOverlay):
(WebCore::InspectorOverlay::drawNodeHighlight):
(WebCore::InspectorOverlay::drawQuadHighlight):
(WebCore::InspectorOverlay::drawElementTitle):
If `showRulersDuringElementSelection` is enabled, draw rulers whenever any highlight bounds
are calculated, but don't update the overlay if it's the only thing enabled (e.g. if there's
no currently hovered node, the overlay will disappear).

* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDOMAgent::inspect):
(WebCore::InspectorDOMAgent::setInspectModeEnabled):
(WebCore::InspectorDOMAgent::setSearchingForNode):
Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
current value of `Page.setShowRulers` as to whether rulers/guides are shown.

Source/WebInspectorUI:

* UserInterface/Base/Setting.js:
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView):
Add a setting for controlling whether rulers/guides are shown during element selection.

* UserInterface/Controllers/DOMManager.js:
(WI.DOMManager.prototype.set inspectModeEnabled):
Pass the setting value as an optional parameter when calling `DOM.setInspectModeEnabled`.

* Localizations/en.lproj/localizedStrings.js:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (245729 => 245730)


--- trunk/Source/_javascript_Core/ChangeLog	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-05-24 01:34:32 UTC (rev 245730)
@@ -1,3 +1,24 @@
+2019-05-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=198088
+
+        Reviewed by Timothy Hatcher.
+
+        When trying to "measure" the absolute position (to the viewport) or relative position (to
+        another element) of a given element, often the easiest way is to enable Element Selection
+        and Show Rulers at the same time.
+
+        This can have the undesired "side-effect" of having the rulers be always present, even when
+        not highlighting any nodes.
+
+        The ideal functionality is to allow the rulers/guides to be shown when element selection is
+        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
+
+        * inspector/protocol/DOM.json:
+        Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
+        current value of `Page.setShowRulers` as to whether rulers/guides are shown.
+
 2019-05-23  Ross Kirsling  <[email protected]>
 
         Socket-based RWI should be able to inspect a JSContext

Modified: trunk/Source/_javascript_Core/inspector/protocol/DOM.json (245729 => 245730)


--- trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2019-05-24 01:34:32 UTC (rev 245730)
@@ -400,7 +400,8 @@
             "description": "Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted. Backend then generates 'inspect' command upon element selection.",
             "parameters": [
                 { "name": "enabled", "type": "boolean", "description": "True to enable inspection mode, false to disable it." },
-                { "name": "highlightConfig", "$ref": "HighlightConfig", "optional": true, "description": "A descriptor for the highlight appearance of hovered-over nodes. May be omitted if <code>enabled == false</code>." }
+                { "name": "highlightConfig", "$ref": "HighlightConfig", "optional": true, "description": "A descriptor for the highlight appearance of hovered-over nodes. May be omitted if <code>enabled == false</code>." },
+                { "name": "showRulers", "type": "boolean", "optional": true, "description": "Whether the rulers should be shown during element selection. This overrides Page.setShowRulers." }
             ]
         },
         {

Modified: trunk/Source/WebCore/ChangeLog (245729 => 245730)


--- trunk/Source/WebCore/ChangeLog	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebCore/ChangeLog	2019-05-24 01:34:32 UTC (rev 245730)
@@ -1,5 +1,42 @@
 2019-05-23  Devin Rousso  <[email protected]>
 
+        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=198088
+
+        Reviewed by Timothy Hatcher.
+
+        When trying to "measure" the absolute position (to the viewport) or relative position (to
+        another element) of a given element, often the easiest way is to enable Element Selection
+        and Show Rulers at the same time.
+
+        This can have the undesired "side-effect" of having the rulers be always present, even when
+        not highlighting any nodes.
+
+        The ideal functionality is to allow the rulers/guides to be shown when element selection is
+        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
+
+        * inspector/InspectorOverlay.h:
+        (WebCore::InspectorOverlay::setShowRulersDuringElementSelection): Added.
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::paint):
+        (WebCore::InspectorOverlay::shouldShowOverlay):
+        (WebCore::InspectorOverlay::drawNodeHighlight):
+        (WebCore::InspectorOverlay::drawQuadHighlight):
+        (WebCore::InspectorOverlay::drawElementTitle):
+        If `showRulersDuringElementSelection` is enabled, draw rulers whenever any highlight bounds
+        are calculated, but don't update the overlay if it's the only thing enabled (e.g. if there's
+        no currently hovered node, the overlay will disappear).
+
+        * inspector/agents/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDOMAgent::inspect):
+        (WebCore::InspectorDOMAgent::setInspectModeEnabled):
+        (WebCore::InspectorDOMAgent::setSearchingForNode):
+        Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
+        current value of `Page.setShowRulers` as to whether rulers/guides are shown.
+
+2019-05-23  Devin Rousso  <[email protected]>
+
         Web Inspector: Overlay: rulers should switch sides if they intersect the highlighted node(s) so they don't obstruct any content
         https://bugs.webkit.org/show_bug.cgi?id=198165
 

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (245729 => 245730)


--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2019-05-24 01:34:32 UTC (rev 245730)
@@ -411,7 +411,7 @@
     if (!m_paintRects.isEmpty())
         drawPaintRects(context, m_paintRects);
 
-    if (m_showRulers)
+    if (m_showRulers || m_showRulersDuringElementSelection)
         drawRulers(context, bounds);
 }
 
@@ -492,6 +492,8 @@
 
 bool InspectorOverlay::shouldShowOverlay() const
 {
+    // Don't show the overlay when m_showRulersDuringElementSelection is true, as it's only supposed
+    // to have an effect when element selection is active (e.g. a node is hovered).
     return m_highlightNode || m_highlightNodeList || m_highlightQuad || m_indicating || m_showPaintRects || m_showRulers;
 }
 
@@ -577,7 +579,7 @@
     if (m_nodeHighlightConfig.showInfo)
         drawShapeHighlight(context, node, bounds);
 
-    if (m_showRulers)
+    if (m_showRulers || m_showRulersDuringElementSelection)
         drawBounds(context, bounds);
 
     // Ensure that the title information is drawn after the bounds.
@@ -597,7 +599,7 @@
     if (highlight.quads.size() >= 1) {
         drawOutlinedQuad(context, highlight.quads[0], highlight.contentColor, highlight.contentOutlineColor, bounds);
 
-        if (m_showRulers)
+        if (m_showRulers || m_showRulersDuringElementSelection)
             drawBounds(context, bounds);
     }
 
@@ -929,7 +931,7 @@
 
     FloatSize contentInset(0, pageView->topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset));
     contentInset.expand(elementDataSpacing, elementDataSpacing);
-    if (m_showRulers)
+    if (m_showRulers || m_showRulersDuringElementSelection)
         contentInset.expand(rulerSize, rulerSize);
 
     float anchorTop = bounds.y();

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.h (245729 => 245730)


--- trunk/Source/WebCore/inspector/InspectorOverlay.h	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.h	2019-05-24 01:34:32 UTC (rev 245730)
@@ -115,6 +115,7 @@
     void showPaintRect(const FloatRect&);
 
     void setShowRulers(bool);
+    void setShowRulersDuringElementSelection(bool enabled) { m_showRulersDuringElementSelection = enabled; }
 
     Node* highlightedNode() const;
 
@@ -150,9 +151,10 @@
     Deque<TimeRectPair> m_paintRects;
     Timer m_paintRectUpdateTimer;
 
-    bool m_indicating {false};
-    bool m_showPaintRects {false};
-    bool m_showRulers {false};
+    bool m_indicating { false };
+    bool m_showPaintRects { false };
+    bool m_showRulers { false };
+    bool m_showRulersDuringElementSelection { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (245729 => 245730)


--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2019-05-24 01:34:32 UTC (rev 245730)
@@ -325,7 +325,7 @@
     m_inspectedNode = nullptr;
 
     ErrorString unused;
-    setSearchingForNode(unused, false, nullptr);
+    setSearchingForNode(unused, false, nullptr, false);
     hideHighlight(unused);
 
     m_instrumentingAgents.setInspectorDOMAgent(nullptr);
@@ -1094,7 +1094,7 @@
 {
     ErrorString unused;
     RefPtr<Node> node = inspectedNode;
-    setSearchingForNode(unused, false, nullptr);
+    setSearchingForNode(unused, false, nullptr, false);
 
     if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE)
         node = node->parentNode();
@@ -1147,7 +1147,7 @@
         m_overlay->highlightNode(node, *m_inspectModeHighlightConfig);
 }
 
-void InspectorDOMAgent::setSearchingForNode(ErrorString& errorString, bool enabled, const JSON::Object* highlightInspectorObject)
+void InspectorDOMAgent::setSearchingForNode(ErrorString& errorString, bool enabled, const JSON::Object* highlightInspectorObject, bool showRulers)
 {
     if (m_searchingForNode == enabled)
         return;
@@ -1154,7 +1154,9 @@
 
     m_searchingForNode = enabled;
 
-    if (enabled) {
+    m_overlay->setShowRulersDuringElementSelection(m_searchingForNode && showRulers);
+
+    if (m_searchingForNode) {
         m_inspectModeHighlightConfig = highlightConfigFromInspectorObject(errorString, highlightInspectorObject);
         if (!m_inspectModeHighlightConfig)
             return;
@@ -1187,9 +1189,9 @@
     return highlightConfig;
 }
 
-void InspectorDOMAgent::setInspectModeEnabled(ErrorString& errorString, bool enabled, const JSON::Object* highlightConfig)
+void InspectorDOMAgent::setInspectModeEnabled(ErrorString& errorString, bool enabled, const JSON::Object* highlightConfig, const bool* showRulers)
 {
-    setSearchingForNode(errorString, enabled, highlightConfig ? highlightConfig : nullptr);
+    setSearchingForNode(errorString, enabled, highlightConfig ? highlightConfig : nullptr, showRulers && *showRulers);
 }
 
 void InspectorDOMAgent::highlightRect(ErrorString&, int x, int y, int width, int height, const JSON::Object* color, const JSON::Object* outlineColor, const bool* usePageCoordinates)

Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h (245729 => 245730)


--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h	2019-05-24 01:34:32 UTC (rev 245730)
@@ -120,7 +120,7 @@
     void discardSearchResults(ErrorString&, const String& searchId) override;
     void resolveNode(ErrorString&, int nodeId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) override;
     void getAttributes(ErrorString&, int nodeId, RefPtr<JSON::ArrayOf<String>>& result) override;
-    void setInspectModeEnabled(ErrorString&, bool enabled, const JSON::Object* highlightConfig) override;
+    void setInspectModeEnabled(ErrorString&, bool enabled, const JSON::Object* highlightConfig, const bool* showRulers) override;
     void requestNode(ErrorString&, const String& objectId, int* nodeId) override;
     void pushNodeByPathToFrontend(ErrorString&, const String& path, int* nodeId) override;
     void hideHighlight(ErrorString&) override;
@@ -204,7 +204,7 @@
 #endif
 
     void highlightMousedOverNode();
-    void setSearchingForNode(ErrorString&, bool enabled, const JSON::Object* highlightConfig);
+    void setSearchingForNode(ErrorString&, bool enabled, const JSON::Object* highlightConfig, bool showRulers);
     std::unique_ptr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString&, const JSON::Object* highlightInspectorObject);
 
     // Node-related methods.

Modified: trunk/Source/WebInspectorUI/ChangeLog (245729 => 245730)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-05-24 01:34:32 UTC (rev 245730)
@@ -1,3 +1,31 @@
+2019-05-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=198088
+
+        Reviewed by Timothy Hatcher.
+
+        When trying to "measure" the absolute position (to the viewport) or relative position (to
+        another element) of a given element, often the easiest way is to enable Element Selection
+        and Show Rulers at the same time.
+
+        This can have the undesired "side-effect" of having the rulers be always present, even when
+        not highlighting any nodes.
+
+        The ideal functionality is to allow the rulers/guides to be shown when element selection is
+        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
+
+        * UserInterface/Base/Setting.js:
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WI.SettingsTabContentView.prototype._createGeneralSettingsView):
+        Add a setting for controlling whether rulers/guides are shown during element selection.
+
+        * UserInterface/Controllers/DOMManager.js:
+        (WI.DOMManager.prototype.set inspectModeEnabled):
+        Pass the setting value as an optional parameter when calling `DOM.setInspectModeEnabled`.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
 2019-05-23  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r245665.

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (245729 => 245730)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2019-05-24 01:34:32 UTC (rev 245730)
@@ -365,6 +365,7 @@
 localizedStrings["Edit custom gradient"] = "Edit custom gradient";
 localizedStrings["Editing audits"] = "Editing audits";
 localizedStrings["Element"] = "Element";
+localizedStrings["Element Selection:"] = "Element Selection:";
 localizedStrings["Element clips compositing descendants"] = "Element clips compositing descendants";
 localizedStrings["Element has CSS blending applied and composited descendants"] = "Element has CSS blending applied and composited descendants";
 localizedStrings["Element has CSS filters applied"] = "Element has CSS filters applied";
@@ -957,6 +958,7 @@
 localizedStrings["Show only for selected node"] = "Show only for selected node";
 localizedStrings["Show page load timing"] = "Show page load timing";
 localizedStrings["Show page resources"] = "Show page resources";
+localizedStrings["Show page rulers and node border lines"] = "Show page rulers and node border lines";
 localizedStrings["Show shadow DOM nodes"] = "Show shadow DOM nodes";
 localizedStrings["Show the details sidebar (%s)"] = "Show the details sidebar (%s)";
 localizedStrings["Show the navigation sidebar (%s)"] = "Show the navigation sidebar (%s)";

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (245729 => 245730)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2019-05-24 01:34:32 UTC (rev 245730)
@@ -166,6 +166,7 @@
     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),
     showShadowDOM: new WI.Setting("show-shadow-dom", false),
     showWhitespaceCharacters: new WI.Setting("show-whitespace-characters", false),

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js (245729 => 245730)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js	2019-05-24 01:34:32 UTC (rev 245730)
@@ -540,7 +540,12 @@
         if (enabled === this._inspectModeEnabled)
             return;
 
-        DOMAgent.setInspectModeEnabled(enabled, this._buildHighlightConfig(), (error) => {
+        let commandArguments = {
+            enabled,
+            highlightConfig: this._buildHighlightConfig(),
+            showRulers: WI.settings.showRulersDuringElementSelection.value,
+        };
+        DOMAgent.setInspectModeEnabled.invoke(commandArguments, (error) => {
             this._inspectModeEnabled = error ? false : enabled;
             this.dispatchEventToListeners(WI.DOMManager.Event.InspectModeStateChanged);
         });

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js (245729 => 245730)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js	2019-05-24 01:22:25 UTC (rev 245729)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js	2019-05-24 01:34:32 UTC (rev 245730)
@@ -222,6 +222,10 @@
 
         generalSettingsView.addSeparator();
 
+        generalSettingsView.addSetting(WI.UIString("Element Selection:"), WI.settings.showRulersDuringElementSelection, WI.UIString("Show page rulers and node border lines"));
+
+        generalSettingsView.addSeparator();
+
         const zoomLevels = [0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4];
         const zoomValues = zoomLevels.map((level) => [level, Number.percentageString(level, 0)]);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to