mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022003 - remove ObjectWrapper.jsm, r=bholley,gwagner
--HG-- extra : rebase_source : cdafaf22aaddbb04519a9bc1099b6a10f7b6c886
This commit is contained in:
parent
a2a4a9a1bc
commit
2333259d84
@ -1,52 +0,0 @@
|
||||
/* 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 Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["ObjectWrapper"];
|
||||
|
||||
// Makes sure that we expose correctly chrome JS objects to content.
|
||||
|
||||
const TypedArrayThings = [
|
||||
"Int8Array",
|
||||
"Uint8Array",
|
||||
"Uint8ClampedArray",
|
||||
"Int16Array",
|
||||
"Uint16Array",
|
||||
"Int32Array",
|
||||
"Uint32Array",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
];
|
||||
|
||||
this.ObjectWrapper = {
|
||||
getObjectKind: function objWrapper_getObjectKind(aObject) {
|
||||
if (aObject === null || aObject === undefined) {
|
||||
return "primitive";
|
||||
} else if (Array.isArray(aObject)) {
|
||||
return "array";
|
||||
} else if (aObject instanceof Ci.nsIDOMFile) {
|
||||
return "file";
|
||||
} else if (aObject instanceof Ci.nsIDOMBlob) {
|
||||
return "blob";
|
||||
} else if (aObject instanceof Date) {
|
||||
return "date";
|
||||
} else if (TypedArrayThings.indexOf(aObject.constructor.name) !== -1) {
|
||||
return aObject.constructor.name;
|
||||
} else if (typeof aObject == "object") {
|
||||
return "object";
|
||||
} else {
|
||||
return "primitive";
|
||||
}
|
||||
},
|
||||
|
||||
wrap: function objWrapper_wrap(aObject, aCtxt) {
|
||||
dump("-*- ObjectWrapper is deprecated. Use Components.utils.cloneInto() instead.\n");
|
||||
return Cu.cloneInto(aObject, aCtxt, { cloneFunctions: true });
|
||||
}
|
||||
}
|
@ -137,7 +137,6 @@ EXTRA_COMPONENTS += [
|
||||
EXTRA_JS_MODULES += [
|
||||
'DOMRequestHelper.jsm',
|
||||
'IndexedDBHelper.jsm',
|
||||
'ObjectWrapper.jsm',
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
@ -17,7 +17,6 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this,
|
||||
"appsService",
|
||||
|
@ -9,7 +9,6 @@ let Ci = Components.interfaces;
|
||||
let Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["SettingsDB", "SETTINGSDB_NAME", "SETTINGSSTORE_NAME"];
|
||||
|
||||
@ -18,6 +17,18 @@ function debug(s) {
|
||||
if (DEBUG) dump("-*- SettingsDB: " + s + "\n");
|
||||
}
|
||||
|
||||
const TYPED_ARRAY_THINGS = new Set([
|
||||
"Int8Array",
|
||||
"Uint8Array",
|
||||
"Uint8ClampedArray",
|
||||
"Int16Array",
|
||||
"Uint16Array",
|
||||
"Int32Array",
|
||||
"Uint32Array",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
]);
|
||||
|
||||
this.SETTINGSDB_NAME = "settings";
|
||||
this.SETTINGSDB_VERSION = 4;
|
||||
this.SETTINGSSTORE_NAME = "settings";
|
||||
@ -176,9 +187,29 @@ SettingsDB.prototype = {
|
||||
return aValue
|
||||
},
|
||||
|
||||
getObjectKind: function(aObject) {
|
||||
if (aObject === null || aObject === undefined) {
|
||||
return "primitive";
|
||||
} else if (Array.isArray(aObject)) {
|
||||
return "array";
|
||||
} else if (aObject instanceof Ci.nsIDOMFile) {
|
||||
return "file";
|
||||
} else if (aObject instanceof Ci.nsIDOMBlob) {
|
||||
return "blob";
|
||||
} else if (aObject.constructor.name == "Date") {
|
||||
return "date";
|
||||
} else if (TYPED_ARRAY_THINGS.has(aObject.constructor.name)) {
|
||||
return aObject.constructor.name;
|
||||
} else if (typeof aObject == "object") {
|
||||
return "object";
|
||||
} else {
|
||||
return "primitive";
|
||||
}
|
||||
},
|
||||
|
||||
// Makes sure any property that is a data: uri gets converted to a Blob.
|
||||
prepareValue: function(aObject) {
|
||||
let kind = ObjectWrapper.getObjectKind(aObject);
|
||||
let kind = this.getObjectKind(aObject);
|
||||
if (kind == "array") {
|
||||
let res = [];
|
||||
aObject.forEach(function(aObj) {
|
||||
|
@ -17,7 +17,6 @@ Cu.import("resource://gre/modules/SettingsQueue.jsm");
|
||||
Cu.import("resource://gre/modules/SettingsDB.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
@ -197,6 +196,13 @@ SettingsLock.prototype = {
|
||||
},
|
||||
|
||||
_serializePreservingBinaries: function _serializePreservingBinaries(aObject) {
|
||||
function needsUUID(aValue) {
|
||||
if (!aValue || !aValue.constructor) {
|
||||
return false;
|
||||
}
|
||||
return (aValue.constructor.name == "Date") || (aValue instanceof Ci.nsIDOMFile) ||
|
||||
(aValue instanceof Ci.nsIDOMBlob);
|
||||
}
|
||||
// We need to serialize settings objects, otherwise they can change between
|
||||
// the set() call and the enqueued request being processed. We can't simply
|
||||
// parse(stringify(obj)) because that breaks things like Blobs, Files and
|
||||
@ -206,8 +212,7 @@ SettingsLock.prototype = {
|
||||
let binaries = Object.create(null);
|
||||
let stringified = JSON.stringify(aObject, function(key, value) {
|
||||
value = manager._settingsDB.prepareValue(value);
|
||||
let kind = ObjectWrapper.getObjectKind(value);
|
||||
if (kind == "file" || kind == "blob" || kind == "date") {
|
||||
if (needsUUID(value)) {
|
||||
let uuid = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)
|
||||
.generateUUID().toString();
|
||||
binaries[uuid] = value;
|
||||
|
Loading…
Reference in New Issue
Block a user