From e08b257a8f10428af9e8fd0f7887b69a136c3bfd Mon Sep 17 00:00:00 2001 From: "philringnalda%gmail.com" Date: Fri, 2 Mar 2007 04:25:02 +0000 Subject: [PATCH] Bug 369341 - gatherTextUnder is a bad treewalker, r+a=mscott git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@221197 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mail/base/content/utilityOverlay.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mozilla/mail/base/content/utilityOverlay.js b/mozilla/mail/base/content/utilityOverlay.js index 30f615e59e7..ae0a2fda37b 100644 --- a/mozilla/mail/base/content/utilityOverlay.js +++ b/mozilla/mail/base/content/utilityOverlay.js @@ -127,11 +127,10 @@ function gatherTextUnder ( root ) // Add this text to our collection. text += " " + node.data; } else if ( node instanceof HTMLImageElement ) { - // If it has an alt= attribute, use that. + // If it has an alt= attribute, add that. var altText = node.getAttribute( "alt" ); if ( altText && altText != "" ) { - text = altText; - break; + text += " " + altText; } } // Find next node to test. @@ -145,9 +144,15 @@ function gatherTextUnder ( root ) if ( node.nextSibling ) { node = node.nextSibling; } else { - // Last resort is our next oldest uncle/aunt. - node = node.parentNode.nextSibling; - depth--; + // Last resort is a sibling of an ancestor. + while ( node && depth > 0 ) { + node = node.parentNode; + depth--; + if ( node.nextSibling ) { + node = node.nextSibling; + break; + } + } } } }