summaryrefslogtreecommitdiffstats
path: root/WebCore/loader
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/loader')
-rw-r--r--WebCore/loader/Cache.cpp28
-rw-r--r--WebCore/loader/Cache.h14
-rw-r--r--WebCore/loader/CachedCSSStyleSheet.h2
-rw-r--r--WebCore/loader/CachedFont.cpp4
-rw-r--r--WebCore/loader/CachedFont.h6
-rw-r--r--WebCore/loader/CachedImage.cpp11
-rw-r--r--WebCore/loader/CachedImage.h4
-rw-r--r--WebCore/loader/CachedResource.cpp12
-rw-r--r--WebCore/loader/CachedResource.h10
-rw-r--r--WebCore/loader/CachedResourceLoader.cpp (renamed from WebCore/loader/DocLoader.cpp)70
-rw-r--r--WebCore/loader/CachedResourceLoader.h (renamed from WebCore/loader/DocLoader.h)12
-rw-r--r--WebCore/loader/CachedScript.h2
-rw-r--r--WebCore/loader/CachedXSLStyleSheet.h2
-rw-r--r--WebCore/loader/DocumentLoader.cpp12
-rw-r--r--WebCore/loader/EmptyClients.h10
-rw-r--r--WebCore/loader/FTPDirectoryDocument.cpp451
-rw-r--r--WebCore/loader/FTPDirectoryDocument.h48
-rw-r--r--WebCore/loader/FrameLoader.cpp31
-rw-r--r--WebCore/loader/FrameLoader.h6
-rw-r--r--WebCore/loader/FrameLoaderClient.h3
-rw-r--r--WebCore/loader/HistoryController.cpp20
-rw-r--r--WebCore/loader/ImageDocument.cpp412
-rw-r--r--WebCore/loader/ImageDocument.h76
-rw-r--r--WebCore/loader/ImageLoader.cpp14
-rw-r--r--WebCore/loader/MediaDocument.cpp215
-rw-r--r--WebCore/loader/MediaDocument.h61
-rw-r--r--WebCore/loader/PingLoader.cpp2
-rw-r--r--WebCore/loader/PluginDocument.cpp161
-rw-r--r--WebCore/loader/PluginDocument.h54
-rw-r--r--WebCore/loader/RedirectScheduler.cpp12
-rw-r--r--WebCore/loader/Request.cpp4
-rw-r--r--WebCore/loader/Request.h8
-rw-r--r--WebCore/loader/ResourceLoader.cpp8
-rw-r--r--WebCore/loader/SubframeLoader.cpp8
-rw-r--r--WebCore/loader/SubresourceLoader.cpp2
-rw-r--r--WebCore/loader/TextDocument.cpp219
-rw-r--r--WebCore/loader/TextDocument.h51
-rw-r--r--WebCore/loader/loader.cpp92
-rw-r--r--WebCore/loader/loader.h10
39 files changed, 233 insertions, 1934 deletions
diff --git a/WebCore/loader/Cache.cpp b/WebCore/loader/Cache.cpp
index cb536e2..7acbd56 100644
--- a/WebCore/loader/Cache.cpp
+++ b/WebCore/loader/Cache.cpp
@@ -28,7 +28,7 @@
#include "CachedImage.h"
#include "CachedScript.h"
#include "CachedXSLStyleSheet.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
#include "FrameLoader.h"
#include "FrameLoaderTypes.h"
@@ -93,7 +93,7 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
return 0;
}
-CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
+CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
{
// FIXME: Do we really need to special-case an empty URL?
// Would it be better to just go on with the cache code and let it fail later?
@@ -106,8 +106,8 @@ CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Typ
if (resource && requestIsPreload && !resource->isPreloaded())
return 0;
- if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canLoad(url, String(), docLoader->doc())) {
- Document* doc = docLoader->doc();
+ if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canDisplay(url, String(), cachedResourceLoader->doc())) {
+ Document* doc = cachedResourceLoader->doc();
if (doc && !requestIsPreload)
FrameLoader::reportLocalLoadFailed(doc->frame(), url.string());
return 0;
@@ -122,7 +122,7 @@ CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Typ
// FIXME: CachedResource should just use normal refcounting instead.
resource->setInCache(true);
- resource->load(docLoader);
+ resource->load(cachedResourceLoader);
if (resource->errorOccurred()) {
// We don't support immediate loads, but we do support immediate failure.
@@ -138,7 +138,7 @@ CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Typ
else {
// Kick the resource out of the cache, because the cache is disabled.
resource->setInCache(false);
- resource->setDocLoader(docLoader);
+ resource->setCachedResourceLoader(cachedResourceLoader);
}
}
@@ -153,7 +153,7 @@ CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Typ
return resource;
}
-CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(DocLoader* docLoader, const String& url, const String& charset)
+CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(CachedResourceLoader* cachedResourceLoader, const String& url, const String& charset)
{
CachedCSSStyleSheet* userSheet;
if (CachedResource* existing = resourceForURL(url)) {
@@ -167,7 +167,7 @@ CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(DocLoader* docLoader, const
// FIXME: CachedResource should just use normal refcounting instead.
userSheet->setInCache(true);
// Don't load incrementally, skip load checks, don't send resource load callbacks.
- userSheet->load(docLoader, false, SkipSecurityCheck, false);
+ userSheet->load(cachedResourceLoader, false, SkipSecurityCheck, false);
if (!disabled())
m_resources.set(url, userSheet);
else
@@ -182,7 +182,7 @@ CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(DocLoader* docLoader, const
return userSheet;
}
-void Cache::revalidateResource(CachedResource* resource, DocLoader* docLoader)
+void Cache::revalidateResource(CachedResource* resource, CachedResourceLoader* cachedResourceLoader)
{
ASSERT(resource);
ASSERT(resource->inCache());
@@ -201,7 +201,7 @@ void Cache::revalidateResource(CachedResource* resource, DocLoader* docLoader)
m_resources.set(url, newResource);
newResource->setInCache(true);
resourceAccessed(newResource);
- newResource->load(docLoader);
+ newResource->load(cachedResourceLoader);
}
void Cache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response)
@@ -422,14 +422,14 @@ void Cache::evict(CachedResource* resource)
delete resource;
}
-void Cache::addDocLoader(DocLoader* docLoader)
+void Cache::addCachedResourceLoader(CachedResourceLoader* cachedResourceLoader)
{
- m_docLoaders.add(docLoader);
+ m_cachedResourceLoaders.add(cachedResourceLoader);
}
-void Cache::removeDocLoader(DocLoader* docLoader)
+void Cache::removeCachedResourceLoader(CachedResourceLoader* cachedResourceLoader)
{
- m_docLoaders.remove(docLoader);
+ m_cachedResourceLoaders.remove(cachedResourceLoader);
}
static inline unsigned fastLog2(unsigned i)
diff --git a/WebCore/loader/Cache.h b/WebCore/loader/Cache.h
index ce8cde4..9d7e8be 100644
--- a/WebCore/loader/Cache.h
+++ b/WebCore/loader/Cache.h
@@ -39,7 +39,7 @@ namespace WebCore {
class CachedCSSStyleSheet;
class CachedResource;
-class DocLoader;
+class CachedResourceLoader;
class KURL;
// This cache holds subresources used by Web pages: images, scripts, stylesheets, etc.
@@ -93,11 +93,11 @@ public:
// Request resources from the cache. A load will be initiated and a cache object created if the object is not
// found in the cache.
- CachedResource* requestResource(DocLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
+ CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
- CachedCSSStyleSheet* requestUserCSSStyleSheet(DocLoader*, const String& url, const String& charset);
+ CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);
- void revalidateResource(CachedResource*, DocLoader*);
+ void revalidateResource(CachedResource*, CachedResourceLoader*);
void revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse&);
void revalidationFailed(CachedResource* revalidatingResource);
@@ -129,8 +129,8 @@ public:
// Remove an existing cache entry from both the resource map and from the LRU list.
void remove(CachedResource* resource) { evict(resource); }
- void addDocLoader(DocLoader*);
- void removeDocLoader(DocLoader*);
+ void addCachedResourceLoader(CachedResourceLoader*);
+ void removeCachedResourceLoader(CachedResourceLoader*);
CachedResource* resourceForURL(const String&);
@@ -176,7 +176,7 @@ private:
void evict(CachedResource*);
// Member variables.
- HashSet<DocLoader*> m_docLoaders;
+ HashSet<CachedResourceLoader*> m_cachedResourceLoaders;
Loader m_loader;
bool m_disabled; // Whether or not the cache is enabled.
diff --git a/WebCore/loader/CachedCSSStyleSheet.h b/WebCore/loader/CachedCSSStyleSheet.h
index f5bf042..03bde69 100644
--- a/WebCore/loader/CachedCSSStyleSheet.h
+++ b/WebCore/loader/CachedCSSStyleSheet.h
@@ -32,7 +32,7 @@
namespace WebCore {
- class DocLoader;
+ class CachedResourceLoader;
class TextResourceDecoder;
class CachedCSSStyleSheet : public CachedResource {
diff --git a/WebCore/loader/CachedFont.cpp b/WebCore/loader/CachedFont.cpp
index 272166e..166fa85 100644
--- a/WebCore/loader/CachedFont.cpp
+++ b/WebCore/loader/CachedFont.cpp
@@ -71,7 +71,7 @@ CachedFont::~CachedFont()
#endif
}
-void CachedFont::load(DocLoader*)
+void CachedFont::load(CachedResourceLoader*)
{
// Don't load the file yet. Wait for an access before triggering the load.
setLoading(true);
@@ -94,7 +94,7 @@ void CachedFont::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
checkNotify();
}
-void CachedFont::beginLoadIfNeeded(DocLoader* dl)
+void CachedFont::beginLoadIfNeeded(CachedResourceLoader* dl)
{
if (!m_loadInitiated) {
m_loadInitiated = true;
diff --git a/WebCore/loader/CachedFont.h b/WebCore/loader/CachedFont.h
index 01c8c9c..95c2423 100644
--- a/WebCore/loader/CachedFont.h
+++ b/WebCore/loader/CachedFont.h
@@ -37,7 +37,7 @@
namespace WebCore {
-class DocLoader;
+class CachedResourceLoader;
class Cache;
class FontPlatformData;
class SVGFontElement;
@@ -49,7 +49,7 @@ public:
CachedFont(const String& url);
virtual ~CachedFont();
- virtual void load(DocLoader* docLoader);
+ virtual void load(CachedResourceLoader* cachedResourceLoader);
virtual void didAddClient(CachedResourceClient*);
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
@@ -59,7 +59,7 @@ public:
void checkNotify();
- void beginLoadIfNeeded(DocLoader* dl);
+ void beginLoadIfNeeded(CachedResourceLoader* dl);
bool ensureCustomFontData();
FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
diff --git a/WebCore/loader/CachedImage.cpp b/WebCore/loader/CachedImage.cpp
index 97b80f2..4dd8ea3 100644
--- a/WebCore/loader/CachedImage.cpp
+++ b/WebCore/loader/CachedImage.cpp
@@ -28,7 +28,7 @@
#include "Cache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Frame.h"
#include "FrameLoaderTypes.h"
#include "FrameView.h"
@@ -80,14 +80,19 @@ void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*)
destroyDecodedData();
}
-void CachedImage::load(DocLoader* docLoader)
+void CachedImage::load(CachedResourceLoader* cachedResourceLoader)
{
+<<<<<<< HEAD
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
if (!docLoader || (docLoader->autoLoadImages() && !docLoader->shouldBlockNetworkImage(m_url)))
#else
if (!docLoader || docLoader->autoLoadImages())
#endif
CachedResource::load(docLoader, true, DoSecurityCheck, true);
+=======
+ if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages())
+ CachedResource::load(cachedResourceLoader, true, DoSecurityCheck, true);
+>>>>>>> webkit.org at r67178
else
setLoading(false);
}
@@ -261,7 +266,7 @@ inline void CachedImage::createImage()
size_t CachedImage::maximumDecodedImageSize()
{
- Frame* frame = m_request ? m_request->docLoader()->frame() : 0;
+ Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
if (!frame)
return 0;
Settings* settings = frame->settings();
diff --git a/WebCore/loader/CachedImage.h b/WebCore/loader/CachedImage.h
index eb55955..15f4238 100644
--- a/WebCore/loader/CachedImage.h
+++ b/WebCore/loader/CachedImage.h
@@ -31,7 +31,7 @@
namespace WebCore {
-class DocLoader;
+class CachedResourceLoader;
class Cache;
class CachedImage : public CachedResource, public ImageObserver {
@@ -42,7 +42,7 @@ public:
CachedImage(Image*);
virtual ~CachedImage();
- virtual void load(DocLoader* docLoader);
+ virtual void load(CachedResourceLoader* cachedResourceLoader);
Image* image() const;
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp
index 887b0b5..a6ff0ff 100644
--- a/WebCore/loader/CachedResource.cpp
+++ b/WebCore/loader/CachedResource.cpp
@@ -29,7 +29,7 @@
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceHandle.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "KURL.h"
@@ -78,7 +78,7 @@ CachedResource::CachedResource(const String& url, Type type)
, m_prevInAllResourcesList(0)
, m_nextInLiveResourcesList(0)
, m_prevInLiveResourcesList(0)
- , m_docLoader(0)
+ , m_cachedResourceLoader(0)
, m_resourceToRevalidate(0)
, m_proxyResource(0)
{
@@ -99,14 +99,14 @@ CachedResource::~CachedResource()
cachedResourceLeakCounter.decrement();
#endif
- if (m_docLoader)
- m_docLoader->removeCachedResource(this);
+ if (m_cachedResourceLoader)
+ m_cachedResourceLoader->removeCachedResource(this);
}
-void CachedResource::load(DocLoader* docLoader, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
+void CachedResource::load(CachedResourceLoader* cachedResourceLoader, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
{
m_sendResourceLoadCallbacks = sendResourceLoadCallbacks;
- cache()->loader()->load(docLoader, this, incremental, securityCheck, sendResourceLoadCallbacks);
+ cache()->loader()->load(cachedResourceLoader, this, incremental, securityCheck, sendResourceLoadCallbacks);
m_loading = true;
}
diff --git a/WebCore/loader/CachedResource.h b/WebCore/loader/CachedResource.h
index f6eb730..958c8fd 100644
--- a/WebCore/loader/CachedResource.h
+++ b/WebCore/loader/CachedResource.h
@@ -39,7 +39,7 @@ class Cache;
class CachedMetadata;
class CachedResourceClient;
class CachedResourceHandleBase;
-class DocLoader;
+class CachedResourceLoader;
class Frame;
class InspectorResource;
class Request;
@@ -77,8 +77,8 @@ public:
CachedResource(const String& url, Type);
virtual ~CachedResource();
- virtual void load(DocLoader* docLoader) { load(docLoader, false, DoSecurityCheck, true); }
- void load(DocLoader*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
+ virtual void load(CachedResourceLoader* cachedResourceLoader) { load(cachedResourceLoader, false, DoSecurityCheck, true); }
+ void load(CachedResourceLoader*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
virtual void setEncoding(const String&) { }
virtual String encoding() const { return String(); }
@@ -182,7 +182,7 @@ public:
virtual void destroyDecodedData() { }
- void setDocLoader(DocLoader* docLoader) { m_docLoader = docLoader; }
+ void setCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_cachedResourceLoader = cachedResourceLoader; }
bool isPreloaded() const { return m_preloadCount; }
void increasePreloadCount() { ++m_preloadCount; }
@@ -269,7 +269,7 @@ private:
CachedResource* m_nextInLiveResourcesList;
CachedResource* m_prevInLiveResourcesList;
- DocLoader* m_docLoader; // only non-0 for resources that are not in the cache
+ CachedResourceLoader* m_cachedResourceLoader; // only non-0 for resources that are not in the cache
// If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
// using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
diff --git a/WebCore/loader/DocLoader.cpp b/WebCore/loader/CachedResourceLoader.cpp
index d04e148..68cd7ec 100644
--- a/WebCore/loader/DocLoader.cpp
+++ b/WebCore/loader/CachedResourceLoader.cpp
@@ -25,7 +25,7 @@
*/
#include "config.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "loader.h"
#include "Cache.h"
@@ -50,7 +50,7 @@
namespace WebCore {
-DocLoader::DocLoader(Document* doc)
+CachedResourceLoader::CachedResourceLoader(Document* doc)
: m_cache(cache())
, m_doc(doc)
, m_requestCount(0)
@@ -61,10 +61,10 @@ DocLoader::DocLoader(Document* doc)
, m_loadInProgress(false)
, m_allowStaleResources(false)
{
- m_cache->addDocLoader(this);
+ m_cache->addCachedResourceLoader(this);
}
-DocLoader::~DocLoader()
+CachedResourceLoader::~CachedResourceLoader()
{
if (m_requestCount)
m_cache->loader()->cancelRequests(this);
@@ -72,19 +72,19 @@ DocLoader::~DocLoader()
clearPreloads();
DocumentResourceMap::iterator end = m_documentResources.end();
for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it)
- it->second->setDocLoader(0);
- m_cache->removeDocLoader(this);
+ it->second->setCachedResourceLoader(0);
+ m_cache->removeCachedResourceLoader(this);
- // Make sure no requests still point to this DocLoader
+ // Make sure no requests still point to this CachedResourceLoader
ASSERT(m_requestCount == 0);
}
-Frame* DocLoader::frame() const
+Frame* CachedResourceLoader::frame() const
{
return m_doc->frame();
}
-void DocLoader::checkForReload(const KURL& fullURL)
+void CachedResourceLoader::checkForReload(const KURL& fullURL)
{
if (m_allowStaleResources)
return; // Don't reload resources while pasting
@@ -123,7 +123,7 @@ void DocLoader::checkForReload(const KURL& fullURL)
m_reloadedURLs.add(fullURL.string());
}
-CachedImage* DocLoader::requestImage(const String& url)
+CachedImage* CachedResourceLoader::requestImage(const String& url)
{
if (Frame* f = frame()) {
Settings* settings = f->settings();
@@ -150,42 +150,42 @@ CachedImage* DocLoader::requestImage(const String& url)
return resource;
}
-CachedFont* DocLoader::requestFont(const String& url)
+CachedFont* CachedResourceLoader::requestFont(const String& url)
{
return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, url, String()));
}
-CachedCSSStyleSheet* DocLoader::requestCSSStyleSheet(const String& url, const String& charset)
+CachedCSSStyleSheet* CachedResourceLoader::requestCSSStyleSheet(const String& url, const String& charset)
{
return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, url, charset));
}
-CachedCSSStyleSheet* DocLoader::requestUserCSSStyleSheet(const String& url, const String& charset)
+CachedCSSStyleSheet* CachedResourceLoader::requestUserCSSStyleSheet(const String& url, const String& charset)
{
return cache()->requestUserCSSStyleSheet(this, url, charset);
}
-CachedScript* DocLoader::requestScript(const String& url, const String& charset)
+CachedScript* CachedResourceLoader::requestScript(const String& url, const String& charset)
{
return static_cast<CachedScript*>(requestResource(CachedResource::Script, url, charset));
}
#if ENABLE(XSLT)
-CachedXSLStyleSheet* DocLoader::requestXSLStyleSheet(const String& url)
+CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(const String& url)
{
return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, url, String()));
}
#endif
#if ENABLE(LINK_PREFETCH)
-CachedResource* DocLoader::requestLinkPrefetch(const String& url)
+CachedResource* CachedResourceLoader::requestLinkPrefetch(const String& url)
{
ASSERT(frame());
return requestResource(CachedResource::LinkPrefetch, url, String());
}
#endif
-bool DocLoader::canRequest(CachedResource::Type type, const KURL& url)
+bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url)
{
// Some types of resources can be loaded only from the same origin. Other
// types of resources, like Images, Scripts, and CSS, can be loaded from
@@ -253,7 +253,7 @@ bool DocLoader::canRequest(CachedResource::Type type, const KURL& url)
return true;
}
-CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String& charset, bool isPreload)
+CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, const String& url, const String& charset, bool isPreload)
{
KURL fullURL = m_doc->completeURL(url);
@@ -264,7 +264,7 @@ CachedResource* DocLoader::requestResource(CachedResource::Type type, const Stri
DocumentResourceMap::iterator it = m_documentResources.find(fullURL.string());
if (it != m_documentResources.end()) {
- it->second->setDocLoader(0);
+ it->second->setCachedResourceLoader(0);
m_documentResources.remove(it);
}
}
@@ -284,7 +284,7 @@ CachedResource* DocLoader::requestResource(CachedResource::Type type, const Stri
return resource;
}
-void DocLoader::printAccessDeniedMessage(const KURL& url) const
+void CachedResourceLoader::printAccessDeniedMessage(const KURL& url) const
{
if (url.isNull())
return;
@@ -308,7 +308,7 @@ void DocLoader::printAccessDeniedMessage(const KURL& url) const
frame()->domWindow()->console()->addMessage(OtherMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
}
-void DocLoader::setAutoLoadImages(bool enable)
+void CachedResourceLoader::setAutoLoadImages(bool enable)
{
if (enable == m_autoLoadImages)
return;
@@ -334,6 +334,7 @@ void DocLoader::setAutoLoadImages(bool enable)
}
}
+<<<<<<< HEAD:WebCore/loader/DocLoader.cpp
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
bool DocLoader::shouldBlockNetworkImage(const String& url) const
{
@@ -370,11 +371,14 @@ void DocLoader::setBlockNetworkImage(bool block)
#endif
CachePolicy DocLoader::cachePolicy() const
+=======
+CachePolicy CachedResourceLoader::cachePolicy() const
+>>>>>>> webkit.org at r67178:WebCore/loader/CachedResourceLoader.cpp
{
return frame() ? frame()->loader()->subresourceCachePolicy() : CachePolicyVerify;
}
-void DocLoader::removeCachedResource(CachedResource* resource) const
+void CachedResourceLoader::removeCachedResource(CachedResource* resource) const
{
#ifndef NDEBUG
DocumentResourceMap::iterator it = m_documentResources.find(resource->url());
@@ -384,14 +388,14 @@ void DocLoader::removeCachedResource(CachedResource* resource) const
m_documentResources.remove(resource->url());
}
-void DocLoader::setLoadInProgress(bool load)
+void CachedResourceLoader::setLoadInProgress(bool load)
{
m_loadInProgress = load;
if (!load && frame())
frame()->loader()->loadDone();
}
-void DocLoader::checkCacheObjectStatus(CachedResource* resource)
+void CachedResourceLoader::checkCacheObjectStatus(CachedResource* resource)
{
// Return from the function for objects that we didn't load from the cache or if we don't have a frame.
if (!resource || !frame())
@@ -411,7 +415,7 @@ void DocLoader::checkCacheObjectStatus(CachedResource* resource)
frame()->loader()->loadedResourceFromMemoryCache(resource);
}
-void DocLoader::incrementRequestCount(const CachedResource* res)
+void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
{
if (res->isPrefetch())
return;
@@ -419,7 +423,7 @@ void DocLoader::incrementRequestCount(const CachedResource* res)
++m_requestCount;
}
-void DocLoader::decrementRequestCount(const CachedResource* res)
+void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
{
if (res->isPrefetch())
return;
@@ -428,14 +432,14 @@ void DocLoader::decrementRequestCount(const CachedResource* res)
ASSERT(m_requestCount > -1);
}
-int DocLoader::requestCount()
+int CachedResourceLoader::requestCount()
{
if (loadInProgress())
return m_requestCount + 1;
return m_requestCount;
}
-void DocLoader::preload(CachedResource::Type type, const String& url, const String& charset, bool referencedFromBody)
+void CachedResourceLoader::preload(CachedResource::Type type, const String& url, const String& charset, bool referencedFromBody)
{
bool hasRendering = m_doc->body() && m_doc->body()->renderer();
if (!hasRendering && (referencedFromBody || type == CachedResource::ImageResource)) {
@@ -448,7 +452,7 @@ void DocLoader::preload(CachedResource::Type type, const String& url, const Stri
requestPreload(type, url, charset);
}
-void DocLoader::checkForPendingPreloads()
+void CachedResourceLoader::checkForPendingPreloads()
{
unsigned count = m_pendingPreloads.size();
if (!count || !m_doc->body() || !m_doc->body()->renderer())
@@ -462,7 +466,7 @@ void DocLoader::checkForPendingPreloads()
m_pendingPreloads.clear();
}
-void DocLoader::requestPreload(CachedResource::Type type, const String& url, const String& charset)
+void CachedResourceLoader::requestPreload(CachedResource::Type type, const String& url, const String& charset)
{
String encoding;
if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet)
@@ -482,7 +486,7 @@ void DocLoader::requestPreload(CachedResource::Type type, const String& url, con
#endif
}
-void DocLoader::clearPreloads()
+void CachedResourceLoader::clearPreloads()
{
#if PRELOAD_DEBUG
printPreloadStats();
@@ -502,13 +506,13 @@ void DocLoader::clearPreloads()
m_preloads.clear();
}
-void DocLoader::clearPendingPreloads()
+void CachedResourceLoader::clearPendingPreloads()
{
m_pendingPreloads.clear();
}
#if PRELOAD_DEBUG
-void DocLoader::printPreloadStats()
+void CachedResourceLoader::printPreloadStats()
{
unsigned scripts = 0;
unsigned scriptMisses = 0;
diff --git a/WebCore/loader/DocLoader.h b/WebCore/loader/CachedResourceLoader.h
index d77bce5..16d73ad 100644
--- a/WebCore/loader/DocLoader.h
+++ b/WebCore/loader/CachedResourceLoader.h
@@ -23,8 +23,8 @@
pages from the web. It has a memory cache for these objects.
*/
-#ifndef DocLoader_h
-#define DocLoader_h
+#ifndef CachedResourceLoader_h
+#define CachedResourceLoader_h
#include "CachedResource.h"
#include "CachedResourceHandle.h"
@@ -46,14 +46,14 @@ class Frame;
class ImageLoader;
class KURL;
-// The DocLoader manages the loading of scripts/images/stylesheets for a single document.
-class DocLoader : public Noncopyable {
+// The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document.
+class CachedResourceLoader : public Noncopyable {
friend class Cache;
friend class ImageLoader;
public:
- DocLoader(Document*);
- ~DocLoader();
+ CachedResourceLoader(Document*);
+ ~CachedResourceLoader();
CachedImage* requestImage(const String& url);
CachedCSSStyleSheet* requestCSSStyleSheet(const String& url, const String& charset);
diff --git a/WebCore/loader/CachedScript.h b/WebCore/loader/CachedScript.h
index beab508..1bc4e8c 100644
--- a/WebCore/loader/CachedScript.h
+++ b/WebCore/loader/CachedScript.h
@@ -31,7 +31,7 @@
namespace WebCore {
- class DocLoader;
+ class CachedResourceLoader;
class TextResourceDecoder;
class CachedScript : public CachedResource {
diff --git a/WebCore/loader/CachedXSLStyleSheet.h b/WebCore/loader/CachedXSLStyleSheet.h
index a0b5477..8587b0b 100644
--- a/WebCore/loader/CachedXSLStyleSheet.h
+++ b/WebCore/loader/CachedXSLStyleSheet.h
@@ -31,7 +31,7 @@
namespace WebCore {
- class DocLoader;
+ class CachedResourceLoader;
class TextResourceDecoder;
#if ENABLE(XSLT)
diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp
index 1e18077..1bb2f87 100644
--- a/WebCore/loader/DocumentLoader.cpp
+++ b/WebCore/loader/DocumentLoader.cpp
@@ -37,7 +37,7 @@
#include "SubstituteResource.h"
#endif
#include "CachedPage.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
#include "DocumentParser.h"
#include "Event.h"
@@ -398,7 +398,7 @@ bool DocumentLoader::isLoadingInAPISense() const
if (!m_subresourceLoaders.isEmpty())
return true;
Document* doc = m_frame->document();
- if (doc->docLoader()->requestCount())
+ if (doc->cachedResourceLoader()->requestCount())
return true;
if (DocumentParser* parser = doc->parser())
if (parser->processingData())
@@ -480,7 +480,7 @@ PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) const
if (!isCommitted())
return 0;
- CachedResource* resource = m_frame->document()->docLoader()->cachedResource(url);
+ CachedResource* resource = m_frame->document()->cachedResourceLoader()->cachedResource(url);
if (!resource || !resource->isLoaded())
return archiveResourceForURL(url);
@@ -503,9 +503,9 @@ void DocumentLoader::getSubresources(Vector<PassRefPtr<ArchiveResource> >& subre
Document* document = m_frame->document();
- const DocLoader::DocumentResourceMap& allResources = document->docLoader()->allCachedResources();
- DocLoader::DocumentResourceMap::const_iterator end = allResources.end();
- for (DocLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
+ const CachedResourceLoader::DocumentResourceMap& allResources = document->cachedResourceLoader()->allCachedResources();
+ CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
+ for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
RefPtr<ArchiveResource> subresource = this->subresource(KURL(ParsedURLString, it->second->url()));
if (subresource)
subresources.append(subresource.release());
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index 32722d6..e012b64 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -40,6 +40,7 @@
#include "FloatRect.h"
#include "FocusDirection.h"
#include "FrameLoaderClient.h"
+#include "FrameNetworkingContext.h"
#include "InspectorClient.h"
#include "PluginHalterClient.h"
#include "PopupMenu.h"
@@ -61,6 +62,8 @@
namespace WebCore {
+class SharedGraphicsContext3D;
+
class EmptyPopupMenu : public PopupMenu {
public:
virtual void show(const IntRect&, FrameView*, int) {}
@@ -194,9 +197,9 @@ public:
virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) {}
#if USE(ACCELERATED_COMPOSITING)
- virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) {};
- virtual void setNeedsOneShotDrawingSynchronization() {};
- virtual void scheduleCompositingLayerSync() {};
+ virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) {}
+ virtual void setNeedsOneShotDrawingSynchronization() {}
+ virtual void scheduleCompositingLayerSync() {}
#endif
#if PLATFORM(WIN)
@@ -372,6 +375,7 @@ public:
virtual bool shouldCacheResponse(DocumentLoader*, unsigned long, const ResourceResponse&, const unsigned char*, unsigned long long) { return true; }
#endif
+ virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() { return PassRefPtr<FrameNetworkingContext>(); }
};
class EmptyEditorClient : public EditorClient, public Noncopyable {
diff --git a/WebCore/loader/FTPDirectoryDocument.cpp b/WebCore/loader/FTPDirectoryDocument.cpp
deleted file mode 100644
index 6475ea9..0000000
--- a/WebCore/loader/FTPDirectoryDocument.cpp
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(FTPDIR)
-#include "FTPDirectoryDocument.h"
-
-#include "CharacterNames.h"
-#include "HTMLDocumentParser.h"
-#include "HTMLNames.h"
-#include "HTMLTableElement.h"
-#include "LocalizedStrings.h"
-#include "Logging.h"
-#include "FTPDirectoryParser.h"
-#include "SegmentedString.h"
-#include "Settings.h"
-#include "SharedBuffer.h"
-#include "Text.h"
-
-#include <wtf/text/CString.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/StdLibExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-class FTPDirectoryDocumentParser : public HTMLDocumentParser {
-public:
- static PassRefPtr<FTPDirectoryDocumentParser> create(HTMLDocument* document)
- {
- return adoptRef(new FTPDirectoryDocumentParser(document));
- }
-
- virtual void append(const SegmentedString&);
- virtual void finish();
-
- virtual bool isWaitingForScripts() const { return false; }
-
- inline void checkBuffer(int len = 10)
- {
- if ((m_dest - m_buffer) > m_size - len) {
- // Enlarge buffer
- int newSize = max(m_size * 2, m_size + len);
- int oldOffset = m_dest - m_buffer;
- m_buffer = static_cast<UChar*>(fastRealloc(m_buffer, newSize * sizeof(UChar)));
- m_dest = m_buffer + oldOffset;
- m_size = newSize;
- }
- }
-
-private:
- FTPDirectoryDocumentParser(HTMLDocument*);
-
- // The parser will attempt to load the document template specified via the preference
- // Failing that, it will fall back and create the basic document which will have a minimal
- // table for presenting the FTP directory in a useful manner
- bool loadDocumentTemplate();
- void createBasicDocument();
-
- void parseAndAppendOneLine(const String&);
- void appendEntry(const String& name, const String& size, const String& date, bool isDirectory);
- PassRefPtr<Element> createTDForFilename(const String&);
-
- RefPtr<HTMLTableElement> m_tableElement;
-
- bool m_skipLF;
- bool m_parsedTemplate;
-
- int m_size;
- UChar* m_buffer;
- UChar* m_dest;
- String m_carryOver;
-
- ListState m_listState;
-};
-
-FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument* document)
- : HTMLDocumentParser(document, false)
- , m_skipLF(false)
- , m_parsedTemplate(false)
- , m_size(254)
- , m_buffer(static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size)))
- , m_dest(m_buffer)
-{
-}
-
-void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory)
-{
- ExceptionCode ec;
-
- RefPtr<Element> rowElement = m_tableElement->insertRow(-1, ec);
- rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec);
-
- RefPtr<Element> element = document()->createElement(tdTag, false);
- element->appendChild(Text::create(document(), String(&noBreakSpace, 1)), ec);
- if (isDirectory)
- element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeDirectory", ec);
- else
- element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeFile", ec);
- rowElement->appendChild(element, ec);
-
- element = createTDForFilename(filename);
- element->setAttribute("class", "ftpDirectoryFileName", ec);
- rowElement->appendChild(element, ec);
-
- element = document()->createElement(tdTag, false);
- element->appendChild(Text::create(document(), date), ec);
- element->setAttribute("class", "ftpDirectoryFileDate", ec);
- rowElement->appendChild(element, ec);
-
- element = document()->createElement(tdTag, false);
- element->appendChild(Text::create(document(), size), ec);
- element->setAttribute("class", "ftpDirectoryFileSize", ec);
- rowElement->appendChild(element, ec);
-}
-
-PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
-{
- ExceptionCode ec;
-
- String fullURL = document()->baseURL().string();
- if (fullURL[fullURL.length() - 1] == '/')
- fullURL.append(filename);
- else
- fullURL.append("/" + filename);
-
- RefPtr<Element> anchorElement = document()->createElement(aTag, false);
- anchorElement->setAttribute("href", fullURL, ec);
- anchorElement->appendChild(Text::create(document(), filename), ec);
-
- RefPtr<Element> tdElement = document()->createElement(tdTag, false);
- tdElement->appendChild(anchorElement, ec);
-
- return tdElement.release();
-}
-
-static String processFilesizeString(const String& size, bool isDirectory)
-{
- if (isDirectory)
- return "--";
-
- bool valid;
- int64_t bytes = size.toUInt64(&valid);
- if (!valid)
- return unknownFileSizeText();
-
- if (bytes < 1000000)
- return String::format("%.2f KB", static_cast<float>(bytes)/1000);
-
- if (bytes < 1000000000)
- return String::format("%.2f MB", static_cast<float>(bytes)/1000000);
-
- return String::format("%.2f GB", static_cast<float>(bytes)/1000000000);
-}
-
-static bool wasLastDayOfMonth(int year, int month, int day)
-{
- static int lastDays[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- if (month < 0 || month > 11)
- return false;
-
- if (month == 2) {
- if (year % 4 == 0 && (year % 100 || year % 400 == 0)) {
- if (day == 29)
- return true;
- return false;
- }
-
- if (day == 28)
- return true;
- return false;
- }
-
- return lastDays[month] == day;
-}
-
-static String processFileDateString(const FTPTime& fileTime)
-{
- // FIXME: Need to localize this string?
-
- String timeOfDay;
-
- if (!(fileTime.tm_hour == 0 && fileTime.tm_min == 0 && fileTime.tm_sec == 0)) {
- int hour = fileTime.tm_hour;
- ASSERT(hour >= 0 && hour < 24);
-
- if (hour < 12) {
- if (hour == 0)
- hour = 12;
- timeOfDay = String::format(", %i:%02i AM", hour, fileTime.tm_min);
- } else {
- hour = hour - 12;
- if (hour == 0)
- hour = 12;
- timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min);
- }
- }
-
- // If it was today or yesterday, lets just do that - but we have to compare to the current time
- struct tm now;
- time_t now_t = time(NULL);
- getLocalTime(&now_t, &now);
-
- // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
- now.tm_year += 1900;
-
- if (fileTime.tm_year == now.tm_year) {
- if (fileTime.tm_mon == now.tm_mon) {
- if (fileTime.tm_mday == now.tm_mday)
- return "Today" + timeOfDay;
- if (fileTime.tm_mday == now.tm_mday - 1)
- return "Yesterday" + timeOfDay;
- }
-
- if (now.tm_mday == 1 && (now.tm_mon == fileTime.tm_mon + 1 || (now.tm_mon == 0 && fileTime.tm_mon == 11)) &&
- wasLastDayOfMonth(fileTime.tm_year, fileTime.tm_mon, fileTime.tm_mday))
- return "Yesterday" + timeOfDay;
- }
-
- if (fileTime.tm_year == now.tm_year - 1 && fileTime.tm_mon == 12 && fileTime.tm_mday == 31 && now.tm_mon == 1 && now.tm_mday == 1)
- return "Yesterday" + timeOfDay;
-
- static const char* months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???" };
-
- int month = fileTime.tm_mon;
- if (month < 0 || month > 11)
- month = 12;
-
- String dateString;
-
- if (fileTime.tm_year > -1)
- dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, fileTime.tm_year);
- else
- dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, now.tm_year);
-
- return dateString + timeOfDay;
-}
-
-void FTPDirectoryDocumentParser::parseAndAppendOneLine(const String& inputLine)
-{
- ListResult result;
- CString latin1Input = inputLine.latin1();
-
- FTPEntryType typeResult = parseOneFTPLine(latin1Input.data(), m_listState, result);
-
- // FTPMiscEntry is a comment or usage statistic which we don't care about, and junk is invalid data - bail in these 2 cases
- if (typeResult == FTPMiscEntry || typeResult == FTPJunkEntry)
- return;
-
- String filename(result.filename, result.filenameLength);
- if (result.type == FTPDirectoryEntry) {
- filename.append("/");
-
- // We have no interest in linking to "current directory"
- if (filename == "./")
- return;
- }
-
- LOG(FTP, "Appending entry - %s, %s", filename.ascii().data(), result.fileSize.ascii().data());
-
- appendEntry(filename, processFilesizeString(result.fileSize, result.type == FTPDirectoryEntry), processFileDateString(result.modifiedTime), result.type == FTPDirectoryEntry);
-}
-
-static inline PassRefPtr<SharedBuffer> createTemplateDocumentData(Settings* settings)
-{
- RefPtr<SharedBuffer> buffer = 0;
- if (settings)
- buffer = SharedBuffer::createWithContentsOfFile(settings->ftpDirectoryTemplatePath());
- if (buffer)
- LOG(FTP, "Loaded FTPDirectoryTemplate of length %i\n", buffer->size());
- return buffer.release();
-}
-
-bool FTPDirectoryDocumentParser::loadDocumentTemplate()
-{
- DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, templateDocumentData, (createTemplateDocumentData(document()->settings())));
- // FIXME: Instead of storing the data, we'd rather actually parse the template data into the template Document once,
- // store that document, then "copy" it whenever we get an FTP directory listing. There are complexities with this
- // approach that make it worth putting this off.
-
- if (!templateDocumentData) {
- LOG_ERROR("Could not load templateData");
- return false;
- }
-
- HTMLDocumentParser::insert(String(templateDocumentData->data(), templateDocumentData->size()));
-
- RefPtr<Element> tableElement = document()->getElementById("ftpDirectoryTable");
- if (!tableElement)
- LOG_ERROR("Unable to find element by id \"ftpDirectoryTable\" in the template document.");
- else if (!tableElement->hasTagName(tableTag))
- LOG_ERROR("Element of id \"ftpDirectoryTable\" is not a table element");
- else
- m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
-
- // Bail if we found the table element
- if (m_tableElement)
- return true;
-
- // Otherwise create one manually
- tableElement = document()->createElement(tableTag, false);
- m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
- ExceptionCode ec;
- m_tableElement->setAttribute("id", "ftpDirectoryTable", ec);
-
- // If we didn't find the table element, lets try to append our own to the body
- // If that fails for some reason, cram it on the end of the document as a last
- // ditch effort
- if (Element* body = document()->body())
- body->appendChild(m_tableElement, ec);
- else
- document()->appendChild(m_tableElement, ec);
-
- return true;
-}
-
-void FTPDirectoryDocumentParser::createBasicDocument()
-{
- LOG(FTP, "Creating a basic FTP document structure as no template was loaded");
-
- // FIXME: Make this "basic document" more acceptable
-
- RefPtr<Element> bodyElement = document()->createElement(bodyTag, false);
-
- ExceptionCode ec;
- document()->appendChild(bodyElement, ec);
-
- RefPtr<Element> tableElement = document()->createElement(tableTag, false);
- m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
- m_tableElement->setAttribute("id", "ftpDirectoryTable", ec);
-
- bodyElement->appendChild(m_tableElement, ec);
-}
-
-void FTPDirectoryDocumentParser::append(const SegmentedString& source)
-{
- // Make sure we have the table element to append to by loading the template set in the pref, or
- // creating a very basic document with the appropriate table
- if (!m_tableElement) {
- if (!loadDocumentTemplate())
- createBasicDocument();
- ASSERT(m_tableElement);
- }
-
- bool foundNewLine = false;
-
- m_dest = m_buffer;
- SegmentedString str = source;
- while (!str.isEmpty()) {
- UChar c = *str;
-
- if (c == '\r') {
- *m_dest++ = '\n';
- foundNewLine = true;
- // possibly skip an LF in the case of an CRLF sequence
- m_skipLF = true;
- } else if (c == '\n') {
- if (!m_skipLF)
- *m_dest++ = c;
- else
- m_skipLF = false;
- } else {
- *m_dest++ = c;
- m_skipLF = false;
- }
-
- str.advance();
-
- // Maybe enlarge the buffer
- checkBuffer();
- }
-
- if (!foundNewLine) {
- m_dest = m_buffer;
- return;
- }
-
- UChar* start = m_buffer;
- UChar* cursor = start;
-
- while (cursor < m_dest) {
- if (*cursor == '\n') {
- m_carryOver.append(String(start, cursor - start));
- LOG(FTP, "%s", m_carryOver.ascii().data());
- parseAndAppendOneLine(m_carryOver);
- m_carryOver = String();
-
- start = ++cursor;
- } else
- cursor++;
- }
-
- // Copy the partial line we have left to the carryover buffer
- if (cursor - start > 1)
- m_carryOver.append(String(start, cursor - start - 1));
-}
-
-void FTPDirectoryDocumentParser::finish()
-{
- // Possible the last line in the listing had no newline, so try to parse it now
- if (!m_carryOver.isEmpty()) {
- parseAndAppendOneLine(m_carryOver);
- m_carryOver = String();
- }
-
- m_tableElement = 0;
- fastFree(m_buffer);
-
- HTMLDocumentParser::finish();
-}
-
-FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
-{
-#ifndef NDEBUG
- LogFTP.state = WTFLogChannelOn;
-#endif
-}
-
-PassRefPtr<DocumentParser> FTPDirectoryDocument::createParser()
-{
- return FTPDirectoryDocumentParser::create(this);
-}
-
-}
-
-#endif // ENABLE(FTPDIR)
diff --git a/WebCore/loader/FTPDirectoryDocument.h b/WebCore/loader/FTPDirectoryDocument.h
deleted file mode 100644
index e7e52f7..0000000
--- a/WebCore/loader/FTPDirectoryDocument.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FTPDirectoryDocument_h
-#define FTPDirectoryDocument_h
-
-#include "HTMLDocument.h"
-
-namespace WebCore {
-
-class DOMImplementation;
-
-class FTPDirectoryDocument : public HTMLDocument {
-public:
- static PassRefPtr<FTPDirectoryDocument> create(Frame* frame, const KURL& url)
- {
- return adoptRef(new FTPDirectoryDocument(frame, url));
- }
-
-private:
- FTPDirectoryDocument(Frame*, const KURL&);
- virtual PassRefPtr<DocumentParser> createParser();
-};
-
-} // namespace WebCore
-
-#endif // FTPDirectoryDocument_h
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 496cac9..4cbfb00 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -45,7 +45,7 @@
#include "Chrome.h"
#include "DOMImplementation.h"
#include "DOMWindow.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
#include "DocumentLoadTiming.h"
#include "DocumentLoader.h"
@@ -60,6 +60,7 @@
#include "Frame.h"
#include "FrameLoadRequest.h"
#include "FrameLoaderClient.h"
+#include "FrameNetworkingContext.h"
#include "FrameTree.h"
#include "FrameView.h"
#include "HTMLAnchorElement.h"
@@ -163,7 +164,7 @@ static int numRequests(Document* document)
if (!document)
return 0;
- return document->docLoader()->requestCount();
+ return document->cachedResourceLoader()->requestCount();
}
// This is not in the FrameLoader class to emphasize that it does not depend on
@@ -223,6 +224,9 @@ FrameLoader::~FrameLoader()
(*it)->loader()->m_opener = 0;
m_client->frameLoaderDestroyed();
+
+ if (m_networkingContext)
+ m_networkingContext->invalidate();
}
void FrameLoader::init()
@@ -243,6 +247,8 @@ void FrameLoader::init()
m_frame->document()->cancelParsing();
m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
m_didCallImplicitClose = true;
+
+ m_networkingContext = m_client->createNetworkingContext();
}
void FrameLoader::setDefersLoading(bool defers)
@@ -426,8 +432,12 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic
m_workingURL = KURL();
if (Document* doc = m_frame->document()) {
- if (DocLoader* docLoader = doc->docLoader())
- cache()->loader()->cancelRequests(docLoader);
+ // FIXME: HTML5 doesn't tell us to set the state to complete when aborting, but we do anyway to match legacy behavior.
+ // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10537
+ doc->setReadyState(Document::Complete);
+
+ if (CachedResourceLoader* cachedResourceLoader = doc->cachedResourceLoader())
+ cache()->loader()->cancelRequests(cachedResourceLoader);
#if ENABLE(DATABASE)
if (databasePolicy == DatabasePolicyStop)
@@ -666,10 +676,14 @@ void FrameLoader::didBeginDocument(bool dispatch)
updateFirstPartyForCookies();
Settings* settings = m_frame->document()->settings();
+<<<<<<< HEAD
m_frame->document()->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
m_frame->document()->docLoader()->setBlockNetworkImage(settings && settings->blockNetworkImage());
#endif
+=======
+ m_frame->document()->cachedResourceLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());
+>>>>>>> webkit.org at r67178
if (m_documentLoader) {
String dnsPrefetchControl = m_documentLoader->response().httpHeaderField("X-DNS-Prefetch-Control");
@@ -842,6 +856,7 @@ void FrameLoader::checkCompleted()
// OK, completed.
m_isComplete = true;
+ m_frame->document()->setReadyState(Document::Complete);
RefPtr<Frame> protect(m_frame);
checkCallImplicitClose(); // if we didn't do it before
@@ -1056,6 +1071,7 @@ void FrameLoader::setOpener(Frame* opener)
}
}
+// FIXME: This does not belong in FrameLoader!
void FrameLoader::handleFallbackContent()
{
HTMLFrameOwnerElement* owner = m_frame->ownerElement();
@@ -1272,7 +1288,7 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
ASSERT(frame()->document());
if (SchemeRegistry::shouldTreatURLAsLocal(url.string()) && !isFeedWithNestedProtocolInHTTPFamily(url)) {
- if (!SecurityOrigin::canLoad(url, String(), frame()->document()) && !SecurityOrigin::canLoad(url, referrer, 0)) {
+ if (!SecurityOrigin::canDisplay(url, String(), frame()->document()) && !SecurityOrigin::canDisplay(url, referrer, 0)) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return;
}
@@ -3478,6 +3494,11 @@ void FrameLoader::tellClientAboutPastMemoryCacheLoads()
}
}
+NetworkingContext* FrameLoader::networkingContext() const
+{
+ return m_networkingContext.get();
+}
+
bool FrameLoaderClient::hasHTMLView() const
{
return true;
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 754c151..a887e3b 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -64,10 +64,12 @@ class FormState;
class FormSubmission;
class Frame;
class FrameLoaderClient;
+class FrameNetworkingContext;
class HistoryItem;
class HTMLFormElement;
class IconLoader;
class NavigationAction;
+class NetworkingContext;
class ProtectionSpace;
class ResourceError;
class ResourceLoader;
@@ -335,6 +337,8 @@ public:
bool pageDismissalEventBeingDispatched() const { return m_pageDismissalEventBeingDispatched; }
+ inline NetworkingContext* networkingContext() const;
+
private:
bool canCachePageContainingThisFrame();
#ifndef NDEBUG
@@ -501,6 +505,8 @@ private:
#ifndef NDEBUG
bool m_didDispatchDidCommitLoad;
#endif
+
+ RefPtr<FrameNetworkingContext> m_networkingContext;
};
// This function is called by createWindow() in JSDOMWindowBase.cpp, for example, for
diff --git a/WebCore/loader/FrameLoaderClient.h b/WebCore/loader/FrameLoaderClient.h
index 26a1259..7c28c51 100644
--- a/WebCore/loader/FrameLoaderClient.h
+++ b/WebCore/loader/FrameLoaderClient.h
@@ -52,6 +52,7 @@ namespace WebCore {
class FormState;
class Frame;
class FrameLoader;
+ class FrameNetworkingContext;
class HistoryItem;
class HTMLAppletElement;
class HTMLFormElement;
@@ -285,6 +286,8 @@ namespace WebCore {
virtual void didNotAllowScript() { }
// This callback is similar, but for plugins.
virtual void didNotAllowPlugins() { }
+
+ virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() = 0;
};
} // namespace WebCore
diff --git a/WebCore/loader/HistoryController.cpp b/WebCore/loader/HistoryController.cpp
index 32a6a91..f06589e 100644
--- a/WebCore/loader/HistoryController.cpp
+++ b/WebCore/loader/HistoryController.cpp
@@ -450,9 +450,9 @@ void HistoryController::setProvisionalItem(HistoryItem* item)
PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
{
- DocumentLoader* docLoader = m_frame->loader()->documentLoader();
+ DocumentLoader* documentLoader = m_frame->loader()->documentLoader();
- KURL unreachableURL = docLoader ? docLoader->unreachableURL() : KURL();
+ KURL unreachableURL = documentLoader ? documentLoader->unreachableURL() : KURL();
KURL url;
KURL originalURL;
@@ -461,11 +461,11 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
url = unreachableURL;
originalURL = unreachableURL;
} else {
- originalURL = docLoader ? docLoader->originalURL() : KURL();
+ originalURL = documentLoader ? documentLoader->originalURL() : KURL();
if (useOriginal)
url = originalURL;
- else if (docLoader)
- url = docLoader->requestURL();
+ else if (documentLoader)
+ url = documentLoader->requestURL();
}
LOG(History, "WebCoreHistory: Creating item for %s", url.string().ascii().data());
@@ -482,20 +482,20 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
Frame* parentFrame = m_frame->tree()->parent();
String parent = parentFrame ? parentFrame->tree()->name() : "";
- String title = docLoader ? docLoader->title() : "";
+ String title = documentLoader ? documentLoader->title() : "";
RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->name(), parent, title);
item->setOriginalURLString(originalURL.string());
- if (!unreachableURL.isEmpty() || !docLoader || docLoader->response().httpStatusCode() >= 400)
+ if (!unreachableURL.isEmpty() || !documentLoader || documentLoader->response().httpStatusCode() >= 400)
item->setLastVisitWasFailure(true);
// Save form state if this is a POST
- if (docLoader) {
+ if (documentLoader) {
if (useOriginal)
- item->setFormInfoFromRequest(docLoader->originalRequest());
+ item->setFormInfoFromRequest(documentLoader->originalRequest());
else
- item->setFormInfoFromRequest(docLoader->request());
+ item->setFormInfoFromRequest(documentLoader->request());
}
// Set the item for which we will save document state
diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp
deleted file mode 100644
index 702ed9d..0000000
--- a/WebCore/loader/ImageDocument.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageDocument.h"
-
-#include "CachedImage.h"
-#include "DocumentLoader.h"
-#include "EventListener.h"
-#include "EventNames.h"
-#include "Frame.h"
-#include "FrameLoaderClient.h"
-#include "FrameView.h"
-#include "HTMLImageElement.h"
-#include "HTMLNames.h"
-#include "LocalizedStrings.h"
-#include "MouseEvent.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "RawDataDocumentParser.h"
-#include "Settings.h"
-
-using std::min;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-class ImageEventListener : public EventListener {
-public:
- static PassRefPtr<ImageEventListener> create(ImageDocument* document) { return adoptRef(new ImageEventListener(document)); }
- static const ImageEventListener* cast(const EventListener* listener)
- {
- return listener->type() == ImageEventListenerType
- ? static_cast<const ImageEventListener*>(listener)
- : 0;
- }
-
- virtual bool operator==(const EventListener& other);
-
-private:
- ImageEventListener(ImageDocument* document)
- : EventListener(ImageEventListenerType)
- , m_doc(document)
- {
- }
-
- virtual void handleEvent(ScriptExecutionContext*, Event*);
-
- ImageDocument* m_doc;
-};
-
-class ImageDocumentParser : public RawDataDocumentParser {
-public:
- static PassRefPtr<ImageDocumentParser> create(ImageDocument* document)
- {
- return adoptRef(new ImageDocumentParser(document));
- }
-
- ImageDocument* document() const
- {
- return static_cast<ImageDocument*>(RawDataDocumentParser::document());
- }
-
-private:
- ImageDocumentParser(ImageDocument* document)
- : RawDataDocumentParser(document)
- {
- }
-
- virtual void appendBytes(DocumentWriter*, const char*, int, bool);
- virtual void finish();
-};
-
-class ImageDocumentElement : public HTMLImageElement {
-public:
- static PassRefPtr<ImageDocumentElement> create(ImageDocument*);
-
-private:
- ImageDocumentElement(ImageDocument* document)
- : HTMLImageElement(imgTag, document)
- , m_imageDocument(document)
- {
- }
-
- virtual ~ImageDocumentElement();
- virtual void willMoveToNewOwnerDocument();
-
- ImageDocument* m_imageDocument;
-};
-
-inline PassRefPtr<ImageDocumentElement> ImageDocumentElement::create(ImageDocument* document)
-{
- return adoptRef(new ImageDocumentElement(document));
-}
-
-// --------
-
-static float pageZoomFactor(Document* document)
-{
- FrameView* view = document->view();
- return view ? view->pageZoomFactor() : 1;
-}
-
-void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
-{
- Frame* frame = document()->frame();
- Settings* settings = frame->settings();
- if (!frame->loader()->client()->allowImages(!settings || settings->areImagesEnabled()))
- return;
-
- CachedImage* cachedImage = document()->cachedImage();
- cachedImage->data(frame->loader()->documentLoader()->mainResourceData(), false);
-
- document()->imageChanged();
-}
-
-void ImageDocumentParser::finish()
-{
- if (!m_parserStopped && document()->imageElement()) {
- CachedImage* cachedImage = document()->cachedImage();
- RefPtr<SharedBuffer> data = document()->frame()->loader()->documentLoader()->mainResourceData();
-
- // If this is a multipart image, make a copy of the current part, since the resource data
- // will be overwritten by the next part.
- if (document()->frame()->loader()->documentLoader()->isLoadingMultipartContent())
- data = data->copy();
-
- cachedImage->data(data.release(), true);
- cachedImage->finish();
-
- cachedImage->setResponse(document()->frame()->loader()->documentLoader()->response());
-
- IntSize size = cachedImage->imageSize(pageZoomFactor(document()));
- if (size.width()) {
- // Compute the title, we use the decoded filename of the resource, falling
- // back on the (decoded) hostname if there is no path.
- String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent());
- if (fileName.isEmpty())
- fileName = document()->url().host();
- document()->setTitle(imageTitle(fileName, size));
- }
-
- document()->imageChanged();
- }
-
- document()->finishedParsing();
-}
-
-// --------
-
-ImageDocument::ImageDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
- , m_imageElement(0)
- , m_imageSizeIsKnown(false)
- , m_didShrinkImage(false)
- , m_shouldShrinkImage(shouldShrinkToFit())
-{
- setCompatibilityMode(QuirksMode);
- lockCompatibilityMode();
-}
-
-PassRefPtr<DocumentParser> ImageDocument::createParser()
-{
- return ImageDocumentParser::create(this);
-}
-
-void ImageDocument::createDocumentStructure()
-{
- ExceptionCode ec;
-
- RefPtr<Element> rootElement = Document::createElement(htmlTag, false);
- appendChild(rootElement, ec);
-
- if (frame() && frame()->loader())
- frame()->loader()->dispatchDocumentElementAvailable();
-
- RefPtr<Element> body = Document::createElement(bodyTag, false);
- body->setAttribute(styleAttr, "margin: 0px;");
-
- rootElement->appendChild(body, ec);
-
- RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(this);
-
- imageElement->setAttribute(styleAttr, "-webkit-user-select: none");
- imageElement->setLoadManually(true);
- imageElement->setSrc(url().string());
-
- body->appendChild(imageElement, ec);
-
- if (shouldShrinkToFit()) {
- // Add event listeners
- RefPtr<EventListener> listener = ImageEventListener::create(this);
- if (DOMWindow* domWindow = this->domWindow())
- domWindow->addEventListener("resize", listener, false);
- imageElement->addEventListener("click", listener.release(), false);
- }
-
- m_imageElement = imageElement.get();
-}
-
-float ImageDocument::scale() const
-{
- if (!m_imageElement)
- return 1.0f;
-
- FrameView* view = frame()->view();
- if (!view)
- return 1;
-
- IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
- IntSize windowSize = IntSize(view->width(), view->height());
-
- float widthScale = (float)windowSize.width() / imageSize.width();
- float heightScale = (float)windowSize.height() / imageSize.height();
-
- return min(widthScale, heightScale);
-}
-
-void ImageDocument::resizeImageToFit()
-{
- if (!m_imageElement)
- return;
-
- IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
-
- float scale = this->scale();
- m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
- m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
-
- ExceptionCode ec;
- m_imageElement->style()->setProperty("cursor", "-webkit-zoom-in", ec);
-}
-
-void ImageDocument::imageClicked(int x, int y)
-{
- if (!m_imageSizeIsKnown || imageFitsInWindow())
- return;
-
- m_shouldShrinkImage = !m_shouldShrinkImage;
-
- if (m_shouldShrinkImage)
- windowSizeChanged();
- else {
- restoreImageSize();
-
- updateLayout();
-
- float scale = this->scale();
-
- int scrollX = static_cast<int>(x / scale - (float)frame()->view()->width() / 2);
- int scrollY = static_cast<int>(y / scale - (float)frame()->view()->height() / 2);
-
- frame()->view()->setScrollPosition(IntPoint(scrollX, scrollY));
- }
-}
-
-void ImageDocument::imageChanged()
-{
- ASSERT(m_imageElement);
-
- if (m_imageSizeIsKnown)
- return;
-
- if (m_imageElement->cachedImage()->imageSize(pageZoomFactor(this)).isEmpty())
- return;
-
- m_imageSizeIsKnown = true;
-
- if (shouldShrinkToFit()) {
- // Force resizing of the image
- windowSizeChanged();
- }
-}
-
-void ImageDocument::restoreImageSize()
-{
- if (!m_imageElement || !m_imageSizeIsKnown)
- return;
-
- m_imageElement->setWidth(m_imageElement->cachedImage()->imageSize(pageZoomFactor(this)).width());
- m_imageElement->setHeight(m_imageElement->cachedImage()->imageSize(pageZoomFactor(this)).height());
-
- ExceptionCode ec;
- if (imageFitsInWindow())
- m_imageElement->style()->removeProperty("cursor", ec);
- else
- m_imageElement->style()->setProperty("cursor", "-webkit-zoom-out", ec);
-
- m_didShrinkImage = false;
-}
-
-bool ImageDocument::imageFitsInWindow() const
-{
- if (!m_imageElement)
- return true;
-
- FrameView* view = frame()->view();
-
- IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
- IntSize windowSize = IntSize(view->width(), view->height());
-
- return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
-}
-
-void ImageDocument::windowSizeChanged()
-{
- if (!m_imageElement || !m_imageSizeIsKnown)
- return;
-
- bool fitsInWindow = imageFitsInWindow();
-
- // If the image has been explicitly zoomed in, restore the cursor if the image fits
- // and set it to a zoom out cursor if the image doesn't fit
- if (!m_shouldShrinkImage) {
- ExceptionCode ec;
-
- if (fitsInWindow)
- m_imageElement->style()->removeProperty("cursor", ec);
- else
- m_imageElement->style()->setProperty("cursor", "-webkit-zoom-out", ec);
- return;
- }
-
- if (m_didShrinkImage) {
- // If the window has been resized so that the image fits, restore the image size
- // otherwise update the restored image size.
- if (fitsInWindow)
- restoreImageSize();
- else
- resizeImageToFit();
- } else {
- // If the image isn't resized but needs to be, then resize it.
- if (!fitsInWindow) {
- resizeImageToFit();
- m_didShrinkImage = true;
- }
- }
-}
-
-CachedImage* ImageDocument::cachedImage()
-{
- if (!m_imageElement)
- createDocumentStructure();
-
- return m_imageElement->cachedImage();
-}
-
-bool ImageDocument::shouldShrinkToFit() const
-{
- return frame()->page()->settings()->shrinksStandaloneImagesToFit() &&
- frame()->page()->mainFrame() == frame();
-}
-
-// --------
-
-void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
-{
- if (event->type() == eventNames().resizeEvent)
- m_doc->windowSizeChanged();
- else if (event->type() == eventNames().clickEvent) {
- MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
- m_doc->imageClicked(mouseEvent->x(), mouseEvent->y());
- }
-}
-
-bool ImageEventListener::operator==(const EventListener& listener)
-{
- if (const ImageEventListener* imageEventListener = ImageEventListener::cast(&listener))
- return m_doc == imageEventListener->m_doc;
- return false;
-}
-
-// --------
-
-ImageDocumentElement::~ImageDocumentElement()
-{
- if (m_imageDocument)
- m_imageDocument->disconnectImageElement();
-}
-
-void ImageDocumentElement::willMoveToNewOwnerDocument()
-{
- if (m_imageDocument) {
- m_imageDocument->disconnectImageElement();
- m_imageDocument = 0;
- }
- HTMLImageElement::willMoveToNewOwnerDocument();
-}
-
-}
diff --git a/WebCore/loader/ImageDocument.h b/WebCore/loader/ImageDocument.h
deleted file mode 100644
index 5d00bd6..0000000
--- a/WebCore/loader/ImageDocument.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageDocument_h
-#define ImageDocument_h
-
-#include "HTMLDocument.h"
-
-namespace WebCore {
-
-class ImageDocumentElement;
-
-class ImageDocument : public HTMLDocument {
-public:
- static PassRefPtr<ImageDocument> create(Frame* frame, const KURL& url)
- {
- return adoptRef(new ImageDocument(frame, url));
- }
-
- CachedImage* cachedImage();
- ImageDocumentElement* imageElement() const { return m_imageElement; }
- void disconnectImageElement() { m_imageElement = 0; }
-
- void windowSizeChanged();
- void imageChanged();
- void imageClicked(int x, int y);
-
-private:
- ImageDocument(Frame*, const KURL&);
-
- virtual PassRefPtr<DocumentParser> createParser();
- virtual bool isImageDocument() const { return true; }
-
- void createDocumentStructure();
- void resizeImageToFit();
- void restoreImageSize();
- bool imageFitsInWindow() const;
- bool shouldShrinkToFit() const;
- float scale() const;
-
- ImageDocumentElement* m_imageElement;
-
- // Whether enough of the image has been loaded to determine its size
- bool m_imageSizeIsKnown;
-
- // Whether the image is shrunk to fit or not
- bool m_didShrinkImage;
-
- // Whether the image should be shrunk or not
- bool m_shouldShrinkImage;
-};
-
-}
-
-#endif // ImageDocument_h
diff --git a/WebCore/loader/ImageLoader.cpp b/WebCore/loader/ImageLoader.cpp
index 242bf94..f6bc8d0 100644
--- a/WebCore/loader/ImageLoader.cpp
+++ b/WebCore/loader/ImageLoader.cpp
@@ -24,7 +24,7 @@
#include "CSSHelper.h"
#include "CachedImage.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
#include "Element.h"
#include "HTMLNames.h"
@@ -161,15 +161,15 @@ void ImageLoader::updateFromElement()
CachedImage* newImage = 0;
if (!(attr.isNull() || (attr.isEmpty() && document->baseURI().isLocalFile()))) {
if (m_loadManually) {
- bool autoLoadOtherImages = document->docLoader()->autoLoadImages();
- document->docLoader()->setAutoLoadImages(false);
+ bool autoLoadOtherImages = document->cachedResourceLoader()->autoLoadImages();
+ document->cachedResourceLoader()->setAutoLoadImages(false);
newImage = new CachedImage(sourceURI(attr));
newImage->setLoading(true);
- newImage->setDocLoader(document->docLoader());
- document->docLoader()->m_documentResources.set(newImage->url(), newImage);
- document->docLoader()->setAutoLoadImages(autoLoadOtherImages);
+ newImage->setCachedResourceLoader(document->cachedResourceLoader());
+ document->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage);
+ document->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages);
} else
- newImage = document->docLoader()->requestImage(sourceURI(attr));
+ newImage = document->cachedResourceLoader()->requestImage(sourceURI(attr));
// If we do not have an image here, it means that a cross-site
// violation occurred.
diff --git a/WebCore/loader/MediaDocument.cpp b/WebCore/loader/MediaDocument.cpp
deleted file mode 100644
index 77c3d1f..0000000
--- a/WebCore/loader/MediaDocument.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-#include "MediaDocument.h"
-
-#include "DocumentLoader.h"
-#include "EventNames.h"
-#include "Frame.h"
-#include "FrameLoaderClient.h"
-#include "HTMLEmbedElement.h"
-#include "HTMLNames.h"
-#include "HTMLVideoElement.h"
-#include "KeyboardEvent.h"
-#include "MainResourceLoader.h"
-#include "NodeList.h"
-#include "RawDataDocumentParser.h"
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// FIXME: Share more code with PluginDocumentParser.
-class MediaDocumentParser : public RawDataDocumentParser {
-public:
- static PassRefPtr<MediaDocumentParser> create(MediaDocument* document)
- {
- return adoptRef(new MediaDocumentParser(document));
- }
-
-private:
- MediaDocumentParser(Document* document)
- : RawDataDocumentParser(document)
- , m_mediaElement(0)
- {
- }
-
- virtual void appendBytes(DocumentWriter*, const char*, int, bool);
-
- void createDocumentStructure();
-
- HTMLMediaElement* m_mediaElement;
-};
-
-void MediaDocumentParser::createDocumentStructure()
-{
- ExceptionCode ec;
- RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
- document()->appendChild(rootElement, ec);
-
- if (document()->frame() && document()->frame()->loader())
- document()->frame()->loader()->dispatchDocumentElementAvailable();
-
- RefPtr<Element> body = document()->createElement(bodyTag, false);
- body->setAttribute(styleAttr, "background-color: rgb(38,38,38);");
-
- rootElement->appendChild(body, ec);
-
- RefPtr<Element> mediaElement = document()->createElement(videoTag, false);
-
- m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get());
- m_mediaElement->setAttribute(controlsAttr, "");
- m_mediaElement->setAttribute(autoplayAttr, "");
- m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;");
-
- m_mediaElement->setAttribute(nameAttr, "media");
- m_mediaElement->setSrc(document()->url());
-
- body->appendChild(mediaElement, ec);
-
- Frame* frame = document()->frame();
- if (!frame)
- return;
-
- frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
-}
-
-void MediaDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
-{
- ASSERT(!m_mediaElement);
- if (m_mediaElement)
- return;
-
- createDocumentStructure();
- finish();
-}
-
-MediaDocument::MediaDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
- , m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired)
-{
- setCompatibilityMode(QuirksMode);
- lockCompatibilityMode();
-}
-
-MediaDocument::~MediaDocument()
-{
- ASSERT(!m_replaceMediaElementTimer.isActive());
-}
-
-PassRefPtr<DocumentParser> MediaDocument::createParser()
-{
- return MediaDocumentParser::create(this);
-}
-
-void MediaDocument::defaultEventHandler(Event* event)
-{
- // Match the default Quicktime plugin behavior to allow
- // clicking and double-clicking to pause and play the media.
- Node* targetNode = event->target()->toNode();
- if (targetNode && targetNode->hasTagName(videoTag)) {
- HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode);
- if (event->type() == eventNames().clickEvent) {
- if (!video->canPlay()) {
- video->pause(event->fromUserGesture());
- event->setDefaultHandled();
- }
- } else if (event->type() == eventNames().dblclickEvent) {
- if (video->canPlay()) {
- video->play(event->fromUserGesture());
- event->setDefaultHandled();
- }
- }
- }
-
- if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
- HTMLVideoElement* video = 0;
- if (targetNode) {
- if (targetNode->hasTagName(videoTag))
- video = static_cast<HTMLVideoElement*>(targetNode);
- else {
- RefPtr<NodeList> nodeList = targetNode->getElementsByTagName("video");
- if (nodeList.get()->length() > 0)
- video = static_cast<HTMLVideoElement*>(nodeList.get()->item(0));
- }
- }
- if (video) {
- KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
- if (keyboardEvent->keyIdentifier() == "U+0020") { // space
- if (video->paused()) {
- if (video->canPlay())
- video->play(event->fromUserGesture());
- } else
- video->pause(event->fromUserGesture());
- event->setDefaultHandled();
- }
- }
- }
-}
-
-void MediaDocument::mediaElementSawUnsupportedTracks()
-{
- // The HTMLMediaElement was told it has something that the underlying
- // MediaPlayer cannot handle so we should switch from <video> to <embed>
- // and let the plugin handle this. Don't do it immediately as this
- // function may be called directly from a media engine callback, and
- // replaceChild will destroy the element, media player, and media engine.
- m_replaceMediaElementTimer.startOneShot(0);
-}
-
-void MediaDocument::replaceMediaElementTimerFired(Timer<MediaDocument>*)
-{
- HTMLElement* htmlBody = body();
- if (!htmlBody)
- return;
-
- // Set body margin width and height to 0 as that is what a PluginDocument uses.
- htmlBody->setAttribute(marginwidthAttr, "0");
- htmlBody->setAttribute(marginheightAttr, "0");
-
- RefPtr<NodeList> nodeList = htmlBody->getElementsByTagName("video");
-
- if (nodeList.get()->length() > 0) {
- HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(nodeList.get()->item(0));
-
- RefPtr<Element> element = Document::createElement(embedTag, false);
- HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(element.get());
-
- embedElement->setAttribute(widthAttr, "100%");
- embedElement->setAttribute(heightAttr, "100%");
- embedElement->setAttribute(nameAttr, "plugin");
- embedElement->setAttribute(srcAttr, url().string());
- embedElement->setAttribute(typeAttr, frame()->loader()->writer()->mimeType());
-
- ExceptionCode ec;
- videoElement->parent()->replaceChild(embedElement, videoElement, ec);
- }
-}
-
-}
-#endif
diff --git a/WebCore/loader/MediaDocument.h b/WebCore/loader/MediaDocument.h
deleted file mode 100644
index 2d81296..0000000
--- a/WebCore/loader/MediaDocument.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2008,2009 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaDocument_h
-#define MediaDocument_h
-
-#if ENABLE(VIDEO)
-
-#include "HTMLDocument.h"
-
-namespace WebCore {
-
-class MediaDocument : public HTMLDocument {
-public:
- static PassRefPtr<MediaDocument> create(Frame* frame, const KURL& url)
- {
- return adoptRef(new MediaDocument(frame, url));
- }
- virtual ~MediaDocument();
-
- void mediaElementSawUnsupportedTracks();
-
-private:
- MediaDocument(Frame*, const KURL&);
-
- virtual bool isMediaDocument() const { return true; }
- virtual PassRefPtr<DocumentParser> createParser();
-
- virtual void defaultEventHandler(Event*);
-
- void replaceMediaElementTimerFired(Timer<MediaDocument>*);
-
- Timer<MediaDocument> m_replaceMediaElementTimer;
-};
-
-}
-
-#endif
-#endif
diff --git a/WebCore/loader/PingLoader.cpp b/WebCore/loader/PingLoader.cpp
index 60c6f30..268e007 100644
--- a/WebCore/loader/PingLoader.cpp
+++ b/WebCore/loader/PingLoader.cpp
@@ -42,7 +42,7 @@ namespace WebCore {
void PingLoader::loadImage(Frame* frame, const KURL& url)
{
- if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canLoad(url, String(), frame->document())) {
+ if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canDisplay(url, String(), frame->document())) {
FrameLoader::reportLocalLoadFailed(frame, url);
return;
}
diff --git a/WebCore/loader/PluginDocument.cpp b/WebCore/loader/PluginDocument.cpp
deleted file mode 100644
index ad11dfb..0000000
--- a/WebCore/loader/PluginDocument.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginDocument.h"
-
-#include "DocumentLoader.h"
-#include "Frame.h"
-#include "FrameLoaderClient.h"
-#include "HTMLEmbedElement.h"
-#include "HTMLNames.h"
-#include "MainResourceLoader.h"
-#include "Page.h"
-#include "RawDataDocumentParser.h"
-#include "RenderEmbeddedObject.h"
-#include "Settings.h"
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// FIXME: Share more code with MediaDocumentParser.
-class PluginDocumentParser : public RawDataDocumentParser {
-public:
- static PassRefPtr<PluginDocumentParser> create(PluginDocument* document)
- {
- return adoptRef(new PluginDocumentParser(document));
- }
-
- static Widget* pluginWidgetFromDocument(Document*);
-
-private:
- PluginDocumentParser(Document* document)
- : RawDataDocumentParser(document)
- , m_embedElement(0)
- {
- }
-
- virtual void appendBytes(DocumentWriter*, const char*, int, bool);
-
- void createDocumentStructure();
-
- HTMLEmbedElement* m_embedElement;
-};
-
-Widget* PluginDocumentParser::pluginWidgetFromDocument(Document* doc)
-{
- ASSERT(doc);
- RefPtr<Element> body = doc->body();
- if (body) {
- RefPtr<Node> node = body->firstChild();
- if (node && node->renderer()) {
- ASSERT(node->renderer()->isEmbeddedObject());
- return toRenderEmbeddedObject(node->renderer())->widget();
- }
- }
- return 0;
-}
-
-void PluginDocumentParser::createDocumentStructure()
-{
- ExceptionCode ec;
- RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
- document()->appendChild(rootElement, ec);
-
- if (document()->frame() && document()->frame()->loader())
- document()->frame()->loader()->dispatchDocumentElementAvailable();
-
- RefPtr<Element> body = document()->createElement(bodyTag, false);
- body->setAttribute(marginwidthAttr, "0");
- body->setAttribute(marginheightAttr, "0");
- body->setAttribute(bgcolorAttr, "rgb(38,38,38)");
-
- rootElement->appendChild(body, ec);
-
- RefPtr<Element> embedElement = document()->createElement(embedTag, false);
-
- m_embedElement = static_cast<HTMLEmbedElement*>(embedElement.get());
- m_embedElement->setAttribute(widthAttr, "100%");
- m_embedElement->setAttribute(heightAttr, "100%");
-
- m_embedElement->setAttribute(nameAttr, "plugin");
- m_embedElement->setAttribute(srcAttr, document()->url().string());
- m_embedElement->setAttribute(typeAttr, document()->frame()->loader()->writer()->mimeType());
-
- body->appendChild(embedElement, ec);
-}
-
-void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
-{
- ASSERT(!m_embedElement);
- if (m_embedElement)
- return;
-
- createDocumentStructure();
-
- Frame* frame = document()->frame();
- if (!frame)
- return;
- Settings* settings = frame->settings();
- if (!settings || !frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
- return;
-
- document()->updateLayout();
-
- if (RenderPart* renderer = m_embedElement->renderPart()) {
- frame->loader()->client()->redirectDataToPlugin(renderer->widget());
- frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
- }
-
- finish();
-}
-
-PluginDocument::PluginDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
-{
- setCompatibilityMode(QuirksMode);
- lockCompatibilityMode();
-}
-
-PassRefPtr<DocumentParser> PluginDocument::createParser()
-{
- return PluginDocumentParser::create(this);
-}
-
-Widget* PluginDocument::pluginWidget()
-{
- return PluginDocumentParser::pluginWidgetFromDocument(this);
-}
-
-Node* PluginDocument::pluginNode()
-{
- RefPtr<Element> body_element = body();
- if (body_element)
- return body_element->firstChild();
-
- return 0;
-}
-
-}
diff --git a/WebCore/loader/PluginDocument.h b/WebCore/loader/PluginDocument.h
deleted file mode 100644
index 3bb5d99..0000000
--- a/WebCore/loader/PluginDocument.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006, 2008, 2009Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginDocument_h
-#define PluginDocument_h
-
-#include "HTMLDocument.h"
-
-namespace WebCore {
-
-class Node;
-class Widget;
-class PluginDocument : public HTMLDocument {
-public:
- static PassRefPtr<PluginDocument> create(Frame* frame, const KURL& url)
- {
- return adoptRef(new PluginDocument(frame, url));
- }
-
- Widget* pluginWidget();
- Node* pluginNode();
-
- virtual bool isPluginDocument() const { return true; }
-
-private:
- PluginDocument(Frame*, const KURL&);
-
- virtual PassRefPtr<DocumentParser> createParser();
-};
-
-}
-
-#endif // PluginDocument_h
diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp
index 461baf7..7cb6090 100644
--- a/WebCore/loader/RedirectScheduler.cpp
+++ b/WebCore/loader/RedirectScheduler.cpp
@@ -172,16 +172,19 @@ private:
class ScheduledFormSubmission : public ScheduledNavigation {
public:
- ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad)
+ ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad, bool wasUserGesture)
: ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true)
, m_submission(submission)
, m_haveToldClient(false)
+ , m_wasUserGesture(wasUserGesture)
{
ASSERT(m_submission->state());
}
virtual void fire(Frame* frame)
{
+ UserGestureIndicator gestureIndicator(m_wasUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
+
// The submitForm function will find a target frame before using the redirection timer.
// Now that the timer has fired, we need to repeat the security check which normally is done when
// selecting a target, in case conditions have changed. Other code paths avoid this by targeting
@@ -211,6 +214,7 @@ public:
private:
RefPtr<FormSubmission> m_submission;
bool m_haveToldClient;
+ bool m_wasUserGesture;
};
RedirectScheduler::RedirectScheduler(Frame* frame)
@@ -311,10 +315,10 @@ void RedirectScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> submis
// If this is a child frame and the form submission was triggered by a script, lock the back/forward list
// to match IE and Opera.
// See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this.
+ bool isUserGesture = m_frame->loader()->isProcessingUserGesture();
+ bool lockBackForwardList = mustLockBackForwardList(m_frame, isUserGesture) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
- bool lockBackForwardList = mustLockBackForwardList(m_frame, UserGestureIndicator::processingUserGesture()) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
-
- schedule(adoptPtr(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad)));
+ schedule(adoptPtr(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad, isUserGesture)));
}
void RedirectScheduler::scheduleRefresh(bool wasUserGesture)
diff --git a/WebCore/loader/Request.cpp b/WebCore/loader/Request.cpp
index 630a4bb..6ad6f9c 100644
--- a/WebCore/loader/Request.cpp
+++ b/WebCore/loader/Request.cpp
@@ -28,9 +28,9 @@
namespace WebCore {
-Request::Request(DocLoader* docLoader, CachedResource* object, bool incremental, SecurityCheckPolicy shouldDoSecurityCheck, bool sendResourceLoadCallbacks)
+Request::Request(CachedResourceLoader* cachedResourceLoader, CachedResource* object, bool incremental, SecurityCheckPolicy shouldDoSecurityCheck, bool sendResourceLoadCallbacks)
: m_object(object)
- , m_docLoader(docLoader)
+ , m_cachedResourceLoader(cachedResourceLoader)
, m_incremental(incremental)
, m_multipart(false)
, m_shouldDoSecurityCheck(shouldDoSecurityCheck)
diff --git a/WebCore/loader/Request.h b/WebCore/loader/Request.h
index 468f8ff..b6a9e90 100644
--- a/WebCore/loader/Request.h
+++ b/WebCore/loader/Request.h
@@ -29,16 +29,16 @@
namespace WebCore {
class CachedResource;
- class DocLoader;
+ class CachedResourceLoader;
class Request : public Noncopyable {
public:
- Request(DocLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
+ Request(CachedResourceLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
~Request();
Vector<char>& buffer() { return m_buffer; }
CachedResource* cachedResource() { return m_object; }
- DocLoader* docLoader() { return m_docLoader; }
+ CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader; }
bool isIncremental() { return m_incremental; }
void setIsIncremental(bool b = true) { m_incremental = b; }
@@ -52,7 +52,7 @@ namespace WebCore {
private:
Vector<char> m_buffer;
CachedResource* m_object;
- DocLoader* m_docLoader;
+ CachedResourceLoader* m_cachedResourceLoader;
bool m_incremental;
bool m_multipart;
SecurityCheckPolicy m_shouldDoSecurityCheck;
diff --git a/WebCore/loader/ResourceLoader.cpp b/WebCore/loader/ResourceLoader.cpp
index b679795..f66aa67 100644
--- a/WebCore/loader/ResourceLoader.cpp
+++ b/WebCore/loader/ResourceLoader.cpp
@@ -412,7 +412,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
{
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent::instanceCount()) {
- InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0;
+ InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
if (timelineAgent)
timelineAgent->willReceiveResourceResponse(identifier(), response);
}
@@ -424,7 +424,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
didReceiveResponse(response);
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent::instanceCount()) {
- InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0;
+ InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
if (timelineAgent)
timelineAgent->didReceiveResourceResponse();
}
@@ -435,7 +435,7 @@ void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int lengt
{
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent::instanceCount()) {
- InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0;
+ InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
if (timelineAgent)
timelineAgent->willReceiveResourceData(identifier());
}
@@ -443,7 +443,7 @@ void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int lengt
didReceiveData(data, length, lengthReceived, false);
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent::instanceCount()) {
- InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0;
+ InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
if (timelineAgent)
timelineAgent->didReceiveResourceData();
}
diff --git a/WebCore/loader/SubframeLoader.cpp b/WebCore/loader/SubframeLoader.cpp
index ceafb88..c25b37e 100644
--- a/WebCore/loader/SubframeLoader.cpp
+++ b/WebCore/loader/SubframeLoader.cpp
@@ -147,7 +147,7 @@ PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const
if (!url.isEmpty())
completedURL = completeURL(url);
- if (!SecurityOrigin::canLoad(completedURL, String(), m_frame->document())) {
+ if (!SecurityOrigin::canDisplay(completedURL, String(), m_frame->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, completedURL.string());
return 0;
}
@@ -205,7 +205,7 @@ PassRefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, H
if (!codeBaseURLString.isEmpty()) {
KURL codeBaseURL = completeURL(codeBaseURLString);
- if (!SecurityOrigin::canLoad(codeBaseURL, String(), element->document())) {
+ if (!SecurityOrigin::canDisplay(codeBaseURL, String(), element->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, codeBaseURL.string());
return 0;
}
@@ -247,7 +247,7 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const K
marginHeight = o->getMarginHeight();
}
- if (!SecurityOrigin::canLoad(url, String(), ownerElement->document())) {
+ if (!SecurityOrigin::canDisplay(url, String(), ownerElement->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return 0;
}
@@ -336,7 +336,7 @@ bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const KUR
if (!renderer || useFallback)
return false;
- if (!SecurityOrigin::canLoad(url, String(), document())) {
+ if (!SecurityOrigin::canDisplay(url, String(), document())) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return false;
}
diff --git a/WebCore/loader/SubresourceLoader.cpp b/WebCore/loader/SubresourceLoader.cpp
index 1e22fb1..a389082 100644
--- a/WebCore/loader/SubresourceLoader.cpp
+++ b/WebCore/loader/SubresourceLoader.cpp
@@ -73,7 +73,7 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc
if (securityCheck == DoSecurityCheck
&& SecurityOrigin::restrictAccessToLocal()
- && !SecurityOrigin::canLoad(request.url(), String(), frame->document())) {
+ && !SecurityOrigin::canDisplay(request.url(), String(), frame->document())) {
FrameLoader::reportLocalLoadFailed(frame, request.url().string());
return 0;
}
diff --git a/WebCore/loader/TextDocument.cpp b/WebCore/loader/TextDocument.cpp
deleted file mode 100644
index 4b09a9e..0000000
--- a/WebCore/loader/TextDocument.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextDocument.h"
-
-#include "DecodedDataDocumentParser.h"
-#include "Element.h"
-#include "HTMLNames.h"
-#include "HTMLViewSourceDocument.h"
-#include "SegmentedString.h"
-#include "Text.h"
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// FIXME: TextDocumentParser could just be an HTMLDocumentParser
-// which started the Tokenizer in the PlainText state.
-class TextDocumentParser : public DecodedDataDocumentParser {
-public:
- static PassRefPtr<TextDocumentParser> create(Document* document)
- {
- return adoptRef(new TextDocumentParser(document));
- }
-
- static PassRefPtr<TextDocumentParser> create(HTMLViewSourceDocument* document)
- {
- return adoptRef(new TextDocumentParser(document));
- }
-
- virtual ~TextDocumentParser();
-
-private:
- TextDocumentParser(Document*);
- TextDocumentParser(HTMLViewSourceDocument*);
-
- virtual void insert(const SegmentedString&);
- virtual void append(const SegmentedString&);
- virtual void finish();
- virtual bool finishWasCalled();
-
- inline void checkBuffer(int len = 10)
- {
- if ((m_dest - m_buffer) > m_size - len) {
- // Enlarge buffer
- int newSize = std::max(m_size * 2, m_size + len);
- int oldOffset = m_dest - m_buffer;
- m_buffer = static_cast<UChar*>(fastRealloc(m_buffer, newSize * sizeof(UChar)));
- m_dest = m_buffer + oldOffset;
- m_size = newSize;
- }
- }
-
-private:
- Element* m_preElement;
-
- bool m_skipLF;
-
- int m_size;
- UChar* m_buffer;
- UChar* m_dest;
-};
-
-TextDocumentParser::TextDocumentParser(Document* document)
- : DecodedDataDocumentParser(document)
- , m_preElement(0)
- , m_skipLF(false)
-{
- // Allocate buffer
- m_size = 254;
- m_buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size));
- m_dest = m_buffer;
-}
-
-TextDocumentParser::TextDocumentParser(HTMLViewSourceDocument* document)
- : DecodedDataDocumentParser(document, true)
- , m_preElement(0)
- , m_skipLF(false)
-{
- // Allocate buffer
- m_size = 254;
- m_buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size));
- m_dest = m_buffer;
-}
-
-TextDocumentParser::~TextDocumentParser()
-{
- // finish() should have been called to prevent any leaks
- ASSERT(!m_buffer);
-}
-
-void TextDocumentParser::insert(const SegmentedString&)
-{
- ASSERT_NOT_REACHED();
-}
-
-void TextDocumentParser::append(const SegmentedString& s)
-{
- ExceptionCode ec;
-
- m_dest = m_buffer;
-
- SegmentedString str = s;
- while (!str.isEmpty()) {
- UChar c = *str;
-
- if (c == '\r') {
- *m_dest++ = '\n';
-
- // possibly skip an LF in the case of an CRLF sequence
- m_skipLF = true;
- } else if (c == '\n') {
- if (!m_skipLF)
- *m_dest++ = c;
- else
- m_skipLF = false;
- } else {
- *m_dest++ = c;
- m_skipLF = false;
- }
-
- str.advance();
-
- // Maybe enlarge the buffer
- checkBuffer();
- }
-
- if (!m_preElement && !inViewSourceMode()) {
- RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
- document()->appendChild(rootElement, ec);
-
- RefPtr<Element> body = document()->createElement(bodyTag, false);
- rootElement->appendChild(body, ec);
-
- RefPtr<Element> preElement = document()->createElement(preTag, false);
- preElement->setAttribute("style", "word-wrap: break-word; white-space: pre-wrap;", ec);
-
- body->appendChild(preElement, ec);
-
- m_preElement = preElement.get();
- }
-
- String string = String(m_buffer, m_dest - m_buffer);
- if (inViewSourceMode()) {
- static_cast<HTMLViewSourceDocument*>(document())->addViewSourceText(string);
- return;
- }
-
- unsigned charsLeft = string.length();
- while (charsLeft) {
- // split large text to nodes of manageable size
- RefPtr<Text> text = Text::createWithLengthLimit(document(), string, charsLeft);
- m_preElement->appendChild(text, ec);
- }
-}
-
-void TextDocumentParser::finish()
-{
- if (!m_preElement)
- append(SegmentedString()); // Create document structure for an empty text document.
- m_preElement = 0;
- fastFree(m_buffer);
- m_buffer = 0;
- m_dest = 0;
-
- // FIXME: Should this call finishParsing even if m_parserStopped is true?
- // See equivalent implementation in RawDataDocumentParser.
- document()->finishedParsing();
-}
-
-bool TextDocumentParser::finishWasCalled()
-{
- // finish() always calls document()->finishedParsing() so we'll be deleted
- // after finish().
- return false;
-}
-
-TextDocument::TextDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
-{
- setCompatibilityMode(QuirksMode);
- lockCompatibilityMode();
-}
-
-PassRefPtr<DocumentParser> TextDocument::createParser()
-{
- return TextDocumentParser::create(this);
-}
-
-PassRefPtr<DocumentParser> createTextDocumentParser(HTMLViewSourceDocument* document)
-{
- return TextDocumentParser::create(document);
-}
-
-}
diff --git a/WebCore/loader/TextDocument.h b/WebCore/loader/TextDocument.h
deleted file mode 100644
index d5bf153..0000000
--- a/WebCore/loader/TextDocument.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextDocument_h
-#define TextDocument_h
-
-#include "HTMLDocument.h"
-
-namespace WebCore {
-
-class HTMLViewSourceDocument;
-
-class TextDocument : public HTMLDocument {
-public:
- static PassRefPtr<TextDocument> create(Frame* frame, const KURL& url)
- {
- return adoptRef(new TextDocument(frame, url));
- }
-
-private:
- TextDocument(Frame*, const KURL&);
-
- virtual PassRefPtr<DocumentParser> createParser();
-};
-
-PassRefPtr<DocumentParser> createTextDocumentParser(HTMLViewSourceDocument*);
-
-}
-
-#endif // TextDocument_h
diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp
index 345d881..3f6fad2 100644
--- a/WebCore/loader/loader.cpp
+++ b/WebCore/loader/loader.cpp
@@ -27,7 +27,7 @@
#include "Cache.h"
#include "CachedImage.h"
#include "CachedResource.h"
-#include "DocLoader.h"
+#include "CachedResourceLoader.h"
#include "InspectorTimelineAgent.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -121,10 +121,10 @@ Loader::Priority Loader::determinePriority(const CachedResource* resource) const
#endif
}
-void Loader::load(DocLoader* docLoader, CachedResource* resource, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
+void Loader::load(CachedResourceLoader* cachedResourceLoader, CachedResource* resource, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
{
- ASSERT(docLoader);
- Request* request = new Request(docLoader, resource, incremental, securityCheck, sendResourceLoadCallbacks);
+ ASSERT(cachedResourceLoader);
+ Request* request = new Request(cachedResourceLoader, resource, incremental, securityCheck, sendResourceLoadCallbacks);
RefPtr<Host> host;
KURL url(ParsedURLString, resource->url());
@@ -142,7 +142,7 @@ void Loader::load(DocLoader* docLoader, CachedResource* resource, bool increment
bool hadRequests = host->hasRequests();
Priority priority = determinePriority(resource);
host->addRequest(request, priority);
- docLoader->incrementRequestCount(request->cachedResource());
+ cachedResourceLoader->incrementRequestCount(request->cachedResource());
if (priority > Low || !url.protocolInHTTPFamily() || (priority == Low && !hadRequests)) {
// Try to request important resources immediately
@@ -151,7 +151,7 @@ void Loader::load(DocLoader* docLoader, CachedResource* resource, bool increment
// Handle asynchronously so early low priority requests don't get scheduled before later high priority ones
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent::instanceCount()) {
- InspectorTimelineAgent* agent = docLoader->doc()->inspectorTimelineAgent();
+ InspectorTimelineAgent* agent = cachedResourceLoader->doc()->inspectorTimelineAgent();
if (agent)
agent->didScheduleResourceRequest(resource->url());
}
@@ -243,12 +243,12 @@ void Loader::nonCacheRequestComplete(const KURL& url)
host->nonCacheRequestComplete();
}
-void Loader::cancelRequests(DocLoader* docLoader)
+void Loader::cancelRequests(CachedResourceLoader* cachedResourceLoader)
{
- docLoader->clearPendingPreloads();
+ cachedResourceLoader->clearPendingPreloads();
if (m_nonHTTPProtocolHost->hasRequests())
- m_nonHTTPProtocolHost->cancelRequests(docLoader);
+ m_nonHTTPProtocolHost->cancelRequests(cachedResourceLoader);
Vector<Host*> hostsToCancel;
m_hosts.checkConsistency();
@@ -260,12 +260,12 @@ void Loader::cancelRequests(DocLoader* docLoader)
for (unsigned n = 0; n < hostsToCancel.size(); ++n) {
Host* host = hostsToCancel[n];
if (host->hasRequests())
- host->cancelRequests(docLoader);
+ host->cancelRequests(cachedResourceLoader);
}
scheduleServePendingRequests();
- ASSERT(docLoader->requestCount() == (docLoader->loadInProgress() ? 1 : 0));
+ ASSERT(cachedResourceLoader->requestCount() == (cachedResourceLoader->loadInProgress() ? 1 : 0));
}
Loader::Host::Host(const AtomicString& name, unsigned maxRequestsInFlight)
@@ -326,13 +326,13 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser
{
while (!requestsPending.isEmpty()) {
Request* request = requestsPending.first();
- DocLoader* docLoader = request->docLoader();
+ CachedResourceLoader* cachedResourceLoader = request->cachedResourceLoader();
bool resourceIsCacheValidator = request->cachedResource()->isCacheValidator();
// For named hosts - which are only http(s) hosts - we should always enforce the connection limit.
// For non-named hosts - everything but http(s) - we should only enforce the limit if the document isn't done parsing
// and we don't know all stylesheets yet.
- bool shouldLimitRequests = !m_name.isNull() || docLoader->doc()->parsing() || !docLoader->doc()->haveStylesheetsLoaded();
+ bool shouldLimitRequests = !m_name.isNull() || cachedResourceLoader->doc()->parsing() || !cachedResourceLoader->doc()->haveStylesheetsLoaded();
if (shouldLimitRequests && m_requestsLoading.size() + m_nonCachedRequestsInFlight >= m_maxRequestsInFlight) {
serveLowerPriority = false;
return;
@@ -354,8 +354,8 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser
const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified");
const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag");
if (!lastModified.isEmpty() || !eTag.isEmpty()) {
- ASSERT(docLoader->cachePolicy() != CachePolicyReload);
- if (docLoader->cachePolicy() == CachePolicyRevalidate)
+ ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload);
+ if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate)
resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0");
if (!lastModified.isEmpty())
resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified);
@@ -364,7 +364,7 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser
}
}
- RefPtr<SubresourceLoader> loader = SubresourceLoader::create(docLoader->doc()->frame(),
+ RefPtr<SubresourceLoader> loader = SubresourceLoader::create(cachedResourceLoader->doc()->frame(),
this, resourceRequest, request->shouldDoSecurityCheck(), request->sendResourceLoadCallbacks());
if (loader) {
m_requestsLoading.add(loader.release(), request);
@@ -373,10 +373,10 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser
printf("HOST %s COUNT %d LOADING %s\n", resourceRequest.url().host().latin1().data(), m_requestsLoading.size(), request->cachedResource()->url().latin1().data());
#endif
} else {
- docLoader->decrementRequestCount(request->cachedResource());
- docLoader->setLoadInProgress(true);
+ cachedResourceLoader->decrementRequestCount(request->cachedResource());
+ cachedResourceLoader->setLoadInProgress(true);
request->cachedResource()->error();
- docLoader->setLoadInProgress(false);
+ cachedResourceLoader->setLoadInProgress(false);
delete request;
}
}
@@ -392,12 +392,12 @@ void Loader::Host::didFinishLoading(SubresourceLoader* loader)
Request* request = i->second;
m_requestsLoading.remove(i);
- DocLoader* docLoader = request->docLoader();
+ CachedResourceLoader* cachedResourceLoader = request->cachedResourceLoader();
// Prevent the document from being destroyed before we are done with
- // the docLoader that it will delete when the document gets deleted.
- RefPtr<Document> protector(docLoader->doc());
+ // the cachedResourceLoader that it will delete when the document gets deleted.
+ RefPtr<Document> protector(cachedResourceLoader->doc());
if (!request->isMultipart())
- docLoader->decrementRequestCount(request->cachedResource());
+ cachedResourceLoader->decrementRequestCount(request->cachedResource());
CachedResource* resource = request->cachedResource();
ASSERT(!resource->resourceToRevalidate());
@@ -405,16 +405,16 @@ void Loader::Host::didFinishLoading(SubresourceLoader* loader)
// If we got a 4xx response, we're pretending to have received a network
// error, so we can't send the successful data() and finish() callbacks.
if (!resource->errorOccurred()) {
- docLoader->setLoadInProgress(true);
+ cachedResourceLoader->setLoadInProgress(true);
resource->data(loader->resourceData(), true);
resource->finish();
}
delete request;
- docLoader->setLoadInProgress(false);
+ cachedResourceLoader->setLoadInProgress(false);
- docLoader->checkForPendingPreloads();
+ cachedResourceLoader->checkForPendingPreloads();
#if REQUEST_DEBUG
KURL u(ParsedURLString, resource->url());
@@ -440,12 +440,12 @@ void Loader::Host::didFail(SubresourceLoader* loader, bool cancelled)
Request* request = i->second;
m_requestsLoading.remove(i);
- DocLoader* docLoader = request->docLoader();
+ CachedResourceLoader* cachedResourceLoader = request->cachedResourceLoader();
// Prevent the document from being destroyed before we are done with
- // the docLoader that it will delete when the document gets deleted.
- RefPtr<Document> protector(docLoader->doc());
+ // the cachedResourceLoader that it will delete when the document gets deleted.
+ RefPtr<Document> protector(cachedResourceLoader->doc());
if (!request->isMultipart())
- docLoader->decrementRequestCount(request->cachedResource());
+ cachedResourceLoader->decrementRequestCount(request->cachedResource());
CachedResource* resource = request->cachedResource();
@@ -453,17 +453,17 @@ void Loader::Host::didFail(SubresourceLoader* loader, bool cancelled)
cache()->revalidationFailed(resource);
if (!cancelled) {
- docLoader->setLoadInProgress(true);
+ cachedResourceLoader->setLoadInProgress(true);
resource->error();
}
- docLoader->setLoadInProgress(false);
+ cachedResourceLoader->setLoadInProgress(false);
if (cancelled || !resource->isPreloaded())
cache()->remove(resource);
delete request;
- docLoader->checkForPendingPreloads();
+ cachedResourceLoader->checkForPendingPreloads();
servePendingRequests();
}
@@ -490,13 +490,13 @@ void Loader::Host::didReceiveResponse(SubresourceLoader* loader, const ResourceR
// 304 Not modified / Use local copy
m_requestsLoading.remove(loader);
loader->clearClient();
- request->docLoader()->decrementRequestCount(request->cachedResource());
+ request->cachedResourceLoader()->decrementRequestCount(request->cachedResource());
// Existing resource is ok, just use it updating the expiration time.
cache()->revalidationSucceeded(resource, response);
- if (request->docLoader()->frame())
- request->docLoader()->frame()->loader()->checkCompleted();
+ if (request->cachedResourceLoader()->frame())
+ request->cachedResourceLoader()->frame()->loader()->checkCompleted();
delete request;
@@ -516,13 +516,13 @@ void Loader::Host::didReceiveResponse(SubresourceLoader* loader, const ResourceR
if (request->isMultipart()) {
ASSERT(resource->isImage());
static_cast<CachedImage*>(resource)->clear();
- if (request->docLoader()->frame())
- request->docLoader()->frame()->loader()->checkCompleted();
+ if (request->cachedResourceLoader()->frame())
+ request->cachedResourceLoader()->frame()->loader()->checkCompleted();
} else if (response.isMultipart()) {
request->setIsMultipart(true);
- // We don't count multiParts in a DocLoader's request count
- request->docLoader()->decrementRequestCount(request->cachedResource());
+ // We don't count multiParts in a CachedResourceLoader's request count
+ request->cachedResourceLoader()->decrementRequestCount(request->cachedResource());
// If we get a multipart response, we must have a handle
ASSERT(loader->handle());
@@ -574,15 +574,15 @@ void Loader::Host::didReceiveCachedMetadata(SubresourceLoader* loader, const cha
resource->setSerializedCachedMetadata(data, size);
}
-void Loader::Host::cancelPendingRequests(RequestQueue& requestsPending, DocLoader* docLoader)
+void Loader::Host::cancelPendingRequests(RequestQueue& requestsPending, CachedResourceLoader* cachedResourceLoader)
{
RequestQueue remaining;
RequestQueue::iterator end = requestsPending.end();
for (RequestQueue::iterator it = requestsPending.begin(); it != end; ++it) {
Request* request = *it;
- if (request->docLoader() == docLoader) {
+ if (request->cachedResourceLoader() == cachedResourceLoader) {
cache()->remove(request->cachedResource());
- docLoader->decrementRequestCount(request->cachedResource());
+ cachedResourceLoader->decrementRequestCount(request->cachedResource());
delete request;
} else
remaining.append(request);
@@ -590,17 +590,17 @@ void Loader::Host::cancelPendingRequests(RequestQueue& requestsPending, DocLoade
requestsPending.swap(remaining);
}
-void Loader::Host::cancelRequests(DocLoader* docLoader)
+void Loader::Host::cancelRequests(CachedResourceLoader* cachedResourceLoader)
{
for (unsigned p = 0; p <= High; p++)
- cancelPendingRequests(m_requestsPending[p], docLoader);
+ cancelPendingRequests(m_requestsPending[p], cachedResourceLoader);
Vector<SubresourceLoader*, 256> loadersToCancel;
RequestMap::iterator end = m_requestsLoading.end();
for (RequestMap::iterator i = m_requestsLoading.begin(); i != end; ++i) {
Request* r = i->second;
- if (r->docLoader() == docLoader)
+ if (r->cachedResourceLoader() == cachedResourceLoader)
loadersToCancel.append(i->first.get());
}
diff --git a/WebCore/loader/loader.h b/WebCore/loader/loader.h
index 52c61aa..4d353e0 100644
--- a/WebCore/loader/loader.h
+++ b/WebCore/loader/loader.h
@@ -35,7 +35,7 @@
namespace WebCore {
class CachedResource;
- class DocLoader;
+ class CachedResourceLoader;
class KURL;
class Request;
@@ -44,9 +44,9 @@ namespace WebCore {
Loader();
~Loader();
- void load(DocLoader*, CachedResource*, bool incremental = true, SecurityCheckPolicy = DoSecurityCheck, bool sendResourceLoadCallbacks = true);
+ void load(CachedResourceLoader*, CachedResource*, bool incremental = true, SecurityCheckPolicy = DoSecurityCheck, bool sendResourceLoadCallbacks = true);
- void cancelRequests(DocLoader*);
+ void cancelRequests(CachedResourceLoader*);
enum Priority { VeryLow, Low, Medium, High };
void servePendingRequests(Priority minimumPriority = VeryLow);
@@ -77,7 +77,7 @@ namespace WebCore {
void nonCacheRequestInFlight();
void nonCacheRequestComplete();
void servePendingRequests(Priority minimumPriority = VeryLow);
- void cancelRequests(DocLoader*);
+ void cancelRequests(CachedResourceLoader*);
bool hasRequests() const;
bool processingResource() const { return m_numResourcesProcessing != 0 || m_nonCachedRequestsInFlight !=0; }
@@ -94,7 +94,7 @@ namespace WebCore {
typedef Deque<Request*> RequestQueue;
void servePendingRequests(RequestQueue& requestsPending, bool& serveLowerPriority);
void didFail(SubresourceLoader*, bool cancelled = false);
- void cancelPendingRequests(RequestQueue& requestsPending, DocLoader*);
+ void cancelPendingRequests(RequestQueue& requestsPending, CachedResourceLoader*);
RequestQueue m_requestsPending[High + 1];
typedef HashMap<RefPtr<SubresourceLoader>, Request*> RequestMap;