Reviewed by Anders and Steve.
Add a flag to DocLoader to prevent it from reloading
when performing a paste or drop operation.
Remove m_cachePolicy from CachedResource as it is never used
Fixes rdar://problem/
5044366 : REGRESSION: Repro ASSERT failures
dragging image into GMail message in _web_writeImage and
documentFragmentFromDragData
* editing/Editor.cpp:
(WebCore::Editor::paste):
prevent the docloader from reloading resources on paste
* html/HTMLImageLoader.cpp:
(WebCore::HTMLImageLoader::updateFromElement):
* loader/Cache.cpp:
(WebCore::createResource):
* loader/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
* loader/CachedCSSStyleSheet.h:
* loader/CachedImage.cpp:
(WebCore::CachedImage::CachedImage):
* loader/CachedImage.h:
* loader/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
* loader/CachedResource.h:
* loader/CachedScript.cpp:
(WebCore::CachedScript::CachedScript):
* loader/CachedScript.h:
* loader/CachedXBLDocument.cpp:
(WebCore::CachedXBLDocument::CachedXBLDocument):
* loader/CachedXBLDocument.h:
* loader/CachedXSLStyleSheet.cpp:
(WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet):
* loader/CachedXSLStyleSheet.h:
* loader/DocLoader.cpp:
(WebCore::DocLoader::DocLoader):
Tidy up constructor initialise new field
(WebCore::DocLoader::checkForReload):
Prevent reload when pasting
* loader/DocLoader.h:
(WebCore::DocLoader::setPasteInProgress):
new field and setter
* page/DragController.cpp:
(WebCore::DragController::concludeDrag):
prevent the docloader from reloading resources on drop
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20567
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-03-28 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Anders and Steve.
+
+ Add a flag to DocLoader to prevent it from reloading
+ when performing a paste or drop operation.
+
+ Remove m_cachePolicy from CachedResource as it is never used
+
+ Fixes rdar://problem/5044366 : REGRESSION: Repro ASSERT failures
+ dragging image into GMail message in _web_writeImage and
+ documentFragmentFromDragData
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::paste):
+ prevent the docloader from reloading resources on paste
+ * html/HTMLImageLoader.cpp:
+ (WebCore::HTMLImageLoader::updateFromElement):
+ * loader/Cache.cpp:
+ (WebCore::createResource):
+ * loader/CachedCSSStyleSheet.cpp:
+ (WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
+ * loader/CachedCSSStyleSheet.h:
+ * loader/CachedImage.cpp:
+ (WebCore::CachedImage::CachedImage):
+ * loader/CachedImage.h:
+ * loader/CachedResource.cpp:
+ (WebCore::CachedResource::CachedResource):
+ * loader/CachedResource.h:
+ * loader/CachedScript.cpp:
+ (WebCore::CachedScript::CachedScript):
+ * loader/CachedScript.h:
+ * loader/CachedXBLDocument.cpp:
+ (WebCore::CachedXBLDocument::CachedXBLDocument):
+ * loader/CachedXBLDocument.h:
+ * loader/CachedXSLStyleSheet.cpp:
+ (WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet):
+ * loader/CachedXSLStyleSheet.h:
+ * loader/DocLoader.cpp:
+ (WebCore::DocLoader::DocLoader):
+ Tidy up constructor initialise new field
+ (WebCore::DocLoader::checkForReload):
+ Prevent reload when pasting
+ * loader/DocLoader.h:
+ (WebCore::DocLoader::setPasteInProgress):
+ new field and setter
+ * page/DragController.cpp:
+ (WebCore::DragController::concludeDrag):
+ prevent the docloader from reloading resources on drop
+
2007-03-27 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
Not reviewed - fix typo in gdk build.
#include "ClipboardEvent.h"
#include "DeleteButtonController.h"
#include "DeleteSelectionCommand.h"
+#include "DocLoader.h"
#include "Document.h"
#include "DocumentFragment.h"
#include "EditCommand.h"
void Editor::paste()
{
+ ASSERT(m_frame->document());
+ DocLoader* loader = m_frame->document()->docLoader();
#if PLATFORM(MAC)
// using the platform independent code below requires moving all of
// WEBHTMLView: _documentFragmentFromPasteboard over to PasteboardMac.
+ loader->setPasteInProgress(true);
m_frame->issuePasteCommand();
+ loader->setPasteInProgress(false);
#else
if (tryDHTMLPaste())
return; // DHTML did the whole operation
if (!canPaste())
return;
+ loader->setPasteInProgress(true);
if (m_frame->selectionController()->isContentRichlyEditable())
pasteWithPasteboard(Pasteboard::generalPasteboard(), true);
else
pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
+ loader->setPasteInProgress(false);
#endif
}
if (!attr.isEmpty()) {
if (m_loadManually) {
doc->docLoader()->setAutoLoadImages(false);
- newImage = new CachedImage(doc->docLoader(), parseURL(attr), CachePolicyVerify, 0);
+ newImage = new CachedImage(doc->docLoader(), parseURL(attr), 0);
newImage->setLoading(true);
doc->docLoader()->m_docResources.set(newImage->url(), newImage);
} else
switch (type) {
case CachedResource::ImageResource:
// User agent images need to null check the docloader. No other resources need to.
- return new CachedImage(docLoader, url.url(), docLoader ? docLoader->cachePolicy() : CachePolicyCache, expireDate);
+ return new CachedImage(docLoader, url.url(), expireDate);
case CachedResource::CSSStyleSheet:
- return new CachedCSSStyleSheet(docLoader, url.url(), docLoader->cachePolicy(), expireDate, *charset, skipCanLoadCheck);
+ return new CachedCSSStyleSheet(docLoader, url.url(), expireDate, *charset, skipCanLoadCheck);
case CachedResource::Script:
- return new CachedScript(docLoader, url.url(), docLoader->cachePolicy(), expireDate, *charset);
+ return new CachedScript(docLoader, url.url(), expireDate, *charset);
#if ENABLE(XSLT)
case CachedResource::XSLStyleSheet:
- return new CachedXSLStyleSheet(docLoader, url.url(), docLoader->cachePolicy(), expireDate);
+ return new CachedXSLStyleSheet(docLoader, url.url(), expireDate);
#endif
#if ENABLE(XBL)
case CachedResource::XBLStyleSheet:
- return new CachedXBLDocument(docLoader, url.url(), docLoader->cachePolicy(), expireDate);
+ return new CachedXBLDocument(docLoader, url.url(), expireDate);
#endif
default:
break;
namespace WebCore {
-CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const String& url, CachePolicy cachePolicy, time_t _expireDate, const String& charset, bool skipCanLoadCheck)
- : CachedResource(url, CSSStyleSheet, cachePolicy, _expireDate)
+CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const String& url, time_t _expireDate, const String& charset, bool skipCanLoadCheck)
+ : CachedResource(url, CSSStyleSheet, _expireDate)
, m_decoder(new TextResourceDecoder("text/css", charset))
{
// Prefer text/css but accept any type (dell.com serves a stylesheet
class CachedCSSStyleSheet : public CachedResource {
public:
- CachedCSSStyleSheet(DocLoader*, const String& URL, CachePolicy, time_t expireDate, const String& charset, bool skipCanLoadCheck = false);
+ CachedCSSStyleSheet(DocLoader*, const String& URL, time_t expireDate, const String& charset, bool skipCanLoadCheck = false);
virtual ~CachedCSSStyleSheet();
const String& sheet() const { return m_sheet; }
namespace WebCore {
-CachedImage::CachedImage(DocLoader* docLoader, const String& url, CachePolicy cachePolicy, time_t _expireDate)
- : CachedResource(url, ImageResource, cachePolicy, _expireDate)
+CachedImage::CachedImage(DocLoader* docLoader, const String& url, time_t _expireDate)
+ : CachedResource(url, ImageResource, _expireDate)
{
m_image = 0;
m_status = Unknown;
}
CachedImage::CachedImage(Image* image)
- : CachedResource(String(), ImageResource, CachePolicyCache, 0)
+ : CachedResource(String(), ImageResource, 0)
{
m_image = image;
m_status = Cached;
class CachedImage : public CachedResource, public ImageObserver {
public:
- CachedImage(DocLoader*, const String& url, CachePolicy, time_t expireDate);
+ CachedImage(DocLoader*, const String& url, time_t expireDate);
CachedImage(Image*);
virtual ~CachedImage();
namespace WebCore {
-CachedResource::CachedResource(const String& URL, Type type, CachePolicy cachePolicy, unsigned size)
+CachedResource::CachedResource(const String& URL, Type type, unsigned size)
{
m_url = URL;
m_type = type;
m_status = Pending;
m_encodedSize = size;
m_inCache = false;
- m_cachePolicy = cachePolicy;
m_request = 0;
m_expireDateChanged = false;
#ifndef CachedResource_h
#define CachedResource_h
-#include "CachePolicy.h"
#include "PlatformString.h"
#include "ResourceResponse.h"
#include "SharedBuffer.h"
Cached // regular case
};
- CachedResource(const String& URL, Type type, CachePolicy cachePolicy, unsigned encodedSize = 0);
+ CachedResource(const String& URL, Type type, unsigned encodedSize = 0);
virtual ~CachedResource();
virtual void setEncoding(const String&) { }
void setInCache(bool b) { m_inCache = b; }
bool inCache() const { return m_inCache; }
- CachePolicy cachePolicy() const { return m_cachePolicy; }
-
void setRequest(Request*);
SharedBuffer* data() const { return m_data.get(); }
unsigned m_liveAccessCount;
protected:
- CachePolicy m_cachePolicy;
bool m_inCache;
bool m_loading;
bool m_expireDateChanged;
namespace WebCore {
-CachedScript::CachedScript(DocLoader* dl, const String& url, CachePolicy cachePolicy, time_t _expireDate, const String& charset)
- : CachedResource(url, Script, cachePolicy, _expireDate)
+CachedScript::CachedScript(DocLoader* dl, const String& url, time_t _expireDate, const String& charset)
+ : CachedResource(url, Script, _expireDate)
, m_encoding(charset)
{
// It's javascript we want.
class CachedScript : public CachedResource {
public:
- CachedScript(DocLoader*, const String& URL, CachePolicy, time_t expireDate, const String& charset);
+ CachedScript(DocLoader*, const String& URL, time_t expireDate, const String& charset);
virtual ~CachedScript();
const String& script() const { return m_script; }
namespace WebCore {
-CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const String &url, CachePolicy cachePolicy, time_t _expireDate)
-: CachedResource(url, XBL, cachePolicy, _expireDate), m_document(0)
+CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const String &url, time_t _expireDate)
+: CachedResource(url, XBL, _expireDate), m_document(0)
{
// It's XML we want.
setAccept("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml");
#if ENABLE(XBL)
class CachedXBLDocument : public CachedResource {
public:
- CachedXBLDocument(DocLoader*, const String& url, CachePolicy, time_t expireDate);
+ CachedXBLDocument(DocLoader*, const String& url, time_t expireDate);
virtual ~CachedXBLDocument();
XBL::XBLDocument* document() const { return m_document; }
#if ENABLE(XSLT)
-CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const String &url, CachePolicy cachePolicy, time_t _expireDate)
- : CachedResource(url, XSLStyleSheet, cachePolicy, _expireDate)
+CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const String &url, time_t _expireDate)
+ : CachedResource(url, XSLStyleSheet, _expireDate)
, m_decoder(new TextResourceDecoder("text/xsl"))
{
// It's XML we want.
#if ENABLE(XSLT)
class CachedXSLStyleSheet : public CachedResource {
public:
- CachedXSLStyleSheet(DocLoader*, const String& url, CachePolicy, time_t expireDate);
+ CachedXSLStyleSheet(DocLoader*, const String& url, time_t expireDate);
const String& sheet() const { return m_sheet; }
namespace WebCore {
DocLoader::DocLoader(Frame *frame, Document* doc)
-: m_cache(cache())
+ : m_cache(cache())
+ , m_expireDate(0)
+ , m_cachePolicy(CachePolicyVerify)
+ , m_frame(frame)
+ , m_doc(doc)
+ , m_autoLoadImages(true)
+ , m_loadInProgress(false)
+ , m_pasteInProgress(false)
{
- m_cachePolicy = CachePolicyVerify;
- m_expireDate = 0;
- m_autoLoadImages = true;
- m_frame = frame;
- m_doc = doc;
- m_loadInProgress = false;
-
m_cache->addDocLoader(this);
}
void DocLoader::checkForReload(const KURL& fullURL)
{
+ if (m_pasteInProgress)
+ return; //Don't reload resources while pasting
if (m_cachePolicy == CachePolicyVerify) {
if (!m_reloadedURLs.contains(fullURL.url())) {
CachedResource* existing = cache()->resourceForURL(fullURL.url());
void setLoadInProgress(bool);
bool loadInProgress() const { return m_loadInProgress; }
+
+ void setPasteInProgress(bool pasteInProgress) { m_pasteInProgress = pasteInProgress; }
private:
CachedResource* requestResource(CachedResource::Type, const String& url, const String* charset = 0, bool skipCanLoadCheck = false);
mutable HashMap<String, CachedResource*> m_docResources;
time_t m_expireDate;
CachePolicy m_cachePolicy;
- bool m_autoLoadImages : 1;
Frame* m_frame;
Document *m_doc;
- bool m_loadInProgress;
+
+ //29 bits left
+ bool m_autoLoadImages : 1;
+ bool m_loadInProgress : 1;
+ bool m_pasteInProgress : 1;
};
}
#include "CSSStyleDeclaration.h"
#include "Document.h"
#include "DocumentFragment.h"
+#include "DocLoader.h"
#include "DragActions.h"
#include "Editor.h"
#include "EditorClient.h"
Selection dragCaret(m_page->dragCaretController()->selection());
m_page->dragCaretController()->clear();
RefPtr<Range> range = dragCaret.toRange();
+ DocLoader* loader = range->ownerDocument()->docLoader();
+ loader->setPasteInProgress(true);
if (dragIsMove(innerFrame->selectionController(), dragData) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false;
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, range, true, chosePlainText);
- if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped))
+ if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
+ loader->setPasteInProgress(false);
return false;
+ }
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
if (dragIsMove(innerFrame->selectionController(), dragData)) {
}
} else {
String text = dragData->asPlainText();
- if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped))
+ if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
+ loader->setPasteInProgress(false);
return false;
+ }
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
if (setSelectionToDragCaret(innerFrame, dragCaret, range, point))
applyCommand(new ReplaceSelectionCommand(m_document, createFragmentFromText(range.get(), text), true, false, true));
}
+ loader->setPasteInProgress(false);
return true;
}