void ImageLoader::notifyFinished(Resource* resource) { ASSERT(m_failedLoadURL.isEmpty()); ASSERT(resource == m_image.get()); m_imageComplete = true; if (!hasPendingBeforeLoadEvent()) updateRenderer(); if (!m_hasPendingLoadEvent) return; if (resource->errorOccurred()) { loadEventSender().cancelEvent(this); m_hasPendingLoadEvent = false; m_hasPendingErrorEvent = true; errorEventSender().dispatchEventSoon(this); // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } if (resource->wasCanceled()) { m_hasPendingLoadEvent = false; // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } loadEventSender().dispatchEventSoon(this); }
void ImageLoader::notifyFinished(CachedResource* resource) { ASSERT(m_failedLoadURL.isEmpty()); ASSERT(resource == m_image.get()); m_imageComplete = true; if (!hasPendingBeforeLoadEvent()) updateRenderer(); if (!m_hasPendingLoadEvent) return; if (m_element->fastHasAttribute(HTMLNames::crossoriginAttr) && !m_element->document()->securityOrigin()->canRequest(image()->response().url()) && !resource->passesAccessControlCheck(m_element->document()->securityOrigin())) { setImageWithoutConsideringPendingLoadEvent(0); m_hasPendingErrorEvent = true; errorEventSender().dispatchEventSoon(this); DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Cross-origin image load denied by Cross-Origin Resource Sharing policy."))); m_element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, consoleMessage); ASSERT(!m_hasPendingLoadEvent); // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } if (resource->wasCanceled()) { m_hasPendingLoadEvent = false; // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } loadEventSender().dispatchEventSoon(this); }
void ImageLoader::notifyFinished(CachedResource* resource) { ASSERT(m_failedLoadURL.isEmpty()); ASSERT(resource == m_image.get()); m_imageComplete = true; if (!hasPendingBeforeLoadEvent()) updateRenderer(); if (!m_hasPendingLoadEvent) return; if (element().fastHasAttribute(HTMLNames::crossoriginAttr) && !resource->passesSameOriginPolicyCheck(*element().document().securityOrigin())) { clearImageWithoutConsideringPendingLoadEvent(); m_hasPendingErrorEvent = true; errorEventSender().dispatchEventSoon(*this); static NeverDestroyed<String> consoleMessage(ASCIILiteral("Cross-origin image load denied by Cross-Origin Resource Sharing policy.")); element().document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage); ASSERT(!m_hasPendingLoadEvent); // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } if (resource->wasCanceled()) { m_hasPendingLoadEvent = false; // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); return; } loadEventSender().dispatchEventSoon(*this); }