Skip to content
Permalink
Browse files
[iOS] Support pasting HTML
https://bugs.webkit.org/show_bug.cgi?id=133581
<rdar://problem/17070305>

Reviewed by Enrica Casucci.

We can probably share a lot of code between Mac and iOS here, but for now, just
implement the unimplemented functions.

* editing/ios/EditorIOS.mm: (WebCore::Editor::WebContentReader::readHTML):
Implemented based on WebArchive reading code above, and on Mac version of readHTML.
Unlike on Mac, we don't need to support Microsoft CF_HTML format, as nothing
generates it.

* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::supportedPasteboardTypes):
Added HTML support, as the second preferred format after WebArchive.


Canonical link: https://commits.webkit.org/151579@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169660 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aproskuryakov committed Jun 6, 2014
1 parent a28ae94 commit bf05b0648e3d43b59b66f33f5b77bc02bd6bcfcf
Showing 3 changed files with 36 additions and 3 deletions.
@@ -1,3 +1,24 @@
2014-06-06 Alexey Proskuryakov <ap@apple.com>

[iOS] Support pasting HTML
https://bugs.webkit.org/show_bug.cgi?id=133581
<rdar://problem/17070305>

Reviewed by Enrica Casucci.

We can probably share a lot of code between Mac and iOS here, but for now, just
implement the unimplemented functions.

* editing/ios/EditorIOS.mm: (WebCore::Editor::WebContentReader::readHTML):
Implemented based on WebArchive reading code above, and on Mac version of readHTML.
Unlike on Mac, we don't need to support Microsoft CF_HTML format, as nothing
generates it.

* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::supportedPasteboardTypes):
Added HTML support, as the second preferred format after WebArchive.

2014-06-06 Alexey Proskuryakov <ap@apple.com>

Try to fix the build after http://trac.webkit.org/changeset/169655
@@ -463,9 +463,13 @@ static void getImage(Element& imageElement, RefPtr<Image>& image, CachedImage*&
return false;
}

bool Editor::WebContentReader::readHTML(const String&)
bool Editor::WebContentReader::readHTML(const String& string)
{
return false;
if (!frame.document())
return false;

addFragment(createFragmentFromMarkup(*frame.document(), string, emptyString(), DisallowScriptingAndPluginContent));
return true;
}

bool Editor::WebContentReader::readRTFD(PassRefPtr<SharedBuffer> buffer)
@@ -77,6 +77,7 @@ - (BOOL)containsAttachments;
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeGIF, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassMIMEType, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassFilenameExtension, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeHTML, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeRTFD, CFStringRef)
SOFT_LINK_CONSTANT(MobileCoreServices, kUTTypeRTF, CFStringRef)

@@ -88,6 +89,7 @@ - (BOOL)containsAttachments;
#define kUTTypeGIF getkUTTypeGIF()
#define kUTTagClassMIMEType getkUTTagClassMIMEType()
#define kUTTagClassFilenameExtension getkUTTagClassFilenameExtension()
#define kUTTypeHTML getkUTTypeHTML()
#define kUTTypeRTFD getkUTTypeRTFD()
#define kUTTypeRTF getkUTTypeRTF()

@@ -197,6 +199,12 @@ - (BOOL)containsAttachments;
}
}

if ([type isEqualToString:(NSString *)kUTTypeHTML]) {
String htmlString = strategy.readStringFromPasteboard(i, kUTTypeHTML);
if (!htmlString.isNull() && reader.readHTML(htmlString))
break;
}

if ([type isEqualToString:(NSString *)kUTTypeRTFD]) {
if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeRTFD)) {
if (reader.readRTFD(buffer.release()))
@@ -236,7 +244,7 @@ - (BOOL)containsAttachments;

NSArray* Pasteboard::supportedPasteboardTypes()
{
return @[(id)WebArchivePboardType, (id)kUTTypePNG, (id)kUTTypeTIFF, (id)kUTTypeJPEG, (id)kUTTypeGIF, (id)kUTTypeURL, (id)kUTTypeText, (id)kUTTypeRTFD, (id)kUTTypeRTF];
return @[(id)WebArchivePboardType, (id)kUTTypeHTML, (id)kUTTypePNG, (id)kUTTypeTIFF, (id)kUTTypeJPEG, (id)kUTTypeGIF, (id)kUTTypeURL, (id)kUTTypeText, (id)kUTTypeRTFD, (id)kUTTypeRTF];
}

bool Pasteboard::hasData()

0 comments on commit bf05b06

Please sign in to comment.