Bug 168172 - Web Inspector: provide a way to show current value of CSS variables in style rules
Summary: Web Inspector: provide a way to show current value of CSS variables in style ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-11 09:14 PST by BJ Burg
Modified: 2017-02-14 11:19 PST (History)
8 users (show)

See Also:


Attachments
Patch (16.02 KB, patch)
2017-02-13 17:09 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (28.05 KB, image/png)
2017-02-13 17:09 PST, Devin Rousso
no flags Details
Patch (16.19 KB, patch)
2017-02-13 17:56 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (29.67 KB, image/png)
2017-02-13 17:58 PST, Devin Rousso
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2017-02-11 09:14:01 PST
As we adopt more variables, it should be really easy to see the resolved values while tweaking rules. Two ideas i have:

1. Replace variables with their values when Shift or Option is held down
2. Show a popover with the value or variable declaration when hovering a variable token
Comment 1 Radar WebKit Bug Importer 2017-02-11 09:14:36 PST
<rdar://problem/30480063>
Comment 2 Nikita Vasilyev 2017-02-13 15:46:26 PST
I agree that seeing variable values would be very useful.

Tangentially, I often want to see a computed value in the Rules panel.

A couple of examples:

    font-size: 1.2em; // 16px
    top: calc(5vh - 12px); // 321px

Switching to "Styles — Computed" and glancing over through the list of all properties is tedious.
Comment 3 Matt Baker 2017-02-13 16:40:54 PST
Over IRC Devin and I discussed some possible UI. Currently we're considering an equals sign swatch [=] immediately before the "var" token, similar to the editing swatches shown for the Bezier curves.

Clicking the swatch would compute the value of the variable and display it in a popover. In the future, we could replace the "var(...)" text with the computed value, and allow live editing of the variable.
Comment 4 Devin Rousso 2017-02-13 17:09:04 PST
Created attachment 301420 [details]
Patch
Comment 5 Devin Rousso 2017-02-13 17:09:21 PST
Created attachment 301421 [details]
[Image] After Patch is applied
Comment 6 Devin Rousso 2017-02-13 17:56:10 PST
Created attachment 301430 [details]
Patch
Comment 7 Devin Rousso 2017-02-13 17:58:56 PST
Created attachment 301431 [details]
[Image] After Patch is applied
Comment 8 WebKit Commit Bot 2017-02-13 18:31:15 PST
Comment on attachment 301430 [details]
Patch

Clearing flags on attachment: 301430

Committed r212273: <http://trac.webkit.org/changeset/212273>
Comment 9 WebKit Commit Bot 2017-02-13 18:31:19 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 BJ Burg 2017-02-13 18:58:02 PST
I think the '=' glyph is unintuitive, but better than nothing. Maybe an underline for the thing with a popup with be less awkward.

(Tim, can you comment r=me in the bug? I couldn't tell in radar or email what happened to land this)
Comment 11 Joseph Pecoraro 2017-02-14 11:19:37 PST
Comment on attachment 301430 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301430&action=review

Nice!

> Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg:1
> +<?xml version="1.0" encoding="utf-8"?>

Is there an Images/gtk variant?

> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:901
> +                const dontCreateIfMissing = true;

Nit: I find "doNot" to be much clearer than "dont"

> Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js:207
> +    const variableRegex = /var\((--[\w-]+)\)/g;

Technically non-ASCII and escape sequences are allowed in the identifier, not just \w. But That is likely to be so rare its fine to ignore it here for simplicity:
https://www.w3.org/TR/css-syntax-3/#ident-token-diagram