Backed out changeset 4fa21c0bcb63 (bug 1307009)

This commit is contained in:
Sebastian Hengst 2016-10-05 17:11:01 +02:00
parent 7520674246
commit aaf2af359e
3 changed files with 29 additions and 6 deletions

View File

@ -10,6 +10,10 @@ loader.lazyGetter(this, "DOMUtils", () => {
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
});
loader.lazyGetter(this, "appInfo", () => {
return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
});
const protocol = require("devtools/shared/protocol");
const { ActorClassWithSpec, Actor } = protocol;
const { cssPropertiesSpec } = require("devtools/shared/specs/css-properties");
@ -28,7 +32,15 @@ exports.CssPropertiesActor = ActorClassWithSpec(cssPropertiesSpec, {
Actor.prototype.destroy.call(this);
},
getCSSDatabase() {
getCSSDatabase(clientBrowserVersion) {
// If the client and server are both the same version of Firefox, do not return a
// database, use the client-side css-properties-db.js.
const serverBrowserVersion = appInfo.platformVersion.match(/^\d+/)[0];
if (clientBrowserVersion !== 0 && clientBrowserVersion === serverBrowserVersion) {
return {};
}
const properties = generateCssProperties();
const pseudoElements = DOMUtils.getCSSPseudoElementNames();

View File

@ -205,10 +205,9 @@ const initCssProperties = Task.async(function* (toolbox) {
// Get the list dynamically if the cssProperties actor exists.
if (toolbox.target.hasActor("cssProperties")) {
front = CssPropertiesFront(client, toolbox.target.form);
const serverDB = yield front.getCSSDatabase();
const serverDB = yield front.getCSSDatabase(getClientBrowserVersion(toolbox));
// Ensure the database was returned in a format that is understood.
// Older versions of the protocol could return a blank database.
// The serverDB will be blank if the browser versions match, so use the static list.
if (!serverDB.properties && !serverDB.margin) {
db = CSS_PROPERTIES_DB;
} else {
@ -250,6 +249,16 @@ function getClientCssProperties() {
return new CssProperties(normalizeCssData(CSS_PROPERTIES_DB));
}
/**
* Get the current browser version.
* @returns {string} The browser version.
*/
function getClientBrowserVersion(toolbox) {
const regexResult = toolbox.win.navigator
.userAgent.match(/Firefox\/(\d+)\.\d/);
return Array.isArray(regexResult) ? regexResult[1] : "0";
}
/**
* Even if the target has the cssProperties actor, the returned data may not be in the
* same shape or have all of the data we need. This normalizes the data and fills in

View File

@ -3,14 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { RetVal, generateActorSpec } = require("devtools/shared/protocol");
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
const cssPropertiesSpec = generateActorSpec({
typeName: "cssProperties",
methods: {
getCSSDatabase: {
request: {},
request: {
clientBrowserVersion: Arg(0, "string"),
},
response: RetVal("json"),
}