- Revision
- 168376
- Author
- beid...@apple.com
- Date
- 2014-05-06 13:10:01 -0700 (Tue, 06 May 2014)
Log Message
"Flash of content without image" when pasting a raw image from the pasteboard
<rdar://problem/16826199> and https://bugs.webkit.org/show_bug.cgi?id=132612
Reviewed by Tim Horton.
Let an ArchiveResource be flagged as "should load immediately":
* loader/archive/ArchiveResource.cpp:
(WebCore::ArchiveResource::ArchiveResource):
* loader/archive/ArchiveResource.h:
(WebCore::ArchiveResource::setShouldLoadImmediately):
(WebCore::ArchiveResource::shouldLoadImmediately):
Set that flag on the ArchiveResource for the image.
Note we quite explicitly do this only in the "read a single image" from the pasteboard
case, because we don't want to do this synchronous step for multiple images at once
such as when pasting a WebArchive:
* editing/mac/EditorMac.mm:
(WebCore::Editor::WebContentReader::readImage):
When creating a new CachedResource, if there is an ArchiveResource that is set to
load immediately, populate the CachedResource immediately instead of scheduling a load:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (168375 => 168376)
--- trunk/Source/WebCore/ChangeLog 2014-05-06 19:48:53 UTC (rev 168375)
+++ trunk/Source/WebCore/ChangeLog 2014-05-06 20:10:01 UTC (rev 168376)
@@ -1,3 +1,29 @@
+2014-05-06 Brady Eidson <beid...@apple.com>
+
+ "Flash of content without image" when pasting a raw image from the pasteboard
+ <rdar://problem/16826199> and https://bugs.webkit.org/show_bug.cgi?id=132612
+
+ Reviewed by Tim Horton.
+
+ Let an ArchiveResource be flagged as "should load immediately":
+ * loader/archive/ArchiveResource.cpp:
+ (WebCore::ArchiveResource::ArchiveResource):
+ * loader/archive/ArchiveResource.h:
+ (WebCore::ArchiveResource::setShouldLoadImmediately):
+ (WebCore::ArchiveResource::shouldLoadImmediately):
+
+ Set that flag on the ArchiveResource for the image.
+ Note we quite explicitly do this only in the "read a single image" from the pasteboard
+ case, because we don't want to do this synchronous step for multiple images at once
+ such as when pasting a WebArchive:
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::WebContentReader::readImage):
+
+ When creating a new CachedResource, if there is an ArchiveResource that is set to
+ load immediately, populate the CachedResource immediately instead of scheduling a load:
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource):
+
2014-05-06 Alex Christensen <achristen...@webkit.org>
Unreviewed build fix for debug after r168367.
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (168375 => 168376)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2014-05-06 19:48:53 UTC (rev 168375)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2014-05-06 20:10:01 UTC (rev 168376)
@@ -542,7 +542,10 @@
typeAsFilenameWithExtension.replace('/', '.');
URL imageURL = URL::fakeURLWithRelativePart(typeAsFilenameWithExtension);
- fragment = frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(buffer, imageURL, type, emptyString(), emptyString()));
+ RefPtr<ArchiveResource> archiveResource = ArchiveResource::create(buffer, imageURL, type, emptyString(), emptyString());
+ archiveResource->setShouldLoadImmediately(true);
+
+ fragment = frame.editor().createFragmentForImageResourceAndAddResource(archiveResource.release());
return fragment;
}
Modified: trunk/Source/WebCore/loader/archive/ArchiveResource.cpp (168375 => 168376)
--- trunk/Source/WebCore/loader/archive/ArchiveResource.cpp 2014-05-06 19:48:53 UTC (rev 168375)
+++ trunk/Source/WebCore/loader/archive/ArchiveResource.cpp 2014-05-06 20:10:01 UTC (rev 168376)
@@ -39,6 +39,7 @@
, m_textEncoding(textEncoding)
, m_frameName(frameName)
, m_shouldIgnoreWhenUnarchiving(false)
+ , m_shouldLoadImmediately(false)
{
}
Modified: trunk/Source/WebCore/loader/archive/ArchiveResource.h (168375 => 168376)
--- trunk/Source/WebCore/loader/archive/ArchiveResource.h 2014-05-06 19:48:53 UTC (rev 168375)
+++ trunk/Source/WebCore/loader/archive/ArchiveResource.h 2014-05-06 20:10:01 UTC (rev 168376)
@@ -47,6 +47,9 @@
void ignoreWhenUnarchiving() { m_shouldIgnoreWhenUnarchiving = true; }
bool shouldIgnoreWhenUnarchiving() const { return m_shouldIgnoreWhenUnarchiving; }
+ void setShouldLoadImmediately(bool shouldLoadImmediately) { m_shouldLoadImmediately = shouldLoadImmediately; }
+ bool shouldLoadImmediately() const { return m_shouldLoadImmediately; }
+
private:
ArchiveResource(PassRefPtr<SharedBuffer>, const URL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
@@ -55,6 +58,7 @@
String m_frameName;
bool m_shouldIgnoreWhenUnarchiving;
+ bool m_shouldLoadImmediately;
};
}
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (168375 => 168376)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-05-06 19:48:53 UTC (rev 168375)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-05-06 20:10:01 UTC (rev 168376)
@@ -27,6 +27,7 @@
#include "config.h"
#include "CachedResourceLoader.h"
+#include "ArchiveResource.h"
#include "CachedCSSStyleSheet.h"
#include "CachedSVGDocument.h"
#include "CachedFont.h"
@@ -51,6 +52,7 @@
#include "PingLoader.h"
#include "PlatformStrategies.h"
#include "RenderElement.h"
+#include "ResourceBuffer.h"
#include "ResourceLoadScheduler.h"
#include "ScriptController.h"
#include "SecurityOrigin.h"
@@ -467,9 +469,17 @@
resource->setLoadPriority(request.priority());
if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) {
- resource->load(this, request.options());
+ ArchiveResource* archiveResource = m_documentLoader ? m_documentLoader->archiveResourceForURL(request.resourceRequest().url()) : nullptr;
- // We don't support immediate loads, but we do support immediate failure.
+ if (archiveResource && archiveResource->shouldLoadImmediately()) {
+ resource->responseReceived(resource->response());
+ RefPtr<ResourceBuffer> buffer = ResourceBuffer::adoptSharedBuffer(archiveResource->data());
+ resource->finishLoading(buffer.get());
+ resource->finish();
+ } else
+ resource->load(this, request.options());
+
+ // We only sometimes support immediate loads, but we always support immediate failure.
if (resource->errorOccurred()) {
if (resource->inCache())
memoryCache()->remove(resource.get());