Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Unified Diff: Source/core/html/HTMLImageLoader.cpp

Issue 481753002: Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLImageLoader.cpp
diff --git a/Source/core/html/HTMLImageLoader.cpp b/Source/core/html/HTMLImageLoader.cpp
index 44fc879fe2f85abc3b3d5fe90ff5fef691766d39..baced28215a3bd5c6556caf011e80b1dcecef008 100644
--- a/Source/core/html/HTMLImageLoader.cpp
+++ b/Source/core/html/HTMLImageLoader.cpp
@@ -27,6 +27,7 @@
#include "core/events/Event.h"
#include "core/fetch/ImageResource.h"
#include "core/html/HTMLImageElement.h"
+#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLObjectElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "platform/Logging.h"
@@ -61,6 +62,16 @@ String HTMLImageLoader::sourceURI(const AtomicString& attr) const
return stripLeadingAndTrailingHTMLSpaces(attr);
}
+void HTMLImageLoader::noImageResourceToLoad()
+{
+ RefPtrWillBeRawPtr<Element> element = this->element();
+ // FIXME: Use fallback content even when there is no alt-text. The only blocker is the large amount of rebaselining it requires.
+ if (isHTMLImageElement(*element) && !toHTMLImageElement(element)->altText().isEmpty())
+ toHTMLImageElement(element)->ensureFallbackContent();
+ if (isHTMLInputElement(*element) && !toHTMLInputElement(element)->altText().isEmpty())
+ toHTMLInputElement(element)->ensureFallbackContent();
esprehn 2014/09/05 00:47:51 Lets just add a virtual method.
rhogan 2014/09/08 19:52:42 Done.
+}
+
void HTMLImageLoader::notifyFinished(Resource*)
{
ImageResource* cachedImage = image();
@@ -69,6 +80,19 @@ void HTMLImageLoader::notifyFinished(Resource*)
ImageLoader::notifyFinished(cachedImage);
bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400;
+ if (isHTMLImageElement(*element)) {
+ if (loadError)
+ toHTMLImageElement(element)->ensureFallbackContent();
+ else
+ toHTMLImageElement(element)->ensurePrimaryContent();
+ }
+
+ if (isHTMLInputElement(*element)) {
+ if (loadError)
+ toHTMLInputElement(element)->ensureFallbackContent();
esprehn 2014/09/05 00:47:51 virtual.
rhogan 2014/09/08 19:52:42 Done.
+ else
+ toHTMLInputElement(element)->ensurePrimaryContent();
+ }
if (loadError && isHTMLObjectElement(*element))
toHTMLObjectElement(element)->renderFallbackContent();

Powered by Google App Engine
This is Rietveld 408576698