Closed
Bug 78351
Opened 24 years ago
Closed 24 years ago
Image Properties dialog should show a preview image and get the natural width and height of images
Categories
(Core :: DOM: Editor, defect, P3)
Core
DOM: Editor
Tracking
()
VERIFIED
FIXED
mozilla0.9.3
People
(Reporter: cmanske, Assigned: cmanske)
References
Details
(Whiteboard: [dialog]DEPENDS FIX IN HAND, checked in, waiting for dependent fix to clear)
Attachments
(6 files)
4.70 KB,
patch
|
Details | Diff | Splinter Review | |
2.48 KB,
patch
|
Details | Diff | Splinter Review | |
3.74 KB,
patch
|
Details | Diff | Splinter Review | |
4.73 KB,
patch
|
Details | Diff | Splinter Review | |
2.68 KB,
patch
|
Details | Diff | Splinter Review | |
6.19 KB,
patch
|
Details | Diff | Splinter Review |
Currently, the small preview image in the Image dialog uses JS timers and tests
for "img.complete" to detect when image is loaded. We can then get the "natural"
width and height of the image.
This depends on being able to set the "src" attribute on a single img element
more than once, causing it to trigger an image load (bug 76177).
Assignee | ||
Comment 1•24 years ago
|
||
Didn't quite complete the description: The work to do is replace the current
timer code with an "onload" handler instead.
Severity: normal → major
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.1
Assignee | ||
Comment 2•24 years ago
|
||
The editor works is done, but won't work until bug 76177 is fixed.
Whiteboard: DEPENDS
Comment 3•24 years ago
|
||
moving to the same milestone as the depends bug
Target Milestone: mozilla0.9.1 → mozilla0.9.2
Assignee | ||
Comment 4•24 years ago
|
||
Changing to using an "onload" handler is done and checked in. In today's build,
setting the image does show up in the preview window.
But that handler isn't getting called at all, so we still aren't getting the
natural width and height correctly.
I tried using XUL like this:
<html id="preview-image-holder">
<html:img id="preview-image" onload="PreviewImageLoaded();"/>
</html>
for the HTML preview img
I also triedcreating a new <img> element, setting the "onload" like this:
image.onload = "PreviewImageLoaded();";
then deleting existing img, and appending the new one at runtime.
But that didn't help at all in triggering the onload firing.
Assignee | ||
Comment 5•24 years ago
|
||
Assignee | ||
Comment 6•24 years ago
|
||
Patch cleans up old "timer" strategy for preview image and uses "onload"
handler. These changes are needed, but complete fix still depends on fixing
bug 76177. On 5/14, the preview image loaded correctly and the natural width
and height were correct after selecting an image for the first time.
If you then select another image, the preview image changes, but the onload
handler is not fired again, thus the natural width and height is not updated for
the new image selected.
Comment 7•24 years ago
|
||
-var gPreviewImage;
+//var gPreviewImage;
Just delete it. Same here:
+dialog.ChooseFile = document.getElementById( "ChooseFile" );
+dump(" ***** ChooseFile button: "+dialog.ChooseFile+"\n");
+
sr=sfraser on the rest.
The other debug dump() calls in the patch should also be removed before checkin.
r=kin@netscape.com
Assignee | ||
Comment 9•24 years ago
|
||
Ooops! All extra junk deleted. Was trying to debug the "missing Choose button"
problem.
Whiteboard: DEPENDS FIX IN HAND need r= sr= → DEPENDS FIX IN HAND
Assignee | ||
Comment 10•24 years ago
|
||
Editor work checked in. Still blocked by dependent bugs.
Updated•24 years ago
|
Assignee | ||
Comment 11•24 years ago
|
||
Patch on 76177 fixes that problem, but there's still a problem getting
naturalWidth and naturalHeight for images already loaded (new bug 82435).
Whiteboard: [dialog]DEPENDS FIX IN HAND → [dialog]DEPENDS
Assignee | ||
Comment 12•24 years ago
|
||
Changing summary to turn this bug into a tracking bug for preview image and
getting natural width and height issues.
Summary: Use "onload" handler to get preview image in Image Properties dialog → Image Properties dialog should show a preview image and get the natural width and height of images
Assignee | ||
Comment 13•24 years ago
|
||
Assignee | ||
Comment 14•24 years ago
|
||
Patch from 5/26/01 adds "_moz-bypass-cache" attribute to EdImageProps.xul, part
of fix to dependent bug 82435. Additional changes in EdImageProps.js protects
existing "width" and "height" attributes on <img> tag when preview image fails to
load (e.g., when SRC is a remote URL and user is offline.)
Whiteboard: [dialog]DEPENDS → [dialog]DEPENDS FIX IN HAND, need r=, sr=
Assignee | ||
Comment 15•24 years ago
|
||
If the ImgLib work required as suggested by JST in bug 82435 isn't done,
then I suggest we use the "_moz-bypass-cache" strategy at least for
an interim fix.
Assignee | ||
Comment 16•24 years ago
|
||
Assignee | ||
Comment 17•24 years ago
|
||
Changes in th 6/13/01 patch do the following:
1. Saves the existing image src URL, so if we can't load the image and thus don't
get the natural width and height, we don't remove the existing HTML "width" and
"height" attributes.
2. Adds the "_moz-bypass-cache" attribute to the <img> tag in the dialog, so
if we do decide to use my suggested fix to bug 82435, this attribute is all
ready. If we don't do that fix, having an attribute that is ignore won't affect
anything.
I won't be around from 6/15 through 7/2 to follow up on the dependent bug
issues, which is why I'd like to do these editor changes now.
Comment 18•24 years ago
|
||
Assignee | ||
Comment 19•24 years ago
|
||
Assignee | ||
Comment 20•24 years ago
|
||
We're making progress! nsIImageCache now has a new method to remove a URL
from the image cache, fixing bug 82435. So the patch on 6/13/01 19:36 now
uses that as well as doing the "save original url and don't trash width and
height when image doesn't load" fix described in last comment.
Unfortunately, there's a new problem we discovered:
After designating the Image SRC once (either typing a URL or selecting an image
with the "Choose File" button), the size from that first image "sticks" for
the preview image. I.e., any image you type or select after that will display
in the preview window with the first image's size. Note that the actual
(natural) width and height are reported correctly, but the nsImageFrame code
doesn't redraw the image correctly in the dialog. A new bug will be filed on
that issue. So this should wrap up the editor changes need for this dialog.
Assignee | ||
Comment 21•24 years ago
|
||
Filed new bug 85911 for the image size problem described above.
Depends on: 85911
Whiteboard: [dialog]DEPENDS FIX IN HAND, need r=, sr= → [dialog]DEPENDS FIX IN HAND, need r=, sr=, a=
Comment 22•24 years ago
|
||
sr=kin@netscape.com with the changes we discussed over aim:
1. Move all the cache uri setup code into the try/catch block.
2. Add a comment bracketing this cache code describing why
it's neccessary.
Assignee | ||
Comment 23•24 years ago
|
||
Assignee | ||
Updated•24 years ago
|
Whiteboard: [dialog]DEPENDS FIX IN HAND, need r=, sr=, a= → [dialog]DEPENDS FIX IN HAND, need r=, a=
Comment 24•24 years ago
|
||
r=brade
Whiteboard: [dialog]DEPENDS FIX IN HAND, need r=, a= → [dialog]DEPENDS FIX IN HAND, need a=
Comment 25•24 years ago
|
||
a= asa@mozilla.org for checkin to the trunk.
(on behalf of drivers)
Blocks: 83989
Assignee | ||
Comment 26•24 years ago
|
||
Assignee | ||
Comment 27•24 years ago
|
||
After thorough testing, I'm adding some changes to the patch to fix lots of
problems. This actually goes back to a strategy we used before: delete the
existing preview image element and create a new one. This removes the dependency
on bug 76177 and bug 85911. Mostly, it also solves a bad problem: as soon
as user entered a URL that didn't exist, it killed the preview image. I.e.,
any further attempt to set the SRC to a valid URL failed.
This is what is new in the 06/14/01 16:24 patch relative to the previous one
that was already reviewed and approved:
+ if(dialog.PreviewImage)
+ removeEventListener("load", PreviewImageLoaded, true);
+
+ if (dialog.ImageHolder.firstChild)
+ dialog.ImageHolder.removeChild(dialog.ImageHolder.firstChild);
+
+ dialog.PreviewImage =
document.createElementNS("http://www.w3.org/1999/xhtml", "html:img");
+ if(dialog.PreviewImage)
+ {
+ dialog.ImageHolder.appendChild(dialog.PreviewImage);
+ dialog.PreviewImage.addEventListener("load",PreviewImageLoaded,true);
+ dialog.PreviewImage.src = imageSrc;
Comment 28•24 years ago
|
||
Looks good. sr=sfraser
Comment 29•24 years ago
|
||
r=blake
Comment 30•24 years ago
|
||
a= asa@mozilla.org for checkin to the trunk.
(on behalf of drivers)
Assignee | ||
Comment 31•24 years ago
|
||
Ok, last patch checked in.
Just waiting for fix to bug 82435 to mark this fixed.
Comment 32•24 years ago
|
||
move to 0.9.3 since the fix is checked in
Comment 33•24 years ago
|
||
because this fix is checked in and we're just waiting for a dependent bug to be
fixed, moving to 0.9.3 milestone
OS: Windows NT → All
Hardware: PC → All
Target Milestone: mozilla0.9.2 → mozilla0.9.3
Comment 34•24 years ago
|
||
wow -- this works great, marking fixed
tested using the build from June 26, 2001 trunk build on win98
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•