Bug 1182194 - Convert LayoutHelpers.jsm into a commonjs module. r=jwalker

--HG--
rename : toolkit/devtools/LayoutHelpers.jsm => toolkit/devtools/layout-helpers.js
This commit is contained in:
Alexandre Poirot 2015-07-30 06:14:08 -07:00
Родитель 37f672e11e
Коммит 5f9afbc4de
17 изменённых файлов: 29 добавлений и 43 удалений

Просмотреть файл

@ -8,7 +8,7 @@
const {Cu, Ci} = require("chrome");
let EventEmitter = require("devtools/toolkit/event-emitter");
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
let LayoutHelpers = require("devtools/toolkit/layout-helpers");
/**
* API

Просмотреть файл

@ -13,7 +13,8 @@
// Some listeners do not send a response message back.
let {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
let {LayoutHelpers} = Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", {});
let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let LayoutHelpers = devtools.require("devtools/toolkit/layout-helpers");
let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);

Просмотреть файл

@ -31,8 +31,8 @@ const {setTimeout, clearTimeout, setInterval, clearInterval} = require("sdk/time
const {parseAttribute} = require("devtools/shared/node-attribute-parser");
const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
const {Task} = require("resource://gre/modules/Task.jsm");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
Cu.import("resource://gre/modules/devtools/Templater.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

Просмотреть файл

@ -5,7 +5,7 @@
// cases including iframes, scroll and zoom
const {utils: Cu} = Components;
const {LayoutHelpers} = Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", {});
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
const TEST_URI = TEST_URI_ROOT + "browser_layoutHelpers-getBoxQuads.html";

Просмотреть файл

@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that scrollIntoViewIfNeeded works properly.
let {LayoutHelpers} = Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", {});
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
const TEST_URI = TEST_URI_ROOT + "browser_layoutHelpers.html";

Просмотреть файл

@ -7,6 +7,7 @@ const { Cc, Ci, Cu, Cr } = require("chrome");
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
const { Heritage, setNamedTimeout, clearNamedTimeout } = require("resource:///modules/devtools/ViewHelpers.jsm");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
loader.lazyRequireGetter(this, "promise");
loader.lazyRequireGetter(this, "EventEmitter",
@ -14,8 +15,6 @@ loader.lazyRequireGetter(this, "EventEmitter",
loader.lazyImporter(this, "DevToolsWorker",
"resource://gre/modules/devtools/shared/worker.js");
loader.lazyImporter(this, "LayoutHelpers",
"resource://gre/modules/devtools/LayoutHelpers.jsm");
const HTML_NS = "http://www.w3.org/1999/xhtml";
const GRAPH_SRC = "chrome://browser/content/devtools/graphs-frame.xhtml";

Просмотреть файл

@ -9,10 +9,8 @@ let {EPSILON, TiltMath, vec3, mat3, mat4, quat4} = devtools.require("devtools/ti
let TiltUtils = devtools.require("devtools/tilt/tilt-utils");
let {TiltVisualizer} = devtools.require("devtools/tilt/tilt-visualizer");
let DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils");
let LayoutHelpers = devtools.require("devtools/toolkit/layout-helpers");
let tempScope = {};
Components.utils.import("resource://gre/modules/devtools/LayoutHelpers.jsm", tempScope);
let LayoutHelpers = tempScope.LayoutHelpers;
const DEFAULT_HTML = "data:text/html," +
"<DOCTYPE html>" +

Просмотреть файл

@ -9,7 +9,7 @@ const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
let LayoutHelpers = require("devtools/toolkit/layout-helpers");
const STACK_THICKNESS = 15;

Просмотреть файл

@ -2,29 +2,29 @@ const Cu = Components.utils;
function run_test() {
// Existing module.
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/devtools/LayoutHelpers.jsm"),
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils.jsm"),
"isModuleLoaded returned correct value for non-loaded module");
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
do_check_true(Cu.isModuleLoaded("resource://gre/modules/devtools/LayoutHelpers.jsm"),
Cu.import("resource://gre/modules/ISO8601DateUtils.jsm");
do_check_true(Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils.jsm"),
"isModuleLoaded returned true after loading that module");
Cu.unload("resource://gre/modules/devtools/LayoutHelpers.jsm");
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/devtools/LayoutHelpers.jsm"),
Cu.unload("resource://gre/modules/ISO8601DateUtils.jsm");
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils.jsm"),
"isModuleLoaded returned false after unloading that module");
// Non-existing module
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/devtools/LayoutHelpers1.jsm"),
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils1.jsm"),
"isModuleLoaded returned correct value for non-loaded module");
try {
Cu.import("resource://gre/modules/devtools/LayoutHelpers1.jsm");
Cu.import("resource://gre/modules/ISO8601DateUtils1.jsm");
do_check_true(false,
"Should have thrown while trying to load a non existing file");
} catch (ex) {}
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/devtools/LayoutHelpers1.jsm"),
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils1.jsm"),
"isModuleLoaded returned correct value for non-loaded module");
// incorrect url
try {
Cu.isModuleLoaded("resource://modules/devtools/LayoutHelpers1.jsm");
Cu.isModuleLoaded("resource://modules/ISO8601DateUtils1.jsm");
do_check_true(false,
"Should have thrown while trying to load a non existing file");
} catch (ex) {

Просмотреть файл

@ -7,9 +7,9 @@
const { Cc, Ci, Cu } = require("chrome");
const l10n = require("gcli/l10n");
const { Services } = require("resource://gre/modules/Services.jsm");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
loader.lazyImporter(this, "Downloads", "resource://gre/modules/Downloads.jsm");
loader.lazyImporter(this, "LayoutHelpers", "resource://gre/modules/devtools/LayoutHelpers.jsm");
loader.lazyImporter(this, "Task", "resource://gre/modules/Task.jsm");
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");

Просмотреть файл

@ -4,16 +4,7 @@
* 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/. */
const Cu = Components.utils;
const Ci = Components.interfaces;
const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
this.EXPORTED_SYMBOLS = ["LayoutHelpers"];
let {Ci} = require("chrome")
let LayoutHelpers = function(aTopLevelWindow) {
this._topDocShell = aTopLevelWindow.QueryInterface(Ci.nsIInterfaceRequestor)
@ -21,7 +12,7 @@ let LayoutHelpers = function(aTopLevelWindow) {
.QueryInterface(Ci.nsIDocShell);
};
this.LayoutHelpers = LayoutHelpers;
module.exports = LayoutHelpers;
LayoutHelpers.prototype = {
@ -354,8 +345,8 @@ LayoutHelpers.prototype = {
}
let winUtils = win.
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
return winUtils.containerElement;
},

Просмотреть файл

@ -35,6 +35,7 @@ EXTRA_JS_MODULES.devtools += [
'DevToolsUtils.js',
'event-emitter.js',
'event-parsers.js',
'layout-helpers.js',
'output-parser.js',
'path.js',
'worker-loader.js',
@ -42,7 +43,6 @@ EXTRA_JS_MODULES.devtools += [
EXTRA_JS_MODULES.devtools += [
'Console.jsm',
'LayoutHelpers.jsm',
'Loader.jsm',
'Require.jsm',
]

Просмотреть файл

@ -11,6 +11,7 @@ const {Arg, Option, method, RetVal} = protocol;
const events = require("sdk/event/core");
const Heritage = require("sdk/core/heritage");
const EventEmitter = require("devtools/toolkit/event-emitter");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
loader.lazyRequireGetter(this, "CssLogic",
@ -20,8 +21,6 @@ loader.lazyRequireGetter(this, "setIgnoreLayoutChanges",
loader.lazyGetter(this, "DOMUtils", function() {
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
});
loader.lazyImporter(this, "LayoutHelpers",
"resource://gre/modules/devtools/LayoutHelpers.jsm");
// FIXME: add ":visited" and ":link" after bug 713106 is fixed
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];

Просмотреть файл

@ -70,6 +70,7 @@ const {
} = require("devtools/server/actors/highlighter");
const {getLayoutChangesObserver, releaseLayoutChangesObserver} =
require("devtools/server/actors/layout");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
const {EventParsers} = require("devtools/toolkit/event-parsers");
@ -116,8 +117,6 @@ const PSEUDO_SELECTORS = [
let HELPER_SHEET = ".__fx-devtools-hide-shortcut__ { visibility: hidden !important } ";
HELPER_SHEET += ":-moz-devtools-highlighted { outline: 2px dashed #F06!important; outline-offset: -2px!important } ";
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
loader.lazyRequireGetter(this, "DevToolsUtils",
"devtools/toolkit/DevToolsUtils");

Просмотреть файл

@ -19,11 +19,10 @@ const {LongStringActor} = require("devtools/server/actors/string");
const {DebuggerServer} = require("devtools/server/main");
const Services = require("Services");
const promise = require("promise");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");
loader.lazyImporter(this, "Sqlite", "resource://gre/modules/Sqlite.jsm");
loader.lazyImporter(this, "LayoutHelpers",
"resource://gre/modules/devtools/LayoutHelpers.jsm");
let gTrackedMessageManager = new Map();

Просмотреть файл

@ -41,6 +41,7 @@
const { Cc, Ci, Cu } = require("chrome");
const Services = require("Services");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
let pseudos = new Set([
":after",
@ -76,7 +77,6 @@ exports.PSEUDO_ELEMENT_SET = PSEUDO_ELEMENT_SET;
// on the worker thread, where Cu is not available.
if (Cu) {
Cu.importGlobalProperties(['CSS']);
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
}
function CssLogic()

Просмотреть файл

@ -11,7 +11,6 @@ const {Cc, Ci, Cu, components} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyImporter(this, "LayoutHelpers", "resource://gre/modules/devtools/LayoutHelpers.jsm");
// TODO: Bug 842672 - toolkit/ imports modules from browser/.
// Note that these are only used in WebConsoleCommands, see $0 and pprint().
@ -19,6 +18,7 @@ loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.j
loader.lazyImporter(this, "devtools", "resource://gre/modules/devtools/Loader.jsm");
loader.lazyImporter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
const LayoutHelpers = require("devtools/toolkit/layout-helpers");
// Match the function name from the result of toString() or toSource().
//