1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 12:38:00 +01:00

Fix finder with iframes. Fix dactyl cleanup on :rehash.

This commit is contained in:
Kris Maglione
2011-01-12 14:15:58 -05:00
parent 0f9a558a3c
commit 0d9f623bea
3 changed files with 13 additions and 11 deletions

View File

@@ -474,11 +474,11 @@ var Buffer = Module("buffer", {
* @property {Window} Returns the currently focused frame. * @property {Window} Returns the currently focused frame.
*/ */
get focusedFrame() { get focusedFrame() {
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame; let frame = this.localStore.focusedFrame;
return frame && frame.get() || content; return frame && frame.get() || content;
}, },
set focusedFrame(frame) { set focusedFrame(frame) {
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame); this.localStore.focusedFrame = Cu.getWeakReference(frame);
}, },
/** /**

View File

@@ -29,7 +29,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
this.commands = {}; this.commands = {};
this.indices = {}; this.indices = {};
this.modules = modules; this.modules = modules;
this.observers = {}; this._observers = {};
util.addObserver(this); util.addObserver(this);
this.commands["dactyl.help"] = function (event) { this.commands["dactyl.help"] = function (event) {
@@ -133,21 +133,21 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
registerObserver: function (type, callback, weak) { registerObserver: function (type, callback, weak) {
if (!(type in this.observers)) if (!(type in this._observers))
this.observers[type] = []; this._observers[type] = [];
this.observers[type].push(weak ? Cu.getWeakReference(callback) : { get: function () callback }); this._observers[type].push(weak ? Cu.getWeakReference(callback) : { get: function () callback });
}, },
unregisterObserver: function (type, callback) { unregisterObserver: function (type, callback) {
if (type in this.observers) if (type in this._observers)
this.observers[type] = this.observers[type].filter(function (c) c.get() != callback); this._observers[type] = this._observers[type].filter(function (c) c.get() != callback);
}, },
// TODO: "zoom": if the zoom value of the current buffer changed // TODO: "zoom": if the zoom value of the current buffer changed
triggerObserver: function (type) { triggerObserver: function (type) {
let args = Array.slice(arguments, 1); let args = Array.slice(arguments, 1);
if (type in this.observers) if (type in this._observers)
this.observers[type] = this.observers[type].filter(function (callback) { this._observers[type] = this._observers[type].filter(function (callback) {
if (callback.get()) { if (callback.get()) {
callback.get().apply(null, args); callback.get().apply(null, args);
return true; return true;

View File

@@ -318,7 +318,7 @@ var RangeFind = Class("RangeFind", {
get selectedRange() { get selectedRange() {
let win = this.content, store = this.content.document.dactylStore;; let win = this.content, store = this.content.document.dactylStore;;
if (store) if (store)
win = store.focusedFrame || win; win = store.focusedFrame && store.focusedFrame.get() || win;
let selection = win.getSelection(); let selection = win.getSelection();
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange(); return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
@@ -328,6 +328,8 @@ var RangeFind = Class("RangeFind", {
this.range.selection.addRange(range); this.range.selection.addRange(range);
this.range.selectionController.scrollSelectionIntoView( this.range.selectionController.scrollSelectionIntoView(
this.range.selectionController.SELECTION_NORMAL, 0, false); this.range.selectionController.SELECTION_NORMAL, 0, false);
services.focus.focusedWindow = range.startContainer.ownerDocument.defaultView;
}, },
cancel: function () { cancel: function () {