Commit 38848efa authored by enrica@apple.com's avatar enrica@apple.com
Browse files

Upstream changes to Pasteboard implementation for iOS.

https://bugs.webkit.org/show_bug.cgi?id=121818

Reviewed by Benjamin Poulain.

Source/WebCore: 

* WebCore.exp.in:
* editing/Editor.cpp:
(WebCore::Editor::dispatchCPPEvent):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::WebContentReader::addFragment):
(WebCore::Editor::WebContentReader::readWebArchive):
(WebCore::Editor::WebContentReader::readFilenames):
(WebCore::Editor::WebContentReader::readHTML):
(WebCore::Editor::WebContentReader::readRTFD):
(WebCore::Editor::WebContentReader::readRTF):
(WebCore::uniqueURLWithRelativePart):
(WebCore::Editor::WebContentReader::readImage):
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::WebContentReader::readPlainText):
(WebCore::Editor::webContentFromPasteboard):
(WebCore::Editor::pasteWithPasteboard):
(WebCore::Editor::createFragmentAndAddResources):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
* platform/Pasteboard.h:
* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/ios/PasteboardIOS.mm:
(WebCore::PasteboardWebContent::PasteboardWebContent):
(WebCore::PasteboardWebContent::~PasteboardWebContent):
(WebCore::PasteboardImage::PasteboardImage):
(WebCore::PasteboardImage::~PasteboardImage):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::clear):
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::writeString):
(WebCore::Pasteboard::types):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::changeCount):
(WebCore::PlatformPasteboard::write):
(WebCore::PlatformPasteboard::count):
(WebCore::PlatformPasteboard::readBuffer):
(WebCore::PlatformPasteboard::readString):
(WebCore::PlatformPasteboard::readURL):
* platform/mac/PasteboardMac.mm:
(WebCore::PasteboardWebContent::PasteboardWebContent):
(WebCore::PasteboardWebContent::~PasteboardWebContent):
(WebCore::PasteboardImage::PasteboardImage):
(WebCore::PasteboardImage::~PasteboardImage):
* platform/mac/PlatformPasteboardMac.mm:

Source/WebKit/mac: 

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::writeToPasteboard):
(WebPlatformStrategies::getPasteboardItemsCount):
(WebPlatformStrategies::readBufferFromPasteboard):
(WebPlatformStrategies::readURLFromPasteboard):
(WebPlatformStrategies::readStringFromPasteboard):
(WebPlatformStrategies::changeCount):

Source/WebKit2: 

* Shared/WebCoreArgumentCoders.cpp:
(CoreIPC::decodeSharedBuffer):
* Shared/WebCoreArgumentCoders.h:
* UIProcess/WebContext.h:
* UIProcess/WebContext.messages.in:
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::writeWebContentToPasteboard):
(WebKit::WebContext::writeImageToPasteboard):
(WebKit::WebContext::writeStringToPasteboard):
(WebKit::WebContext::readStringFromPasteboard):
(WebKit::WebContext::readURLFromPasteboard):
(WebKit::WebContext::readBufferFromPasteboard):
(WebKit::WebContext::getPasteboardItemsCount):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToPasteboard):
(WebKit::WebPlatformStrategies::getPasteboardItemsCount):
(WebKit::WebPlatformStrategies::readBufferFromPasteboard):
(WebKit::WebPlatformStrategies::readURLFromPasteboard):
(WebKit::WebPlatformStrategies::readStringFromPasteboard):
(WebKit::WebPlatformStrategies::changeCount):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156588 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 19e5534f
2013-09-27 Enrica Casucci <enrica@apple.com>
Upstream changes to Pasteboard implementation for iOS.
https://bugs.webkit.org/show_bug.cgi?id=121818
Reviewed by Benjamin Poulain.
* WebCore.exp.in:
* editing/Editor.cpp:
(WebCore::Editor::dispatchCPPEvent):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::WebContentReader::addFragment):
(WebCore::Editor::WebContentReader::readWebArchive):
(WebCore::Editor::WebContentReader::readFilenames):
(WebCore::Editor::WebContentReader::readHTML):
(WebCore::Editor::WebContentReader::readRTFD):
(WebCore::Editor::WebContentReader::readRTF):
(WebCore::uniqueURLWithRelativePart):
(WebCore::Editor::WebContentReader::readImage):
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::WebContentReader::readPlainText):
(WebCore::Editor::webContentFromPasteboard):
(WebCore::Editor::pasteWithPasteboard):
(WebCore::Editor::createFragmentAndAddResources):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
* platform/Pasteboard.h:
* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/ios/PasteboardIOS.mm:
(WebCore::PasteboardWebContent::PasteboardWebContent):
(WebCore::PasteboardWebContent::~PasteboardWebContent):
(WebCore::PasteboardImage::PasteboardImage):
(WebCore::PasteboardImage::~PasteboardImage):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::clear):
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::writeString):
(WebCore::Pasteboard::types):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::changeCount):
(WebCore::PlatformPasteboard::write):
(WebCore::PlatformPasteboard::count):
(WebCore::PlatformPasteboard::readBuffer):
(WebCore::PlatformPasteboard::readString):
(WebCore::PlatformPasteboard::readURL):
* platform/mac/PasteboardMac.mm:
(WebCore::PasteboardWebContent::PasteboardWebContent):
(WebCore::PasteboardWebContent::~PasteboardWebContent):
(WebCore::PasteboardImage::PasteboardImage):
(WebCore::PasteboardImage::~PasteboardImage):
* platform/mac/PlatformPasteboardMac.mm:
2013-09-27 Hans Muller <hmuller@adobe.com>
 
Crash on shape-outside when using calc()
......@@ -486,6 +486,8 @@ __ZN7WebCore15GraphicsContext9translateEff
__ZN7WebCore15GraphicsContextD1Ev
__ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
__ZN7WebCore15JSDOMWindowBase8commonVMEv
__ZN7WebCore15PasteboardImageC1Ev
__ZN7WebCore15PasteboardImageD1Ev
__ZN7WebCore15PlatformCALayer18setGeometryFlippedEb
__ZN7WebCore15ProtectionSpaceC1ERKN3WTF6StringEiNS_25ProtectionSpaceServerTypeES4_NS_35ProtectionSpaceAuthenticationSchemeE
__ZN7WebCore15ProtectionSpaceC1Ev
......@@ -668,6 +670,8 @@ __ZN7WebCore20DictationAlternativeC1Ejjy
__ZN7WebCore20DictationAlternativeC1Ev
__ZN7WebCore20DisplaySleepDisablerC1EPKc
__ZN7WebCore20DisplaySleepDisablerD1Ev
__ZN7WebCore20PasteboardWebContentC1Ev
__ZN7WebCore20PasteboardWebContentD1Ev
__ZN7WebCore20RenderEmbeddedObject29setPluginUnavailabilityReasonENS0_26PluginUnavailabilityReasonE
__ZN7WebCore20RenderEmbeddedObject37setUnavailablePluginIndicatorIsHiddenEb
__ZN7WebCore20RenderEmbeddedObject44setPluginUnavailabilityReasonWithDescriptionENS0_26PluginUnavailabilityReasonERKN3WTF6StringE
......
......@@ -438,7 +438,7 @@ String Editor::plainTextFromPasteboard(const PasteboardPlainText& text)
#endif
#if !(PLATFORM(MAC) && !PLATFORM(IOS)) && !PLATFORM(EFL)
#if !PLATFORM(MAC) && !PLATFORM(EFL)
void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
{
RefPtr<Range> range = selectedRange();
......@@ -713,10 +713,6 @@ bool Editor::dispatchCPPEvent(const AtomicString& eventType, ClipboardAccessPoli
RefPtr<Clipboard> clipboard = Clipboard::createForCopyAndPaste(policy);
#if PLATFORM(IOS)
clipboard->pasteboard().setFrame(m_frame);
#endif
RefPtr<Event> event = ClipboardEvent::create(eventType, true, true, clipboard);
target->dispatchEvent(event, IGNORE_EXCEPTION);
bool noDefaultProcessing = event->defaultPrevented();
......
......@@ -31,9 +31,12 @@
#include "CSSComputedStyleDeclaration.h"
#include "CSSPrimitiveValueMappings.h"
#include "DOMRangeInternal.h"
#include "DocumentFragment.h"
#include "DocumentLoader.h"
#include "EditorClient.h"
#include "Font.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "HTMLConverter.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
......@@ -41,18 +44,40 @@
#include "HTMLTextAreaElement.h"
#include "LegacyWebArchive.h"
#include "NodeTraversal.h"
#include "Page.h"
#include "Pasteboard.h"
#include "RenderBlock.h"
#include "RenderImage.h"
#include "SharedBuffer.h"
#include "SoftLinking.h"
#include "StylePropertySet.h"
#include "Text.h"
#include "TypingCommand.h"
#include "WAKAppKitStubs.h"
#include "htmlediting.h"
#include "markup.h"
#if PLATFORM(IOS)
SOFT_LINK_FRAMEWORK(AppSupport)
SOFT_LINK(AppSupport, CPSharedResourcesDirectory, CFStringRef, (void), ())
SOFT_LINK_FRAMEWORK(MobileCoreServices)
SOFT_LINK(MobileCoreServices, UTTypeConformsTo, Boolean, (CFStringRef inUTI, CFStringRef inConformsToUTI), (inUTI, inConformsToUTI))
SOFT_LINK(MobileCoreServices, UTTypeCreatePreferredIdentifierForTag, CFStringRef, (CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI), (inTagClass, inTag, inConformingToUTI))
SOFT_LINK(MobileCoreServices, UTTypeCopyPreferredTagWithClass, CFStringRef, (CFStringRef inUTI, CFStringRef inTagClass), (inUTI, inTagClass))
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypePNG, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeJPEG, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassFilenameExtension, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassMIMEType, CFStringRef)
#define kUTTypePNG getkUTTypePNG()
#define kUTTypeJPEG getkUTTypeJPEG()
#define kUTTagClassFilenameExtension getkUTTagClassFilenameExtension()
#define kUTTagClassMIMEType getkUTTagClassMIMEType()
@interface NSAttributedString (NSAttributedStringKitAdditions)
- (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary **)dict;
- (id)initWithRTFD:(NSData *)data documentAttributes:(NSDictionary **)dict;
......@@ -353,6 +378,234 @@ void Editor::writeImageToPasteboard(Pasteboard& pasteboard, Element& imageElemen
pasteboard.write(pasteboardImage);
}
class Editor::WebContentReader FINAL : public PasteboardWebContentReader {
public:
WebContentReader(Frame& frame, Range& context, bool allowPlainText)
: frame(frame)
, context(context)
, allowPlainText(allowPlainText)
, madeFragmentFromPlainText(false)
{
}
Frame& frame;
Range& context;
const bool allowPlainText;
RefPtr<DocumentFragment> fragment;
bool madeFragmentFromPlainText;
private:
virtual bool readWebArchive(PassRefPtr<SharedBuffer>) OVERRIDE;
virtual bool readFilenames(const Vector<String>&) OVERRIDE;
virtual bool readHTML(const String&) OVERRIDE;
virtual bool readRTFD(PassRefPtr<SharedBuffer>) OVERRIDE;
virtual bool readRTF(PassRefPtr<SharedBuffer>) OVERRIDE;
virtual bool readImage(PassRefPtr<SharedBuffer>, const String& type) OVERRIDE;
virtual bool readURL(const URL&, const String& title) OVERRIDE;
virtual bool readPlainText(const String&) OVERRIDE;
void addFragment(PassRefPtr<DocumentFragment>);
};
void Editor::WebContentReader::addFragment(PassRefPtr<DocumentFragment> newFragment)
{
if (fragment) {
if (newFragment && newFragment->firstChild()) {
ExceptionCode ec;
fragment->appendChild(newFragment->firstChild(), ec);
}
} else
fragment = newFragment;
}
bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
{
if (!frame.document())
return false;
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(URL(), buffer.get());
if (!archive)
return false;
RefPtr<ArchiveResource> mainResource = archive->mainResource();
if (!mainResource)
return false;
const String& type = mainResource->mimeType();
if (frame.loader()->client()->canShowMIMETypeAsHTML(type)) {
// FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
if (DocumentLoader* loader = frame.loader()->documentLoader())
loader->addAllArchiveResources(archive.get());
String markupString = String::fromUTF8(mainResource->data()->data(), mainResource->data()->size());
addFragment(createFragmentFromMarkup(frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
return true;
}
return false;
}
bool Editor::WebContentReader::readFilenames(const Vector<String>&)
{
return false;
}
bool Editor::WebContentReader::readHTML(const String&)
{
return false;
}
bool Editor::WebContentReader::readRTFD(PassRefPtr<SharedBuffer> buffer)
{
addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer->createNSData() documentAttributes:nullptr]).get()));
return fragment;
}
bool Editor::WebContentReader::readRTF(PassRefPtr<SharedBuffer> buffer)
{
addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer->createNSData() documentAttributes:nullptr]).get()));
return fragment;
}
static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
{
RetainPtr<CFUUIDRef> UUIDRef = adoptCF(CFUUIDCreate(kCFAllocatorDefault));
RetainPtr<NSString> UUIDString = adoptNS((NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef.get()));
return [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", @"webkit-fake-url", UUIDString.get(), relativePart]];;
}
bool Editor::WebContentReader::readImage(PassRefPtr<SharedBuffer> buffer, const String& type)
{
RetainPtr<CFStringRef> stringType = type.createCFString();
RetainPtr<NSString> filenameExtension = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassFilenameExtension));
NSString *relativeURLPart = [@"image" stringByAppendingString:filenameExtension.get()];
RetainPtr<NSString> mimeType = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassMIMEType));
addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(buffer, uniqueURLWithRelativePart(relativeURLPart), mimeType.get(), emptyString(), emptyString())));
return fragment;
}
bool Editor::WebContentReader::readURL(const URL& url, const String&)
{
if (url.isEmpty())
return false;
if (!frame.editor().client()->hasRichlyEditableSelection()) {
if (readPlainText([(NSURL *)url absoluteString]))
return true;
}
if ([(NSURL *)url isFileURL]) {
NSString *localPath = [(NSURL *)url relativePath];
// Only allow url attachments from ~/Media for now.
if (![localPath hasPrefix:[(NSString *)CPSharedResourcesDirectory() stringByAppendingString:@"/Media/DCIM/"]])
return false;
RetainPtr<NSString> fileType = adoptNS((NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[localPath pathExtension], NULL));
NSData *data = [NSData dataWithContentsOfFile:localPath];
if (UTTypeConformsTo((CFStringRef)fileType.get(), kUTTypePNG)) {
addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(SharedBuffer::wrapNSData([[data copy] autorelease]), uniqueURLWithRelativePart(@"image.png"), @"image/png", emptyString(), emptyString())));
return fragment;
} else if (UTTypeConformsTo((CFStringRef)fileType.get(), kUTTypeJPEG)) {
addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(SharedBuffer::wrapNSData([[data copy] autorelease]), uniqueURLWithRelativePart(@"image.jpg"), @"image/jpg", emptyString(), emptyString())));
return fragment;
}
} else {
RefPtr<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
anchor->setAttribute(HTMLNames::hrefAttr, url.string());
anchor->appendChild(frame.document()->createTextNode([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]));
RefPtr<DocumentFragment> newFragment = frame.document()->createDocumentFragment();
newFragment->appendChild(anchor.release());
addFragment(newFragment);
return true;
}
return false;
}
bool Editor::WebContentReader::readPlainText(const String& text)
{
if (!allowPlainText)
return false;
addFragment(createFragmentFromText(&context, [text precomposedStringWithCanonicalMapping]));
if (!fragment)
return false;
madeFragmentFromPlainText = true;
return true;
}
// FIXME: Should give this function a name that makes it clear it adds resources to the document loader as a side effect.
// Or refactor so it does not do that.
PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
{
WebContentReader reader(*m_frame, context, allowPlainText);
pasteboard.read(reader);
chosePlainText = reader.madeFragmentFromPlainText;
return reader.fragment.release();
}
void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
{
RefPtr<Range> range = selectedRange();
bool chosePlainText;
RefPtr<DocumentFragment> fragment = client()->documentFragmentFromDelegate(0);
if (!fragment)
fragment = webContentFromPasteboard(*pasteboard, *range, allowPlainText, chosePlainText);
if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false);
}
PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
{
if (!m_frame->page() || !m_frame->document() || !m_frame->document()->isHTMLDocument())
return nullptr;
if (!string)
return nullptr;
bool wasDeferringCallbacks = m_frame->page()->defersLoading();
if (!wasDeferringCallbacks)
m_frame->page()->setDefersLoading(true);
Vector<RefPtr<ArchiveResource>> resources;
RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
if (DocumentLoader* loader = m_frame->loader()->documentLoader()) {
for (size_t i = 0, size = resources.size(); i < size; ++i)
loader->addArchiveResource(resources[i]);
}
if (!wasDeferringCallbacks)
m_frame->page()->setDefersLoading(false);
return fragment.release();
}
PassRefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource> resource)
{
if (!resource)
return nullptr;
RefPtr<Element> imageElement = m_frame->document()->createElement(HTMLNames::imgTag, false);
// FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
if (DocumentLoader* loader = m_frame->loader()->documentLoader())
loader->addArchiveResource(resource.get());
NSURL *URL = resource->url();
imageElement->setAttribute(HTMLNames::srcAttr, [URL isFileURL] ? [URL absoluteString] : resource->url());
RefPtr<DocumentFragment> fragment = m_frame->document()->createDocumentFragment();
fragment->appendChild(imageElement.release());
return fragment.release();
}
} // namespace WebCore
#endif // PLATFORM(IOS)
......@@ -27,9 +27,7 @@
#define Pasteboard_h
#include "DragImage.h"
#include "Image.h"
#include "URL.h"
#include "SharedBuffer.h"
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
......@@ -38,6 +36,11 @@
typedef struct _GtkClipboard GtkClipboard;
#endif
#if PLATFORM(IOS)
OBJC_CLASS NSArray;
OBJC_CLASS NSString;
#endif
#if PLATFORM(QT)
#include <QMimeData>
#endif
......@@ -50,11 +53,6 @@ typedef struct _GtkClipboard GtkClipboard;
typedef struct HWND__* HWND;
#endif
#if PLATFORM(IOS)
OBJC_CLASS NSArray;
OBJC_CLASS NSString;
#endif
// FIXME: This class uses the DOM and makes calls to Editor.
// It should be divested of its knowledge of the frame and editor.
......@@ -75,6 +73,8 @@ enum ShouldSerializeSelectedTextForClipboard { DefaultSelectedTextType, IncludeI
struct PasteboardWebContent {
#if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WIN))
PasteboardWebContent();
~PasteboardWebContent();
bool canSmartCopyOrDelete;
RefPtr<SharedBuffer> dataInWebArchiveFormat;
RefPtr<SharedBuffer> dataInRTFDFormat;
......@@ -94,6 +94,8 @@ struct PasteboardURL {
};
struct PasteboardImage {
PasteboardImage();
~PasteboardImage();
RefPtr<Image> image;
#if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WIN))
PasteboardURL url;
......@@ -108,7 +110,7 @@ class PasteboardWebContentReader {
public:
virtual ~PasteboardWebContentReader() { }
#if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(IOS) || PLATFORM(QT) || PLATFORM(WIN))
#if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WIN))
virtual bool readWebArchive(PassRefPtr<SharedBuffer>) = 0;
virtual bool readFilenames(const Vector<String>&) = 0;
virtual bool readHTML(const String&) = 0;
......@@ -165,7 +167,7 @@ public:
void setDragImage(DragImageRef, const IntPoint& hotSpot);
#endif
#if PLATFORM(GTK) || PLATFORM(IOS) || PLATFORM(QT) || PLATFORM(WIN)
#if PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WIN)
PassRefPtr<DocumentFragment> documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
#endif
......@@ -185,10 +187,8 @@ public:
#endif
#if PLATFORM(IOS)
void setFrame(Frame*); // FIXME: Layering violation.
static NSArray* supportedPasteboardTypes();
static String resourceMIMEType(NSString *mimeType);
static String resourceMIMEType(const NSString *mimeType);
#endif
#if PLATFORM(MAC) && !PLATFORM(IOS)
......@@ -223,10 +223,6 @@ private:
Pasteboard(GtkClipboard*);
#endif
#if PLATFORM(IOS)
PassRefPtr<DocumentFragment> documentFragmentForPasteboardItemAtIndex(Frame*, int index, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
#endif
#if PLATFORM(QT)
Pasteboard(const QMimeData* , bool);
......@@ -250,7 +246,6 @@ private:
#endif
#if PLATFORM(IOS)
Frame* m_frame; // FIXME: Layering violation.
long m_changeCount;
#endif
......
......@@ -26,10 +26,6 @@
#ifndef PasteboardStrategy_h
#define PasteboardStrategy_h
#if PLATFORM(IOS)
#include "Pasteboard.h"
#endif
#include "SharedBuffer.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
......@@ -37,17 +33,25 @@
namespace WebCore {
class Color;
class SharedBuffer;
class URL;
struct PasteboardImage;
struct PasteboardWebContent;
class PasteboardStrategy {
public:
#if PLATFORM(MAC)
#if PLATFORM(IOS)
// FIXME: we should move Mac to this.
virtual void writeToPasteboard(const PasteboardWebContent& content) = 0;
virtual void writeToPasteboard(const PasteboardImage& pasteboardImage) = 0;
virtual void writeToPasteboard(const String& text) = 0;
#endif
// FIXME: We should move Mac to this.
virtual void writeToPasteboard(const PasteboardWebContent&) = 0;
virtual void writeToPasteboard(const PasteboardImage&) = 0;
virtual void writeToPasteboard(const String& pasteboardType, const String&) = 0;
virtual int getPasteboardItemsCount() = 0;
virtual String readStringFromPasteboard(int index, const String& pasteboardType) = 0;
virtual PassRefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) = 0;
virtual URL readURLFromPasteboard(int index, const String& pasteboardType) = 0;
virtual long changeCount() = 0;
#endif // PLATFORM(IOS)
#if PLATFORM(MAC)
virtual void getTypes(Vector<String>& types, const String& pasteboardName) = 0;
virtual PassRefPtr<SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) = 0;
virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) = 0;
......
......@@ -26,10 +26,9 @@
#ifndef PlatformPasteboard_h
#define PlatformPasteboard_h
#include "Pasteboard.h"
#include "SharedBuffer.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
#if PLATFORM(MAC) && !PLATFORM(IOS)
......@@ -43,15 +42,18 @@ OBJC_CLASS UIPasteboard;
namespace WebCore {
class Color;
class SharedBuffer;
class URL;
struct PasteboardImage;
struct PasteboardWebContent;
class PlatformPasteboard {
public:
// FIXME: probably we don't need a constructor that takes a pasteboard name for iOS.
explicit PlatformPasteboard(const String& pasteboardName);
#if PLATFORM(IOS)
PlatformPasteboard();
#endif
// FIXME: probably we don't need a constructor that takes a pasteboard name for iOS.
explicit PlatformPasteboard(const String& pasteboardName);
static String uniqueName();
void getTypes(Vector<String>& types);
......@@ -71,9 +73,13 @@ public:
long setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType);
long setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType);
long setStringForType(const String&, const String& pasteboardType);
void write(const PasteboardWebContent& content);
void write(const PasteboardImage& pasteboardImage);
void write(const String& text);
void write(const PasteboardWebContent&);
void write(const PasteboardImage&);
void write(const String& pasteboardType, const String&);
PassRefPtr<SharedBuffer> readBuffer(int index, const String& pasteboardType);
String readString(int index, const String& pasteboardType);
URL readURL(int index, const String& pasteboardType);
int count();
private:
#if PLATFORM(MAC) && !PLATFORM(IOS)
......
......@@ -59,12 +59,10 @@
- (BOOL)containsAttachments;
@end
// FIXME: the following soft linking and #define needs to be shared
// with PlatformPasteboardIOS.mm
// FIXME: The following soft linking and #define needs to be shared with PlatformPasteboardIOS.mm and EditorIOS.mm
SOFT_LINK_FRAMEWORK(MobileCoreServices)
SOFT_LINK(MobileCoreServices, UTTypeConformsTo, Boolean, (CFStringRef inUTI, CFStringRef inConformsToUTI), (inUTI, inConformsToUTI))
SOFT_LINK(MobileCoreServices, UTTypeCreatePreferredIdentifierForTag, CFStringRef, (CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI), (inTagClass, inTag, inConformingToUTI))
SOFT_LINK(MobileCoreServices, UTTypeCopyPreferredTagWithClass, CFStringRef, (CFStringRef inUTI, CFStringRef inTagClass), (inUTI, inTagClass))
......@@ -90,16 +88,31 @@ SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeRTF, CFStringRef)
#define kUTTypeRTFD getkUTTypeRTFD()
#define kUTTypeRTF getkUTTypeRTF()
SOFT_LINK_FRAMEWORK(AppSupport)
SOFT_LINK(AppSupport, CPSharedResourcesDirectory, CFStringRef, (void), ())