Bug 1464192 - Part 18: Lazy load modules in the css-logic. r=pbro
authorGabriel Luong <gabriel.luong@gmail.com>
Fri, 28 Sep 2018 13:14:34 -0400
changeset 494544 522b47a9ae93d9959915f148345ff8ec852341ea
parent 494543 14272a8b7f3243856e969468ff751b375ad1b7ca
child 494545 2396739f4dfc27bf3ede8055aa637fdf2501ea6c
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1464192
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464192 - Part 18: Lazy load modules in the css-logic. r=pbro
devtools/shared/inspector/css-logic.js
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -1,17 +1,16 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 { getTabPrefs } = require("devtools/shared/indentation");
 const InspectorUtils = require("InspectorUtils");
 
 const MAX_DATA_URL_LENGTH = 40;
 
 /*
  * About the objects defined in this file:
  * - CssLogic contains style information about a view context. It provides
  *   access to 2 sets of objects: Css[Sheet|Rule|Selector] provide access to
@@ -45,18 +44,19 @@ const MAX_DATA_URL_LENGTH = 40;
  * @constructor
  */
 
 const Services = require("Services");
 
 loader.lazyImporter(this, "findCssSelector", "resource://gre/modules/css-selector.js");
 loader.lazyImporter(this, "getCssPath", "resource://gre/modules/css-selector.js");
 loader.lazyImporter(this, "getXPath", "resource://gre/modules/css-selector.js");
+loader.lazyRequireGetter(this, "getCSSLexer", "devtools/shared/css/lexer", true);
+loader.lazyRequireGetter(this, "getTabPrefs", "devtools/shared/indentation", true);
 
-const CSSLexer = require("devtools/shared/css/lexer");
 const {LocalizationHelper} = require("devtools/shared/l10n");
 const styleInspectorL10N =
   new LocalizationHelper("devtools/shared/locales/styleinspector.properties");
 
 /**
  * Special values for filter, in addition to an href these values can be used
  */
 exports.FILTER = {
@@ -185,17 +185,17 @@ function prettifyCSS(text, ruleCount) {
   // * A "}" symbol ensures there is a preceding newline, and
   //   decreases the indentation level.
   // * Ensure there is whitespace before a "{".
   //
   // This approach can be confused sometimes, but should do ok on a
   // minified file.
   let indent = "";
   let indentLevel = 0;
-  const tokens = CSSLexer.getCSSLexer(text);
+  const tokens = getCSSLexer(text);
   let result = "";
   let pushbackToken = undefined;
 
   // A helper function that reads tokens, looking for the next
   // non-comment, non-whitespace token.  Comment and whitespace tokens
   // are appended to |result|.  If this encounters EOF, it returns
   // null.  Otherwise it returns the last whitespace token that was
   // seen.  This function also updates |pushbackToken|.