[Pkg-mozext-commits] [itsalltext] 294/459: It's working mostly. The API is working again. It doesn't yet find changes in the DOM, but that's next...
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository itsalltext.
commit 9820ea9de3e85bf38da2120c5a7788fd668ed85d
Author: Christian Höltje <docwhat at gerf.org>
Date: Sun Nov 11 22:43:29 2007 -0500
It's working mostly. The API is working again.
It doesn't yet find changes in the DOM, but that's next...
---
src/chrome/content/API.js | 61 ++++++++++++++++++++++------------------
src/chrome/content/cacheobj.js | 2 +-
src/chrome/content/itsalltext.js | 33 ++++++++++++++--------
src/chrome/content/monitor.js | 38 ++++++++++++-------------
4 files changed, 75 insertions(+), 59 deletions(-)
diff --git a/src/chrome/content/API.js b/src/chrome/content/API.js
index e508d28..4f688f5 100644
--- a/src/chrome/content/API.js
+++ b/src/chrome/content/API.js
@@ -48,9 +48,41 @@
var objScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
objScriptLoader.loadSubScript('chrome://itsalltext/content/itsalltext.js');
+ /**
+ * This is part of the public XUL API.
+ * Use this to open an editor for a specific textarea or textbox with
+ * the id 'id'. The file will have the extension 'extension'. Include
+ * the leading dot in the extension.
+ * @param {String} id The id of textarea or textbody that should be opened in the editor.
+ * @param {String} extension The extension of the file used as a temporary file. Example: '.css' (optional)
+ */
+ var openEditorCommand = function(event) {
+ var id = this.getAttribute("itsalltext-control");
+ var extension = this.getAttribute("itsalltext-extension");
+ var node = document.getElementById(id);
+ var narf=ItsAllText.debug;
+ narf('oec narf 1', id, extension, node);
+
+ /* The only way I can adjust the background of the textbox is
+ * to turn off the -moz-appearance attribute.
+ */
+ node.style.MozAppearance = 'none';
+ narf('oec narf 2');
+
+ var cache_object = node && ItsAllText.getCacheObj(node);
+ narf('oec narf 3', cache_object);
+ if(!cache_object) { return; }
+ narf('oec narf 4');
+ cache_object.edit(extension);
+
+ narf('oec narf 5');
+ return false;
+ };
+
+
var onload = function (event) {
/* Start watching the document, but force it. */
- ItsAllText.monitor.startPage(document, true);
+ ItsAllText.new_monitor.startPage({originalTarget: document}, true);
/* Turn on all the hidden CSS */
var nodes = [], i;
@@ -63,15 +95,10 @@
nodes.push(node);
node = nodesIter.iterateNext();
}
- var command = function(event) {
- ItsAllText.openEditor( this.getAttribute("itsalltext-control"),
- this.getAttribute("itsalltext-extension") );
- return false;
- };
for(i in nodes) {
if (nodes.hasOwnProperty(i)) {
node = nodes[i];
- node.addEventListener('command', command, true);
+ node.addEventListener('command', openEditorCommand, true);
node.style.display = '-moz-box';
}
}
@@ -79,23 +106,3 @@
};
window.addEventListener("load", onload, true);
})();
-
-/**
- * This is part of the public XUL API.
- * Use this to open an editor for a specific textarea or textbox with
- * the id 'id'. The file will have the extension 'extension'. Include
- * the leading dot in the extension.
- * @param {String} id The id of textarea or textbody that should be opened in the editor.
- * @param {String} extension The extension of the file used as a temporary file. Example: '.css' (optional)
- */
-ItsAllText.openEditor = function(id, extension) {
- var node = document.getElementById(id);
- /* The only way I can adjust the background of the textbox is
- * to turn off the -moz-appearance attribute.
- */
- node.style.MozAppearance = 'none';
- var cache_object = node && ItsAllText.getCacheObj(node);
- if(!cache_object) { return; }
- cache_object.edit(extension);
-};
-
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 41fe9af..011f2cf 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -579,7 +579,7 @@ CacheObj.prototype.addGumDrop = function() {
if (ItsAllText.getDisableGumdrops()) {
return;
}
- ItsAllText.debug('addGumDrop()',cache_object.node_id,cache_object.uid);
+ ItsAllText.debug('addGumDrop()',cache_object);
var doc = node.ownerDocument;
if (!node.parentNode) { return; }
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 840a002..81bf9eb 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -822,13 +822,15 @@ Line 0
// Do the startup when things are loaded.
- that.listen(window, 'load', function () {
- // Add a callback to be run every time a document loads.
- // note that this includes frames/iframes within the document
- that.listen(gBrowser, "load",
- that.hitch(that.new_monitor, 'registerPage'), true);
- that.listen(gBrowser, "unload",
- that.hitch(that.new_monitor, 'unregisterPage'), true);
+ that.listen(window, 'load', function (event) {
+ if (typeof(gBrowser) === 'undefined') {
+ that.new_monitor.registerPage(event);
+ } else {
+ // Add a callback to be run every time a document loads.
+ // note that this includes frames/iframes within the document
+ that.listen(gBrowser, "load",
+ that.new_monitor.registerPage, true);
+ }
// Start watching the preferences.
that.preference_observer.register();
@@ -840,7 +842,10 @@ Line 0
}
}, false);
- that.listen(window, 'unload', function () {
+ that.listen(window, 'unload', function (event) {
+ if (typeof(gBrowser) === 'undefined') {
+ that.new_monitor.stopPage(event);
+ }
var doc = event.originalTarget;
that.debug("pageunload(): A page has been unloaded", doc && doc.location);
that.cleanCacheObjs();
@@ -889,8 +894,10 @@ ItsAllText.prototype.hitch = function(object, method) {
* @param opt_capture {Boolean} Should the event be captured?
*/
ItsAllText.prototype.listen = function (source, event, listener, opt_capture) {
- Components.lookupMethod(source, "addEventListener")(
- event, listener, opt_capture);
+ opt_capture = !!opt_capture;
+ this.debug("listen(%o, %o, -, %o)", source, event, opt_capture);
+ Components.lookupMethod(source, "addEventListener")(
+ event, listener, opt_capture);
}
/**
@@ -901,8 +908,10 @@ ItsAllText.prototype.listen = function (source, event, listener, opt_capture) {
* @param opt_capture {Boolean} Should the event be captured?
*/
ItsAllText.prototype.unlisten = function (source, event, listener, opt_capture) {
- Components.lookupMethod(source, "removeEventListener")(
- event, listener, opt_capture);
+ opt_capture = !!opt_capture;
+ this.debug("unlisten(%o, %o, -, %o)", source, event, opt_capture);
+ Components.lookupMethod(source, "removeEventListener")(
+ event, listener, opt_capture);
}
/**
diff --git a/src/chrome/content/monitor.js b/src/chrome/content/monitor.js
index 33edf97..5fb41ad 100644
--- a/src/chrome/content/monitor.js
+++ b/src/chrome/content/monitor.js
@@ -46,10 +46,10 @@ new_monitor.prototype.hitched_restart = function () {
this.id = setInterval(this.watcher, rate);
};
-new_monitor.prototype.registerPage = function (event) {
+new_monitor.prototype.hitched_registerPage = function (event) {
if (event.originalTarget instanceof HTMLDocument) {
var doc = event.originalTarget;
- if (event.originalTarget.defaultView.frameElement) {
+ if (doc.defaultView.frameElement) {
// Frame within a tab was loaded. doc should be the root document of
// the frameset. If you don't want do anything when frames/iframes
// are loaded in this web page, uncomment the following line:
@@ -65,24 +65,12 @@ new_monitor.prototype.registerPage = function (event) {
/* appContent is the browser chrome. */
var appContent = document.getElementById("appcontent");
this.iat.listen(appContent, 'DOMContentLoaded', this.startPage, true);
+ this.iat.listen(document, 'unload', this.stopPage, true);
this.iat.listen(gBrowser.tabContainer, 'TabSelect', this.watcher, true);
this.iat.debug('RegisterPage: END');
}
};
-new_monitor.prototype.unregisterPage = function (event) {
- var doc = event.originalTarget;
- this.iat.debug('unregisterPage', doc && doc.location);
-
- // Stop any monitoring.
- this.stopPage(event);
-
- // Remove any other handlers.
- var appContent = document.getElementById("appcontent");
- this.iat.unlisten(appContent, 'DOMContentLoaded', this.startPage, true);
- this.iat.unlisten(gBrowser.tabContainer, 'TabSelect', this.watcher, true);
-};
-
new_monitor.prototype.hitched_watcher = function (offset, init) {
if (offset.type === 'TabSelect') {
init = true;
@@ -95,7 +83,14 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
}
this.last_watcher_call = now;
- var doc = gBrowser.selectedBrowser.contentDocument;
+ var doc;
+ if (typeof(gBrowser) === 'undefined') {
+ /* If we're in chrome. */
+ doc = document;
+ } else {
+ /* If we're in a tabbed browser. */
+ doc = gBrowser.selectedBrowser.contentDocument;
+ }
this.iat.debug('watcher: ', offset, init, doc && doc.location);
var nodes = [];
var i, cobj, node;
@@ -108,7 +103,7 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
/* XUL */
nodes = doc.getElementsByTagName('textbox');
} else {
- this.unregisterPage(doc);
+ this.stopPage({originalTarget: doc});
return;
}
for(i=0; i < nodes.length; i++) {
@@ -128,12 +123,14 @@ new_monitor.prototype.hitched_startPage = function (event, force) {
var doc = event.originalTarget;
this.iat.debug('startPage', doc && doc.location, force);
if (!(force || this.isHTML(doc))) {
- this.unregisterPage(event);
+ this.stopPage(event);
return;
}
var unsafeWin = doc.defaultView.wrappedJSObject;
- this.iat.listen(unsafeWin, 'pagehide', this.iat.hitch(this, 'stopPage'));
+ if (unsafeWin) {
+ this.iat.listen(unsafeWin, 'pagehide', this.stopPage);
+ }
// Kick off a watcher now...
this.watcher(0, true);
@@ -144,6 +141,9 @@ new_monitor.prototype.hitched_startPage = function (event, force) {
new_monitor.prototype.hitched_stopPage = function (event) {
var doc = event.originalTarget;
this.iat.debug('stopPage', doc && doc.location);
+
+ var unsafeWin = doc.defaultView.wrappedJSObject;
+ this.iat.unlisten(unsafeWin, 'pagehide', this.stopPage);
};
new_monitor.prototype.isXUL = function (doc) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git
More information about the Pkg-mozext-commits
mailing list