Bug 1464796 - (Part 1) Hide list of node used fonts from overview. r=pbro draft
authorRazvan Caliman <rcaliman@mozilla.com>
Mon, 28 May 2018 11:16:24 +0200
changeset 808650 2eda1a2ab66b87a62ffc22c7750e7a323bb2adf3
parent 808580 e429320fcdd2d5236bb4713e6c435456146e42b9
child 808651 ba6d8d38cd897df2a4daf6deb5dcac13f4af3488
push id113452
push userbmo:rcaliman@mozilla.com
push dateWed, 20 Jun 2018 09:12:20 +0000
reviewerspbro
bugs1464796
milestone62.0a1
Bug 1464796 - (Part 1) Hide list of node used fonts from overview. r=pbro MozReview-Commit-ID: 8Py0TLlzHEP
devtools/client/inspector/fonts/components/FontOverview.js
--- a/devtools/client/inspector/fonts/components/FontOverview.js
+++ b/devtools/client/inspector/fonts/components/FontOverview.js
@@ -2,23 +2,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+const Services = require("Services");
 
 const Accordion = createFactory(require("devtools/client/inspector/layout/components/Accordion"));
 const FontList = createFactory(require("./FontList"));
 
 const { getStr } = require("../utils/l10n");
 const Types = require("../types");
 
+const PREF_FONT_EDITOR = "devtools.inspector.fonteditor.enabled";
+
 class FontOverview extends PureComponent {
   static get propTypes() {
     return {
       fontData: PropTypes.shape(Types.fontData).isRequired,
       fontOptions: PropTypes.shape(Types.fontOptions).isRequired,
       onPreviewFonts: PropTypes.func.isRequired,
       onToggleFontHighlight: PropTypes.func.isRequired,
     };
@@ -27,16 +30,22 @@ class FontOverview extends PureComponent
   constructor(props) {
     super(props);
     this.onToggleFontHighlightGlobal = (font, show) => {
       this.props.onToggleFontHighlight(font, show, false);
     };
   }
 
   renderElementFonts() {
+    // Do not show element fonts if the font editor is enabled.
+    // It handles this differently. Rendering twice is not desired.
+    if (Services.prefs.getBoolPref(PREF_FONT_EDITOR)) {
+      return null;
+    }
+
     const {
       fontData,
       fontOptions,
       onPreviewFonts,
       onToggleFontHighlight,
     } = this.props;
     const { fonts } = fontData;