summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLImageLoader.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLImageLoader.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/HTMLImageLoader.cpp')
-rw-r--r--Source/WebCore/html/HTMLImageLoader.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/Source/WebCore/html/HTMLImageLoader.cpp b/Source/WebCore/html/HTMLImageLoader.cpp
index 4743dcb22..7f908d22b 100644
--- a/Source/WebCore/html/HTMLImageLoader.cpp
+++ b/Source/WebCore/html/HTMLImageLoader.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2010, 2015 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,22 +23,25 @@
#include "HTMLImageLoader.h"
#include "CachedImage.h"
+#include "CommonVM.h"
+#include "DOMWindow.h"
#include "Element.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "HTMLParserIdioms.h"
+#include "HTMLVideoElement.h"
#include "Settings.h"
#include "JSDOMWindowBase.h"
+#include <runtime/JSCInlines.h>
#include <runtime/JSLock.h>
-#include <runtime/Operations.h>
namespace WebCore {
-HTMLImageLoader::HTMLImageLoader(Element* node)
- : ImageLoader(node)
+HTMLImageLoader::HTMLImageLoader(Element& element)
+ : ImageLoader(element)
{
}
@@ -48,45 +51,49 @@ HTMLImageLoader::~HTMLImageLoader()
void HTMLImageLoader::dispatchLoadEvent()
{
+#if ENABLE(VIDEO)
// HTMLVideoElement uses this class to load the poster image, but it should not fire events for loading or failure.
- if (isHTMLVideoElement(element()))
+ if (is<HTMLVideoElement>(element()))
return;
+#endif
bool errorOccurred = image()->errorOccurred();
if (!errorOccurred && image()->response().httpStatusCode() >= 400)
- errorOccurred = isHTMLObjectElement(element()); // An <object> considers a 404 to be an error and should fire onerror.
- element()->dispatchEvent(Event::create(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false));
+ errorOccurred = is<HTMLObjectElement>(element()); // An <object> considers a 404 to be an error and should fire onerror.
+ element().dispatchEvent(Event::create(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false));
}
String HTMLImageLoader::sourceURI(const AtomicString& attr) const
{
#if ENABLE(DASHBOARD_SUPPORT)
- Settings* settings = element()->document().settings();
- if (settings && settings->usesDashboardBackwardCompatibilityMode() && attr.length() > 7 && attr.startsWith("url(\"") && attr.endsWith("\")"))
+ if (element().document().settings().usesDashboardBackwardCompatibilityMode() && attr.length() > 7 && attr.startsWith("url(\"") && attr.endsWith("\")"))
return attr.string().substring(5, attr.length() - 7);
#endif
return stripLeadingAndTrailingHTMLSpaces(attr);
}
-void HTMLImageLoader::notifyFinished(CachedResource*)
+void HTMLImageLoader::notifyFinished(CachedResource&)
{
- CachedImage* cachedImage = image();
+ ASSERT(image());
+ CachedImage& cachedImage = *image();
- RefPtr<Element> element = this->element();
+ Ref<Element> protect(element());
ImageLoader::notifyFinished(cachedImage);
- bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400;
+ bool loadError = cachedImage.errorOccurred() || cachedImage.response().httpStatusCode() >= 400;
if (!loadError) {
- if (!element->inDocument()) {
- JSC::VM* vm = JSDOMWindowBase::commonVM();
+ if (!element().isConnected()) {
+ JSC::VM& vm = commonVM();
JSC::JSLockHolder lock(vm);
- vm->heap.reportExtraMemoryCost(cachedImage->encodedSize());
+ // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
+ // https://bugs.webkit.org/show_bug.cgi?id=142595
+ vm.heap.deprecatedReportExtraMemory(cachedImage.encodedSize());
}
}
- if (loadError && isHTMLObjectElement(element.get()))
- toHTMLObjectElement(element.get())->renderFallbackContent();
+ if (loadError && is<HTMLObjectElement>(element()))
+ downcast<HTMLObjectElement>(element()).renderFallbackContent();
}
}