| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 bool errorOccurred = image()->errorOccurred(); | 50 bool errorOccurred = image()->errorOccurred(); |
| 51 if (isHTMLObjectElement(*element()) && !errorOccurred) { | 51 if (isHTMLObjectElement(*element()) && !errorOccurred) { |
| 52 // An <object> considers a 404 to be an error and should fire onerror. | 52 // An <object> considers a 404 to be an error and should fire onerror. |
| 53 errorOccurred = (image()->response().httpStatusCode() >= 400); | 53 errorOccurred = (image()->response().httpStatusCode() >= 400); |
| 54 } | 54 } |
| 55 element()->dispatchEvent(Event::create(errorOccurred ? EventTypeNames::error | 55 element()->dispatchEvent(Event::create(errorOccurred ? EventTypeNames::error |
| 56 : EventTypeNames::load)); | 56 : EventTypeNames::load)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 static void loadFallbackContentForElement(Element* element) { | |
| 60 if (isHTMLImageElement(element)) | |
| 61 toHTMLImageElement(element)->ensureFallbackContent(); | |
| 62 else if (isHTMLInputElement(element)) | |
| 63 toHTMLInputElement(element)->ensureFallbackContent(); | |
| 64 } | |
| 65 | |
| 66 void HTMLImageLoader::noImageResourceToLoad() { | 59 void HTMLImageLoader::noImageResourceToLoad() { |
| 67 // FIXME: Use fallback content even when there is no alt-text. The only | 60 // FIXME: Use fallback content even when there is no alt-text. The only |
| 68 // blocker is the large amount of rebaselining it requires. | 61 // blocker is the large amount of rebaselining it requires. |
| 69 if (!toHTMLElement(element())->altText().isEmpty()) | 62 if (toHTMLElement(element())->altText().isEmpty()) |
| 70 loadFallbackContentForElement(element()); | 63 return; |
| 64 |
| 65 if (isHTMLImageElement(element())) |
| 66 toHTMLImageElement(element())->ensureCollapsedOrFallbackContent(); |
| 67 else if (isHTMLInputElement(element())) |
| 68 toHTMLInputElement(element())->ensureFallbackContent(); |
| 71 } | 69 } |
| 72 | 70 |
| 73 void HTMLImageLoader::imageNotifyFinished(ImageResource*) { | 71 void HTMLImageLoader::imageNotifyFinished(ImageResource*) { |
| 74 ImageResource* cachedImage = image(); | 72 ImageResource* cachedImage = image(); |
| 75 Element* element = this->element(); | 73 Element* element = this->element(); |
| 76 ImageLoader::imageNotifyFinished(cachedImage); | 74 ImageLoader::imageNotifyFinished(cachedImage); |
| 77 | 75 |
| 78 bool loadError = cachedImage->errorOccurred(); | 76 bool loadError = cachedImage->errorOccurred(); |
| 79 if (isHTMLImageElement(*element)) { | 77 if (isHTMLImageElement(*element)) { |
| 80 if (loadError) | 78 if (loadError) |
| 81 ensureFallbackContent(); | 79 toHTMLImageElement(element)->ensureCollapsedOrFallbackContent(); |
| 82 else | 80 else |
| 83 toHTMLImageElement(element)->ensurePrimaryContent(); | 81 toHTMLImageElement(element)->ensurePrimaryContent(); |
| 84 } | 82 } |
| 85 | 83 |
| 86 if (isHTMLInputElement(*element)) { | 84 if (isHTMLInputElement(*element)) { |
| 87 if (loadError) | 85 if (loadError) |
| 88 ensureFallbackContent(); | 86 toHTMLInputElement(element)->ensureFallbackContent(); |
| 89 else | 87 else |
| 90 toHTMLInputElement(element)->ensurePrimaryContent(); | 88 toHTMLInputElement(element)->ensurePrimaryContent(); |
| 91 } | 89 } |
| 92 | 90 |
| 93 if ((loadError || cachedImage->response().httpStatusCode() >= 400) && | 91 if ((loadError || cachedImage->response().httpStatusCode() >= 400) && |
| 94 isHTMLObjectElement(*element)) | 92 isHTMLObjectElement(*element)) |
| 95 toHTMLObjectElement(element)->renderFallbackContent(); | 93 toHTMLObjectElement(element)->renderFallbackContent(); |
| 96 } | 94 } |
| 97 | 95 |
| 98 void HTMLImageLoader::ensureFallbackContent() { | |
| 99 loadFallbackContentForElement(element()); | |
| 100 } | |
| 101 | |
| 102 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |