mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 19:44:13 +01:00
Fix more cross-window object issues.
This commit is contained in:
@@ -1000,11 +1000,10 @@ var CommandLine = Module("commandline", {
|
|||||||
if (privateData == "never-save")
|
if (privateData == "never-save")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.store = this.store.filter(line => (line.value || line) != str);
|
let store = Array.filter(this.store, line => (line.value || line) != str);
|
||||||
dactyl.trapErrors(function () {
|
dactyl.trapErrors(
|
||||||
this.store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData });
|
() => store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData }));
|
||||||
}, this);
|
this.store = store.slice(Math.max(0, store.length - options["history"]));
|
||||||
this.store = this.store.slice(Math.max(0, this.store.length - options["history"]));
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @property {function} Returns whether a data item should be
|
* @property {function} Returns whether a data item should be
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ var Marks = Module("marks", {
|
|||||||
let mark = this.Mark();
|
let mark = this.Mark();
|
||||||
|
|
||||||
if (Marks.isURLMark(name)) {
|
if (Marks.isURLMark(name)) {
|
||||||
mark.tab = util.weakReference(tabs.getTab());
|
// FIXME: Disabled due to cross-compartment magic.
|
||||||
|
// mark.tab = util.weakReference(tabs.getTab());
|
||||||
this._urlMarks.set(name, mark);
|
this._urlMarks.set(name, mark);
|
||||||
var message = "mark.addURL";
|
var message = "mark.addURL";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ lazyRequire("resource://gre/modules/osfile.jsm", ["OS"]);
|
|||||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||||
var myObject = JSON.parse("{}").constructor;
|
var myObject = JSON.parse("{}").constructor;
|
||||||
|
|
||||||
|
var global = Cu.getGlobalForObject(this);
|
||||||
|
|
||||||
var StoreBase = Class("StoreBase", {
|
var StoreBase = Class("StoreBase", {
|
||||||
OPTIONS: ["privateData", "replacer"],
|
OPTIONS: ["privateData", "replacer"],
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@ var StoreBase = Class("StoreBase", {
|
|||||||
|
|
||||||
get serial() JSON.stringify(this._object, this.replacer),
|
get serial() JSON.stringify(this._object, this.replacer),
|
||||||
|
|
||||||
init: function (name, store, load, options) {
|
init: function init(name, store, load, options) {
|
||||||
this._load = load;
|
this._load = load;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
|
||||||
@@ -37,13 +39,21 @@ var StoreBase = Class("StoreBase", {
|
|||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function (storage) {
|
clone: function clone(storage) {
|
||||||
let store = storage.privateMode ? false : this.store;
|
let store = storage.privateMode ? false : this.store;
|
||||||
let res = this.constructor(this.name, store, this._load, this._options);
|
let res = this.constructor(this.name, store, this._load, this._options);
|
||||||
res.storage = storage;
|
res.storage = storage;
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeOwn: function makeOwn(val) {
|
||||||
|
if (typeof val != "object")
|
||||||
|
return val;
|
||||||
|
if (Cu.getGlobalForObject(val) == global)
|
||||||
|
return val;
|
||||||
|
return JSON.parse(JSON.stringify(val, this.replacer));
|
||||||
|
},
|
||||||
|
|
||||||
changed: function () { this.timer && this.timer.tell(); },
|
changed: function () { this.timer && this.timer.tell(); },
|
||||||
|
|
||||||
reload: function reload() {
|
reload: function reload() {
|
||||||
@@ -70,7 +80,7 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
|
|||||||
|
|
||||||
set: function set(index, value, quiet) {
|
set: function set(index, value, quiet) {
|
||||||
var orig = this._object[index];
|
var orig = this._object[index];
|
||||||
this._object[index] = value;
|
this._object[index] = this.makeOwn(value);
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
this.fireEvent("change", index);
|
this.fireEvent("change", index);
|
||||||
|
|
||||||
@@ -78,7 +88,7 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
push: function push(value) {
|
push: function push(value) {
|
||||||
this._object.push(value);
|
this._object.push(this.makeOwn(value));
|
||||||
this.fireEvent("push", this._object.length);
|
this.fireEvent("push", this._object.length);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -99,6 +109,7 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
insert: function insert(value, ord) {
|
insert: function insert(value, ord) {
|
||||||
|
value = this.makeOwn(value);
|
||||||
if (ord == 0)
|
if (ord == 0)
|
||||||
this._object.unshift(value);
|
this._object.unshift(value);
|
||||||
else
|
else
|
||||||
@@ -123,7 +134,8 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
|
|||||||
mutate: function mutate(funcName) {
|
mutate: function mutate(funcName) {
|
||||||
var _funcName = funcName;
|
var _funcName = funcName;
|
||||||
arguments[0] = this._object;
|
arguments[0] = this._object;
|
||||||
this._object = Array[_funcName].apply(Array, arguments);
|
this._object = Array[_funcName].apply(Array, arguments)
|
||||||
|
.map(this.makeOwn.bind(this));
|
||||||
this.fireEvent("change", null);
|
this.fireEvent("change", null);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -158,7 +170,7 @@ var ObjectStore = Class("ObjectStore", StoreBase, {
|
|||||||
set: function set(key, val) {
|
set: function set(key, val) {
|
||||||
var defined = key in this._object;
|
var defined = key in this._object;
|
||||||
var orig = this._object[key];
|
var orig = this._object[key];
|
||||||
this._object[key] = val;
|
this._object[key] = this.makeOwn(val);
|
||||||
if (!defined)
|
if (!defined)
|
||||||
this.fireEvent("add", key);
|
this.fireEvent("add", key);
|
||||||
else if (orig != val)
|
else if (orig != val)
|
||||||
|
|||||||
Reference in New Issue
Block a user