Bug 1268461 - Decouple OriginalSourceFront from OriginalSourceActor;r=jryans

This commit is contained in:
Eddy Bruel 2016-05-03 13:14:52 +02:00
Родитель 4abe158198
Коммит 56aee50d78
6 изменённых файлов: 67 добавлений и 37 удалений

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

@ -1,7 +1,10 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DevToolsModules(
'storage.js',
'stylesheets.js'
)

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

@ -0,0 +1,36 @@
/* 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 { Front, FrontClassWithSpec } = require("devtools/server/protocol.js");
const { originalSourceSpec } = require("devtools/shared/specs/stylesheets.js");
/**
* The client-side counterpart for an OriginalSourceActor.
*/
const OriginalSourceFront = FrontClassWithSpec(originalSourceSpec, {
initialize: function (client, form) {
Front.prototype.initialize.call(this, client, form);
this.isOriginalSource = true;
},
form: function (form, detail) {
if (detail === "actorid") {
this.actorID = form;
return;
}
this.actorID = form.actor;
this._form = form;
},
get href() {
return this._form.url;
},
get url() {
return this._form.url;
}
});
exports.OriginalSourceFront = OriginalSourceFront;

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

@ -14,11 +14,13 @@ Cu.import("resource://gre/modules/Task.jsm");
const promise = require("promise");
const events = require("sdk/event/core");
const {OriginalSourceFront} = require("devtools/client/fronts/stylesheets");
const protocol = require("devtools/server/protocol");
const {Arg, Option, method, RetVal, types} = protocol;
const {LongStringActor, ShortLongString} = require("devtools/server/actors/string");
const {fetch} = require("devtools/shared/DevToolsUtils");
const {listenOnce} = require("devtools/shared/async-utils");
const {originalSourceSpec} = require("devtools/shared/specs/stylesheets");
const {SourceMapConsumer} = require("source-map");
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
@ -66,9 +68,7 @@ let modifiedStyleSheets = new WeakMap();
* Actor representing an original source of a style sheet that was specified
* in a source map.
*/
var OriginalSourceActor = protocol.ActorClass({
typeName: "originalsource",
var OriginalSourceActor = protocol.ActorClassWithSpec(originalSourceSpec, {
initialize: function(aUrl, aSourceMap, aParentActor) {
protocol.Actor.prototype.initialize.call(this, null);
@ -110,43 +110,12 @@ var OriginalSourceActor = protocol.ActorClass({
/**
* Protocol method to get the text of this source.
*/
getText: method(function() {
getText: function() {
return this._getText().then((text) => {
return new LongStringActor(this.conn, text || "");
});
}, {
response: {
text: RetVal("longstring")
}
})
})
/**
* The client-side counterpart for an OriginalSourceActor.
*/
var OriginalSourceFront = protocol.FrontClass(OriginalSourceActor, {
initialize: function(client, form) {
protocol.Front.prototype.initialize.call(this, client, form);
this.isOriginalSource = true;
},
form: function(form, detail) {
if (detail === "actorid") {
this.actorID = form;
return;
}
this.actorID = form.actor;
this._form = form;
},
get href() {
return this._form.url;
},
get url() {
return this._form.url;
}
});
})
/**
* A MediaRuleActor lives on the server and provides access to properties

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

@ -24,6 +24,7 @@ DIRS += [
'sourcemap',
'specs',
'shims',
'specs',
'touch',
'transport',
'webconsole',

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

@ -5,5 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DevToolsModules(
'storage.js'
'storage.js',
'stylesheets.js'
)

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

@ -0,0 +1,20 @@
/* 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 { RetVal, generateActorSpec } = require("devtools/server/protocol.js");
const originalSourceSpec = generateActorSpec({
typeName: "originalsource",
methods: {
getText: {
response: {
text: RetVal("longstring")
}
}
}
});
exports.originalSourceSpec = originalSourceSpec;