Bug 1418874 part 1 - Use JS impl of CSS lexer instead of that from InspectorUtils in devtools. r=tromey
authorXidorn Quan <me@upsuper.org>
Thu, 14 Jun 2018 18:02:02 -0700
changeset 423023 e10c1e086d804edfc5b3e4cc6adc2dd429dd5b56
parent 423022 fb22e95175eac721f1c260bffc969bbdb26ab440
child 423024 d65d4848c69c78d515753a9f3b22968dbae05e51
push id65334
push userxquan@mozilla.com
push dateWed, 20 Jun 2018 00:58:57 +0000
treeherderautoland@ad44fc73cf4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1418874
milestone62.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 1418874 part 1 - Use JS impl of CSS lexer instead of that from InspectorUtils in devtools. r=tromey MozReview-Commit-ID: 3mam0A2JNif
devtools/client/shared/test/browser_filter-editor-01.js
devtools/server/actors/styles.js
--- a/devtools/client/shared/test/browser_filter-editor-01.js
+++ b/devtools/client/shared/test/browser_filter-editor-01.js
@@ -1,25 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Tests that the Filter Editor Widget parses filter values correctly (setCssValue)
 
 const {CSSFilterEditorWidget} = require("devtools/client/shared/widgets/FilterWidget");
-const InspectorUtils = require("InspectorUtils");
 
 const TEST_URI = CHROME_URL_ROOT + "doc_filter-editor-01.html";
 const {getClientCssProperties} = require("devtools/shared/fronts/css-properties");
+const {getCSSLexer} = require("devtools/shared/css/lexer");
 
 // Verify that the given string consists of a valid CSS URL token.
 // Return true on success, false on error.
 function verifyURL(string) {
-  const lexer = InspectorUtils.getCSSLexer(string);
+  const lexer = getCSSLexer(string);
 
   const token = lexer.nextToken();
   if (!token || token.tokenType !== "url") {
     return false;
   }
 
   return lexer.nextToken() === null;
 }
--- a/devtools/server/actors/styles.js
+++ b/devtools/server/actors/styles.js
@@ -1,16 +1,17 @@
 /* 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 Services = require("Services");
 const protocol = require("devtools/shared/protocol");
+const {getCSSLexer} = require("devtools/shared/css/lexer");
 const {LongStringActor} = require("devtools/server/actors/string");
 const InspectorUtils = require("InspectorUtils");
 
 // This will also add the "stylesheet" actor type for protocol.js to recognize
 
 const {pageStyleSpec, styleRuleSpec, ELEMENT_STYLE} = require("devtools/shared/specs/styles");
 
 loader.lazyRequireGetter(this, "CssLogic", "devtools/server/actors/inspector/css-logic", true);
@@ -1606,17 +1607,17 @@ exports.getFontPreviewData = getFontPrev
  */
 function getRuleText(initialText, line, column) {
   if (typeof line === "undefined" || typeof column === "undefined") {
     throw new Error("Location information is missing");
   }
 
   const {offset: textOffset, text} =
       getTextAtLineColumn(initialText, line, column);
-  const lexer = InspectorUtils.getCSSLexer(text);
+  const lexer = getCSSLexer(text);
 
   // Search forward for the opening brace.
   while (true) {
     const token = lexer.nextToken();
     if (!token) {
       throw new Error("couldn't find start of the rule");
     }
     if (token.tokenType === "symbol" && token.text === "{") {
@@ -1680,17 +1681,17 @@ exports.getRuleText = getRuleText;
  */
 function getSelectorOffsets(initialText, line, column) {
   if (typeof line === "undefined" || typeof column === "undefined") {
     throw new Error("Location information is missing");
   }
 
   const {offset: textOffset, text} =
       getTextAtLineColumn(initialText, line, column);
-  const lexer = InspectorUtils.getCSSLexer(text);
+  const lexer = getCSSLexer(text);
 
   // Search forward for the opening brace.
   let endOffset;
   while (true) {
     const token = lexer.nextToken();
     if (!token) {
       break;
     }