LayoutTests:
authorgdennis <gdennis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2007 04:57:21 +0000 (04:57 +0000)
committergdennis <gdennis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2007 04:57:21 +0000 (04:57 +0000)
        Reviewed by Maciej.

        - test for http://bugs.webkit.org/show_bug.cgi?id=10725
          Image data in from RTFD clipboard data thrown away

        * editing/pasteboard/paste-RTFD-expected.checksum: Added.
        * editing/pasteboard/paste-RTFD-expected.png: Added.
        * editing/pasteboard/paste-RTFD-expected.txt: Added.
        * editing/pasteboard/paste-RTFD.html: Added.
        * editing/pasteboard/paste-TIFF-expected.checksum: Added.
        * editing/pasteboard/paste-TIFF-expected.png: Added.
        * editing/pasteboard/paste-TIFF-expected.txt: Added.
        * editing/pasteboard/paste-TIFF.html: Added.
        * editing/resources/RTFD-pasteboard-data.dat: Added.
        * editing/resources/TIFF-pasteboard-data.dat: Added.

WebCore:

        Reviewed by Maciej.

        Part of fix for http://bugs.webkit.org/show_bug.cgi?id=10725
        Image data in from RTFD clipboard data thrown away

        ResourceHandles no longer need to be able to defer loading as that is
        now handled by the ResourceLoader.

        * loader/MainResourceLoader.cpp:
        (WebCore::MainResourceLoader::loadNow): updated to remove defersLoading argument.
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::releaseResources): release the deferred request.
        (WebCore::ResourceLoader::load): defer creating the ResourceHandle instead of
        asking the ResourceHandle to defer loading.
        (WebCore::ResourceLoader::setDefersLoading): create the ResourceHandle if we have deferred creating it.
        * loader/ResourceLoader.h:
        * platform/network/ResourceHandle.cpp: ResourceHandle's don't need to know about deferLoading.
        (WebCore::ResourceHandle::ResourceHandle):
        (WebCore::ResourceHandle::create):
        * platform/network/ResourceHandle.h: ditto.
        * platform/network/ResourceHandleInternal.h: ditto.
        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
        * platform/network/mac/ResourceHandleMac.mm: ditto.
        (WebCore::ResourceHandle::start):

WebKit:

        Reviewed by Maciej.

        Part of fix for http://bugs.webkit.org/show_bug.cgi?id=10725
        Image data in from RTFD clipboard data thrown away

        The URLs for images in RTFD data must not be loaded until the resources
        have been added to the WebUnarchivingState. This can't happen until
        after the RTFD data has been parsed, so we must delay loading while this
        RTFD data is being parsed to a document fragment.

        * WebView/WebHTMLView.mm:
        (uniqueURLWithRelativePart):
        (-[WebHTMLView _documentFragmentFromPasteboard:inContext:allowPlainText:chosePlainText:]): defer loading the resources while RTFD data is being parsed.
        (+[NSURL _web_uniqueWebDataURL]): Added this back because AppKit uses it.
        * WebView/WebUnarchivingState.m:
        (-[WebUnarchivingState archivedResourceForURL:]): orkaround for workaround for rdar://problem/4699166 so that other people can use archivedResourceForURL: too.

WebKitTools:

        Reviewed by Maciej.

        Enables layout test for: http://bugs.webkit.org/show_bug.cgi?id=10725
        Image data in from RTFD clipboard data thrown away

        - This method is needed because NSArray's ar bridged to JS Array's,
          which in turn are bridged back to WebScriptObject's when passed from
          JS to ObjC. Hence it is not possbile to pass an NSArray from JS.

        * DumpRenderTree/DumpRenderTree.m:
        (-[DumpRenderTreePasteboard declareType:owner:]): Added a convenience method for JS.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19244 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/paste-RTFD-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-RTFD-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-RTFD-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-RTFD.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-TIFF-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-TIFF-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-TIFF-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-TIFF.html [new file with mode: 0644]
LayoutTests/editing/resources/RTFD-pasteboard-data.dat [new file with mode: 0644]
LayoutTests/editing/resources/TIFF-pasteboard-data.dat [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/MainResourceLoader.cpp
WebCore/loader/ResourceLoader.cpp
WebCore/loader/ResourceLoader.h
WebCore/platform/network/ResourceHandle.cpp
WebCore/platform/network/ResourceHandle.h
WebCore/platform/network/ResourceHandleInternal.h
WebCore/platform/network/mac/ResourceHandleMac.mm
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.mm
WebKit/WebView/WebUnarchivingState.m
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.m

index 05c1255..754d1b7 100644 (file)
@@ -1,3 +1,21 @@
+2007-01-29  Graham Dennis  <graham.dennis@gmail.com>
+
+        Reviewed by Maciej.
+        
+        - test for http://bugs.webkit.org/show_bug.cgi?id=10725
+          Image data in from RTFD clipboard data thrown away
+
+        * editing/pasteboard/paste-RTFD-expected.checksum: Added.
+        * editing/pasteboard/paste-RTFD-expected.png: Added.
+        * editing/pasteboard/paste-RTFD-expected.txt: Added.
+        * editing/pasteboard/paste-RTFD.html: Added.
+        * editing/pasteboard/paste-TIFF-expected.checksum: Added.
+        * editing/pasteboard/paste-TIFF-expected.png: Added.
+        * editing/pasteboard/paste-TIFF-expected.txt: Added.
+        * editing/pasteboard/paste-TIFF.html: Added.
+        * editing/resources/RTFD-pasteboard-data.dat: Added.
+        * editing/resources/TIFF-pasteboard-data.dat: Added.
+
 2007-01-29  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/editing/pasteboard/paste-RTFD-expected.checksum b/LayoutTests/editing/pasteboard/paste-RTFD-expected.checksum
new file mode 100644 (file)
index 0000000..30d2a09
--- /dev/null
@@ -0,0 +1 @@
+1a19af1ed3bdc0e1b11382b229301784
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/paste-RTFD-expected.png b/LayoutTests/editing/pasteboard/paste-RTFD-expected.png
new file mode 100644 (file)
index 0000000..c427af3
Binary files /dev/null and b/LayoutTests/editing/pasteboard/paste-RTFD-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/paste-RTFD-expected.txt b/LayoutTests/editing/pasteboard/paste-RTFD-expected.txt
new file mode 100644 (file)
index 0000000..a0b048f
--- /dev/null
@@ -0,0 +1,36 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of P > DIV > DIV > BODY > HTML > #document to 0 of P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x260 [border: (2px solid #FF0000)]
+        RenderBlock {DIV} at (14,14) size 756x0
+        RenderBlock {DIV} at (14,14) size 756x28
+          RenderBR {BR} at (0,0) size 0x28
+        RenderBlock {DIV} at (14,42) size 756x204
+          RenderBlock {P} at (0,0) size 756x14
+            RenderBR {BR} at (0,0) size 0x14
+          RenderBlock {P} at (0,14) size 756x14
+            RenderText {#text} at (0,0) size 86x14
+              text run at (0,0) width 86: "this is some text"
+          RenderBlock {P} at (0,28) size 756x14
+            RenderBR {BR} at (0,0) size 0x14
+          RenderBlock {P} at (0,42) size 756x120
+            RenderImage {IMG} at (0,0) size 180x120
+          RenderBlock {P} at (0,162) size 756x14
+            RenderBR {BR} at (0,0) size 0x14
+          RenderBlock {P} at (0,176) size 756x14
+            RenderText {#text} at (0,0) size 117x14
+              text run at (0,0) width 117: "this is some more text"
+          RenderBlock {P} at (0,190) size 756x14
+            RenderBR {BR} at (0,0) size 0x14
+          RenderBlock (anonymous) at (0,204) size 756x0
+      RenderBlock {DIV} at (0,260) size 784x0
+caret: position 0 of child 0 {BR} of child 12 {P} of child 4 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/paste-RTFD.html b/LayoutTests/editing/pasteboard/paste-RTFD.html
new file mode 100644 (file)
index 0000000..b4b08f3
--- /dev/null
@@ -0,0 +1,58 @@
+<html>
+<head>
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+
+function print(message) {
+    var paragraph = document.createElement('p');
+    paragraph.appendChild(document.createTextNode(message));
+    document.getElementById('console').appendChild(paragraph);
+}
+
+function editingTest() {
+    if (!window.objCPlugin)
+        return print('FAIL - no objCPlugin');
+
+    objCPlugin.removeBridgeRestrictions_(window);
+    if (!window.objc)
+        return print('FAIL - no window.objc');
+
+    // get the data for the pasteboard
+    var myURL = document.URL;
+    var resourceURL = myURL.replace('pasteboard/paste-RTFD.html','resources/RTFD-pasteboard-data.dat');
+    var data = objc('NSData').dataWithContentsOfURL_(objc('NSURL').URLWithString_(resourceURL));
+    
+    // This actually returns DumpRenderTree's local pasteboard
+    var pasteboard = objc('NSPasteboard').generalPasteboard();
+    var pasteboardType = 'NeXT RTFD pasteboard type';
+
+    pasteboard.declareType_owner_(pasteboardType, 0);
+    pasteboard.setData_forType_(data, pasteboardType);
+    
+    pasteCommand();
+    
+    
+}
+</script>
+
+<title>RTFD paste test</title>
+</head>
+<body>
+<div contentEditable="true" id="root" class="editing">
+<div id="test"> </div>
+</div>
+<div id='console'/>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/paste-TIFF-expected.checksum b/LayoutTests/editing/pasteboard/paste-TIFF-expected.checksum
new file mode 100644 (file)
index 0000000..54d38c3
--- /dev/null
@@ -0,0 +1 @@
+28119df9c2edf952117a5b89bbf20575
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/paste-TIFF-expected.png b/LayoutTests/editing/pasteboard/paste-TIFF-expected.png
new file mode 100644 (file)
index 0000000..f0e2181
Binary files /dev/null and b/LayoutTests/editing/pasteboard/paste-TIFF-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/paste-TIFF-expected.txt b/LayoutTests/editing/pasteboard/paste-TIFF-expected.txt
new file mode 100644 (file)
index 0000000..d06db36
--- /dev/null
@@ -0,0 +1,18 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x125 [border: (2px solid #FF0000)]
+        RenderBlock (anonymous) at (14,14) size 756x97
+          RenderImage {IMG} at (0,0) size 593x97
+        RenderBlock {DIV} at (14,111) size 756x0
+      RenderBlock {DIV} at (0,125) size 784x0
+caret: position 1 of child 0 {IMG} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/paste-TIFF.html b/LayoutTests/editing/pasteboard/paste-TIFF.html
new file mode 100644 (file)
index 0000000..b8e2b73
--- /dev/null
@@ -0,0 +1,58 @@
+<html>
+<head>
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+
+function print(message) {
+    var paragraph = document.createElement('p');
+    paragraph.appendChild(document.createTextNode(message));
+    document.getElementById('console').appendChild(paragraph);
+}
+
+function editingTest() {
+    if (!window.objCPlugin)
+        return print('FAIL - no objCPlugin');
+
+    objCPlugin.removeBridgeRestrictions_(window);
+    if (!window.objc)
+        return print('FAIL - no window.objc');
+
+    // get the data for the pasteboard
+    var myURL = document.URL;
+    var resourceURL = myURL.replace('pasteboard/paste-TIFF.html','resources/TIFF-pasteboard-data.dat');
+    var data = objc('NSData').dataWithContentsOfURL_(objc('NSURL').URLWithString_(resourceURL));
+    
+    // This actually returns DumpRenderTree's local pasteboard
+    var pasteboard = objc('NSPasteboard').generalPasteboard();
+    var pasteboardType = 'NeXT TIFF v4.0 pasteboard type';
+
+    pasteboard.declareType_owner_(pasteboardType, 0);
+    pasteboard.setData_forType_(data, pasteboardType);
+    
+    pasteCommand();
+    
+    
+}
+</script>
+
+<title>Image (TIFF) paste test</title>
+</head>
+<body>
+<div contentEditable="true" id="root" class="editing">
+<div id="test"> </div>
+</div>
+<div id='console'/>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/editing/resources/RTFD-pasteboard-data.dat b/LayoutTests/editing/resources/RTFD-pasteboard-data.dat
new file mode 100644 (file)
index 0000000..5ea78be
Binary files /dev/null and b/LayoutTests/editing/resources/RTFD-pasteboard-data.dat differ
diff --git a/LayoutTests/editing/resources/TIFF-pasteboard-data.dat b/LayoutTests/editing/resources/TIFF-pasteboard-data.dat
new file mode 100644 (file)
index 0000000..9739923
Binary files /dev/null and b/LayoutTests/editing/resources/TIFF-pasteboard-data.dat differ
index 07e46b3..72b9d44 100644 (file)
@@ -1,3 +1,30 @@
+2007-01-30  Graham Dennis  <graham.dennis@gmail.com>
+
+        Reviewed by Maciej.
+
+        Part of fix for http://bugs.webkit.org/show_bug.cgi?id=10725
+        Image data in from RTFD clipboard data thrown away
+        
+        ResourceHandles no longer need to be able to defer loading as that is
+        now handled by the ResourceLoader.
+
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::loadNow): updated to remove defersLoading argument.
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::releaseResources): release the deferred request.
+        (WebCore::ResourceLoader::load): defer creating the ResourceHandle instead of
+        asking the ResourceHandle to defer loading.
+        (WebCore::ResourceLoader::setDefersLoading): create the ResourceHandle if we have deferred creating it.
+        * loader/ResourceLoader.h:
+        * platform/network/ResourceHandle.cpp: ResourceHandle's don't need to know about deferLoading.
+        (WebCore::ResourceHandle::ResourceHandle):
+        (WebCore::ResourceHandle::create):
+        * platform/network/ResourceHandle.h: ditto.
+        * platform/network/ResourceHandleInternal.h: ditto.
+        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+        * platform/network/mac/ResourceHandleMac.mm: ditto.
+        (WebCore::ResourceHandle::start):
+
 2007-01-29  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Alice
index 4b67744..d1f8646 100644 (file)
@@ -354,7 +354,7 @@ bool MainResourceLoader::loadNow(ResourceRequest& r)
     else if (shouldLoadEmpty || frameLoader()->representationExistsForURLScheme(url.protocol()))
         handleEmptyLoad(url, !shouldLoadEmpty);
     else
-        m_handle = ResourceHandle::create(r, this, m_frame.get(), false, true);
+        m_handle = ResourceHandle::create(r, this, m_frame.get(), true);
 
     return false;
 }
index fb0f617..3e56baf 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -87,11 +88,13 @@ void ResourceLoader::releaseResources()
 #endif
     m_handle = 0;
     m_resourceData = 0;
+    m_deferredRequest = 0;
 }
 
 bool ResourceLoader::load(const ResourceRequest& r)
 {
     ASSERT(!m_handle);
+    ASSERT(m_deferrerdRequest.isNull());
     ASSERT(!frameLoader()->isArchiveLoadPending(this));
     
     m_originalURL = r.url();
@@ -106,7 +109,12 @@ bool ResourceLoader::load(const ResourceRequest& r)
     if (frameLoader()->willUseArchive(this, clientRequest, m_originalURL))
         return true;
     
-    m_handle = ResourceHandle::create(clientRequest, this, m_frame.get(), m_defersLoading);
+    if (m_defersLoading) {
+        m_deferredRequest = clientRequest;
+        return true;
+    }
+    
+    m_handle = ResourceHandle::create(clientRequest, this, m_frame.get());
 
     return true;
 }
@@ -114,8 +122,11 @@ bool ResourceLoader::load(const ResourceRequest& r)
 void ResourceLoader::setDefersLoading(bool defers)
 {
     m_defersLoading = defers;
-    if (m_handle)
-        m_handle->setDefersLoading(defers);
+    if (!defers && !m_deferredRequest.isNull()) {
+        ResourceRequest request(m_deferredRequest);
+        m_deferredRequest = 0;
+        load(request);
+    }
 }
 
 FrameLoader* ResourceLoader::frameLoader() const
index c26a649..e2fd16f 100644 (file)
@@ -140,6 +140,7 @@ protected:
         KURL m_originalURL;
         RefPtr<SharedBuffer> m_resourceData;
         bool m_defersLoading;
+        ResourceRequest m_deferredRequest;
     };
 
 }
index 0d6e9dc..8f65792 100644 (file)
 
 namespace WebCore {
 
-ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool mightDownloadFromHandle)
-    : d(new ResourceHandleInternal(this, request, client, defersLoading, mightDownloadFromHandle))
+ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool mightDownloadFromHandle)
+    : d(new ResourceHandleInternal(this, request, client, mightDownloadFromHandle))
 {
 }
 
-PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, ResourceHandleClient* client, Frame* frame, bool defersLoading, bool mightDownloadFromHandle)
+PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, ResourceHandleClient* client, Frame* frame, bool mightDownloadFromHandle)
 {
-    RefPtr<ResourceHandle> newLoader(new ResourceHandle(request, client, defersLoading, mightDownloadFromHandle));
+    RefPtr<ResourceHandle> newLoader(new ResourceHandle(request, client, mightDownloadFromHandle));
     
     if (newLoader->start(frame))
         return newLoader.release();
index 9844f11..fb250b6 100644 (file)
@@ -84,11 +84,11 @@ template <typename T> class Timer;
 
 class ResourceHandle : public Shared<ResourceHandle> {
 private:
-    ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool mightDownloadFromHandle);
+    ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool mightDownloadFromHandle);
 
 public:
     // FIXME: should not need the Frame
-    static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, Frame*, bool defersLoading, bool mightDownloadFromHandle = false);
+    static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, Frame*, bool mightDownloadFromHandle = false);
 
     static void loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data);
     static bool willLoadFromCache(ResourceRequest&);
@@ -139,7 +139,6 @@ public:
     void cancel();
     
     ResourceHandleClient* client() const;
-    void setDefersLoading(bool);
       
     const HTTPHeaderMap& requestHeaders() const;
     const KURL& url() const;
index 8bf6813..ef09bb1 100644 (file)
@@ -65,11 +65,10 @@ namespace WebCore {
 
     class ResourceHandleInternal : Noncopyable {
     public:
-        ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool mightDownloadFromHandle)
+        ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool mightDownloadFromHandle)
             : m_client(c)
             , m_request(request)
             , status(0)
-            , m_defersLoading(defersLoading)
             , m_mightDownloadFromHandle(mightDownloadFromHandle)
 #if USE(CFNETWORK)
             , m_connection(0)
@@ -107,7 +106,6 @@ namespace WebCore {
         
         int status;
 
-        bool m_defersLoading;
         bool m_mightDownloadFromHandle;
 #if USE(CFNETWORK)
         RetainPtr<CFURLConnectionRef> m_connection;
index 391b96f..35b035a 100644 (file)
@@ -108,8 +108,6 @@ bool ResourceHandle::start(Frame* frame)
 #endif
     d->m_connection = connection;
     [connection release];
-    if (d->m_defersLoading)
-        wkSetNSURLConnectionDefersCallbacks(d->m_connection.get(), YES);
     
     if (d->m_connection)
         return true;
@@ -124,12 +122,6 @@ void ResourceHandle::cancel()
     [d->m_connection.get() cancel];
 }
 
-void ResourceHandle::setDefersLoading(bool defers)
-{
-    d->m_defersLoading = defers;
-    wkSetNSURLConnectionDefersCallbacks(d->m_connection.get(), defers);
-}
-
 WebCoreResourceHandleAsDelegate *ResourceHandle::delegate()
 {
     if (!d->m_delegate) {
index d1b6760..dd23bf4 100644 (file)
@@ -1,3 +1,22 @@
+2007-01-30  Graham Dennis  <graham.dennis@gmail.com>
+
+        Reviewed by Maciej.
+
+        Part of fix for http://bugs.webkit.org/show_bug.cgi?id=10725
+        Image data in from RTFD clipboard data thrown away
+        
+        The URLs for images in RTFD data must not be loaded until the resources
+        have been added to the WebUnarchivingState. This can't happen until
+        after the RTFD data has been parsed, so we must delay loading while this
+        RTFD data is being parsed to a document fragment.
+
+        * WebView/WebHTMLView.mm:
+        (uniqueURLWithRelativePart):
+        (-[WebHTMLView _documentFragmentFromPasteboard:inContext:allowPlainText:chosePlainText:]): defer loading the resources while RTFD data is being parsed.
+        (+[NSURL _web_uniqueWebDataURL]): Added this back because AppKit uses it.
+        * WebView/WebUnarchivingState.m:
+        (-[WebUnarchivingState archivedResourceForURL:]): orkaround for workaround for rdar://problem/4699166 so that other people can use archivedResourceForURL: too.
+
 2007-01-29  Jim Correia  <jim.correia@pobox.com>
 
         Reviewed by Mark.
@@ -15,6 +34,7 @@
         (-[WebView undoManager]):
         * WebView/WebViewPrivate.h:
 
+>>>>>>> .r19243
 2007-01-29  Ada Chan  <adachan@apple.com>
 
         Reviewed by Brady.
index b98f861..c8464fd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *           (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *           (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -98,6 +98,9 @@ using namespace WebCore;
 
 extern "C" {
 
+// Fake URL scheme.
+static NSString *WebDataProtocolScheme = @"webkit-fake-url";
+
 // need to declare this because AppKit does not make it available as API or SPI
 extern NSString *NSMarkedClauseSegmentAttributeName; 
 extern NSString *NSTextInputReplacementRangeAttributeName; 
@@ -412,7 +415,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
     CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
     NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
     CFRelease(UUIDRef);
-    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"-webkit-fake-url://%@/%@", UUIDString, relativePart]];
+    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", WebDataProtocolScheme, UUIDString, relativePart]];
     CFRelease(UUIDString);
 
     return URL;
@@ -472,10 +475,25 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
             [[self class] _excludedElementsForAttributedStringConversion], NSExcludedElementsDocumentAttribute,
             self, @"WebResourceHandler", nil];
         NSArray *subresources;
+        
+        BOOL wasDeferringCallbacks = [[self _webView] defersCallbacks];
+        if (!wasDeferringCallbacks)
+            [[self _webView] setDefersCallbacks:YES];
+            
         DOMDocumentFragment *fragment = [string _documentFromRange:NSMakeRange(0, [string length]) 
                                                           document:[[self _frame] DOMDocument] 
                                                 documentAttributes:documentAttributes
                                                       subresources:&subresources];
+        
+        NSEnumerator *e = [subresources objectEnumerator];
+        WebResource *r;
+        while ((r = [e nextObject])) {
+            [[self _dataSource] addSubresource:r];
+        }
+        
+        if (!wasDeferringCallbacks)
+            [[self _webView] setDefersCallbacks:NO];
+        
         [documentAttributes release];
         [string release];
         return fragment;
@@ -5992,3 +6010,18 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
 }
 
 @end
+
+// This is used by AppKit and is included here so that WebDataProtocolScheme is only defined once.
+@implementation NSURL (WebDataURL)
+
++ (NSURL *)_web_uniqueWebDataURL
+{
+    CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
+    NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
+    CFRelease(UUIDRef);
+    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", WebDataProtocolScheme, UUIDString]];
+    CFRelease(UUIDString);
+    return URL;
+}
+
+@end
index 0a8ff0b..33acf6f 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 - (WebResource *)archivedResourceForURL:(NSURL *)URL
 {
     // FIXME: <rdar://problem/4699166> REGRESSION: Background images in Mail stationery do not load
-    // This should be [URL _web_originalDataAsString]
-    return [archivedResources objectForKey:URL];
+    // This should be just return [URL _web_originalDataAsString]
+    WebResource *resource = [archivedResources objectForKey:URL];
+    if (!resource)
+        resource = [archivedResources objectForKey:[URL _web_originalDataAsString]];
+    return resource;
 }
 
 - (WebArchive *)popSubframeArchiveWithFrameName:(NSString *)frameName
index 8794683..23e4389 100644 (file)
@@ -1,3 +1,17 @@
+2007-01-29  Graham Dennis  <graham.dennis@gmail.com>
+
+        Reviewed by Maciej.
+        
+        Enables layout test for: http://bugs.webkit.org/show_bug.cgi?id=10725
+        Image data in from RTFD clipboard data thrown away
+        
+        - This method is needed because NSArray's ar bridged to JS Array's,
+          which in turn are bridged back to WebScriptObject's when passed from
+          JS to ObjC. Hence it is not possbile to pass an NSArray from JS.
+
+        * DumpRenderTree/DumpRenderTree.m:
+        (-[DumpRenderTreePasteboard declareType:owner:]): Added a convenience method for JS.
+
 2007-01-25  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 939641b..e6f3424 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -69,6 +70,7 @@
 @end
 
 @interface DumpRenderTreePasteboard : NSPasteboard
+- (int)declareType:(NSString *)type owner:(id)newOwner;
 @end
 
 @interface DumpRenderTreeEvent : NSEvent
@@ -1129,6 +1131,13 @@ static NSString *md5HashStringForBitmap(CGImageRef bitmap)
     return pasteboard;
 }
 
+// Convenience method for JS so that it doesn't have to try and create a NSArray on the objc side instead
+// of the usual WebScriptObject that is passed around
+- (int)declareType:(NSString *)type owner:(id)newOwner
+{
+    return [self declareTypes:[NSArray arrayWithObject:type] owner:newOwner];
+}
+
 @end
 
 @implementation LocalPasteboard