[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
enrica at apple.com
enrica at apple.com
Wed Dec 22 13:23:01 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 0f0dd6cda6e410d01c429290b36d37f8b2b903ff
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 13 19:16:23 2010 +0000
Paste should be implemented in WebCore like Copy and Cut for Mac also.
https://bugs.webkit.org/show_bug.cgi?id=45494
<rdar://problem/7660537>
WebCore:
Reviewed by Sam Weining.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* editing/Editor.cpp:
(WebCore::Editor::shouldInsertFragment):
* editing/mac/EditorMac.mm: extended to support Mail specific scenarios.
(WebCore::Editor::pasteWithPasteboard):
* loader/EmptyClients.h:
(WebCore::EmptyFrameLoaderClient::canShowMIMETypeAsHTML): Added.
(WebCore::EmptyEditorClient::documentFragmentFromAttributedString): Added.
(WebCore::EmptyEditorClient::setInsertionPasteboard): Added to support Mail.
* loader/FrameLoaderClient.h:
* page/EditorClient.h:
* platform/Pasteboard.h:
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::writeSelection): replaced call to Appkit with one that
doesn't calll back into WebKit.
(WebCore::Pasteboard::documentFragmentWithImageResource): Re-implemented at the
WebCore level.
(WebCore::Pasteboard::documentFragmentWithRtf): Re-implemented at the
WebCore level.
(WebCore::uniqueURLWithRelativePart): Added.
(WebCore::Pasteboard::documentFragment): Extended to include all the functionality
provided in documentFragmentFromPasteboard in WebHTMLView.mm.
WebKit/chromium:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::canShowMIMETypeAsHTML): Added stub.
* src/FrameLoaderClientImpl.h:
WebKit/efl:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebCoreSupport/FrameLoaderClientEfl.cpp:
(WebCore::FrameLoaderClientEfl::canShowMIMETypeAsHTML): Added stub.
* WebCoreSupport/FrameLoaderClientEfl.h:
WebKit/gtk:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::canShowMIMETypeAsHTML): Added stub.
* WebCoreSupport/FrameLoaderClientGtk.h:
WebKit/haiku:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebCoreSupport/FrameLoaderClientHaiku.cpp:
(WebCore::FrameLoaderClientHaiku::canShowMIMETypeAsHTML): Added stub.
* WebCoreSupport/FrameLoaderClientHaiku.h:
WebKit/mac:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(excludedElementsForAttributedStringConversion):
(WebEditorClient::documentFragmentFromAttributedString): Added.
(WebEditorClient::setInsertionPasteboard):
* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canShowMIMETypeAsHTML): Re-implemented at the level
of the editor client.
* WebView/WebHTMLView.mm: Removed paste method.
WebKit/qt:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::canShowMIMETypeAsHTML): Added stub.
* WebCoreSupport/FrameLoaderClientQt.h:
WebKit/win:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebFrame.cpp:
(WebFrame::canShowMIMETypeASHTML): Added.
WebKit/wx:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebKitSupport/FrameLoaderClientWx.cpp:
(WebCore::FrameLoaderClientWx::canShowMIMETypeAsHTML): Added stub.
* WebKitSupport/FrameLoaderClientWx.h:
WebKit2:
Reviewed by Sam Weinig.
On the Mac platform, the implementation of the paste operation is all done
at the WebKit level. In order to support it on WebKit2 it is necessary to
refactor the code and move this functionality at the level of WebCore like
we already have on Windows.
The original code relies on some in AppKit functions that call back into
WebKit causing problems in WebKit2. All this functionality has been moved
at the level of the editor client where it can be dealt with appropriately.
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::documentFragmentFromAttributedString): Added.
(WebKit::WebEditorClient::setInsertionPasteboard): Added.
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::canShowMIMETypeAsHTML): Added.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8f9cb5d..14b8b28 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weining.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::shouldInsertFragment):
+ * editing/mac/EditorMac.mm: extended to support Mail specific scenarios.
+ (WebCore::Editor::pasteWithPasteboard):
+ * loader/EmptyClients.h:
+ (WebCore::EmptyFrameLoaderClient::canShowMIMETypeAsHTML): Added.
+ (WebCore::EmptyEditorClient::documentFragmentFromAttributedString): Added.
+ (WebCore::EmptyEditorClient::setInsertionPasteboard): Added to support Mail.
+ * loader/FrameLoaderClient.h:
+ * page/EditorClient.h:
+ * platform/Pasteboard.h:
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::writeSelection): replaced call to Appkit with one that
+ doesn't calll back into WebKit.
+ (WebCore::Pasteboard::documentFragmentWithImageResource): Re-implemented at the
+ WebCore level.
+ (WebCore::Pasteboard::documentFragmentWithRtf): Re-implemented at the
+ WebCore level.
+ (WebCore::uniqueURLWithRelativePart): Added.
+ (WebCore::Pasteboard::documentFragment): Extended to include all the functionality
+ provided in documentFragmentFromPasteboard in WebHTMLView.mm.
+
2010-09-13 Alejandro G. Castro <alex at igalia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 01e6c05..c8f8d8b 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -341,6 +341,7 @@ void Editor::pasteAsPlainTextWithPasteboard(Pasteboard* pasteboard)
pasteAsPlainText(text, canSmartReplaceWithPasteboard(pasteboard));
}
+#if !PLATFORM(MAC)
void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
{
RefPtr<Range> range = selectedRange();
@@ -349,6 +350,7 @@ void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), chosePlainText);
}
+#endif
bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard)
{
@@ -359,10 +361,12 @@ bool Editor::shouldInsertFragment(PassRefPtr<DocumentFragment> fragment, PassRef
{
if (!client())
return false;
-
- Node* child = fragment->firstChild();
- if (child && fragment->lastChild() == child && child->isCharacterDataNode())
- return client()->shouldInsertText(static_cast<CharacterData*>(child)->data(), replacingDOMRange.get(), givenAction);
+
+ if (fragment) {
+ Node* child = fragment->firstChild();
+ if (child && fragment->lastChild() == child && child->isCharacterDataNode())
+ return client()->shouldInsertText(static_cast<CharacterData*>(child)->data(), replacingDOMRange.get(), givenAction);
+ }
return client()->shouldInsertNode(fragment.get(), replacingDOMRange.get(), givenAction);
}
@@ -1193,8 +1197,6 @@ void Editor::copy()
didWriteSelectionToPasteboard();
}
-#if !PLATFORM(MAC)
-
void Editor::paste()
{
ASSERT(m_frame->document());
@@ -1211,8 +1213,6 @@ void Editor::paste()
loader->setAllowStaleResources(false);
}
-#endif
-
void Editor::pasteAsPlainText()
{
if (tryDHTMLPaste())
diff --git a/WebCore/editing/mac/EditorMac.mm b/WebCore/editing/mac/EditorMac.mm
index ac658c8..f010908 100644
--- a/WebCore/editing/mac/EditorMac.mm
+++ b/WebCore/editing/mac/EditorMac.mm
@@ -29,9 +29,14 @@
#import "ColorMac.h"
#import "ClipboardMac.h"
#import "CachedResourceLoader.h"
+#import "DocumentFragment.h"
+#import "Editor.h"
+#import "EditorClient.h"
#import "Frame.h"
#import "FrameView.h"
+#import "Pasteboard.h"
#import "RenderBlock.h"
+#import "RuntimeApplicationChecks.h"
namespace WebCore {
@@ -55,20 +60,32 @@ void Editor::showColorPanel()
[[NSApplication sharedApplication] orderFrontColorPanel:nil];
}
-// FIXME: We want to use the platform-independent code instead. But when we last
-// tried to do so it seemed that we first need to move more of the logic from
-// -[WebHTMLView.cpp _documentFragmentFromPasteboard] into PasteboardMac.
-
-void Editor::paste()
+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
{
- ASSERT(m_frame->document());
- FrameView* view = m_frame->view();
- if (!view)
- return;
- CachedResourceLoader* loader = m_frame->document()->cachedResourceLoader();
- loader->setAllowStaleResources(true);
- [view->documentView() tryToPerform:@selector(paste:) with:nil];
- loader->setAllowStaleResources(false);
+ RefPtr<Range> range = selectedRange();
+ bool choosePlainText;
+
+ m_frame->editor()->client()->setInsertionPasteboard([NSPasteboard generalPasteboard]);
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, range, allowPlainText, choosePlainText);
+ if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), false);
+#else
+ // Mail is ignoring the frament passed to the delegate and creates a new one.
+ // We want to avoid creating the fragment twice.
+ if (applicationIsAppleMail()) {
+ if (shouldInsertFragment(NULL, range, EditorInsertActionPasted)) {
+ RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, range, allowPlainText, choosePlainText);
+ if (fragment)
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), false);
+ }
+ } else {
+ RefPtr<DocumentFragment>fragment = pasteboard->documentFragment(m_frame, range, allowPlainText, choosePlainText);
+ if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), false);
+ }
+#endif
+ m_frame->editor()->client()->setInsertionPasteboard(nil);
}
NSDictionary* Editor::fontAttributesForSelectionStart() const
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index d1e406c..30b7857 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -305,6 +305,7 @@ public:
virtual bool canHandleRequest(const ResourceRequest&) const { return false; }
virtual bool canShowMIMEType(const String&) const { return false; }
+ virtual bool canShowMIMETypeAsHTML(const String&) const { return false; }
virtual bool representationExistsForURLScheme(const String&) const { return false; }
virtual String generatedMIMETypeForURLScheme(const String&) const { return ""; }
@@ -434,6 +435,8 @@ public:
virtual void markedTextAbandoned(Frame*) { }
virtual NSString* userVisibleString(NSURL*) { return 0; }
+ virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<ArchiveResource*>&) { return 0; };
+ virtual void setInsertionPasteboard(NSPasteboard*) { };
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; }
#endif
diff --git a/WebCore/loader/FrameLoaderClient.h b/WebCore/loader/FrameLoaderClient.h
index 04a8868..1b7e9c0 100644
--- a/WebCore/loader/FrameLoaderClient.h
+++ b/WebCore/loader/FrameLoaderClient.h
@@ -204,6 +204,7 @@ namespace WebCore {
virtual bool canHandleRequest(const ResourceRequest&) const = 0;
virtual bool canShowMIMEType(const String& MIMEType) const = 0;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const = 0;
virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0;
virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0;
diff --git a/WebCore/page/EditorClient.h b/WebCore/page/EditorClient.h
index 4a192d7..d50a1f5 100644
--- a/WebCore/page/EditorClient.h
+++ b/WebCore/page/EditorClient.h
@@ -37,12 +37,16 @@
#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSArray;
+ at class NSAttributedString;
@class NSData;
+ at class NSPasteboard;
@class NSString;
@class NSURL;
#else
class NSArray;
+class NSAttributedString;
class NSData;
+class NSPasteboard;
class NSString;
class NSURL;
#endif
@@ -50,7 +54,9 @@ class NSURL;
namespace WebCore {
+class ArchiveResource;
class CSSStyleDeclaration;
+class DocumentFragment;
class EditCommand;
class Editor;
class Element;
@@ -147,6 +153,8 @@ public:
#if PLATFORM(MAC)
virtual NSString* userVisibleString(NSURL*) = 0;
+ virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<ArchiveResource*>&) = 0;
+ virtual void setInsertionPasteboard(NSPasteboard*) = 0;
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(Frame*) = 0;
#endif
diff --git a/WebCore/platform/Pasteboard.h b/WebCore/platform/Pasteboard.h
index 7773624..7c50737 100644
--- a/WebCore/platform/Pasteboard.h
+++ b/WebCore/platform/Pasteboard.h
@@ -79,6 +79,7 @@ class HitTestResult;
class KURL;
class Node;
class Range;
+class ArchiveResource;
class Pasteboard : public Noncopyable {
public:
@@ -118,6 +119,8 @@ private:
#if PLATFORM(MAC)
Pasteboard(NSPasteboard *);
RetainPtr<NSPasteboard> m_pasteboard;
+ PassRefPtr<DocumentFragment> documentFragmentWithImageResource(Frame* frame, PassRefPtr<ArchiveResource> resource);
+ PassRefPtr<DocumentFragment> documentFragmentWithRtf(Frame* frame, NSString* pboardType);
#endif
#if PLATFORM(WIN)
diff --git a/WebCore/platform/mac/PasteboardMac.mm b/WebCore/platform/mac/PasteboardMac.mm
index bba7cac..7ddba0d 100644
--- a/WebCore/platform/mac/PasteboardMac.mm
+++ b/WebCore/platform/mac/PasteboardMac.mm
@@ -31,16 +31,22 @@
#import "DOMRangeInternal.h"
#import "Document.h"
#import "DocumentFragment.h"
+#import "DocumentLoader.h"
#import "Editor.h"
#import "EditorClient.h"
#import "Frame.h"
+#import "FrameLoaderClient.h"
#import "HitTestResult.h"
+#import "HTMLAnchorElement.h"
+#import "HTMLNames.h"
#import "Image.h"
#import "KURL.h"
#import "LegacyWebArchive.h"
#import "LoaderNSURLExtras.h"
#import "MIMETypeRegistry.h"
+#import "Page.h"
#import "RenderImage.h"
+#import "Text.h"
#import "WebCoreNSStringExtras.h"
#import "markup.h"
@@ -139,7 +145,8 @@ void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange,
Pasteboard::generalPasteboard(); // Initializes pasteboard types.
ASSERT(selectedRange);
- NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:kit(selectedRange)] autorelease];
+ NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:selectedRange->text()] autorelease];
+
#ifdef BUILDING_ON_TIGER
// 4930197: Mail overrides [WebHTMLView pasteboardTypesForSelection] in order to add another type to the pasteboard
// after WebKit does. On Tiger we must call this function so that Mail code will be executed, meaning that
@@ -362,12 +369,124 @@ String Pasteboard::plainText(Frame* frame)
return String();
}
+
+PassRefPtr<DocumentFragment> Pasteboard::documentFragmentWithImageResource(Frame* frame, PassRefPtr<ArchiveResource> resource)
+{
+ if (DocumentLoader* loader = frame->loader()->documentLoader())
+ loader->addArchiveResource(resource.get());
+
+ RefPtr<Element> imageElement = frame->document()->createElement(HTMLNames::imgTag, false);
+ if (!imageElement)
+ return 0;
+
+ NSURL *URL = resource->url();
+ imageElement->setAttribute(HTMLNames::srcAttr, [URL isFileURL] ? [URL absoluteString] : resource->url());
+ RefPtr<DocumentFragment> fragment = frame->document()->createDocumentFragment();
+ if (fragment) {
+ ExceptionCode ec;
+ fragment->appendChild(imageElement, ec);
+ return fragment.release();
+ }
+ return 0;
+}
+
+PassRefPtr<DocumentFragment> Pasteboard::documentFragmentWithRtf(Frame* frame, NSString* pboardType)
+{
+ if (!frame || !frame->document() || !frame->document()->isHTMLDocument())
+ return 0;
+
+ NSAttributedString *string = nil;
+ if (pboardType == NSRTFDPboardType)
+ string = [[NSAttributedString alloc] initWithRTFD:[m_pasteboard.get() dataForType:NSRTFDPboardType] documentAttributes:NULL];
+ if (string == nil)
+ string = [[NSAttributedString alloc] initWithRTF:[m_pasteboard.get() dataForType:NSRTFPboardType] documentAttributes:NULL];
+ if (string == nil)
+ return nil;
+
+ bool wasDeferringCallbacks = frame->page()->defersLoading();
+ if (!wasDeferringCallbacks)
+ frame->page()->setDefersLoading(true);
+
+ Vector<ArchiveResource*> resources;
+ RefPtr<DocumentFragment> fragment = frame->editor()->client()->documentFragmentFromAttributedString(string, resources);
+
+ size_t size = resources.size();
+ if (size) {
+ DocumentLoader* loader = frame->loader()->documentLoader();
+ for (size_t i = 0; i < size; ++i)
+ loader->addArchiveResource(resources[i]);
+ }
+
+ if (!wasDeferringCallbacks)
+ frame->page()->setDefersLoading(false);
+
+ [string release];
+ return fragment.release();
+}
+
+#define WebDataProtocolScheme @"webkit-fake-url"
+
+static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
+{
+ CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
+ NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
+ CFRelease(UUIDRef);
+ NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", WebDataProtocolScheme, UUIDString, relativePart]];
+ CFRelease(UUIDString);
+ return URL;
+}
+
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
{
NSArray *types = [m_pasteboard.get() types];
+ RefPtr<DocumentFragment> fragment;
chosePlainText = false;
+ if ([types containsObject:WebArchivePboardType]) {
+ RefPtr<LegacyWebArchive> coreArchive = LegacyWebArchive::create(SharedBuffer::wrapNSData([m_pasteboard.get() dataForType:WebArchivePboardType]).get());
+ if (coreArchive) {
+ RefPtr<ArchiveResource> mainResource = coreArchive->mainResource();
+ if (mainResource) {
+ NSString *MIMEType = mainResource->mimeType();
+ if (!frame || !frame->document())
+ return 0;
+ if (frame->loader()->client()->canShowMIMETypeAsHTML(MIMEType)) {
+ NSString *markupString = [[NSString alloc] initWithData:[mainResource->data()->createNSData() autorelease] encoding:NSUTF8StringEncoding];
+ // FIXME: seems poor form to do this as a side effect of getting a document fragment
+ if (DocumentLoader* loader = frame->loader()->documentLoader())
+ loader->addAllArchiveResources(coreArchive.get());
+
+ fragment = createFragmentFromMarkup(frame->document(), markupString, mainResource->url(), FragmentScriptingNotAllowed);
+ [markupString release];
+ } else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType))
+ fragment = documentFragmentWithImageResource(frame, mainResource);
+ }
+ }
+ if (fragment)
+ return fragment.release();
+ }
+
+ if ([types containsObject:NSFilenamesPboardType]) {
+ NSArray* paths = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
+ NSEnumerator* enumerator = [paths objectEnumerator];
+ NSString* path;
+ Vector< RefPtr<Node> > refNodesVector;
+ Vector<Node*> nodesVector;
+
+ while ((path = [enumerator nextObject]) != nil) {
+ // Non-image file types; _web_userVisibleString is appropriate here because this will
+ // be pasted as visible text.
+ NSString *url = frame->editor()->client()->userVisibleString([NSURL fileURLWithPath:path]);
+ RefPtr<Node> textNode = frame->document()->createTextNode(url);
+ refNodesVector.append(textNode.get());
+ nodesVector.append(textNode.get());
+ }
+ fragment = createFragmentFromNodes(frame->document(), nodesVector);
+ if (fragment && fragment->firstChild())
+ return fragment.release();
+ }
+
if ([types containsObject:NSHTMLPboardType]) {
NSString *HTMLString = [m_pasteboard.get() stringForType:NSHTMLPboardType];
// This is a hack to make Microsoft's HTML pasteboard data work. See 3778785.
@@ -377,24 +496,66 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
HTMLString = [HTMLString substringFromIndex:range.location];
}
}
- if ([HTMLString length] != 0) {
- // FIXME: FragmentScriptingNotAllowed is a HACK and should
- // be removed or replaced with an enum with a better name.
- // FragmentScriptingNotAllowed causes the Parser to remove children
- // of <script> tags (so javascript doesn't show up in pastes).
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", FragmentScriptingNotAllowed);
- if (fragment)
- return fragment.release();
+ if ([HTMLString length] != 0 &&
+ (fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", FragmentScriptingNotAllowed)))
+ return fragment.release();
+ }
+
+ if ([types containsObject:NSRTFDPboardType] &&
+ (fragment = documentFragmentWithRtf(frame, NSRTFDPboardType)))
+ return fragment.release();
+
+ if ([types containsObject:NSRTFPboardType] &&
+ (fragment = documentFragmentWithRtf(frame, NSRTFPboardType)))
+ return fragment.release();
+
+ if ([types containsObject:NSTIFFPboardType] &&
+ (fragment = documentFragmentWithImageResource(frame, ArchiveResource::create(SharedBuffer::wrapNSData([[[m_pasteboard.get() dataForType:NSTIFFPboardType] copy] autorelease]), uniqueURLWithRelativePart(@"image.tiff"), "image/tiff", "", ""))))
+ return fragment.release();
+
+ if ([types containsObject:NSPDFPboardType] &&
+ (fragment = documentFragmentWithImageResource(frame, ArchiveResource::create(SharedBuffer::wrapNSData([[[m_pasteboard.get() dataForType:NSPDFPboardType] copy] autorelease]), uniqueURLWithRelativePart(@"application.pdf"), "application/pdf", "", ""))))
+ return fragment.release();
+
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
+ if ([types containsObject:NSPICTPboardType] &&
+ (fragment = documentFragmentWithImageResource(frame, ArchiveResource::create(SharedBuffer::wrapNSData([[[m_pasteboard.get() dataForType:NSPICTPboardType] copy] autorelease]), uniqueURLWithRelativePart(@"image.pict"), "image/pict", "", ""))))
+ return fragment.release();
+#endif
+
+ // Only 10.5 and higher support setting and retrieving pasteboard types with UTIs, but we don't believe
+ // that any applications on Tiger put types for which we only have a UTI, like PNG, on the pasteboard.
+ if ([types containsObject:(NSString*)kUTTypePNG] &&
+ (fragment = documentFragmentWithImageResource(frame, ArchiveResource::create(SharedBuffer::wrapNSData([[[m_pasteboard.get() dataForType:(NSString*)kUTTypePNG] copy] autorelease]), uniqueURLWithRelativePart(@"image.png"), "image/png", "", ""))))
+ return fragment.release();
+
+ if ([types containsObject:NSURLPboardType]) {
+ NSURL *URL = [NSURL URLFromPasteboard:m_pasteboard.get()];
+ Document* document = frame->document();
+ ASSERT(document);
+ if (!document)
+ return 0;
+ RefPtr<Element> anchor = document->createElement(HTMLNames::aTag, false);
+ NSString *URLString = [URL absoluteString]; // Original data is ASCII-only, so there is no need to precompose.
+ if ([URLString length] == 0)
+ return nil;
+ NSString *URLTitleString = [[m_pasteboard.get() stringForType:WebURLNamePboardType] precomposedStringWithCanonicalMapping];
+ ExceptionCode ec;
+ anchor->setAttribute(HTMLNames::hrefAttr, URLString);
+ anchor->appendChild(document->createTextNode(URLTitleString), ec);
+ fragment = document->createDocumentFragment();
+ if (fragment) {
+ fragment->appendChild(anchor, ec);
+ return fragment.release();
}
}
-
+
if (allowPlainText && [types containsObject:NSStringPboardType]) {
chosePlainText = true;
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), [[m_pasteboard.get() stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]);
- if (fragment)
- return fragment.release();
+ fragment = createFragmentFromText(context.get(), [[m_pasteboard.get() stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]);
+ return fragment.release();
}
-
+
return 0;
}
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 53c16c8..b18d447 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * src/FrameLoaderClientImpl.cpp:
+ (WebKit::FrameLoaderClientImpl::canShowMIMETypeAsHTML): Added stub.
+ * src/FrameLoaderClientImpl.h:
+
2010-09-13 Jonathan Dixon <joth at chromium.org>
Reviewed by Steve Block.
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
index 55f4c72..368694d 100644
--- a/WebKit/chromium/src/FrameLoaderClientImpl.cpp
+++ b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
@@ -1206,6 +1206,12 @@ bool FrameLoaderClientImpl::canHandleRequest(const ResourceRequest& request) con
m_webFrame, WrappedResourceRequest(request));
}
+bool FrameLoaderClientImpl::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const
{
// This method is called to determine if the media type can be shown
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.h b/WebKit/chromium/src/FrameLoaderClientImpl.h
index 361bae4..57105de 100644
--- a/WebKit/chromium/src/FrameLoaderClientImpl.h
+++ b/WebKit/chromium/src/FrameLoaderClientImpl.h
@@ -149,6 +149,7 @@ public:
virtual bool shouldFallBack(const WebCore::ResourceError&);
virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
virtual bool canShowMIMEType(const WTF::String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const;
virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const;
virtual void frameLoadCompleted();
diff --git a/WebKit/efl/ChangeLog b/WebKit/efl/ChangeLog
index 09a897c..7122f8e 100644
--- a/WebKit/efl/ChangeLog
+++ b/WebKit/efl/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebCoreSupport/FrameLoaderClientEfl.cpp:
+ (WebCore::FrameLoaderClientEfl::canShowMIMETypeAsHTML): Added stub.
+ * WebCoreSupport/FrameLoaderClientEfl.h:
+
2010-09-11 Ryuan Choi <ryuan.choi at samsung.com>
Reviewed by Antonio Gomes.
diff --git a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
index 9409776..a623a8f 100644
--- a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
+++ b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
@@ -678,6 +678,12 @@ bool FrameLoaderClientEfl::canHandleRequest(const ResourceRequest&) const
return true;
}
+virtual bool FrameLoaderClientEfl::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
bool FrameLoaderClientEfl::canShowMIMEType(const String& MIMEType) const
{
if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType))
diff --git a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
index 6b66ee0..68f145d 100644
--- a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
+++ b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
@@ -181,6 +181,7 @@ class FrameLoaderClientEfl : public FrameLoaderClient {
virtual bool canHandleRequest(const ResourceRequest&) const;
virtual bool canShowMIMEType(const String&) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const String&) const;
virtual String generatedMIMETypeForURLScheme(const String&) const;
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index a77b2d4..9371523 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::canShowMIMETypeAsHTML): Added stub.
+ * WebCoreSupport/FrameLoaderClientGtk.h:
+
2010-09-13 Mario Sanchez Prada <msanchez at igalia.com>
Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index 156c0d0..54762ca 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -955,6 +955,12 @@ bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const
return true;
}
+bool FrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
bool FrameLoaderClient::canShowMIMEType(const String& type) const
{
return (MIMETypeRegistry::isSupportedImageMIMEType(type)
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
index 753576b..c5ffc6a 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
@@ -160,6 +160,7 @@ namespace WebKit {
virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
virtual bool canShowMIMEType(const WTF::String&) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const WTF::String&) const;
virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String&) const;
diff --git a/WebKit/haiku/ChangeLog b/WebKit/haiku/ChangeLog
index 129eb86..718c4c3 100644
--- a/WebKit/haiku/ChangeLog
+++ b/WebKit/haiku/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebCoreSupport/FrameLoaderClientHaiku.cpp:
+ (WebCore::FrameLoaderClientHaiku::canShowMIMETypeAsHTML): Added stub.
+ * WebCoreSupport/FrameLoaderClientHaiku.h:
+
2010-09-10 Adam Barth <abarth at webkit.org>
Reviewed by Darin Fisher.
diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
index d6f708f..705a333 100644
--- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
+++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
@@ -361,6 +361,12 @@ void FrameLoaderClientHaiku::finishedLoading(DocumentLoader*)
notImplemented();
}
+bool FrameLoaderClientHaiku::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
bool FrameLoaderClientHaiku::canShowMIMEType(const String& MIMEType) const
{
notImplemented();
diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
index dfe5747..eafbfc3 100644
--- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
+++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
@@ -130,6 +130,7 @@ namespace WebCore {
virtual void finishedLoading(DocumentLoader*);
virtual bool canShowMIMEType(const String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const String& URLScheme) const;
virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const;
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index d303fcc..38b3d25 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,30 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebCoreSupport/WebEditorClient.h:
+ * WebCoreSupport/WebEditorClient.mm:
+ (excludedElementsForAttributedStringConversion):
+ (WebEditorClient::documentFragmentFromAttributedString): Added.
+ (WebEditorClient::setInsertionPasteboard):
+ * WebCoreSupport/WebFrameLoaderClient.h:
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::canShowMIMETypeAsHTML): Re-implemented at the level
+ of the editor client.
+ * WebView/WebHTMLView.mm: Removed paste method.
+
2010-09-13 John Sullivan <sullivan at apple.com>
Reviewed by Adam Roben.
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h
index fe33e05..bddf87d 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.h
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h
@@ -71,6 +71,8 @@ public:
virtual void didSetSelectionTypesForPasteboard();
virtual NSString* userVisibleString(NSURL*);
+ virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<WebCore::ArchiveResource*>&);
+ virtual void setInsertionPasteboard(NSPasteboard*);
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(WebCore::Frame*);
#endif
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
index 41cff68..dfeea70 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
@@ -30,6 +30,7 @@
#import "WebEditorClient.h"
#import "DOMCSSStyleDeclarationInternal.h"
+#import "DOMDocumentFragmentInternal.h"
#import "DOMHTMLElementInternal.h"
#import "DOMHTMLInputElementInternal.h"
#import "DOMHTMLTextAreaElementInternal.h"
@@ -48,8 +49,11 @@
#import "WebKitVersionChecks.h"
#import "WebLocalizableStrings.h"
#import "WebNSURLExtras.h"
+#import "WebResourceInternal.h"
#import "WebViewInternal.h"
+#import <WebCore/ArchiveResource.h>
#import <WebCore/Document.h>
+#import <WebCore/DocumentFragment.h>
#import <WebCore/EditAction.h>
#import <WebCore/EditCommand.h>
#import <WebCore/HTMLInputElement.h>
@@ -73,6 +77,11 @@ using namespace WTF;
using namespace HTMLNames;
+ at interface NSAttributedString (WebNSAttributedStringDetails)
+- (id)_initWithDOMRange:(DOMRange *)range;
+- (DOMDocumentFragment *)_documentFromRange:(NSRange)range document:(DOMDocument *)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
+ at end
+
static WebViewInsertAction kit(EditorInsertAction coreAction)
{
return static_cast<WebViewInsertAction>(coreAction);
@@ -330,6 +339,52 @@ NSString* WebEditorClient::userVisibleString(NSURL *URL)
return [URL _web_userVisibleString];
}
+static NSArray* excludedElementsForAttributedStringConversion()
+{
+ static NSArray *elements = nil;
+ if (elements == nil) {
+ elements = [[NSArray alloc] initWithObjects:
+ // Omit style since we want style to be inline so the fragment can be easily inserted.
+ @"style",
+ // Omit xml so the result is not XHTML.
+ @"xml",
+ // Omit tags that will get stripped when converted to a fragment anyway.
+ @"doctype", @"html", @"head", @"body",
+ // Omit deprecated tags.
+ @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
+ // Omit object so no file attachments are part of the fragment.
+ @"object", nil];
+ CFRetain(elements);
+ }
+ return elements;
+}
+
+DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString* string, Vector<ArchiveResource*>& resources)
+{
+ NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
+ excludedElementsForAttributedStringConversion(), NSExcludedElementsDocumentAttribute,
+ m_webView, @"WebResourceHandler", nil];
+
+ NSArray* s;
+ DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
+ document:[[m_webView mainFrame] DOMDocument]
+ documentAttributes:dictionary
+ subresources:&s];
+ NSEnumerator *e = [s objectEnumerator];
+ WebResource *r;
+ while ((r = [e nextObject])) {
+ RefPtr<ArchiveResource> ar = [r _coreResource];
+ resources.append(ar.get());
+ }
+ [dictionary release];
+ return core(fragment);
+}
+
+void WebEditorClient::setInsertionPasteboard(NSPasteboard* pasteboard)
+{
+ [m_webView _setInsertionPasteboard:pasteboard];
+}
+
#ifdef BUILDING_ON_TIGER
NSArray* WebEditorClient::pasteboardTypesForSelection(Frame* selectedFrame)
{
diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
index cbb89ec..447c515 100644
--- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
+++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
@@ -177,6 +177,7 @@ private:
virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
virtual bool canShowMIMEType(const WTF::String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const;
virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const;
virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const;
diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
index dcbca28..a398ef7 100644
--- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
@@ -1018,6 +1018,11 @@ bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
return [getWebView(m_webFrame.get()) _canShowMIMEType:MIMEType];
}
+bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ return [WebView canShowMIMETypeAsHTML:MIMEType];
+}
+
bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
{
return [WebView _representationExistsForURLScheme:URLScheme];
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 65b266a..b392318 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -2528,6 +2528,7 @@ WEBCORE_COMMAND(alignLeft)
WEBCORE_COMMAND(alignRight)
WEBCORE_COMMAND(copy)
WEBCORE_COMMAND(cut)
+WEBCORE_COMMAND(paste)
WEBCORE_COMMAND(delete)
WEBCORE_COMMAND(deleteBackward)
WEBCORE_COMMAND(deleteBackwardByDecomposingPreviousCharacter)
@@ -5162,24 +5163,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
return [_private->dataSource webFrame];
}
-- (void)paste:(id)sender
-{
- COMMAND_PROLOGUE
-
- RetainPtr<WebHTMLView> selfProtector = self;
- RefPtr<Frame> coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- if (coreFrame->editor()->tryDHTMLPaste())
- return; // DHTML did the whole operation
- if (!coreFrame->editor()->canPaste())
- return;
- if (coreFrame->selection()->isContentRichlyEditable())
- [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES];
- else
- coreFrame->editor()->pasteAsPlainTextBypassingDHTML();
-}
-
- (void)closeIfNotCurrentView
{
if ([[[self _frame] frameView] documentView] != self)
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index bdb8145..f96f942 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::canShowMIMETypeAsHTML): Added stub.
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
2010-08-27 Kenneth Rohde Christiansen <kenneth.christiansen at openbossa.org>
Reviewed by Antti Koivisto.
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 5980c27..a661848 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -612,7 +612,12 @@ void FrameLoaderClientQt::finishedLoading(DocumentLoader* loader)
m_hasSentResponseToPlugin = false;
}
-
+bool FrameLoaderClientQt::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
bool FrameLoaderClientQt::canShowMIMEType(const String& MIMEType) const
{
String type = MIMEType;
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index 9941324..5265354 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -174,6 +174,7 @@ public:
virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
virtual bool canShowMIMEType(const String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const String& URLScheme) const;
virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const;
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 369241a..8c8e7a3 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,22 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebFrame.cpp:
+ (WebFrame::canShowMIMETypeASHTML): Added.
+
2010-09-11 Adam Barth <abarth at webkit.org>
Reviewed by Sam Weinig.
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index 1c021f9..55bf59d 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -1604,6 +1604,12 @@ bool WebFrame::canHandleRequest(const ResourceRequest& request) const
return WebView::canHandleRequest(request);
}
+bool WebFrame::canShowMIMETypeASHTML(const String& /*MIMEType*/) const
+{
+ notImplemented();
+ return true;
+}
+
bool WebFrame::canShowMIMEType(const String& /*MIMEType*/) const
{
notImplemented();
diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog
index 0293589..d2b7271 100644
--- a/WebKit/wx/ChangeLog
+++ b/WebKit/wx/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebKitSupport/FrameLoaderClientWx.cpp:
+ (WebCore::FrameLoaderClientWx::canShowMIMETypeAsHTML): Added stub.
+ * WebKitSupport/FrameLoaderClientWx.h:
+
2010-09-10 Adam Barth <abarth at webkit.org>
Reviewed by Darin Fisher.
diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
index 999d2cd..0dcbf69 100644
--- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
+++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
@@ -445,7 +445,13 @@ void FrameLoaderClientWx::finishedLoading(DocumentLoader* loader)
}
}
+bool FrameLoaderClientWx::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return true;
+}
+
bool FrameLoaderClientWx::canShowMIMEType(const String& MIMEType) const
{
notImplemented();
diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
index 0dee4bf..c8c9b83 100644
--- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
+++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
@@ -131,6 +131,7 @@ namespace WebCore {
virtual void finishedLoading(DocumentLoader*);
virtual bool canShowMIMEType(const String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const String& URLScheme) const;
virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const;
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 9237595..1fa8227 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,27 @@
+2010-09-13 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Paste should be implemented in WebCore like Copy and Cut for Mac also.
+ https://bugs.webkit.org/show_bug.cgi?id=45494
+ <rdar://problem/7660537>
+
+ On the Mac platform, the implementation of the paste operation is all done
+ at the WebKit level. In order to support it on WebKit2 it is necessary to
+ refactor the code and move this functionality at the level of WebCore like
+ we already have on Windows.
+ The original code relies on some in AppKit functions that call back into
+ WebKit causing problems in WebKit2. All this functionality has been moved
+ at the level of the editor client where it can be dealt with appropriately.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::documentFragmentFromAttributedString): Added.
+ (WebKit::WebEditorClient::setInsertionPasteboard): Added.
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::canShowMIMETypeAsHTML): Added.
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
2010-09-11 Daniel Bates <dbates at rim.com>
Attempt to fix the Qt Linux Release build after changeset 67312 <http://trac.webkit.org/changeset/67312>.
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
index 357c66f..8d599a1 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
@@ -32,6 +32,8 @@
#include "WebPage.h"
#include "WebPageProxyMessageKinds.h"
#include "WebProcess.h"
+#include <WebCore/ArchiveResource.h>
+#include <WebCore/DocumentFragment.h>
#include <WebCore/EditCommand.h>
#include <WebCore/Frame.h>
#include <WebCore/HTMLInputElement.h>
@@ -313,6 +315,17 @@ NSString* WebEditorClient::userVisibleString(NSURL*)
return nil;
}
+DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString*, Vector<ArchiveResource*>&)
+{
+ // FIXME: add code here to create fake WebView and load WebKit 1
+ notImplemented();
+ return 0;
+}
+
+void WebEditorClient::setInsertionPasteboard(NSPasteboard*)
+{
+}
+
#ifdef BUILDING_ON_TIGER
NSArray* WebEditorClient::pasteboardTypesForSelection(Frame*)
{
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
index c7521f7..6f89a31 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
@@ -92,6 +92,8 @@ private:
#if PLATFORM(MAC)
virtual NSString* userVisibleString(NSURL*);
+ virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<WebCore::ArchiveResource*>&);
+ virtual void setInsertionPasteboard(NSPasteboard*);
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(WebCore::Frame*);
#endif
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index 1bc1ed7..93c65b0 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -772,6 +772,11 @@ bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
return true;
}
+bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ return true;
+}
+
bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
{
notImplemented();
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
index d652a81..bcde537 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
@@ -150,6 +150,7 @@ private:
virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
virtual bool canShowMIMEType(const WTF::String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const;
virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list