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 805237 a9d6bbe35ad3aad767aca2afa150a17e2a37a7bd
parent 804003 a358755643e92f8fc55a23e3ab1fbf88695b8bf3
child 805238 83fc67507b0764d597d7115814d7384cf24dc257
push id112609
push userbmo:rcaliman@mozilla.com
push dateThu, 07 Jun 2018 15:22:13 +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;