From 7d0dcf53e5b3bc370200cb7ba856edf37014767f Mon Sep 17 00:00:00 2001 From: "caillon%returnzero.com" Date: Sat, 29 Jul 2006 05:41:11 +0000 Subject: [PATCH] Bug 155062. View background image fails/works incorrectly when things have a background attribute, but a different specified style. We should always get the computed background-image and ignore what the background attribute says. r=bzbarsky sr=blake git-svn-id: svn://10.0.0.236/trunk@205675 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/suite/common/nsContextMenu.js | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mozilla/suite/common/nsContextMenu.js b/mozilla/suite/common/nsContextMenu.js index 7bde392502d..9fddb7acc07 100644 --- a/mozilla/suite/common/nsContextMenu.js +++ b/mozilla/suite/common/nsContextMenu.js @@ -277,12 +277,11 @@ nsContextMenu.prototype = { // pages with multiple s are lame. we'll teach them a lesson. var bodyElt = this.target.ownerDocument.getElementsByTagName("body")[0]; if ( bodyElt ) { - var attr = bodyElt.getAttribute( "background" ); - if ( attr || - ( attr = this.getComputedURL( bodyElt, "background-image" ) ) ) { + var computedURL = this.getComputedURL( bodyElt, "background-image" ); + if ( computedURL ) { this.hasBGImage = true; this.bgImageURL = this.makeURLAbsolute( bodyElt.baseURI, - attr ); + computedURL ); } } } else if ( "HTTPIndex" in _content && @@ -382,17 +381,16 @@ nsContextMenu.prototype = { } } - // Background image? We don't bother if we've already found a background - // image further down the hierarchy. Otherwise, we look for background= - // attribute on html elements that support that, or, background-image style. - var bgImgUrl = null; - if ( !this.hasBGImage && - ( ( localname.search( /^(?:TD|TH|TABLE|BODY)$/ ) != -1 && - ( bgImgUrl = elem.getAttribute( "background" ) ) ) || - ( bgImgUrl = this.getComputedURL( elem, "background-image" ) ) ) ) { - this.hasBGImage = true; - this.bgImageURL = this.makeURLAbsolute( elem.baseURI, - bgImgUrl ); + // Background image? Don't bother if we've already found a + // background image further down the hierarchy. Otherwise, + // we look for the computed background-image style. + if ( !this.hasBGImage ) { + var bgImgUrl = this.getComputedURL( elem, "background-image" ); + if ( bgImgUrl ) { + this.hasBGImage = true; + this.bgImageURL = this.makeURLAbsolute( elem.baseURI, + bgImgUrl ); + } } } elem = elem.parentNode;