[Pkg-mozext-commits] [itsalltext] 253/459: Finally found the blasted wordpress bug. It's a DOMContentLoaded already fired problem.
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:27 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 430548e13258195d36f0a86d5a858dccf28ab93d
Author: Christian Höltje <docwhat at gerf.org>
Date: Wed Jun 20 22:04:28 2007 -0400
Finally found the blasted wordpress bug. It's a DOMContentLoaded already fired problem.
---
src/chrome/content/cacheobj.js | 98 ++++++++++++++++++++++------------------
src/chrome/content/itsalltext.js | 38 +++++++++++-----
2 files changed, 81 insertions(+), 55 deletions(-)
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index c4cfdee..cd86612 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -94,8 +94,8 @@ function CacheObj(node) {
var style = that.button?that.button.style:null;
if (style) {
style.setProperty('opacity', '0.7', 'important');
- ItsAllText.refreshTextarea(that.node);
}
+ ItsAllText.refreshTextarea(that.node);
};
/**
@@ -115,7 +115,7 @@ function CacheObj(node) {
* Destroys the object, unallocating as much as possible to prevent leaks.
*/
CacheObj.prototype.destroy = function() {
- ItsAllText.debug('destroying %o',this);
+ ItsAllText.debug('destroying', this.node_id, this);
var node = this.node;
var doc = this.node.ownerDocument;
var html = doc.getElementsByTagName('html')[0];
@@ -125,6 +125,8 @@ CacheObj.prototype.destroy = function() {
delete this.node;
delete this.button;
+ delete this.file;
+ this.file = this.node = this.button = null;
};
/**
@@ -377,15 +379,12 @@ CacheObj.prototype.read = function() {
*/
CacheObj.prototype.hasChanged = function() {
/* Check exists. Check ts and size. */
- if(!this.private_is_watching ||
- !this.file.exists() ||
- !this.file.isReadable() ||
- (this.file.lastModifiedTime == this.timestamp &&
- this.file.fileSize == this.size)) {
- return false;
- } else {
- return true;
- }
+ return this.private_is_watching &&
+ this.file &&
+ this.file.exists() &&
+ this.file.isReadable() &&
+ (this.file.lastModifiedTime != this.timestamp ||
+ this.file.fileSize != this.size);
};
/**
@@ -445,6 +444,39 @@ CacheObj.prototype.update = function() {
};
/**
+ * The function to execute when a gumdrop is clicked.
+ * @param {Object} event The event that triggered this.
+ */
+CacheObj.prototype.onClick = function(event) {
+ cache_object.edit();
+ event.stopPropagation();
+ return false;
+};
+
+/**
+ * The function to execute when a gumdrop is right clicked (context)
+ * @param {Object} event The event that triggered this.
+ */
+CacheObj.prototype.onContext = function(event) {
+ /* This took forever to fix; roughly 80+ man hours were spent
+ * over 5 months trying to make this stupid thing work.
+ * The documentation is completely wrong and useless.
+ *
+ * Excuse me while I scream.
+ *
+ * See Mozilla bugs: 287357, 362403, 279703
+ */
+ var popup = ItsAllText.rebuildMenu(cache_object.uid);
+ document.popupNode = popup;
+ popup.showPopup(popup,
+ event.screenX, event.screenY,
+ 'context', null, null);
+ event.stopPropagation();
+ return false;
+};
+
+
+/**
* Add the gumdrop to a textarea.
* @param {Object} cache_object The Cache Object that contains the node.
*/
@@ -454,14 +486,17 @@ CacheObj.prototype.addGumDrop = function() {
cache_object.adjust();
return; /*already done*/
}
+
+ // Add the textarea mouseovers even if the button is disabled
+ var node = cache_object.node;
+ node.addEventListener( "mouseover", cache_object.mouseover, false);
+ node.addEventListener( "mouseout", cache_object.mouseout, false);
if (ItsAllText.getDisableGumdrops()) {
return;
}
ItsAllText.debug('addGumDrop()',cache_object.node_id,cache_object.uid);
- var node = cache_object.node;
var doc = node.ownerDocument;
- var offsetNode = node;
if (!node.parentNode) { return; }
var gumdrop = doc.createElementNS(ItsAllText.XHTMLNS, "img");
@@ -489,32 +524,9 @@ CacheObj.prototype.addGumDrop = function() {
gumdrop.setAttribute(ItsAllText.MYSTRING+'_UID', cache_object.uid);
- var clickfun = function(event) {
- cache_object.edit();
- event.stopPropagation();
- return false;
- };
- var contextfun = function(event) {
- /* This took forever to fix; roughly 80+ man hours were spent
- * over 5 months trying to make this stupid thing work.
- * The documentation is completely wrong and useless.
- *
- * Excuse me while I scream.
- *
- * See Mozilla bugs: 287357, 362403, 279703
- */
- var popup = ItsAllText.rebuildMenu(cache_object.uid);
- document.popupNode = popup;
- popup.showPopup(popup,
- event.screenX, event.screenY,
- 'context', null, null);
- event.stopPropagation();
- return false;
- };
-
- // Click event handler
- gumdrop.addEventListener("click", clickfun, false);
- gumdrop.addEventListener("contextmenu", contextfun, false);
+ // Click event handlers
+ gumdrop.addEventListener("click", cache_object.onClick, false);
+ gumdrop.addEventListener("contextmenu", cache_object.onContext, false);
// Insert it into the document
var parent = node.parentNode;
@@ -527,10 +539,8 @@ CacheObj.prototype.addGumDrop = function() {
}
// Add mouseovers/outs
- node.addEventListener("mouseover", cache_object.mouseover, false);
- node.addEventListener("mouseout", cache_object.mouseout, false);
- gumdrop.addEventListener("mouseover", cache_object.mouseover, false);
- gumdrop.addEventListener("mouseout", cache_object.mouseout, false);
+ gumdrop.addEventListener("mouseover", cache_object.mouseover, false);
+ gumdrop.addEventListener("mouseout", cache_object.mouseout, false);
cache_object.mouseout(null);
cache_object.adjust();
@@ -554,7 +564,7 @@ CacheObj.prototype.adjust = function() {
var style = gumdrop.style;
if (!gumdrop || !el) { return; }
var display = '';
- var cstyle = doc.defaultView.getComputedStyle(el, '');
+ var cstyle = doc.defaultView && doc.defaultView.getComputedStyle(el, '');
if ((cstyle && (cstyle.display == 'none' ||
cstyle.visibility == 'hidden')) ||
el.getAttribute('readonly') ||
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 523ebeb..5539c62 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -94,7 +94,7 @@ var ItsAllText = function() {
var args = Array.prototype.slice.apply(arguments,[0]);
for (var i=0; i<args.length; i++) {
try {
- args[i] = args[i].toString();
+ args[i] = "" + args[i];
} catch(e) {
Components.utils.reportError(e);
args[i] = 'toStringFailed';
@@ -494,7 +494,9 @@ var ItsAllText = function() {
* @param {Object} doc The document to refresh.
*/
that.refreshDocument = function(doc) {
- if(!doc.location) { return; } // it's being cached, but not shown.
+ if(!doc.location) {
+ return; // it's being cached, but not shown.
+ }
var is_chrome = (doc.location.protocol == 'chrome:' &&
doc.location.href != that.README);
var nodes = doc.getElementsByTagName('textarea');
@@ -564,9 +566,10 @@ var ItsAllText = function() {
contentType=='application/xhtml+xml');
//var is_xul=(contentType=='application/vnd.mozilla.xul+xml');
is_usable = (is_html) &&
+ location &&
location.protocol != 'about:' &&
location.protocol != 'chrome:';
- is_my_readme = location.href == that.README;
+ is_my_readme = location && location.href == that.README;
if (!(is_usable || is_my_readme)) {
that.debuglog('watch(): ignoring -- ',
location, contentType);
@@ -632,8 +635,10 @@ var ItsAllText = function() {
* @param {Object} event An event passed in.
*/
that.onDOMContentLoad = function(event) {
- if (event.originalTarget.nodeName != "#document") { return; }
- var doc = event.originalTarget || document;
+ var doc = event.originalTarget;
+ if (!doc || doc.nodeName != "#document") {
+ return;
+ }
that.monitor.watch(doc);
return;
};
@@ -655,19 +660,23 @@ var ItsAllText = function() {
* @param {Object} event The event passed in by the event handler.
*/
that.onContextMenu = function(event) {
- var tid, node, tag, is_disabled, cobj, menu;
+ var tid, node, tag, is_disabled, cobj, menu, cstyle, doc;
if(event.target) {
tid = event.target.id;
if (tid == "itsalltext-context-popup" ||
tid == "contentAreaContextMenu") {
node = document.popupNode;
tag = node.nodeName.toLowerCase();
+ doc = node.ownerDocument;
+ cstyle = doc.defaultView.getComputedStyle(node, '');
is_disabled = (!(tag == 'textarea' ||
- tag == 'textbox') ||
- node.style.display == 'none' ||
- node.getAttribute('readonly') ||
- node.getAttribute('disabled')
- );
+ tag == 'textbox') ||
+ node.style.display == 'none' ||
+ (cstyle && (cstyle.display == 'none' ||
+ cstyle.visibility == 'hidden')) ||
+ node.getAttribute('readonly') ||
+ node.getAttribute('disabled')
+ );
if (tid == "itsalltext-context-popup") {
cobj = that.getCacheObj(node);
that.rebuildMenu(cobj.uid,
@@ -749,8 +758,10 @@ ItsAllText.prototype.menuNewExtEdit = function(event) {
ItsAllText.prototype.menuExtEdit = function(event) {
var that = this;
var uid = that.private_current_uid;
+ ItsAllText.debug('menuExtEdit:',uid);
var ext = event.target.getAttribute('label');
var cobj = that.getCacheObj(uid);
+ that.monitor.watch(cobj.node.ownerDocument);
cobj.edit(ext);
};
@@ -838,6 +849,11 @@ ItsAllText.prototype.pageload = function(event) {
// Normal web-page.
appcontent.addEventListener("DOMContentLoaded", this.onDOMContentLoad,
true);
+ /* This is a fallback. It seems that sometimes I get here
+ * AFTER the DOMContentLoaded event has fired. :-( Better late
+ * than never, I guess.
+ */
+ setTimeout(function() {ItsAllText.onDOMContentLoad({originalTarget: event.originalTarget});}, 5000);
} else {
this.onDOMContentLoad(event);
}
--
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