Closed Bug 22820 Opened 25 years ago Closed 22 years ago

Broken IMG 'src' cannot be changed to valid 'src' dynamically

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.3alpha

People

(Reporter: cjacob, Assigned: bryner)

References

()

Details

(Keywords: css-moz, testcase, topembed+, Whiteboard: [Hixie-P2])

Attachments

(3 files, 5 obsolete files)

Platform: WinNT server 4.0 UK - SP6a --- Images that are not found usually get a broken image icon. But when the image source is changed by javascript code, and the image is not available, the broken image is replaced by the ALT text. --- Curiously, this text can't be change back to an image by the same javascript code.
Punting from "Architecture" product back to "Browser". Mozilla will be complying with HTML 4.0 for ALT text, see http://www.w3.org/TR/html4/struct/objects.html#adef-alt In particular that means that the ALT text will replace the image when it does not load and no "broken image" icons will appear -- see bug 1994. Ian, is there any limitation imposed by a CSS spec, that prevents, after an image is replaced by its ALT text when it fails to load, a reload of the image replacing the ALT text again, or is this a limitation of Mozilla's implementation or the site's code? Note that mapping the units of meaning made available at this site as words onto specific images is not even theoretically possible...
Component: GFX → Layout
Product: Architecture → Browser
QA Contact: nobody → py8ieh=bugzilla
Version: 5.0 → other
rickg, who would get this bug? enhancement?
Assignee: nobody → rickg
Component: Layout → HTML Element
Troy -- this is a feature request. Please disposition as you see fit.
Assignee: rickg → troy
I'm not sure I follow every step here, but it seems reasonable that if you use JS to change the SRC attribute of the image, then we should try and load that image. Even if we have replaced the image with its alternate content because it failed to render That said, we don't do that today, and this seems too low of priority to consider for version 1.0 What will probably happen is that CSS will introduce more flexibility in this area, so the content creator can specify what's displayed at each step of the way: - while the image is loading (today hardcoded by ua to be placeholder icon and ALT text) - once it's loaded (that's what the style rule controls today) - if the image fails to load (today per HTML4 spec) Ian suggested we introduce some Mozilla specific peseudo-element rules, but that was LATER'D for version 1.0 as well
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → LATER
Ok, verifying for LATER. Troy, just out of interest, why is it that we don't pick up changes in the 'src' attribute of broken IMG elements? Is it that the image frame is the one which deals with that and we remove the IMG frame when we put in the alt text's frame? If so, I would guess that we'll have to make the IMG frame and the alt text frame have a common ancestor which knows about the 'src' attribute, right? (I'm just guessing here, I have not even remotely looked at the source...) This is probably an HTML4 compliance issue (albeit a low priority one), so marking dependencies. Also marking css-moz, since Troy thinks CSS extensions may come in useful here. Lowering priority, updating summary, platform, os.
Blocks: html4.01
Status: RESOLVED → VERIFIED
Component: HTML Element → Layout
Keywords: css-moz
OS: Windows NT → All
Priority: P3 → P4
Hardware: PC → All
Summary: JS changed image SRC that are not available change in ALT tag → Broken IMG 'src' cannot be changed to valid 'src' dynamically
Yes, we throw away the IMG frame and replace it with either a block or inline frame. We could try and have a common parent frame for both, but we've been hesitant to do that in the past because things get thorny. The IMG can be either block-level or inline-level and that makes it complicated. We like frames to be one or the other I think what we'll probably do is make the frame construction code re-create an image frame and try and load the load. I don't think it's an HTML4 compliance issue, because HTML4 has no way to change the SRC attribute. It probably is a DOM compliance issue. If people feel it's something that needs to get fixed (I don't), then we'll have to disable displaying the alternate content (and not be HTML4 compliant) and instead display the broken icon like Nav and IE do
Reopening and moving to Future...
Status: VERIFIED → REOPENED
Resolution: LATER → ---
Target Milestone: --- → Future
Reassigning to buster, troy no longer with us.
Assignee: troy → buster
Status: REOPENED → NEW
Priority: P4 → P3
This bug (probably) blocks bug 42499, where an image is replaced by another in a mouseOver handler, but since the new image is not yet loaded we replace it with the alt text and then can never get an image back. If this is indeed the underlying cause of bug 42499, then this will happen a lot on the web.
Blocks: 42499
*** Bug 67954 has been marked as a duplicate of this bug. ***
Attached file testcase
See also: bug 70820 Broken image 'alt' can't be changed through dom. bug 77279 Replacing loading image's src breaks image.
Keywords: testcase
Blocks: 61480
Whiteboard: [Hixie-P2]
buster *so* isn't going to fix this.
Assignee: buster → pavlov
Target Milestone: Future → mozilla1.0
*** Bug 86257 has been marked as a duplicate of this bug. ***
*** Bug 93584 has been marked as a duplicate of this bug. ***
*** Bug 100493 has been marked as a duplicate of this bug. ***
*** Bug 106719 has been marked as a duplicate of this bug. ***
Status: NEW → ASSIGNED
Target Milestone: mozilla1.0 → mozilla0.9.9
*** Bug 119650 has been marked as a duplicate of this bug. ***
*** Bug 120587 has been marked as a duplicate of this bug. ***
this works with non-strict mode images. We need to add a NS_STYLE_HINT_FRAMECHANGE when 'src' is set for some element.. just not sure which one yet. Marc? any hints?
Target Milestone: mozilla0.9.9 → mozilla1.0
Moving Netscape owned 0.9.9 and 1.0 bugs that don't have an nsbeta1, nsbeta1+, topembed, topembed+, Mozilla0.9.9+ or Mozilla1.0+ keyword. Please send any questions or feedback about this to adt@netscape.com. You can search for "Moving bugs not scheduled for a project" to quickly delete this bugmail.
Target Milestone: mozilla1.0 → mozilla1.2
Target Milestone: mozilla1.2 → mozilla1.0
Keywords: nsbeta1
per adt, not critical for nsbeta1. hence minus.
It looks like Gagan didn't change the keyword, so adding nsbeta1- per ADT triage with Gagan.
Keywords: nsbeta1nsbeta1-
Target Milestone: mozilla1.0 → mozilla1.0.1
*** Bug 151245 has been marked as a duplicate of this bug. ***
carrying over topembed+ from bug 151245.
Keywords: topembed+
Slightly less hacky than my patch in bug 151245. Here I make GetMappedAttributeImpact return NS_STYLE_HINT_FRAMECHANGE if the 'src' attribute changes and we have no image frame. In order to make this possible from GetMappedAttributeImpact, which is declared |const|, I had to spread the const love elsewhere. Fortunately, it turns out that the whole operation really _is_ |const| as far as the content node goes.
Attached patch alternative patch (obsolete) — Splinter Review
This is a more contained fix; instead of propagating |const| I just cast it away.
Fixed a bug in the original patch that caused some weird rendering bugs due to nsTextNode not using the subclass version of IsContentOfType().
Attachment #103237 - Attachment is obsolete: true
taking
Assignee: pavlov → bryner
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Target Milestone: mozilla1.0.1 → mozilla1.3alpha
Comment on attachment 103267 [details] [diff] [review] alternative patch + else if (aAttribute == nsHTMLAtoms::src) { + // If 'src' changed and we don't have a real image frame, + // we need to cause a reframe. + nsIImageFrame* imageFrame; + // cast away |const| because the underlying interfaces don't use it. + nsHTMLImageElement* self = NS_CONST_CAST(nsHTMLImageElement*, this); + if (self->GetImageFrame(&imageFrame) == NS_ERROR_NO_INTERFACE || + !imageFrame) + aHint = NS_STYLE_HINT_FRAMECHANGE; GetImageFrame() will never return NS_ERROR_NO_INTERFACE so no need to check that, just call it and ignore the return value and check for a null imageFrame. If you want to, you could even make nsHTMLImageElement::GetImageFrame() be a void method since there's no useful information we'll ever want to return from it. Also, please add braces around the (one line) body of the if statement, all other one-line if's in that file uses braces. With that, sr=jst
Attachment #103267 - Flags: superreview+
Comment on attachment 103267 [details] [diff] [review] alternative patch r=dbaron given jst's comments are handled
Attachment #103267 - Flags: review+
Comment on attachment 103267 [details] [diff] [review] alternative patch a=roc+moz for trunk
Attachment #103267 - Flags: approval+
checked in.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago22 years ago
Resolution: --- → FIXED
Reopening. I backed this out due to a large pageload regression (6.6% on btek; 5.8% on luna). (It was initially a test-backout to see if it was the problem, but since it was I'm leaving it backed out.)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch patch that was checked in (obsolete) — Splinter Review
This is the patch that was checked in, since it's been backed out. For the record, I don't see any reason to null-check aImageFrame.
Attachment #103267 - Attachment is obsolete: true
Blocks: 176020
The patch checked in by bryner also caused this regression in Composer: bug 176020 It also caused a broken icon image to appear in the activation dialogs in Netscape builds (I don't know of a bug filed on that issue).
Well, we hit this during parsing, which I wasn't expecting, which is why it impacts pageload times. At that point, we have no image frame, and so it sets NS_STYLE_HINT_FRAMECHANGE. Still trying to figure out whether the slowdown is from setting the framechange hint or just from looking for the frame.
I measured a 7% slowdown on jrgm's pageload test on my machine with _only_ the image frame lookup when the 'src' attribute is set (without setting the framechange hint).
This is from an optimized build, so the line numbers might be a bit wacky, but the function names are correct.
So, we could key off of whether mParent is null in nsHTMLImageElement::GetMappedAttributeImpact to decide that a frame couldn't possibly exist yet. I think that would solve the performance regression with this patch. Another possibility would be to set a flag on the element when the image load fails, then return FRAMECHANGE from GMAI if the flag is set (and clear the flag), but that would create a somewhat fragile dependence on the behavior of the image frame, and increase the size of image elements. What might be more interesting is to avoid calling GetMappedAttributeImpact on every attribute of every node during parsing. It's a near-constant-time implementation on every element (except for image, with my patch), but it is a virtual function call that's happening hundreds of times for a typical page, for no reason. We do use the impact to decide whether the attribute is mapped to style, which determines where it's stored in the attributes collection. Since the vast majority of elements on a page are never changed, it may be possible to delay determining if the attribute has a style impact until the attribute is actually changed, _after_ the initial parse.
Attached patch quick fix for perf regression (obsolete) — Splinter Review
Check |mParent| before doing a frame lookup; assume no frame if there is no parent. I also removed the null check as dbaron pointed out I could do, and removed some unneeded null initialization of pointers passed to GetImageFrame (since it always initializes the return value).
Comment on attachment 103796 [details] [diff] [review] quick fix for perf regression r=dbaron
Attachment #103796 - Flags: review+
I filed bug 176139 on the general issue of calling GetMappedAttributeImpact during HTML parsing.
Comment on attachment 103796 [details] [diff] [review] quick fix for perf regression sr=jst
Attachment #103796 - Flags: superreview+
Comment on attachment 103796 [details] [diff] [review] quick fix for perf regression Actually, this patch still causes the composer "Insert image" regression on Mac. Investigating.
Attachment #103796 - Flags: needs-work+
The composer "insert image" problem happens on Linux as well.
Make sure to return NS_STYLE_HINT_CONTENT for 'src' attribute changes when there _is_ an image frame, like we did before the patch.
Attachment #103305 - Attachment is obsolete: true
Attachment #103715 - Attachment is obsolete: true
Attachment #103796 - Attachment is obsolete: true
Comment on attachment 103924 [details] [diff] [review] new patch to fix composer regression r=dbaron, although it might be consistent with other code in the tree (mostly scc's) to call the variable |mutable_this| instead of |self|.
Attachment #103924 - Flags: review+
Comment on attachment 103924 [details] [diff] [review] new patch to fix composer regression sr=jst
Attachment #103924 - Flags: superreview+
Comment on attachment 103924 [details] [diff] [review] new patch to fix composer regression a=dbaron for trunk checkin
Attachment #103924 - Flags: approval+
checked in.
Status: REOPENED → RESOLVED
Closed: 22 years ago22 years ago
Resolution: --- → FIXED
This caused bug 176926
Blocks: 176926
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: