⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245730 in webkit


Ignore:
Timestamp:
May 23, 2019, 6:34:32 PM (7 years ago)
Author:
Devin Rousso
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/JavaScriptCore:

  • 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:
Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r245726 r245730  
     12019-05-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=198088
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        When trying to "measure" the absolute position (to the viewport) or relative position (to
     9        another element) of a given element, often the easiest way is to enable Element Selection
     10        and Show Rulers at the same time.
     11
     12        This can have the undesired "side-effect" of having the rulers be always present, even when
     13        not highlighting any nodes.
     14
     15        The ideal functionality is to allow the rulers/guides to be shown when element selection is
     16        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
     17
     18        * inspector/protocol/DOM.json:
     19        Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
     20        current value of `Page.setShowRulers` as to whether rulers/guides are shown.
     21
    1222019-05-23  Ross Kirsling  <ross.kirsling@sony.com>
    223
  • trunk/Source/JavaScriptCore/inspector/protocol/DOM.json

    r244933 r245730  
    401401            "parameters": [
    402402                { "name": "enabled", "type": "boolean", "description": "True to enable inspection mode, false to disable it." },
    403                 { "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>." }
     403                { "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>." },
     404                { "name": "showRulers", "type": "boolean", "optional": true, "description": "Whether the rulers should be shown during element selection. This overrides Page.setShowRulers." }
    404405            ]
    405406        },
  • trunk/Source/WebCore/ChangeLog

    r245728 r245730  
     12019-05-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=198088
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        When trying to "measure" the absolute position (to the viewport) or relative position (to
     9        another element) of a given element, often the easiest way is to enable Element Selection
     10        and Show Rulers at the same time.
     11
     12        This can have the undesired "side-effect" of having the rulers be always present, even when
     13        not highlighting any nodes.
     14
     15        The ideal functionality is to allow the rulers/guides to be shown when element selection is
     16        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
     17
     18        * inspector/InspectorOverlay.h:
     19        (WebCore::InspectorOverlay::setShowRulersDuringElementSelection): Added.
     20        * inspector/InspectorOverlay.cpp:
     21        (WebCore::InspectorOverlay::paint):
     22        (WebCore::InspectorOverlay::shouldShowOverlay):
     23        (WebCore::InspectorOverlay::drawNodeHighlight):
     24        (WebCore::InspectorOverlay::drawQuadHighlight):
     25        (WebCore::InspectorOverlay::drawElementTitle):
     26        If `showRulersDuringElementSelection` is enabled, draw rulers whenever any highlight bounds
     27        are calculated, but don't update the overlay if it's the only thing enabled (e.g. if there's
     28        no currently hovered node, the overlay will disappear).
     29
     30        * inspector/agents/InspectorDOMAgent.cpp:
     31        (WebCore::InspectorDOMAgent::willDestroyFrontendAndBackend):
     32        (WebCore::InspectorDOMAgent::inspect):
     33        (WebCore::InspectorDOMAgent::setInspectModeEnabled):
     34        (WebCore::InspectorDOMAgent::setSearchingForNode):
     35        Add an optional `showRulers` parameter to `DOM.setInspectModeEnabled` that supersedes the
     36        current value of `Page.setShowRulers` as to whether rulers/guides are shown.
     37
    1382019-05-23  Devin Rousso  <drousso@apple.com>
    239
  • trunk/Source/WebCore/inspector/InspectorOverlay.cpp

    r245728 r245730  
    412412        drawPaintRects(context, m_paintRects);
    413413
    414     if (m_showRulers)
     414    if (m_showRulers || m_showRulersDuringElementSelection)
    415415        drawRulers(context, bounds);
    416416}
     
    493493bool InspectorOverlay::shouldShowOverlay() const
    494494{
     495    // Don't show the overlay when m_showRulersDuringElementSelection is true, as it's only supposed
     496    // to have an effect when element selection is active (e.g. a node is hovered).
    495497    return m_highlightNode || m_highlightNodeList || m_highlightQuad || m_indicating || m_showPaintRects || m_showRulers;
    496498}
     
    578580        drawShapeHighlight(context, node, bounds);
    579581
    580     if (m_showRulers)
     582    if (m_showRulers || m_showRulersDuringElementSelection)
    581583        drawBounds(context, bounds);
    582584
     
    598600        drawOutlinedQuad(context, highlight.quads[0], highlight.contentColor, highlight.contentOutlineColor, bounds);
    599601
    600         if (m_showRulers)
     602        if (m_showRulers || m_showRulersDuringElementSelection)
    601603            drawBounds(context, bounds);
    602604    }
     
    930932    FloatSize contentInset(0, pageView->topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset));
    931933    contentInset.expand(elementDataSpacing, elementDataSpacing);
    932     if (m_showRulers)
     934    if (m_showRulers || m_showRulersDuringElementSelection)
    933935        contentInset.expand(rulerSize, rulerSize);
    934936
  • trunk/Source/WebCore/inspector/InspectorOverlay.h

    r245728 r245730  
    116116
    117117    void setShowRulers(bool);
     118    void setShowRulersDuringElementSelection(bool enabled) { m_showRulersDuringElementSelection = enabled; }
    118119
    119120    Node* highlightedNode() const;
     
    151152    Timer m_paintRectUpdateTimer;
    152153
    153     bool m_indicating {false};
    154     bool m_showPaintRects {false};
    155     bool m_showRulers {false};
     154    bool m_indicating { false };
     155    bool m_showPaintRects { false };
     156    bool m_showRulers { false };
     157    bool m_showRulersDuringElementSelection { false };
    156158};
    157159
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r244933 r245730  
    326326
    327327    ErrorString unused;
    328     setSearchingForNode(unused, false, nullptr);
     328    setSearchingForNode(unused, false, nullptr, false);
    329329    hideHighlight(unused);
    330330
     
    10951095    ErrorString unused;
    10961096    RefPtr<Node> node = inspectedNode;
    1097     setSearchingForNode(unused, false, nullptr);
     1097    setSearchingForNode(unused, false, nullptr, false);
    10981098
    10991099    if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE)
     
    11481148}
    11491149
    1150 void InspectorDOMAgent::setSearchingForNode(ErrorString& errorString, bool enabled, const JSON::Object* highlightInspectorObject)
     1150void InspectorDOMAgent::setSearchingForNode(ErrorString& errorString, bool enabled, const JSON::Object* highlightInspectorObject, bool showRulers)
    11511151{
    11521152    if (m_searchingForNode == enabled)
     
    11551155    m_searchingForNode = enabled;
    11561156
    1157     if (enabled) {
     1157    m_overlay->setShowRulersDuringElementSelection(m_searchingForNode && showRulers);
     1158
     1159    if (m_searchingForNode) {
    11581160        m_inspectModeHighlightConfig = highlightConfigFromInspectorObject(errorString, highlightInspectorObject);
    11591161        if (!m_inspectModeHighlightConfig)
     
    11881190}
    11891191
    1190 void InspectorDOMAgent::setInspectModeEnabled(ErrorString& errorString, bool enabled, const JSON::Object* highlightConfig)
    1191 {
    1192     setSearchingForNode(errorString, enabled, highlightConfig ? highlightConfig : nullptr);
     1192void InspectorDOMAgent::setInspectModeEnabled(ErrorString& errorString, bool enabled, const JSON::Object* highlightConfig, const bool* showRulers)
     1193{
     1194    setSearchingForNode(errorString, enabled, highlightConfig ? highlightConfig : nullptr, showRulers && *showRulers);
    11931195}
    11941196
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h

    r244933 r245730  
    121121    void resolveNode(ErrorString&, int nodeId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) override;
    122122    void getAttributes(ErrorString&, int nodeId, RefPtr<JSON::ArrayOf<String>>& result) override;
    123     void setInspectModeEnabled(ErrorString&, bool enabled, const JSON::Object* highlightConfig) override;
     123    void setInspectModeEnabled(ErrorString&, bool enabled, const JSON::Object* highlightConfig, const bool* showRulers) override;
    124124    void requestNode(ErrorString&, const String& objectId, int* nodeId) override;
    125125    void pushNodeByPathToFrontend(ErrorString&, const String& path, int* nodeId) override;
     
    205205
    206206    void highlightMousedOverNode();
    207     void setSearchingForNode(ErrorString&, bool enabled, const JSON::Object* highlightConfig);
     207    void setSearchingForNode(ErrorString&, bool enabled, const JSON::Object* highlightConfig, bool showRulers);
    208208    std::unique_ptr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString&, const JSON::Object* highlightInspectorObject);
    209209
  • trunk/Source/WebInspectorUI/ChangeLog

    r245729 r245730  
     12019-05-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=198088
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        When trying to "measure" the absolute position (to the viewport) or relative position (to
     9        another element) of a given element, often the easiest way is to enable Element Selection
     10        and Show Rulers at the same time.
     11
     12        This can have the undesired "side-effect" of having the rulers be always present, even when
     13        not highlighting any nodes.
     14
     15        The ideal functionality is to allow the rulers/guides to be shown when element selection is
     16        active and a node is hovered, regardless of whether "Show Rulers" is enabled.
     17
     18        * UserInterface/Base/Setting.js:
     19        * UserInterface/Views/SettingsTabContentView.js:
     20        (WI.SettingsTabContentView.prototype._createGeneralSettingsView):
     21        Add a setting for controlling whether rulers/guides are shown during element selection.
     22
     23        * UserInterface/Controllers/DOMManager.js:
     24        (WI.DOMManager.prototype.set inspectModeEnabled):
     25        Pass the setting value as an optional parameter when calling `DOM.setInspectModeEnabled`.
     26
     27        * Localizations/en.lproj/localizedStrings.js:
     28
    1292019-05-23  Commit Queue  <commit-queue@webkit.org>
    230
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r245729 r245730  
    366366localizedStrings["Editing audits"] = "Editing audits";
    367367localizedStrings["Element"] = "Element";
     368localizedStrings["Element Selection:"] = "Element Selection:";
    368369localizedStrings["Element clips compositing descendants"] = "Element clips compositing descendants";
    369370localizedStrings["Element has CSS blending applied and composited descendants"] = "Element has CSS blending applied and composited descendants";
     
    958959localizedStrings["Show page load timing"] = "Show page load timing";
    959960localizedStrings["Show page resources"] = "Show page resources";
     961localizedStrings["Show page rulers and node border lines"] = "Show page rulers and node border lines";
    960962localizedStrings["Show shadow DOM nodes"] = "Show shadow DOM nodes";
    961963localizedStrings["Show the details sidebar (%s)"] = "Show the details sidebar (%s)";
  • trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js

    r245657 r245730  
    167167    showPaintRects: new WI.Setting("show-paint-rects", false),
    168168    showRulers: new WI.Setting("show-rulers", false),
     169    showRulersDuringElementSelection: new WI.Setting("show-rulers-during-element-selection", true),
    169170    showScopeChainOnPause: new WI.Setting("show-scope-chain-sidebar", true),
    170171    showShadowDOM: new WI.Setting("show-shadow-dom", false),
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js

    r244933 r245730  
    541541            return;
    542542
    543         DOMAgent.setInspectModeEnabled(enabled, this._buildHighlightConfig(), (error) => {
     543        let commandArguments = {
     544            enabled,
     545            highlightConfig: this._buildHighlightConfig(),
     546            showRulers: WI.settings.showRulersDuringElementSelection.value,
     547        };
     548        DOMAgent.setInspectModeEnabled.invoke(commandArguments, (error) => {
    544549            this._inspectModeEnabled = error ? false : enabled;
    545550            this.dispatchEventToListeners(WI.DOMManager.Event.InspectModeStateChanged);
  • trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

    r245657 r245730  
    223223        generalSettingsView.addSeparator();
    224224
     225        generalSettingsView.addSetting(WI.UIString("Element Selection:"), WI.settings.showRulersDuringElementSelection, WI.UIString("Show page rulers and node border lines"));
     226
     227        generalSettingsView.addSeparator();
     228
    225229        const zoomLevels = [0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4];
    226230        const zoomValues = zoomLevels.map((level) => [level, Number.percentageString(level, 0)]);
Note: See TracChangeset for help on using the changeset viewer.