WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
8087
REGRESSION: Image width & height not valid on generated elements
https://bugs.webkit.org/show_bug.cgi?id=8087
Summary
REGRESSION: Image width & height not valid on generated elements
Niels Meersschaert
Reported
2006-03-30 11:05:28 PST
If an image is generated in the DOM, either manually or thru an XMLHttpRequest, querying that image for it's height & width no longer works (it did earlier). Here's a test case: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"> <html xmlns="
http://www.w3.org/1999/xhtml
" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Image bug</title> <script type="text/javascript"> function test() { var srcImage = document.createElement("img"); srcImage.setAttribute("src","
http://images.apple.com/macosx/images/indextop20060109.jpg
"); //Source image is 670x275 var image = new Image(); image.src=srcImage.getAttribute("src"); image.onload=testImage(image); } function testImage(image) { //The image object should return a width of 670 since the image has been loaded alert("Image " + image.src+" width:"+image.width); //It actually returns 0 } </script> </head> <body onload="test();"> </body> </html> The alert box returns width: 0. The alert box should have returned width: 670. If the image is loaded already such as: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"> <html xmlns="
http://www.w3.org/1999/xhtml
" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Image bug</title> <script type="text/javascript"> function test() { var srcImage = document.createElement("img"); srcImage.setAttribute("src","
http://images.apple.com/macosx/images/indextop20060109.jpg
"); //Source image is 670x275 var image = new Image(); image.src=srcImage.getAttribute("src"); image.onload=testImage(image); } function testImage(image) { //The image object should return a width of 670 since the image has been loaded alert("Image " + image.src+" width:"+image.width); //It actually returns 0 } </script> </head> <body onload="test();"> <img id="testSubject" src="
http://images.apple.com/macosx/images/indextop20060109.jpg
" alt="OS X" /> </body> </html> The alert box returns width: 670. Since the script is explicitedly displaying the alert only after the onload of the image, it should display properly.
Attachments
test 1
(1.03 KB, application/xhtml+xml)
2006-03-30 20:46 PST
,
Alexey Proskuryakov
no flags
Details
test 2
(1.12 KB, application/xhtml+xml)
2006-03-30 20:47 PST
,
Alexey Proskuryakov
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2006-03-30 20:46:52 PST
Created
attachment 7410
[details]
test 1
Alexey Proskuryakov
Comment 2
2006-03-30 20:47:10 PST
Created
attachment 7411
[details]
test 2
Alexey Proskuryakov
Comment 3
2006-03-30 20:53:41 PST
Reporter, do you know when the behavior has changed? I'm getting identical results from stock 10.4.5 and ToT. Actually, Firefox also reports zero width once after a relaunch.
Niels Meersschaert
Comment 4
2006-03-31 05:06:44 PST
I was using this code in a widget developed and released under 10.4.4. Thus, I believe the change occurred with 10.4.5 and it's update to the safari webkit.
Mark Rowe (bdash)
Comment 5
2006-07-02 07:24:20 PDT
My brief testing shows that Camino demonstrates identical behaviour to WebKit in always returning zero for the width, while Firefox returns zero when first run and then the correct value thereafter. I'm not sure if this should be considered a bug.
Mark Rowe (bdash)
Comment 6
2006-07-06 05:35:17 PDT
Joost has convinced me this is a bug.
Gavin Sherlock
Comment 7
2008-08-01 06:44:52 PDT
Both tests now report an image width of 670 with
r35417
, so this may be fixed.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug