This source file includes following definitions.
- dispatchLoadEvent
- sourceURI
- notifyFinished
#include "config.h"
#include "core/html/HTMLImageLoader.h"
#include "HTMLNames.h"
#include "core/dom/Element.h"
#include "core/events/Event.h"
#include "core/fetch/ImageResource.h"
#include "core/html/HTMLObjectElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
namespace WebCore {
HTMLImageLoader::HTMLImageLoader(Element* node)
: ImageLoader(node)
{
}
HTMLImageLoader::~HTMLImageLoader()
{
}
void HTMLImageLoader::dispatchLoadEvent()
{
if (isHTMLVideoElement(*element()))
return;
bool errorOccurred = image()->errorOccurred();
if (!errorOccurred && image()->response().httpStatusCode() >= 400)
errorOccurred = isHTMLObjectElement(*element());
element()->dispatchEvent(Event::create(errorOccurred ? EventTypeNames::error : EventTypeNames::load));
}
String HTMLImageLoader::sourceURI(const AtomicString& attr) const
{
return stripLeadingAndTrailingHTMLSpaces(attr);
}
void HTMLImageLoader::notifyFinished(Resource*)
{
ImageResource* cachedImage = image();
RefPtr<Element> element = this->element();
ImageLoader::notifyFinished(cachedImage);
bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400;
if (loadError && isHTMLObjectElement(*element))
toHTMLObjectElement(element)->renderFallbackContent();
}
}