mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:27:59 +01:00
Avoid storing strong references to DOM nodes.
This commit is contained in:
@@ -440,10 +440,13 @@ const Buffer = Module("buffer", {
|
|||||||
/**
|
/**
|
||||||
* @property {Window} Returns the currently focused frame.
|
* @property {Window} Returns the currently focused frame.
|
||||||
*/
|
*/
|
||||||
get focusedFrame()
|
get focusedFrame() {
|
||||||
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame,
|
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
|
||||||
set focusedFrame(frame)
|
return frame && frame.get();
|
||||||
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = frame,
|
},
|
||||||
|
set focusedFrame(frame) {
|
||||||
|
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently selected word. If the selection is
|
* Returns the currently selected word. If the selection is
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
const Marks = Module("marks", {
|
const Marks = Module("marks", {
|
||||||
init: function init() {
|
init: function init() {
|
||||||
function replacer(key, val) val instanceof Node ? null : val;
|
function replacer(key, val) val instanceof Ci.nsISupports ? null : val;
|
||||||
this._localMarks = storage.newMap("local-marks", { privateData: true, replacer: replacer, store: true });
|
this._localMarks = storage.newMap("local-marks", { privateData: true, replacer: replacer, store: true });
|
||||||
this._urlMarks = storage.newMap("url-marks", { privateData: true, replacer: replacer, store: true });
|
this._urlMarks = storage.newMap("url-marks", { privateData: true, replacer: replacer, store: true });
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ const Marks = Module("marks", {
|
|||||||
let position = { x: x, y: y };
|
let position = { x: x, y: y };
|
||||||
|
|
||||||
if (Marks.isURLMark(mark)) {
|
if (Marks.isURLMark(mark)) {
|
||||||
let res = this._urlMarks.set(mark, { location: doc.URL, position: position, tab: tabs.getTab(), timestamp: Date.now()*1000 });
|
let res = this._urlMarks.set(mark, { location: doc.URL, position: position, tab: Cu.getWeakReference(tabs.getTab()), timestamp: Date.now()*1000 });
|
||||||
if (!silent)
|
if (!silent)
|
||||||
dactyl.log("Adding URL mark: " + Marks.markToString(mark, res), 5);
|
dactyl.log("Adding URL mark: " + Marks.markToString(mark, res), 5);
|
||||||
}
|
}
|
||||||
@@ -107,18 +107,19 @@ const Marks = Module("marks", {
|
|||||||
|
|
||||||
if (Marks.isURLMark(mark)) {
|
if (Marks.isURLMark(mark)) {
|
||||||
let slice = this._urlMarks.get(mark);
|
let slice = this._urlMarks.get(mark);
|
||||||
if (slice && slice.tab && slice.tab.linkedBrowser) {
|
let tab = slice && slice.tab && slice.tab.get();
|
||||||
if (slice.tab.parentNode != config.browser.tabContainer) {
|
if (tab && tab.linkedBrowser) {
|
||||||
|
if (tab.parentNode != config.browser.tabContainer) {
|
||||||
this._pendingJumps.push(slice);
|
this._pendingJumps.push(slice);
|
||||||
// NOTE: this obviously won't work on generated pages using
|
// NOTE: this obviously won't work on generated pages using
|
||||||
// non-unique URLs :(
|
// non-unique URLs :(
|
||||||
dactyl.open(slice.location, dactyl.NEW_TAB);
|
dactyl.open(slice.location, dactyl.NEW_TAB);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let index = tabs.index(slice.tab);
|
let index = tabs.index(tab);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
tabs.select(index);
|
tabs.select(index);
|
||||||
let win = slice.tab.linkedBrowser.contentWindow;
|
let win = tab.linkedBrowser.contentWindow;
|
||||||
if (win.location.href != slice.location) {
|
if (win.location.href != slice.location) {
|
||||||
this._pendingJumps.push(slice);
|
this._pendingJumps.push(slice);
|
||||||
win.location.href = slice.location;
|
win.location.href = slice.location;
|
||||||
@@ -180,10 +181,11 @@ const Marks = Module("marks", {
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
markToString: function markToString(name, mark) {
|
markToString: function markToString(name, mark) {
|
||||||
|
let tab = mark.tab && mark.tab.get();
|
||||||
return name + ", " + mark.location +
|
return name + ", " + mark.location +
|
||||||
", (" + Math.round(mark.position.x * 100) +
|
", (" + Math.round(mark.position.x * 100) +
|
||||||
"%, " + Math.round(mark.position.y * 100) + "%)" +
|
"%, " + Math.round(mark.position.y * 100) + "%)" +
|
||||||
(("tab" in mark) ? ", tab: " + tabs.index(mark.tab) : "");
|
(tab ? ", tab: " + tabs.index(tab) : "");
|
||||||
},
|
},
|
||||||
|
|
||||||
isLocalMark: function isLocalMark(mark) /^['`a-z]$/.test(mark),
|
isLocalMark: function isLocalMark(mark) /^['`a-z]$/.test(mark),
|
||||||
|
|||||||
Reference in New Issue
Block a user