mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1225254 - split css-logic.js into server and shared files; r=pbro
MozReview-Commit-ID: BTFVQJcVI5d --HG-- extra : transplant_source : n%A3%EF0e%9F%8E%09%FC4%95%F8%60l3%B73%BDS%C7
This commit is contained in:
parent
1006edd234
commit
469cee9bad
@ -109,6 +109,7 @@ devtools/client/webconsole/**
|
||||
devtools/client/webide/**
|
||||
!devtools/client/webide/components/webideCli.js
|
||||
devtools/server/**
|
||||
!devtools/server/css-logic.js
|
||||
!devtools/server/actors/webbrowser.js
|
||||
!devtools/server/actors/styles.js
|
||||
!devtools/server/actors/string.js
|
||||
@ -125,7 +126,6 @@ devtools/shared/discovery/**
|
||||
devtools/shared/gcli/**
|
||||
!devtools/shared/gcli/templater.js
|
||||
devtools/shared/heapsnapshot/**
|
||||
devtools/shared/inspector/**
|
||||
devtools/shared/layout/**
|
||||
devtools/shared/locales/**
|
||||
devtools/shared/performance/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
const {Cc, Ci} = require("chrome");
|
||||
|
||||
const ToolDefinitions = require("devtools/client/definitions").Tools;
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const CssLogic = require("devtools/shared/inspector/css-logic");
|
||||
const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
const {Cc, Ci} = require("chrome");
|
||||
const promise = require("promise");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const CssLogic = require("devtools/shared/inspector/css-logic");
|
||||
const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
|
||||
const {TextProperty} =
|
||||
require("devtools/client/inspector/rules/models/text-property");
|
||||
|
@ -14,7 +14,7 @@ const Services = require("Services");
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const {Task} = require("devtools/shared/task");
|
||||
const {Tools} = require("devtools/client/definitions");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {l10n} = require("devtools/shared/inspector/css-logic");
|
||||
const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
|
||||
const {OutputParser} = require("devtools/client/shared/output-parser");
|
||||
const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
|
||||
@ -968,7 +968,7 @@ CssRuleView.prototype = {
|
||||
|
||||
createChild(this.element, "div", {
|
||||
id: "noResults",
|
||||
textContent: CssLogic.l10n("rule.empty")
|
||||
textContent: l10n("rule.empty")
|
||||
});
|
||||
},
|
||||
|
||||
@ -1011,7 +1011,7 @@ CssRuleView.prototype = {
|
||||
if (this._selectedElementLabel) {
|
||||
return this._selectedElementLabel;
|
||||
}
|
||||
this._selectedElementLabel = CssLogic.l10n("rule.selectedElement");
|
||||
this._selectedElementLabel = l10n("rule.selectedElement");
|
||||
return this._selectedElementLabel;
|
||||
},
|
||||
|
||||
@ -1022,7 +1022,7 @@ CssRuleView.prototype = {
|
||||
if (this._pseudoElementLabel) {
|
||||
return this._pseudoElementLabel;
|
||||
}
|
||||
this._pseudoElementLabel = CssLogic.l10n("rule.pseudoElement");
|
||||
this._pseudoElementLabel = l10n("rule.pseudoElement");
|
||||
return this._pseudoElementLabel;
|
||||
},
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
var {isContentStylesheet} = require("devtools/shared/inspector/css-logic");
|
||||
var defer = require("devtools/shared/defer");
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ addMessageListener("Test:GetStyleSheetsInfoForNode", function (msg) {
|
||||
let sheet = domRules.GetElementAt(i).parentStyleSheet;
|
||||
sheets.push({
|
||||
href: sheet.href,
|
||||
isContentSheet: CssLogic.isContentStylesheet(sheet)
|
||||
isContentSheet: isContentStylesheet(sheet)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
const {Ci} = require("chrome");
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {l10n} = require("devtools/shared/inspector/css-logic");
|
||||
const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
|
||||
const {PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
|
||||
const {Rule} = require("devtools/client/inspector/rules/models/rule");
|
||||
@ -159,7 +159,7 @@ RuleEditor.prototype = {
|
||||
class: "ruleview-selectorhighlighter" +
|
||||
(this.ruleView.highlightedSelector === selector ?
|
||||
" highlighted" : ""),
|
||||
title: CssLogic.l10n("rule.selectorHighlighter.tooltip")
|
||||
title: l10n("rule.selectorHighlighter.tooltip")
|
||||
});
|
||||
selectorHighlighter.addEventListener("click", () => {
|
||||
this.ruleView.toggleSelectorHighlighter(selectorHighlighter, selector);
|
||||
|
@ -5,7 +5,7 @@
|
||||
"use strict";
|
||||
|
||||
const {Ci} = require("chrome");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {l10n} = require("devtools/shared/inspector/css-logic");
|
||||
const {getCssProperties} = require("devtools/shared/fronts/css-properties");
|
||||
const {InplaceEditor, editableField} =
|
||||
require("devtools/client/shared/inplace-editor");
|
||||
@ -176,7 +176,7 @@ TextPropertyEditor.prototype = {
|
||||
this.warning = createChild(this.container, "div", {
|
||||
class: "ruleview-warning",
|
||||
hidden: "",
|
||||
title: CssLogic.l10n("rule.warning.title"),
|
||||
title: l10n("rule.warning.title"),
|
||||
});
|
||||
|
||||
// Filter button that filters for the current property name and is
|
||||
@ -184,7 +184,7 @@ TextPropertyEditor.prototype = {
|
||||
this.filterProperty = createChild(this.container, "div", {
|
||||
class: "ruleview-overridden-rule-filter",
|
||||
hidden: "",
|
||||
title: CssLogic.l10n("rule.filterProperty.title"),
|
||||
title: l10n("rule.filterProperty.title"),
|
||||
});
|
||||
|
||||
this.filterProperty.addEventListener("click", event => {
|
||||
@ -371,7 +371,7 @@ TextPropertyEditor.prototype = {
|
||||
onRevert: this._onSwatchRevert
|
||||
});
|
||||
span.on("unit-change", this._onSwatchCommit);
|
||||
let title = CssLogic.l10n("rule.colorSwatch.tooltip");
|
||||
let title = l10n("rule.colorSwatch.tooltip");
|
||||
span.setAttribute("title", title);
|
||||
}
|
||||
}
|
||||
@ -389,7 +389,7 @@ TextPropertyEditor.prototype = {
|
||||
onCommit: this._onSwatchCommit,
|
||||
onRevert: this._onSwatchRevert
|
||||
});
|
||||
let title = CssLogic.l10n("rule.bezierSwatch.tooltip");
|
||||
let title = l10n("rule.bezierSwatch.tooltip");
|
||||
span.setAttribute("title", title);
|
||||
}
|
||||
}
|
||||
@ -406,7 +406,7 @@ TextPropertyEditor.prototype = {
|
||||
onCommit: this._onSwatchCommit,
|
||||
onRevert: this._onSwatchRevert
|
||||
}, outputParser, parserOptions);
|
||||
let title = CssLogic.l10n("rule.filterSwatch.tooltip");
|
||||
let title = l10n("rule.filterSwatch.tooltip");
|
||||
span.setAttribute("title", title);
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ TextPropertyEditor.prototype = {
|
||||
if (this.ruleEditor.isEditable) {
|
||||
for (let angleSpan of this.angleSwatchSpans) {
|
||||
angleSpan.on("unit-change", this._onSwatchCommit);
|
||||
let title = CssLogic.l10n("rule.angleSwatch.tooltip");
|
||||
let title = l10n("rule.angleSwatch.tooltip");
|
||||
angleSpan.setAttribute("title", title);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
var {isContentStylesheet} = require("devtools/shared/inspector/css-logic");
|
||||
var defer = require("devtools/shared/defer");
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ addMessageListener("Test:GetStyleSheetsInfoForNode", function (msg) {
|
||||
let sheet = domRules.GetElementAt(i).parentStyleSheet;
|
||||
sheets.push({
|
||||
href: sheet.href,
|
||||
isContentSheet: CssLogic.isContentStylesheet(sheet)
|
||||
isContentSheet: isContentStylesheet(sheet)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ Services.scriptloader.loadSubScript(
|
||||
this);
|
||||
|
||||
var {CssRuleView} = require("devtools/client/inspector/rules/rules");
|
||||
var {CssLogic, CssSelector} = require("devtools/shared/inspector/css-logic");
|
||||
var {getInplaceEditorForSpan: inplaceEditor} =
|
||||
require("devtools/client/shared/inplace-editor");
|
||||
|
||||
|
@ -15,7 +15,7 @@ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const Editor = require("devtools/client/sourceeditor/editor");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {shortSource, prettifyCSS} = require("devtools/shared/inspector/css-logic");
|
||||
const {console} = require("resource://gre/modules/Console.jsm");
|
||||
const Services = require("Services");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
@ -196,7 +196,7 @@ StyleSheetEditor.prototype = {
|
||||
|
||||
if (!this._friendlyName) {
|
||||
let sheetURI = this.styleSheet.href;
|
||||
this._friendlyName = CssLogic.shortSource({ href: sheetURI });
|
||||
this._friendlyName = shortSource({ href: sheetURI });
|
||||
try {
|
||||
this._friendlyName = decodeURI(this._friendlyName);
|
||||
} catch (ex) {
|
||||
@ -262,9 +262,8 @@ StyleSheetEditor.prototype = {
|
||||
|
||||
/**
|
||||
* A helper function that fetches the source text from the style
|
||||
* sheet. The text is possibly prettified using
|
||||
* CssLogic.prettifyCSS. This also sets |this._state.text| to the
|
||||
* new text.
|
||||
* sheet. The text is possibly prettified using prettifyCSS. This
|
||||
* also sets |this._state.text| to the new text.
|
||||
*
|
||||
* @return {Promise} a promise that resolves to the new text
|
||||
*/
|
||||
@ -274,7 +273,7 @@ StyleSheetEditor.prototype = {
|
||||
}).then((source) => {
|
||||
let ruleCount = this.styleSheet.ruleCount;
|
||||
if (!this.styleSheet.isOriginalSource) {
|
||||
source = CssLogic.prettifyCSS(source, ruleCount);
|
||||
source = prettifyCSS(source, ruleCount);
|
||||
}
|
||||
this._state.text = source;
|
||||
return source;
|
||||
|
@ -18,7 +18,7 @@ loader.lazyGetter(this, "DOMUtils", () => {
|
||||
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
|
||||
});
|
||||
loader.lazyRequireGetter(this, "stylesheets", "devtools/server/actors/stylesheets");
|
||||
loader.lazyRequireGetter(this, "CssLogic", "devtools/shared/inspector/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "prettifyCSS", "devtools/shared/inspector/css-logic", true);
|
||||
|
||||
const CSSRule = Ci.nsIDOMCSSRule;
|
||||
|
||||
@ -397,7 +397,7 @@ var CSSUsageActor = protocol.ActorClassWithSpec(cssUsageSpec, {
|
||||
shortUrl: rule.url.split("/").slice(-1)[0],
|
||||
start: { line: rule.line, column: rule.column },
|
||||
selectorText: ruleData.selectorText,
|
||||
formattedCssText: CssLogic.prettifyCSS(ruleData.cssText)
|
||||
formattedCssText: prettifyCSS(ruleData.cssText)
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@ const { on, emit } = require("sdk/event/core");
|
||||
const lazyContainer = {};
|
||||
|
||||
loader.lazyRequireGetter(lazyContainer, "CssLogic",
|
||||
"devtools/shared/inspector/css-logic", true);
|
||||
"devtools/server/css-logic", true);
|
||||
exports.getComputedStyle = (node) =>
|
||||
lazyContainer.CssLogic.getComputedStyle(node);
|
||||
|
||||
|
@ -150,7 +150,7 @@ loader.lazyGetter(this, "eventListenerService", function () {
|
||||
.getService(Ci.nsIEventListenerService);
|
||||
});
|
||||
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/server/css-logic").CssLogic);
|
||||
|
||||
/**
|
||||
* We only send nodeValue up to a certain size by default. This stuff
|
||||
|
@ -33,7 +33,7 @@ loader.lazyGetter(this, "Debugger", () => {
|
||||
hackDebugger(Debugger);
|
||||
return Debugger;
|
||||
});
|
||||
loader.lazyRequireGetter(this, "CssLogic", "devtools/shared/inspector/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "CssLogic", "devtools/server/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "events", "sdk/event/core");
|
||||
loader.lazyRequireGetter(this, "mapURIToAddonID", "devtools/server/actors/utils/map-uri-to-addon-id");
|
||||
|
||||
|
@ -14,7 +14,7 @@ const {Arg, method, RetVal} = protocol;
|
||||
const {fetch} = require("devtools/shared/DevToolsUtils");
|
||||
const {oldStyleSheetSpec, styleEditorSpec} = require("devtools/shared/specs/styleeditor");
|
||||
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic"));
|
||||
|
||||
var TRANSITION_CLASS = "moz-styleeditor-transitioning";
|
||||
var TRANSITION_DURATION_MS = 500;
|
||||
|
@ -19,7 +19,8 @@ const {UPDATE_PRESERVING_RULES, UPDATE_GENERAL} = require("devtools/server/actor
|
||||
const {pageStyleSpec, styleRuleSpec, ELEMENT_STYLE} = require("devtools/shared/specs/styles");
|
||||
|
||||
loader.lazyRequireGetter(this, "CSS", "CSS");
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/server/css-logic").CssLogic);
|
||||
loader.lazyGetter(this, "SharedCssLogic", () => require("devtools/shared/inspector/css-logic"));
|
||||
loader.lazyGetter(this, "DOMUtils", () => Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils));
|
||||
|
||||
// When gathering rules to read for pseudo elements, we will skip
|
||||
@ -202,7 +203,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
||||
getComputed: function (node, options) {
|
||||
let ret = Object.create(null);
|
||||
|
||||
this.cssLogic.sourceFilter = options.filter || CssLogic.FILTER.UA;
|
||||
this.cssLogic.sourceFilter = options.filter || SharedCssLogic.FILTER.UA;
|
||||
this.cssLogic.highlight(node.rawNode);
|
||||
let computed = this.cssLogic.computedStyle || [];
|
||||
|
||||
@ -380,7 +381,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
||||
* }
|
||||
*/
|
||||
getMatchedSelectors: function (node, property, options) {
|
||||
this.cssLogic.sourceFilter = options.filter || CssLogic.FILTER.UA;
|
||||
this.cssLogic.sourceFilter = options.filter || SharedCssLogic.FILTER.UA;
|
||||
this.cssLogic.highlight(node.rawNode);
|
||||
|
||||
let rules = new Set();
|
||||
@ -577,9 +578,9 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
||||
for (let i = domRules.Count() - 1; i >= 0; i--) {
|
||||
let domRule = domRules.GetElementAt(i);
|
||||
|
||||
let isSystem = !CssLogic.isContentStylesheet(domRule.parentStyleSheet);
|
||||
let isSystem = !SharedCssLogic.isContentStylesheet(domRule.parentStyleSheet);
|
||||
|
||||
if (isSystem && options.filter != CssLogic.FILTER.UA) {
|
||||
if (isSystem && options.filter != SharedCssLogic.FILTER.UA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ const {originalSourceSpec, mediaRuleSpec, styleSheetSpec,
|
||||
styleSheetsSpec} = require("devtools/shared/specs/stylesheets");
|
||||
const {SourceMapConsumer} = require("source-map");
|
||||
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
|
||||
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic"));
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () {
|
||||
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
|
||||
|
1544
devtools/server/css-logic.js
Normal file
1544
devtools/server/css-logic.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@ DevToolsModules(
|
||||
'child.js',
|
||||
'content-globals.js',
|
||||
'content-server.jsm',
|
||||
'css-logic.js',
|
||||
'main.js',
|
||||
'primitive.js',
|
||||
'service-worker-child.js',
|
||||
|
@ -33,7 +33,7 @@ Test that css-logic handles media-queries correctly
|
||||
|
||||
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var Services = require("Services");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {CssLogic} = require("devtools/server/css-logic");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
@ -15,7 +15,7 @@ Test that css-logic calculates CSS specificity properly
|
||||
var {utils: Cu, classes: Cc, interfaces: Ci} = Components;
|
||||
|
||||
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const {CssLogic, CssSelector} = require("devtools/shared/inspector/css-logic");
|
||||
const {CssLogic, CssSelector} = require("devtools/server/css-logic");
|
||||
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(Ci.inIDOMUtils);
|
||||
|
||||
|
@ -11,7 +11,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {CssLogic} = require("devtools/server/css-logic");
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
const inspector = require("devtools/server/actors/inspector");
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const CssLogic = require("devtools/shared/inspector/css-logic");
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||
const {prettifyCSS} = require("devtools/shared/inspector/css-logic");
|
||||
|
||||
const TESTS = [
|
||||
{ name: "simple test",
|
||||
@ -52,17 +52,17 @@ const TESTS = [
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
// Note that CssLogic.LINE_SEPARATOR is computed lazily, so we
|
||||
// Note that prettifyCSS.LINE_SEPARATOR is computed lazily, so we
|
||||
// ensure it is set.
|
||||
CssLogic.prettifyCSS("");
|
||||
prettifyCSS("");
|
||||
|
||||
for (let test of TESTS) {
|
||||
do_print(test.name);
|
||||
|
||||
let input = test.input.split("\n").join(CssLogic.LINE_SEPARATOR);
|
||||
let output = CssLogic.prettifyCSS(input);
|
||||
let expected = test.expected.join(CssLogic.LINE_SEPARATOR) +
|
||||
CssLogic.LINE_SEPARATOR;
|
||||
let input = test.input.split("\n").join(prettifyCSS.LINE_SEPARATOR);
|
||||
let output = prettifyCSS(input);
|
||||
let expected = test.expected.join(prettifyCSS.LINE_SEPARATOR) +
|
||||
prettifyCSS.LINE_SEPARATOR;
|
||||
equal(output, expected, test.name);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user