summaryrefslogtreecommitdiffstats
path: root/WebCore/loader
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/loader')
-rw-r--r--WebCore/loader/CrossOriginAccessControl.cpp8
-rw-r--r--WebCore/loader/DocLoader.cpp3
-rw-r--r--WebCore/loader/DocumentLoader.cpp6
-rw-r--r--WebCore/loader/DocumentThreadableLoader.cpp4
-rw-r--r--WebCore/loader/DocumentWriter.cpp4
-rw-r--r--WebCore/loader/DocumentWriter.h2
-rw-r--r--WebCore/loader/EmptyClients.h13
-rw-r--r--WebCore/loader/FormSubmission.cpp4
-rw-r--r--WebCore/loader/FrameLoader.cpp48
-rw-r--r--WebCore/loader/HistoryController.cpp24
-rw-r--r--WebCore/loader/HistoryController.h2
-rw-r--r--WebCore/loader/ImageDocument.cpp3
-rw-r--r--WebCore/loader/ImageLoader.cpp67
-rw-r--r--WebCore/loader/ImageLoader.h2
-rw-r--r--WebCore/loader/MediaDocument.cpp6
-rw-r--r--WebCore/loader/PingLoader.cpp2
-rw-r--r--WebCore/loader/PluginDocument.cpp8
-rw-r--r--WebCore/loader/ProgressTracker.cpp2
-rw-r--r--WebCore/loader/RedirectScheduler.cpp20
-rw-r--r--WebCore/loader/SinkDocument.cpp3
-rw-r--r--WebCore/loader/SubframeLoader.cpp89
-rw-r--r--WebCore/loader/SubframeLoader.h11
-rw-r--r--WebCore/loader/TextDocument.cpp2
-rw-r--r--WebCore/loader/WorkerThreadableLoader.cpp2
-rw-r--r--WebCore/loader/archive/ArchiveResource.cpp47
-rw-r--r--WebCore/loader/archive/ArchiveResource.h19
-rw-r--r--WebCore/loader/archive/cf/LegacyWebArchive.cpp2
-rw-r--r--WebCore/loader/icon/IconDatabase.cpp2
-rw-r--r--WebCore/loader/icon/IconLoader.cpp2
29 files changed, 211 insertions, 196 deletions
diff --git a/WebCore/loader/CrossOriginAccessControl.cpp b/WebCore/loader/CrossOriginAccessControl.cpp
index 630f2b7..f510704 100644
--- a/WebCore/loader/CrossOriginAccessControl.cpp
+++ b/WebCore/loader/CrossOriginAccessControl.cpp
@@ -71,9 +71,9 @@ bool isSimpleCrossOriginAccessRequest(const String& method, const HTTPHeaderMap&
}
typedef HashSet<String, CaseFoldingHash> HTTPHeaderSet;
-static HTTPHeaderSet* createAllowedCrossOriginResponseHeadersSet()
+static PassOwnPtr<HTTPHeaderSet> createAllowedCrossOriginResponseHeadersSet()
{
- HTTPHeaderSet* headerSet = new HashSet<String, CaseFoldingHash>;
+ OwnPtr<HTTPHeaderSet> headerSet = adoptPtr(new HashSet<String, CaseFoldingHash>);
headerSet->add("cache-control");
headerSet->add("content-language");
@@ -82,12 +82,12 @@ static HTTPHeaderSet* createAllowedCrossOriginResponseHeadersSet()
headerSet->add("last-modified");
headerSet->add("pragma");
- return headerSet;
+ return headerSet.release();
}
bool isOnAccessControlResponseHeaderWhitelist(const String& name)
{
- AtomicallyInitializedStatic(HTTPHeaderSet*, allowedCrossOriginResponseHeaders = createAllowedCrossOriginResponseHeadersSet());
+ AtomicallyInitializedStatic(HTTPHeaderSet*, allowedCrossOriginResponseHeaders = createAllowedCrossOriginResponseHeadersSet().leakPtr());
return allowedCrossOriginResponseHeaders->contains(name);
}
diff --git a/WebCore/loader/DocLoader.cpp b/WebCore/loader/DocLoader.cpp
index d63123e..d04e148 100644
--- a/WebCore/loader/DocLoader.cpp
+++ b/WebCore/loader/DocLoader.cpp
@@ -180,6 +180,7 @@ CachedXSLStyleSheet* DocLoader::requestXSLStyleSheet(const String& url)
#if ENABLE(LINK_PREFETCH)
CachedResource* DocLoader::requestLinkPrefetch(const String& url)
{
+ ASSERT(frame());
return requestResource(CachedResource::LinkPrefetch, url, String());
}
#endif
@@ -473,7 +474,7 @@ void DocLoader::requestPreload(CachedResource::Type type, const String& url, con
resource->increasePreloadCount();
if (!m_preloads)
- m_preloads.set(new ListHashSet<CachedResource*>);
+ m_preloads = adoptPtr(new ListHashSet<CachedResource*>);
m_preloads->add(resource);
#if PRELOAD_DEBUG
diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp
index 26d66e8..1e18077 100644
--- a/WebCore/loader/DocumentLoader.cpp
+++ b/WebCore/loader/DocumentLoader.cpp
@@ -91,7 +91,7 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData&
, m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired)
, m_didCreateGlobalHistoryEntry(false)
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- , m_applicationCacheHost(new ApplicationCacheHost(this))
+ , m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this)))
#endif
{
}
@@ -411,7 +411,7 @@ bool DocumentLoader::isLoadingInAPISense() const
void DocumentLoader::addAllArchiveResources(Archive* archive)
{
if (!m_archiveResourceCollection)
- m_archiveResourceCollection.set(new ArchiveResourceCollection);
+ m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection);
ASSERT(archive);
if (!archive)
@@ -425,7 +425,7 @@ void DocumentLoader::addAllArchiveResources(Archive* archive)
void DocumentLoader::addArchiveResource(PassRefPtr<ArchiveResource> resource)
{
if (!m_archiveResourceCollection)
- m_archiveResourceCollection.set(new ArchiveResourceCollection);
+ m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection);
ASSERT(resource);
if (!resource)
diff --git a/WebCore/loader/DocumentThreadableLoader.cpp b/WebCore/loader/DocumentThreadableLoader.cpp
index 16f114d..a792144 100644
--- a/WebCore/loader/DocumentThreadableLoader.cpp
+++ b/WebCore/loader/DocumentThreadableLoader.cpp
@@ -83,7 +83,7 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document* document, Threadabl
ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
- OwnPtr<ResourceRequest> crossOriginRequest(new ResourceRequest(request));
+ OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceRequest(request));
crossOriginRequest->removeCredentials();
crossOriginRequest->setAllowCookies(m_options.allowCredentials);
@@ -195,7 +195,7 @@ void DocumentThreadableLoader::didReceiveResponse(SubresourceLoader* loader, con
return;
}
- OwnPtr<CrossOriginPreflightResultCacheItem> preflightResult(new CrossOriginPreflightResultCacheItem(m_options.allowCredentials));
+ OwnPtr<CrossOriginPreflightResultCacheItem> preflightResult = adoptPtr(new CrossOriginPreflightResultCacheItem(m_options.allowCredentials));
if (!preflightResult->parse(response, accessControlErrorDescription)
|| !preflightResult->allowsCrossOriginMethod(m_actualRequest->httpMethod(), accessControlErrorDescription)
|| !preflightResult->allowsCrossOriginHeaders(m_actualRequest->httpHeaderFields(), accessControlErrorDescription)) {
diff --git a/WebCore/loader/DocumentWriter.cpp b/WebCore/loader/DocumentWriter.cpp
index d99f340..cd82d6e 100644
--- a/WebCore/loader/DocumentWriter.cpp
+++ b/WebCore/loader/DocumentWriter.cpp
@@ -72,7 +72,7 @@ void DocumentWriter::replaceDocument(const String& source)
if (!source.isNull()) {
if (!m_receivedData) {
m_receivedData = true;
- m_frame->document()->setParseMode(Document::Strict);
+ m_frame->document()->setCompatibilityMode(Document::NoQuirksMode);
}
// FIXME: This should call DocumentParser::appendBytes instead of append
@@ -179,7 +179,7 @@ TextResourceDecoder* DocumentWriter::createDecoderIfNeeded()
return m_decoder.get();
}
-void DocumentWriter::reportDataRecieved()
+void DocumentWriter::reportDataReceived()
{
ASSERT(m_decoder);
if (!m_receivedData) {
diff --git a/WebCore/loader/DocumentWriter.h b/WebCore/loader/DocumentWriter.h
index b1007ef..531a632 100644
--- a/WebCore/loader/DocumentWriter.h
+++ b/WebCore/loader/DocumentWriter.h
@@ -69,7 +69,7 @@ public:
// Exposed for DoucmentParser::appendBytes
TextResourceDecoder* createDecoderIfNeeded();
- void reportDataRecieved();
+ void reportDataReceived();
private:
PassRefPtr<Document> createDocument(const KURL&);
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index 0d30713..32722d6 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -46,10 +46,6 @@
#include "ResourceError.h"
#include "SearchPopupMenu.h"
-#if USE(GLES2_RENDERING)
-#include "GLES2Context.h"
-#endif
-
/*
This file holds empty Client stubs for use by WebCore.
Viewless element needs to create a dummy Page->Frame->FrameView tree for use in parsing or executing JavaScript.
@@ -203,11 +199,6 @@ public:
virtual void scheduleCompositingLayerSync() {};
#endif
-#if USE(GLES2_RENDERING)
- virtual PassOwnPtr<GLES2Context> getOnscreenGLES2Context() { return 0; }
- virtual PassOwnPtr<GLES2Context> getOffscreenGLES2Context() { return 0; }
-#endif
-
#if PLATFORM(WIN)
virtual void setLastSetCursorToCurrentCursor() { }
#endif
@@ -477,6 +468,10 @@ public:
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
virtual void checkTextOfParagraph(const UChar*, int, uint64_t, Vector<TextCheckingResult>&) { };
#endif
+#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ virtual void showCorrectionPanel(const FloatRect&, const String&, const String&, Editor*) { }
+ virtual void dismissCorrectionPanel(bool) { }
+#endif
virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { }
virtual void updateSpellingUIWithMisspelledWord(const String&) { }
virtual void showSpellingUI(bool) { }
diff --git a/WebCore/loader/FormSubmission.cpp b/WebCore/loader/FormSubmission.cpp
index 22e89d7..98a545e 100644
--- a/WebCore/loader/FormSubmission.cpp
+++ b/WebCore/loader/FormSubmission.cpp
@@ -162,10 +162,10 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
String boundary;
if (isMultiPartForm) {
- formData = FormData::createMultiPart(domFormData->items(), domFormData->encoding(), document);
+ formData = FormData::createMultiPart(*(static_cast<FormDataList*>(domFormData.get())), domFormData->encoding(), document);
boundary = formData->boundary().data();
} else {
- formData = FormData::create(domFormData->items(), domFormData->encoding());
+ formData = FormData::create(*(static_cast<FormDataList*>(domFormData.get())), domFormData->encoding());
if (attributes.method() == PostMethod && isMailtoForm) {
// Convert the form data into a string that we put into the URL.
appendMailtoPostFormDataToURL(actionURL, *formData, encodingType);
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index dc2c68c..496cac9 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -166,11 +166,6 @@ static int numRequests(Document* document)
return document->docLoader()->requestCount();
}
-static inline bool canReferToParentFrameEncoding(const Frame* frame, const Frame* parentFrame)
-{
- return parentFrame && parentFrame->document()->securityOrigin()->canAccess(frame->document()->securityOrigin());
-}
-
// This is not in the FrameLoader class to emphasize that it does not depend on
// private FrameLoader data, and to avoid increasing the number of public functions
// with access to private data. Since only this .cpp file needs it, making it
@@ -841,6 +836,10 @@ void FrameLoader::checkCompleted()
if (numRequests(m_frame->document()))
return;
+ // Still waiting for elements that don't go through a FrameLoader?
+ if (m_frame->document()->isDelayingLoadEvent())
+ return;
+
// OK, completed.
m_isComplete = true;
@@ -889,7 +888,7 @@ void FrameLoader::scheduleCheckLoadComplete()
void FrameLoader::checkCallImplicitClose()
{
- if (m_didCallImplicitClose || m_frame->document()->parsing())
+ if (m_didCallImplicitClose || m_frame->document()->parsing() || m_frame->document()->isDelayingLoadEvent())
return;
if (!allChildrenAreComplete())
@@ -1187,10 +1186,8 @@ void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* sta
m_client->dispatchDidNavigateWithinPage();
- if (stateObject) {
- m_frame->document()->statePopped(stateObject);
- m_client->dispatchDidPopStateWithinPage();
- }
+ m_frame->document()->statePopped(stateObject ? stateObject : SerializedScriptValue::nullValue());
+ m_client->dispatchDidPopStateWithinPage();
if (hashChange) {
m_frame->document()->enqueueHashchangeEvent(oldURL, url);
@@ -1968,7 +1965,8 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
history()->updateForBackForwardNavigation();
- if (history()->currentItem())
+ // For cached pages, CachedFrame::restore will take care of firing the popstate event with the history item's state object
+ if (history()->currentItem() && !cachedPage)
m_pendingStateObject = history()->currentItem()->stateObject();
// Create a document view for this document, or used the cached view.
@@ -2182,6 +2180,10 @@ void FrameLoader::finishedLoading()
dl->setPrimaryLoadComplete(true);
m_client->dispatchDidLoadMainResource(dl.get());
checkLoadComplete();
+
+ DOMWindow* window = m_frame->existingDOMWindow();
+ if (window && window->printDeferred())
+ window->print();
}
bool FrameLoader::isHostedByObjectElement() const
@@ -2530,6 +2532,7 @@ void FrameLoader::closeAndRemoveChild(Frame* child)
child->setView(0);
if (child->ownerElement() && child->page())
child->page()->decrementFrameCount();
+ // FIXME: The page isn't being destroyed, so it's not right to call a function named pageDestroyed().
child->pageDestroyed();
m_frame->tree()->removeChild(child);
@@ -2618,6 +2621,7 @@ void FrameLoader::detachFromParent()
parent->loader()->scheduleCheckCompleted();
} else {
m_frame->setView(0);
+ // FIXME: The page isn't being destroyed, so it's not right to call a function named pageDestroyed().
m_frame->pageDestroyed();
}
}
@@ -2670,17 +2674,19 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp
request.setCachePolicy(documentLoader()->originalRequest().cachePolicy());
else
request.setCachePolicy(UseProtocolCachePolicy);
- } else if (loadType == FrameLoadTypeReload) {
- request.setCachePolicy(ReloadIgnoringCacheData);
- request.setHTTPHeaderField("Cache-Control", "max-age=0");
- } else if (loadType == FrameLoadTypeReloadFromOrigin) {
- request.setCachePolicy(ReloadIgnoringCacheData);
- request.setHTTPHeaderField("Cache-Control", "no-cache");
- request.setHTTPHeaderField("Pragma", "no-cache");
- } else if (request.isConditional())
+ } else if (loadType == FrameLoadTypeReload || loadType == FrameLoadTypeReloadFromOrigin || request.isConditional())
request.setCachePolicy(ReloadIgnoringCacheData);
else if (isBackForwardLoadType(loadType) && m_stateMachine.committedFirstRealDocumentLoad() && !request.url().protocolIs("https"))
request.setCachePolicy(ReturnCacheDataElseLoad);
+
+ if (request.cachePolicy() == ReloadIgnoringCacheData) {
+ if (loadType == FrameLoadTypeReload)
+ request.setHTTPHeaderField("Cache-Control", "max-age=0");
+ else if (loadType == FrameLoadTypeReloadFromOrigin) {
+ request.setHTTPHeaderField("Cache-Control", "no-cache");
+ request.setHTTPHeaderField("Pragma", "no-cache");
+ }
+ }
if (mainResource)
request.setHTTPAccept(defaultAcceptHeader);
@@ -3260,11 +3266,11 @@ void FrameLoader::navigateToDifferentDocument(HistoryItem* item, FrameLoadType l
void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
{
// We do same-document navigation in the following cases:
- // - The HistoryItem corresponds to the same document.
+ // - The HistoryItem corresponds to the same document (or documents in the case of frames).
// - The HistoryItem is not the same as the current item.
HistoryItem* currentItem = history()->currentItem();
bool sameDocumentNavigation = currentItem && item != currentItem
- && item->documentSequenceNumber() == currentItem->documentSequenceNumber();
+ && item->hasSameDocuments(currentItem);
#if ENABLE(WML)
// All WML decks should go through the real load mechanism, not the scroll-to-anchor code
diff --git a/WebCore/loader/HistoryController.cpp b/WebCore/loader/HistoryController.cpp
index 144faa5..32a6a91 100644
--- a/WebCore/loader/HistoryController.cpp
+++ b/WebCore/loader/HistoryController.cpp
@@ -558,9 +558,10 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt
// to match.
// Note: If item and fromItem are the same, then we need to create a new
// document.
- if (item != fromItem && item->itemSequenceNumber() == fromItem->itemSequenceNumber()
- && ((m_frame->tree()->name().isEmpty() && item->target().isEmpty()) || m_frame->tree()->name() == item->target())
- && childFramesMatchItem(item))
+ if (item != fromItem
+ && item->itemSequenceNumber() == fromItem->itemSequenceNumber()
+ && currentFramesMatchItem(item)
+ && fromItem->hasSameFrames(item))
{
// This content is good, so leave it alone and look for children that need reloading
// Save form state (works from currentItem, since prevItem is nil)
@@ -585,7 +586,7 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt
for (int i = 0; i < size; ++i) {
String childFrameName = childItems[i]->target();
HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFrameName);
- ASSERT(fromChildItem || fromItem->isTargetItem());
+ ASSERT(fromChildItem);
Frame* childFrame = m_frame->tree()->child(childFrameName);
ASSERT(childFrame);
childFrame->loader()->history()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
@@ -595,10 +596,12 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt
}
}
-// helper method that determines whether the subframes described by the item's subitems
-// match our own current frameset
-bool HistoryController::childFramesMatchItem(HistoryItem* item) const
+// Helper method that determines whether the current frame tree matches given history item's.
+bool HistoryController::currentFramesMatchItem(HistoryItem* item) const
{
+ if ((!m_frame->tree()->name().isEmpty() || !item->target().isEmpty()) && m_frame->tree()->name() != item->target())
+ return false;
+
const HistoryItemVector& childItems = item->children();
if (childItems.size() != m_frame->tree()->childCount())
return false;
@@ -609,7 +612,6 @@ bool HistoryController::childFramesMatchItem(HistoryItem* item) const
return false;
}
- // Found matches for all item targets
return true;
}
@@ -655,12 +657,6 @@ void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject,
m_currentItem->setStateObject(stateObject);
m_currentItem->setURLString(urlString);
- // Create a null state object for the previous HistoryItem so that we will
- // generate a popstate event when navigating back to it.
- // FIXME: http://webkit.org/b/41372 implies that we shouldn't need this.
- if (!m_previousItem->stateObject())
- m_previousItem->setStateObject(SerializedScriptValue::create());
-
page->backForwardList()->addItem(topItem.release());
}
diff --git a/WebCore/loader/HistoryController.h b/WebCore/loader/HistoryController.h
index 19902f8..487fdc9 100644
--- a/WebCore/loader/HistoryController.h
+++ b/WebCore/loader/HistoryController.h
@@ -86,7 +86,7 @@ private:
PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
- bool childFramesMatchItem(HistoryItem*) const;
+ bool currentFramesMatchItem(HistoryItem*) const;
void updateBackForwardListClippedAtTarget(bool doClip);
Frame* m_frame;
diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp
index a1a9f80..702ed9d 100644
--- a/WebCore/loader/ImageDocument.cpp
+++ b/WebCore/loader/ImageDocument.cpp
@@ -177,7 +177,8 @@ ImageDocument::ImageDocument(Frame* frame, const KURL& url)
, m_didShrinkImage(false)
, m_shouldShrinkImage(shouldShrinkToFit())
{
- setParseMode(Compat);
+ setCompatibilityMode(QuirksMode);
+ lockCompatibilityMode();
}
PassRefPtr<DocumentParser> ImageDocument::createParser()
diff --git a/WebCore/loader/ImageLoader.cpp b/WebCore/loader/ImageLoader.cpp
index d169d3e..242bf94 100644
--- a/WebCore/loader/ImageLoader.cpp
+++ b/WebCore/loader/ImageLoader.cpp
@@ -31,6 +31,13 @@
#include "HTMLObjectElement.h"
#include "RenderImage.h"
+#if ENABLE(SVG)
+#include "RenderSVGImage.h"
+#endif
+#if ENABLE(VIDEO)
+#include "RenderVideo.h"
+#endif
+
#if !ASSERT_DISABLED
// ImageLoader objects are allocated as members of other objects, so generic pointer check would always fail.
namespace WTF {
@@ -130,11 +137,8 @@ void ImageLoader::setImage(CachedImage* newImage)
oldImage->removeClient(this);
}
- if (RenderObject* renderer = m_element->renderer()) {
- if (!renderer->isImage())
- return;
- toRenderImage(renderer)->resetAnimation();
- }
+ if (RenderImageResource* imageResource = renderImageResource())
+ imageResource->resetAnimation();
}
void ImageLoader::updateFromElement()
@@ -195,11 +199,8 @@ void ImageLoader::updateFromElement()
oldImage->removeClient(this);
}
- if (RenderObject* renderer = m_element->renderer()) {
- if (!renderer->isImage())
- return;
- toRenderImage(renderer)->resetAnimation();
- }
+ if (RenderImageResource* imageResource = renderImageResource())
+ imageResource->resetAnimation();
}
void ImageLoader::updateFromElementIgnoringPreviousError()
@@ -223,20 +224,42 @@ void ImageLoader::notifyFinished(CachedResource*)
loadEventSender().dispatchEventSoon(this);
}
+RenderImageResource* ImageLoader::renderImageResource()
+{
+ RenderObject* renderer = m_element->renderer();
+
+ if (!renderer)
+ return 0;
+
+ if (renderer->isImage())
+ return toRenderImage(renderer)->imageResource();
+
+#if ENABLE(SVG)
+ if (renderer->isSVGImage())
+ return toRenderSVGImage(renderer)->imageResource();
+#endif
+
+#if ENABLE(VIDEO)
+ if (renderer->isVideo())
+ return toRenderVideo(renderer)->imageResource();
+#endif
+
+ return 0;
+}
+
void ImageLoader::updateRenderer()
{
- if (RenderObject* renderer = m_element->renderer()) {
- if (!renderer->isImage() && !renderer->isVideo())
- return;
- RenderImage* imageRenderer = toRenderImage(renderer);
-
- // Only update the renderer if it doesn't have an image or if what we have
- // is a complete image. This prevents flickering in the case where a dynamic
- // change is happening between two images.
- CachedImage* cachedImage = imageRenderer->cachedImage();
- if (m_image != cachedImage && (m_imageComplete || !cachedImage))
- imageRenderer->setCachedImage(m_image.get());
- }
+ RenderImageResource* imageResource = renderImageResource();
+
+ if (!imageResource)
+ return;
+
+ // Only update the renderer if it doesn't have an image or if what we have
+ // is a complete image. This prevents flickering in the case where a dynamic
+ // change is happening between two images.
+ CachedImage* cachedImage = imageResource->cachedImage();
+ if (m_image != cachedImage && (m_imageComplete || !cachedImage))
+ imageResource->setCachedImage(m_image.get());
}
void ImageLoader::dispatchPendingBeforeLoadEvent()
diff --git a/WebCore/loader/ImageLoader.h b/WebCore/loader/ImageLoader.h
index 02ddce8..9bf7624 100644
--- a/WebCore/loader/ImageLoader.h
+++ b/WebCore/loader/ImageLoader.h
@@ -31,6 +31,7 @@ namespace WebCore {
class Element;
class ImageLoadEventSender;
+class RenderImageResource;
class ImageLoader : public CachedResourceClient {
public:
@@ -72,6 +73,7 @@ private:
void dispatchPendingBeforeLoadEvent();
void dispatchPendingLoadEvent();
+ RenderImageResource* renderImageResource();
void updateRenderer();
Element* m_element;
diff --git a/WebCore/loader/MediaDocument.cpp b/WebCore/loader/MediaDocument.cpp
index 7e28d02..77c3d1f 100644
--- a/WebCore/loader/MediaDocument.cpp
+++ b/WebCore/loader/MediaDocument.cpp
@@ -71,6 +71,9 @@ 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);");
@@ -110,7 +113,8 @@ MediaDocument::MediaDocument(Frame* frame, const KURL& url)
: HTMLDocument(frame, url)
, m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired)
{
- setParseMode(Compat);
+ setCompatibilityMode(QuirksMode);
+ lockCompatibilityMode();
}
MediaDocument::~MediaDocument()
diff --git a/WebCore/loader/PingLoader.cpp b/WebCore/loader/PingLoader.cpp
index d2c6410..60c6f30 100644
--- a/WebCore/loader/PingLoader.cpp
+++ b/WebCore/loader/PingLoader.cpp
@@ -53,7 +53,7 @@ void PingLoader::loadImage(Frame* frame, const KURL& url)
if (!SecurityOrigin::shouldHideReferrer(request.url(), frame->loader()->outgoingReferrer()))
request.setHTTPReferrer(frame->loader()->outgoingReferrer());
frame->loader()->addExtraFieldsToSubresourceRequest(request);
- OwnPtr<PingLoader> pingLoader(new PingLoader(frame, request));
+ OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
// Leak the ping loader, since it will kill itself as soon as it receives a response.
PingLoader* leakedPingLoader = pingLoader.leakPtr();
diff --git a/WebCore/loader/PluginDocument.cpp b/WebCore/loader/PluginDocument.cpp
index 54e686c..ad11dfb 100644
--- a/WebCore/loader/PluginDocument.cpp
+++ b/WebCore/loader/PluginDocument.cpp
@@ -84,6 +84,9 @@ void PluginDocumentParser::createDocumentStructure()
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");
@@ -121,7 +124,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
document()->updateLayout();
- if (RenderWidget* renderer = toRenderWidget(m_embedElement->renderer())) {
+ if (RenderPart* renderer = m_embedElement->renderPart()) {
frame->loader()->client()->redirectDataToPlugin(renderer->widget());
frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
}
@@ -132,7 +135,8 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
PluginDocument::PluginDocument(Frame* frame, const KURL& url)
: HTMLDocument(frame, url)
{
- setParseMode(Compat);
+ setCompatibilityMode(QuirksMode);
+ lockCompatibilityMode();
}
PassRefPtr<DocumentParser> PluginDocument::createParser()
diff --git a/WebCore/loader/ProgressTracker.cpp b/WebCore/loader/ProgressTracker.cpp
index 88231c8..7f61cd1 100644
--- a/WebCore/loader/ProgressTracker.cpp
+++ b/WebCore/loader/ProgressTracker.cpp
@@ -169,7 +169,7 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const Resource
item->bytesReceived = 0;
item->estimatedLength = estimatedLength;
} else
- m_progressItems.set(identifier, new ProgressItem(estimatedLength));
+ m_progressItems.set(identifier, adoptPtr(new ProgressItem(estimatedLength)).leakPtr());
}
void ProgressTracker::incrementProgress(unsigned long identifier, const char*, int length)
diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp
index 26d7787..461baf7 100644
--- a/WebCore/loader/RedirectScheduler.cpp
+++ b/WebCore/loader/RedirectScheduler.cpp
@@ -250,7 +250,7 @@ void RedirectScheduler::scheduleRedirect(double delay, const String& url)
// We want a new back/forward list item if the refresh timeout is > 1 second.
if (!m_redirect || delay <= m_redirect->delay())
- schedule(new ScheduledRedirect(delay, url, true, delay <= 1, false));
+ schedule(adoptPtr(new ScheduledRedirect(delay, url, true, delay <= 1, false)));
}
bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame, bool wasUserGesture)
@@ -294,7 +294,7 @@ void RedirectScheduler::scheduleLocationChange(const String& url, const String&
// This may happen when a frame changes the location of another frame.
bool duringLoad = !loader->stateMachine()->committedFirstRealDocumentLoad();
- schedule(new ScheduledLocationChange(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, duringLoad));
+ schedule(adoptPtr(new ScheduledLocationChange(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, duringLoad)));
}
void RedirectScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> submission)
@@ -314,7 +314,7 @@ void RedirectScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> submis
bool lockBackForwardList = mustLockBackForwardList(m_frame, UserGestureIndicator::processingUserGesture()) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
- schedule(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad));
+ schedule(adoptPtr(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad)));
}
void RedirectScheduler::scheduleRefresh(bool wasUserGesture)
@@ -325,7 +325,7 @@ void RedirectScheduler::scheduleRefresh(bool wasUserGesture)
if (url.isEmpty())
return;
- schedule(new ScheduledRefresh(url.string(), m_frame->loader()->outgoingReferrer(), wasUserGesture));
+ schedule(adoptPtr(new ScheduledRefresh(url.string(), m_frame->loader()->outgoingReferrer(), wasUserGesture)));
}
void RedirectScheduler::scheduleHistoryNavigation(int steps)
@@ -341,18 +341,8 @@ void RedirectScheduler::scheduleHistoryNavigation(int steps)
return;
}
-#if !ENABLE(HISTORY_ALWAYS_ASYNC)
- // If the specified entry and the current entry have the same document (or documents, in there are frames), this is either a
- // state object traversal or a fragment traversal (or both) and should be performed synchronously.
- HistoryItem* currentEntry = m_frame->loader()->history()->currentItem();
- if (currentEntry != specifiedEntry && currentEntry->hasSameDocuments(specifiedEntry)) {
- m_frame->loader()->history()->goToItem(specifiedEntry, FrameLoadTypeIndexedBackForward);
- return;
- }
-#endif
-
// In all other cases, schedule the history traversal to occur asynchronously.
- schedule(new ScheduledHistoryNavigation(steps));
+ schedule(adoptPtr(new ScheduledHistoryNavigation(steps)));
}
void RedirectScheduler::timerFired(Timer<RedirectScheduler>*)
diff --git a/WebCore/loader/SinkDocument.cpp b/WebCore/loader/SinkDocument.cpp
index 262d318..47535dc 100644
--- a/WebCore/loader/SinkDocument.cpp
+++ b/WebCore/loader/SinkDocument.cpp
@@ -50,7 +50,8 @@ private:
SinkDocument::SinkDocument(Frame* frame, const KURL& url)
: HTMLDocument(frame, url)
{
- setParseMode(Compat);
+ setCompatibilityMode(QuirksMode);
+ lockCompatibilityMode();
}
PassRefPtr<DocumentParser> SinkDocument::createParser()
diff --git a/WebCore/loader/SubframeLoader.cpp b/WebCore/loader/SubframeLoader.cpp
index f56ebf1..ceafb88 100644
--- a/WebCore/loader/SubframeLoader.cpp
+++ b/WebCore/loader/SubframeLoader.cpp
@@ -38,9 +38,8 @@
#include "HTMLAppletElement.h"
#include "HTMLFrameElementBase.h"
#include "HTMLNames.h"
-#include "HTMLPlugInElement.h"
+#include "HTMLPlugInImageElement.h"
#include "MIMETypeRegistry.h"
-#include "Node.h"
#include "Page.h"
#include "PluginData.h"
#include "RenderEmbeddedObject.h"
@@ -63,16 +62,6 @@ SubframeLoader::SubframeLoader(Frame* frame)
{
}
-static HTMLPlugInElement* toPlugInElement(Node* node)
-{
- if (!node)
- return 0;
-
- ASSERT(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag));
-
- return static_cast<HTMLPlugInElement*>(node);
-}
-
void SubframeLoader::clear()
{
m_containsPlugins = false;
@@ -99,7 +88,7 @@ bool SubframeLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const Str
return true;
}
-bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String& url, const AtomicString& frameName,
+bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName,
const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
{
if (url.isEmpty() && mimeType.isEmpty())
@@ -110,6 +99,12 @@ bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String&
return false;
}
+ // FIXME: None of this code should use renderers!
+ RenderEmbeddedObject* renderer = ownerElement->renderEmbeddedObject();
+ ASSERT(renderer);
+ if (!renderer)
+ return false;
+
KURL completedURL;
if (!url.isEmpty())
completedURL = completeURL(url);
@@ -126,19 +121,19 @@ bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String&
return false;
if (m_frame->document() && m_frame->document()->securityOrigin()->isSandboxed(SandboxPlugins))
return false;
- return loadPlugin(renderer, completedURL, mimeType, paramNames, paramValues, useFallback);
- }
- ASSERT(renderer->node()->hasTagName(objectTag) || renderer->node()->hasTagName(embedTag));
- HTMLPlugInElement* element = static_cast<HTMLPlugInElement*>(renderer->node());
+ ASSERT(ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embedTag));
+ HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(ownerElement);
+
+ return loadPlugin(pluginElement, completedURL, mimeType, paramNames, paramValues, useFallback);
+ }
// If the plug-in element already contains a subframe, loadOrRedirectSubframe will re-use it. Otherwise,
// it will create a new frame and set it as the RenderPart's widget, causing what was previously
// in the widget to be torn down.
- return loadOrRedirectSubframe(element, completedURL, frameName, true, true);
+ return loadOrRedirectSubframe(ownerElement, completedURL, frameName, true, true);
}
-
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const KURL& url,
const Vector<String>& paramNames, const Vector<String>& paramValues)
@@ -252,7 +247,7 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const K
marginHeight = o->getMarginHeight();
}
- if (!SecurityOrigin::canLoad(url, referrer, 0)) {
+ if (!SecurityOrigin::canLoad(url, String(), ownerElement->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return 0;
}
@@ -304,7 +299,6 @@ bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
return allowed;
}
-
bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback)
{
if (m_frame->loader()->client()->shouldUsePluginDocument(mimeType)) {
@@ -327,37 +321,46 @@ bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bo
useFallback = objectType == ObjectContentNone && hasFallback;
return objectType == ObjectContentNone || objectType == ObjectContentNetscapePlugin || objectType == ObjectContentOtherPlugin;
}
-
-bool SubframeLoader::loadPlugin(RenderEmbeddedObject* renderer, const KURL& url, const String& mimeType,
+
+Document* SubframeLoader::document() const
+{
+ return m_frame->document();
+}
+
+bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const KURL& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback)
{
- RefPtr<Widget> widget;
+ RenderEmbeddedObject* renderer = pluginElement->renderEmbeddedObject();
- if (renderer && !useFallback) {
- HTMLPlugInElement* element = toPlugInElement(renderer->node());
+ // FIXME: This code should not depend on renderer!
+ if (!renderer || useFallback)
+ return false;
- if (!SecurityOrigin::canLoad(url, String(), m_frame->document())) {
- FrameLoader::reportLocalLoadFailed(m_frame, url.string());
- return false;
- }
+ if (!SecurityOrigin::canLoad(url, String(), document())) {
+ FrameLoader::reportLocalLoadFailed(m_frame, url.string());
+ return false;
+ }
- m_frame->loader()->checkIfRunInsecureContent(m_frame->document()->securityOrigin(), url);
+ FrameLoader* frameLoader = m_frame->loader();
+ frameLoader->checkIfRunInsecureContent(document()->securityOrigin(), url);
- widget = m_frame->loader()->client()->createPlugin(IntSize(renderer->contentWidth(), renderer->contentHeight()),
- element, url, paramNames, paramValues, mimeType,
- m_frame->document()->isPluginDocument() && !m_containsPlugins);
- if (widget) {
- renderer->setWidget(widget);
- m_containsPlugins = true;
+ IntSize contentSize(renderer->contentWidth(), renderer->contentHeight());
+ bool loadManually = document()->isPluginDocument() && !m_containsPlugins;
+ RefPtr<Widget> widget = frameLoader->client()->createPlugin(contentSize,
+ pluginElement, url, paramNames, paramValues, mimeType, loadManually);
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
- renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
-#endif
- } else
- renderer->setShowsMissingPluginIndicator();
+ if (!widget) {
+ renderer->setShowsMissingPluginIndicator();
+ return false;
}
- return widget;
+ renderer->setWidget(widget);
+ m_containsPlugins = true;
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+ pluginElement->setNeedsStyleRecalc(SyntheticStyleChange);
+#endif
+ return true;
}
KURL SubframeLoader::completeURL(const String& url) const
diff --git a/WebCore/loader/SubframeLoader.h b/WebCore/loader/SubframeLoader.h
index d42ef2c..6c3baf8 100644
--- a/WebCore/loader/SubframeLoader.h
+++ b/WebCore/loader/SubframeLoader.h
@@ -40,16 +40,17 @@
namespace WebCore {
+class Document;
class Frame;
class FrameLoaderClient;
class HTMLAppletElement;
class HTMLFrameOwnerElement;
+class HTMLPlugInImageElement;
class IntSize;
class KURL;
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
class Node;
#endif
-class RenderEmbeddedObject;
class Widget;
// This is a slight misnomer. It handles the higher level logic of loading both subframes and plugins.
@@ -60,10 +61,12 @@ public:
void clear();
bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true);
- bool requestObject(RenderEmbeddedObject*, const String& url, const AtomicString& frameName,
+ bool requestObject(HTMLPlugInImageElement*, const String& url, const AtomicString& frameName,
const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+ // FIXME: This should take Element* instead of Node*, or better yet the
+ // specific type of Element which this code depends on.
PassRefPtr<Widget> loadMediaPlayerProxyPlugin(Node*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues);
#endif
@@ -76,11 +79,13 @@ public:
private:
Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement*, const KURL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList);
Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
- bool loadPlugin(RenderEmbeddedObject*, const KURL&, const String& mimeType,
+ bool loadPlugin(HTMLPlugInImageElement*, const KURL&, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
+ Document* document() const;
+
bool m_containsPlugins;
Frame* m_frame;
diff --git a/WebCore/loader/TextDocument.cpp b/WebCore/loader/TextDocument.cpp
index 5e2b774..4b09a9e 100644
--- a/WebCore/loader/TextDocument.cpp
+++ b/WebCore/loader/TextDocument.cpp
@@ -202,6 +202,8 @@ bool TextDocumentParser::finishWasCalled()
TextDocument::TextDocument(Frame* frame, const KURL& url)
: HTMLDocument(frame, url)
{
+ setCompatibilityMode(QuirksMode);
+ lockCompatibilityMode();
}
PassRefPtr<DocumentParser> TextDocument::createParser()
diff --git a/WebCore/loader/WorkerThreadableLoader.cpp b/WebCore/loader/WorkerThreadableLoader.cpp
index 4789a05..4d18c28 100644
--- a/WebCore/loader/WorkerThreadableLoader.cpp
+++ b/WebCore/loader/WorkerThreadableLoader.cpp
@@ -193,7 +193,7 @@ static void workerContextDidReceiveData(ScriptExecutionContext* context, RefPtr<
void WorkerThreadableLoader::MainThreadBridge::didReceiveData(const char* data, int lengthReceived)
{
- OwnPtr<Vector<char> > vector(new Vector<char>(lengthReceived)); // needs to be an OwnPtr for usage with createCallbackTask.
+ OwnPtr<Vector<char> > vector = adoptPtr(new Vector<char>(lengthReceived)); // needs to be an OwnPtr for usage with createCallbackTask.
memcpy(vector->data(), data, lengthReceived);
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveData, m_workerClientWrapper, vector.release()), m_taskMode);
}
diff --git a/WebCore/loader/archive/ArchiveResource.cpp b/WebCore/loader/archive/ArchiveResource.cpp
index 691f66a..7dedc93 100644
--- a/WebCore/loader/archive/ArchiveResource.cpp
+++ b/WebCore/loader/archive/ArchiveResource.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -33,31 +33,8 @@
namespace WebCore {
-PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response)
-{
- return data ? adoptRef(new ArchiveResource(data, url, response)) : 0;
-}
-
-PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName)
-{
- return data ? adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName)) : 0;
-}
-
-PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& resourceResponse)
-{
- return data ? adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, resourceResponse)) : 0;
-}
-
-ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response)
+inline ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
: SubstituteResource(url, response, data)
- , m_mimeType(response.mimeType())
- , m_textEncoding(response.textEncodingName())
- , m_shouldIgnoreWhenUnarchiving(false)
-{
-}
-
-ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName)
- : SubstituteResource(url, ResourceResponse(url, mimeType, data ? data->size() : 0, textEncoding, String()), data)
, m_mimeType(mimeType)
, m_textEncoding(textEncoding)
, m_frameName(frameName)
@@ -65,13 +42,21 @@ ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url,
{
}
-ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
- : SubstituteResource(url, response.isNull() ? ResourceResponse(url, mimeType, data ? data->size() : 0, textEncoding, String()) : response, data)
- , m_mimeType(mimeType)
- , m_textEncoding(textEncoding)
- , m_frameName(frameName)
- , m_shouldIgnoreWhenUnarchiving(false)
+PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
+{
+ if (!data)
+ return 0;
+ if (response.isNull()) {
+ unsigned dataSize = data->size();
+ return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName,
+ ResourceResponse(url, mimeType, dataSize, textEncoding, String())));
+ }
+ return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, response));
+}
+
+PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response)
{
+ return create(data, url, response.mimeType(), response.textEncodingName(), String(), response);
}
}
diff --git a/WebCore/loader/archive/ArchiveResource.h b/WebCore/loader/archive/ArchiveResource.h
index d975e04..97d6e32 100644
--- a/WebCore/loader/archive/ArchiveResource.h
+++ b/WebCore/loader/archive/ArchiveResource.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -31,32 +31,29 @@
#include "SubstituteResource.h"
-#include "PlatformString.h"
-
namespace WebCore {
class ArchiveResource : public SubstituteResource {
public:
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&);
- static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName);
- static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
-
+ static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&,
+ const String& mimeType, const String& textEncoding, const String& frameName,
+ const ResourceResponse& = ResourceResponse());
+
const String& mimeType() const { return m_mimeType; }
const String& textEncoding() const { return m_textEncoding; }
const String& frameName() const { return m_frameName; }
-
+
void ignoreWhenUnarchiving() { m_shouldIgnoreWhenUnarchiving = true; }
bool shouldIgnoreWhenUnarchiving() const { return m_shouldIgnoreWhenUnarchiving; }
private:
- ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&);
- ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName);
ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
-
+
String m_mimeType;
String m_textEncoding;
String m_frameName;
-
+
bool m_shouldIgnoreWhenUnarchiving;
};
diff --git a/WebCore/loader/archive/cf/LegacyWebArchive.cpp b/WebCore/loader/archive/cf/LegacyWebArchive.cpp
index 3a144c2..ea0ce74 100644
--- a/WebCore/loader/archive/cf/LegacyWebArchive.cpp
+++ b/WebCore/loader/archive/cf/LegacyWebArchive.cpp
@@ -233,7 +233,7 @@ PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dic
response = createResourceResponseFromPropertyListData(resourceResponseData, resourceResponseVersion);
}
- return ArchiveResource::create(SharedBuffer::create(CFDataGetBytePtr(resourceData), CFDataGetLength(resourceData)), KURL(ParsedURLString, url), mimeType, textEncoding, frameName, response);
+ return ArchiveResource::create(SharedBuffer::wrapCFData(resourceData), KURL(KURL(), url), mimeType, textEncoding, frameName, response);
}
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create()
diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp
index f708622..130b442 100644
--- a/WebCore/loader/icon/IconDatabase.cpp
+++ b/WebCore/loader/icon/IconDatabase.cpp
@@ -1846,7 +1846,7 @@ inline void readySQLiteStatement(OwnPtr<SQLiteStatement>& statement, SQLiteDatab
statement.set(0);
}
if (!statement) {
- statement.set(new SQLiteStatement(db, str));
+ statement = adoptPtr(new SQLiteStatement(db, str));
if (statement->prepare() != SQLResultOk)
LOG_ERROR("Preparing statement %s failed", str.ascii().data());
}
diff --git a/WebCore/loader/icon/IconLoader.cpp b/WebCore/loader/icon/IconLoader.cpp
index 6e2762f..877c80e 100644
--- a/WebCore/loader/icon/IconLoader.cpp
+++ b/WebCore/loader/icon/IconLoader.cpp
@@ -51,7 +51,7 @@ IconLoader::IconLoader(Frame* frame)
PassOwnPtr<IconLoader> IconLoader::create(Frame* frame)
{
- return new IconLoader(frame);
+ return adoptPtr(new IconLoader(frame));
}
IconLoader::~IconLoader()