Closed Bug 1399886 Opened 7 years ago Closed 7 years ago

Stop using SVG filters for devtools icons

Categories

(DevTools :: General, enhancement, P3)

enhancement

Tracking

(firefox58 fixed)

RESOLVED FIXED
Firefox 58
Tracking Status
firefox58 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 1 obsolete file)

Follow up to Bug 1399028. In this bug we introduced some new SVG filters in order to highlight the selected tool icon. 

We could achieve the same effect only using context-fill, see https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties

This would be easier to maintain because we wouldn't have to define filter matrices, that need to remain in sync with our CSS variables. Also this would have no effect for themes that are using real images instead of SVGs , such as the Firebug theme.

In order to do that we need to first modify our SVGs to use fill="context-fill", and then instead of using 

> filter: var(--theme-icon-checked-filter); 

(or similar) we need to use

> fill: var(--theme-icon-checked-color);
--theme-icon-checked-color being a new CSS variable pointing to the appropriate color we need to use.
See Also: → 1399841
I had a got at this, and the current patch switches most of our filter usage to context-fill. A few things though:
- we have to keep the checked filter as it is also applied to a png (chrome://devtools/skin/images/vview-open-inspector.png)
- context-fill is only supported in Firefox (and even then, not for webcontent), which means we need an alternative for tools running inside launchpad

On the plus side, this allows to get rid of 4 filters, 3 "highlighted" icons + the logic linked to it. And most importantly allows to reuse the same variables for colors rather than maintaining transformation matrices. 

Using context-fill also makes it easier to work with "non-SVG" icons. Since it only applies on SVG, no need to explicitly protect icons that don't use SVG.
(In reply to Julian Descottes [:jdescottes] from comment #2)
> - context-fill is only supported in Firefox (and even then, not for
> webcontent), which means we need an alternative for tools running inside
> launchpad
> 

Nevermind, the debugger only uses inline SVG, so they already use fill in CSS to set the color of their SVGs.
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Comment on attachment 8915270 [details]
Bug 1399886 - modify devtools SVG files to use fill=context-fill;

https://reviewboard.mozilla.org/r/186402/#review191708
Attachment #8915270 - Flags: review?(gl) → review+
Comment on attachment 8914325 [details]
Bug 1399886 - use fill from CSS to set the fill color of devtools icons;

https://reviewboard.mozilla.org/r/185606/#review191710
Attachment #8914325 - Flags: review?(gl) → review+
Comment on attachment 8915271 [details]
Bug 1399886 - use fill to highlight devtools toolbar icons;

https://reviewboard.mozilla.org/r/186472/#review191712

::: devtools/client/themes/variables.css:30
(Diff revision 1)
>    --theme-tab-toolbar-background: var(--grey-10);
>    --theme-toolbar-background: var(--grey-10);
>    --theme-toolbar-color: var(--grey-90);
>    --theme-toolbar-selected-color: var(--blue-60);
>    --theme-toolbar-checked-color: var(--blue-60);
> +  --theme-toolbar-highlighted-color: #5FC749;

I think we might want to use a photon green color here.
Attachment #8915271 - Flags: review?(gl) → review+
Comment on attachment 8915272 [details]
Bug 1399886 - remove unnecessary invertable CSS classes on devtools icons;

https://reviewboard.mozilla.org/r/186494/#review191714
Attachment #8915272 - Flags: review?(gl) → review+
Thanks for the reviews! 

(In reply to Gabriel [:gl] (ΦωΦ) from comment #11)
> Comment on attachment 8915271 [details]
> Bug 1399886 - use fill to highlight devtools toolbar icons;
> 
> https://reviewboard.mozilla.org/r/186472/#review191712
> 
> ::: devtools/client/themes/variables.css:30
> (Diff revision 1)
> >    --theme-tab-toolbar-background: var(--grey-10);
> >    --theme-toolbar-background: var(--grey-10);
> >    --theme-toolbar-color: var(--grey-90);
> >    --theme-toolbar-selected-color: var(--blue-60);
> >    --theme-toolbar-checked-color: var(--blue-60);
> > +  --theme-toolbar-highlighted-color: #5FC749;
> 
> I think we might want to use a photon green color here.

Yep, thought we could handle that as a follow up. The current fill color for highlighted icons is hardcoded to #5FC749. The closest photon colors to #5FC749 are
- Green 50 (#30e60b) -> a bit lighter
- Green 60 (#12bc00) -> a bit darker

My proposal would be to go for:
- Green 60 in light theme
- Green 50 in dark theme

I tried a few combinations, you can see the summary at: https://docs.google.com/a/mozilla.com/document/d/1OtYNxvmcuTbsidnSA-NsakSf_cCo8VbH7MwJwePTMDI/edit?usp=sharing

Victoria: are you okay with those colors?
Flags: needinfo?(victoria)
Comment on attachment 8915612 [details]
Bug 1399886 - use photon colors for highlighted devtools toolbar icons;

https://reviewboard.mozilla.org/r/186804/#review191912
Attachment #8915612 - Flags: review?(gl) → review+
Attachment #8915612 - Attachment is obsolete: true
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1229b8a6eefc
modify devtools SVG files to use fill=context-fill;r=gl
https://hg.mozilla.org/integration/autoland/rev/62cc82c624ea
use fill from CSS to set the fill color of devtools icons;r=gl
https://hg.mozilla.org/integration/autoland/rev/4b4f0c7ccd9b
use fill to highlight devtools toolbar icons;r=gl
https://hg.mozilla.org/integration/autoland/rev/534f2a0caa2c
remove unnecessary invertable CSS classes on devtools icons;r=gl
This brought noticeable perf improvements! Good work!
== Change summary for alert #9850 (as of October 05 2017 18:19 UTC) ==

Improvements:

  4%  damp summary windows7-32 opt e10s     285.47 -> 272.78
  4%  damp summary windows10-64 opt e10s    266.57 -> 256.51
  4%  damp summary windows7-32 pgo e10s     227.06 -> 218.65
  3%  damp summary windows10-64 pgo e10s    223.46 -> 216.43
  3%  damp summary linux64 opt e10s         268.86 -> 260.92
  3%  damp summary linux64 pgo e10s         240.37 -> 234.20
  2%  damp summary osx-10-10 opt e10s       310.35 -> 304.26

For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=9850
Thanks for the clear screenshots, Julian! I agree with your suggestions of Green 60 in light theme and Green 50 in dark theme. 

Two other changes I want to make, which should probably made in separate bugs/discussions: remove background color of those tabs unless there is some reasoning I don't understand there. Also, maybe some kind of "stopped" icon appearing would be make the Debugger indicator more clear.
Flags: needinfo?(victoria)
The invertIconForLightTheme/DarkTheme classes was introduced for add-ons. If support for it is removed, the webextension references should also be removed: https://dxr.mozilla.org/mozilla-central/search?q=invertIconFor&redirect=false
Attached image Style Editor bug
Julian, Gabe, have you considered using fill: currentColor everywhere (with different opacities if plain black/white is too strong) ?

Trying to figure out what the right variable for the icon fill in every case, when the information is already in the text color (most of the time), seems a bit odd and causes bugs like the one shown in the screenshot.

On the Firefox UI side, using this approach for the close icons has proved very effective, by removing many many custom rules deciding whether the icon should white/black in different situations: bug 1385702.
Flags: needinfo?(jdescottes)
Flags: needinfo?(gl)
(In reply to Tim Nguyen :ntim from comment #21)
> The invertIconForLightTheme/DarkTheme classes was introduced for add-ons. If
> support for it is removed, the webextension references should also be
> removed:
> https://dxr.mozilla.org/mozilla-central/search?q=invertIconFor&redirect=false

Will file a follow up, thanks.

(In reply to Tim Nguyen :ntim from comment #22)
> Created attachment 8917043 [details]
> Style Editor bug
> 
> Julian, Gabe, have you considered using fill: currentColor everywhere (with
> different opacities if plain black/white is too strong) ?
> 

Not really, my goal was to stop using filters to be able to reuse variables. I overlooked the usage of the -1 filter in the netmonitor and will log a follow up to fix it.

We can experiment with currentColor in another bug.
Flags: needinfo?(jdescottes)
(In reply to Julian Descottes [:jdescottes] from comment #23)
> Not really, my goal was to stop using filters to be able to reuse variables.
> I overlooked the usage of the -1 filter in the netmonitor and will log a
> follow up to fix it.

s/netmonitor/style editor ...
Depends on: 1407322
Depends on: 1407326
Flags: needinfo?(gl)
Depends on: 1410659
Depends on: 1408198
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: