- Revision
- 207797
- Author
- cdu...@apple.com
- Date
- 2016-10-24 18:48:42 -0700 (Mon, 24 Oct 2016)
Log Message
event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
https://bugs.webkit.org/show_bug.cgi?id=19893
<rdar://problem/6055546>
Reviewed by Ryosuke Niwa.
Source/WebCore:
We now write selection as HTML as well to the pasteboard so that
event.(dataTransfer|clipboardData).getData('text/html') now works.
I have verified manually that it is still possible to copy text from
Safari and paste it to Excel 2011 Mac after this change. The text is
now pasted as HTML instead of text, which is fine because Excel can
display HTML.
No new tests, unskipped existing tests.
* editing/Editor.h:
* editing/mac/EditorMac.mm:
(WebCore::Editor::selectionInHTMLFormat):
(WebCore::Editor::writeSelectionToPasteboard):
* platform/Pasteboard.h:
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::write):
LayoutTests:
Unskip corresponding tests on Mac.
* editing/pasteboard/onpaste-text-html-expected.txt:
* fast/events/ondrop-text-html-expected.txt:
* platform/mac/TestExpectations:
* platform/wk2/TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (207796 => 207797)
--- trunk/LayoutTests/ChangeLog 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/LayoutTests/ChangeLog 2016-10-25 01:48:42 UTC (rev 207797)
@@ -1,3 +1,18 @@
+2016-10-24 Chris Dumez <cdu...@apple.com>
+
+ event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
+ https://bugs.webkit.org/show_bug.cgi?id=19893
+ <rdar://problem/6055546>
+
+ Reviewed by Ryosuke Niwa.
+
+ Unskip corresponding tests on Mac.
+
+ * editing/pasteboard/onpaste-text-html-expected.txt:
+ * fast/events/ondrop-text-html-expected.txt:
+ * platform/mac/TestExpectations:
+ * platform/wk2/TestExpectations:
+
2016-10-24 Alex Christensen <achristen...@webkit.org>
URLParser should match old URL::parse with %2E in path
Modified: trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt (207796 => 207797)
--- trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt 2016-10-25 01:48:42 UTC (rev 207797)
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the clipboard during an onpaste event.
-CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
+CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
This test verifies that we can get text/html from the clipboard during an onpaste event. This test requires DRT.
Paste content in this div.This test verifies that we can get text/html from the clipboard during an onpaste event.
PASS
Modified: trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt (207796 => 207797)
--- trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt 2016-10-25 01:48:42 UTC (rev 207797)
@@ -1,4 +1,4 @@
CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the drag object during an ondrop event.
-CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
+CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
This test verifies that we can get text/html from the drag object during an ondrop event. This test requires DRT.
PASS
Modified: trunk/LayoutTests/platform/mac/TestExpectations (207796 => 207797)
--- trunk/LayoutTests/platform/mac/TestExpectations 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2016-10-25 01:48:42 UTC (rev 207797)
@@ -96,11 +96,6 @@
# Need to add functionality to DumpRenderTree to handle scrollbar policy changes
fast/overflow/scrollbar-restored-and-then-locked.html
-# Mac port doesn't put text/html on the pasteboard for app compatibility: https://bugs.webkit.org/show_bug.cgi?id=19893
-editing/pasteboard/onpaste-text-html-types.html
-editing/pasteboard/onpaste-text-html.html
-fast/events/ondrop-text-html.html
-
# EventSendingController does not send events on areas outside the WebView.
scrollbars/scrollbar-click-does-not-blur-content.html
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (207796 => 207797)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2016-10-25 01:48:42 UTC (rev 207797)
@@ -224,6 +224,7 @@
fast/events/controlclick-no-onclick.html
fast/events/moving-text-should-fire-drop-and-dragend-events.html
fast/events/moving-text-should-fire-drop-and-dragend-events-2.html
+fast/events/ondrop-text-html.html
editing/pasteboard/drag-drop-url-with-style.html
# WTR needs an implementation for eventSender.continuousMouseScrollBy
Modified: trunk/Source/WebCore/ChangeLog (207796 => 207797)
--- trunk/Source/WebCore/ChangeLog 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/Source/WebCore/ChangeLog 2016-10-25 01:48:42 UTC (rev 207797)
@@ -1,3 +1,29 @@
+2016-10-24 Chris Dumez <cdu...@apple.com>
+
+ event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
+ https://bugs.webkit.org/show_bug.cgi?id=19893
+ <rdar://problem/6055546>
+
+ Reviewed by Ryosuke Niwa.
+
+ We now write selection as HTML as well to the pasteboard so that
+ event.(dataTransfer|clipboardData).getData('text/html') now works.
+
+ I have verified manually that it is still possible to copy text from
+ Safari and paste it to Excel 2011 Mac after this change. The text is
+ now pasted as HTML instead of text, which is fine because Excel can
+ display HTML.
+
+ No new tests, unskipped existing tests.
+
+ * editing/Editor.h:
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::selectionInHTMLFormat):
+ (WebCore::Editor::writeSelectionToPasteboard):
+ * platform/Pasteboard.h:
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::write):
+
2016-10-24 Alex Christensen <achristen...@webkit.org>
URLParser should match old URL::parse with %2E in path
Modified: trunk/Source/WebCore/editing/Editor.h (207796 => 207797)
--- trunk/Source/WebCore/editing/Editor.h 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/Source/WebCore/editing/Editor.h 2016-10-25 01:48:42 UTC (rev 207797)
@@ -509,6 +509,7 @@
#if PLATFORM(COCOA)
RefPtr<SharedBuffer> selectionInWebArchiveFormat();
+ String selectionInHTMLFormat();
RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&);
RefPtr<Range> adjustedSelectionRange();
RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (207796 => 207797)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-10-25 01:48:42 UTC (rev 207797)
@@ -310,6 +310,11 @@
return SharedBuffer::wrapCFData(archive->rawDataRepresentation().get());
}
+String Editor::selectionInHTMLFormat()
+{
+ return createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+}
+
RefPtr<SharedBuffer> Editor::imageInWebArchiveFormat(Element& imageElement)
{
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(imageElement);
@@ -393,6 +398,7 @@
content.dataInWebArchiveFormat = selectionInWebArchiveFormat();
content.dataInRTFDFormat = [attributedString containsAttachments] ? dataInRTFDFormat(attributedString) : 0;
content.dataInRTFFormat = dataInRTFFormat(attributedString);
+ content.dataInHTMLFormat = selectionInHTMLFormat();
content.dataInStringFormat = stringSelectionForPasteboardWithImageAltText();
client()->getClientPasteboardDataForRange(selectedRange().get(), content.clientTypes, content.clientData);
Modified: trunk/Source/WebCore/platform/Pasteboard.h (207796 => 207797)
--- trunk/Source/WebCore/platform/Pasteboard.h 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2016-10-25 01:48:42 UTC (rev 207797)
@@ -70,6 +70,7 @@
RefPtr<SharedBuffer> dataInWebArchiveFormat;
RefPtr<SharedBuffer> dataInRTFDFormat;
RefPtr<SharedBuffer> dataInRTFFormat;
+ String dataInHTMLFormat;
String dataInStringFormat;
Vector<String> clientTypes;
Vector<RefPtr<SharedBuffer>> clientData;
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (207796 => 207797)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2016-10-25 01:38:19 UTC (rev 207796)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2016-10-25 01:48:42 UTC (rev 207797)
@@ -153,6 +153,8 @@
types.append(String(NSRTFDPboardType));
if (content.dataInRTFFormat)
types.append(String(NSRTFPboardType));
+ if (!content.dataInHTMLFormat.isNull())
+ types.append(String(NSHTMLPboardType));
if (!content.dataInStringFormat.isNull())
types.append(String(NSStringPboardType));
types.appendVector(content.clientTypes);
@@ -170,6 +172,8 @@
m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(content.dataInRTFDFormat.get(), NSRTFDPboardType, m_pasteboardName);
if (content.dataInRTFFormat)
m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(content.dataInRTFFormat.get(), NSRTFPboardType, m_pasteboardName);
+ if (!content.dataInHTMLFormat.isNull())
+ m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(content.dataInHTMLFormat, NSHTMLPboardType, m_pasteboardName);
if (!content.dataInStringFormat.isNull())
m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(content.dataInStringFormat, NSStringPboardType, m_pasteboardName);
}