Title: [222228] trunk
Revision
222228
Author
[email protected]
Date
2017-09-19 14:50:03 -0700 (Tue, 19 Sep 2017)

Log Message

On iOS, getData can't get text set by setData during copy event
https://bugs.webkit.org/show_bug.cgi?id=176980
<rdar://problem/34453915>

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by iOS port not implementing Pasteboard::createPrivate(). Rather than implementing this in iOS,
replace its use for copy & paste events by StaticPasteboard Wenson added for input events. This makes read-write
pasteboard platform agnostic and paves the way to make writing to pasteboard in a single IPC in WebKit2.

Also fixed a bug that iOS port's Pasteboard::types returned the list of all supported types instead of ones
actually present in the pasteboard.

This patch also adds a vector of types to StaticPasteboard to maintain the type order.

Tests: editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html
       editing/pasteboard/dataTransfer-types-pasting-plaintext.html

* dom/DataTransfer.cpp:
(WebCore::DataTransfer::createForCopyAndPaste): Make StaticPasteboard instead of a private pasteboard.
(WebCore::DataTransfer::createForInputEvent):
* editing/Editor.cpp:
(WebCore::dispatchClipboardEvent): Call newly added commitToPasteboard on StaticPasteboard.
* platform/Pasteboard.h:
(WebCore::Pasteboard::isStatic const):
* platform/PasteboardStrategy.h:
* platform/StaticPasteboard.cpp:
(WebCore::StaticPasteboard::create): Deleted.
(WebCore::StaticPasteboard::StaticPasteboard):
(WebCore::StaticPasteboard::hasData):
(WebCore::StaticPasteboard::types): Deleted. Now simply returns m_type.
(WebCore::StaticPasteboard::readString): Added.
(WebCore::StaticPasteboard::writeString): Added.
(WebCore::StaticPasteboard::clear): Added.
(WebCore::StaticPasteboard::commitToPasteboard): Added.
(isType): Added.
* platform/StaticPasteboard.h:
(WebCore::Pasteboard::isStatic const): Added.
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::createPrivate): Deleted.
(WebCore::Pasteboard::writePasteboard): Deleted.
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::createPrivate): Deleted.
(WebCore::Pasteboard::writePasteboard): Deleted.
(WebCore::addHTMLClipboardTypesForCocoaType):
(WebCore::Pasteboard::types): Return the actual list of types in the pasteboard.
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::createPrivate): Deleted.
(WebCore::Pasteboard::writePasteboard): Deleted.
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::createPrivate): Deleted.
(WebCore::Pasteboard::writePasteboard): Deleted.
* platform/wpe/PasteboardWPE.cpp:
(WebCore::Pasteboard::createPrivate): Deleted.
(WebCore::Pasteboard::writePasteboard): Deleted.

Source/WebKit:

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::copy): Deleted.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::copy): Deleted.

LayoutTests:

Added regression tests to make sure dataTransfer.types returns an empty list when writing to a pasteboard (copy),
and doesn't contain image types when pasting plain text. Unfortunately, pasting image does result in plain text
content being present in the pasteboard in the form of URL so we can't test that scenario.

Also removed failing expectations from a number of tests that are now passing on iOS.

* editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt: Added.
* editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html: Added.
* editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt: Added.
* editing/pasteboard/dataTransfer-types-pasting-plaintext.html: Added.
* platform/ios/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222227 => 222228)


--- trunk/LayoutTests/ChangeLog	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/LayoutTests/ChangeLog	2017-09-19 21:50:03 UTC (rev 222228)
@@ -1,3 +1,23 @@
+2017-09-19  Ryosuke Niwa  <[email protected]>
+
+        On iOS, getData can't get text set by setData during copy event
+        https://bugs.webkit.org/show_bug.cgi?id=176980
+        <rdar://problem/34453915>
+
+        Reviewed by Darin Adler.
+
+        Added regression tests to make sure dataTransfer.types returns an empty list when writing to a pasteboard (copy),
+        and doesn't contain image types when pasting plain text. Unfortunately, pasting image does result in plain text
+        content being present in the pasteboard in the form of URL so we can't test that scenario.
+
+        Also removed failing expectations from a number of tests that are now passing on iOS.
+
+        * editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt: Added.
+        * editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html: Added.
+        * editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt: Added.
+        * editing/pasteboard/dataTransfer-types-pasting-plaintext.html: Added.
+        * platform/ios/TestExpectations:
+
 2017-09-19  Zalan Bujtas  <[email protected]>
 
         AXObjectCache::performDeferredCacheUpdate is called recursively through FrameView::layout. 

Added: trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt (0 => 222228)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt	2017-09-19 21:50:03 UTC (rev 222228)
@@ -0,0 +1,10 @@
+Tests that DataTransfer's types is initially empty on copy. To manually test, press the button below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS JSON.stringify(event.clipboardData.types) is "[]"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html (0 => 222228)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html	2017-09-19 21:50:03 UTC (rev 222228)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<div id="container">
+<div id="source" contenteditable="true" _oncopy_="check(event)">hello</div>
+<button _onclick_="runTest()">Start the test</button>
+</div>
+<script>
+description("Tests that DataTransfer's types is initially empty on copy. To manually test, press the button below.");
+jsTestIsAsync = true;
+
+function check(event) {
+    shouldBeEqualToString('JSON.stringify(event.clipboardData.types)', '[]');
+}
+
+function runTest()
+{
+    const source = document.getElementById('source');
+    source.focus();
+    document.execCommand('SelectAll', false, null);
+    document.execCommand('Copy', false, null);
+    source.parentNode.style.display = 'none';
+    finishJSTest();
+}
+
+if (window.testRunner)
+    runTest();
+
+successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt (0 => 222228)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt	2017-09-19 21:50:03 UTC (rev 222228)
@@ -0,0 +1,13 @@
+Tests that DataTransfer's types contains text/plain but not no image types when pasting a plain text. To manually test, click on the button below then trigger paste (Command+V or Control+V).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS types.includes("text/plain") is true
+PASS types.find((type) => type.includes("png")) is undefined.
+PASS types.find((type) => type.includes("jpeg")) is undefined.
+PASS types.find((type) => type.includes("tiff")) is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext.html (0 => 222228)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-types-pasting-plaintext.html	2017-09-19 21:50:03 UTC (rev 222228)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that DataTransfer's types contains text/plain but not no image types when pasting a plain text. To manually test, click on the button below then trigger paste (Command+V or Control+V).");
+jsTestIsAsync = true;
+
+function check(event) {
+    types = event.clipboardData.types;
+    shouldBeTrue('types.includes("text/plain")');
+    shouldBeUndefined('types.find((type) => type.includes("png"))');
+    shouldBeUndefined('types.find((type) => type.includes("jpeg"))');
+    shouldBeUndefined('types.find((type) => type.includes("tiff"))');
+    document.getElementById('container').style.display = 'none';
+    finishJSTest();
+}
+
+function runTest()
+{
+    const source = document.getElementById('source');
+    source.focus();
+    source.contentDocument.execCommand('selectAll', false, null);
+    source.contentDocument.execCommand('copy', false, null);
+    document.getElementById('destination').focus();
+    document.getElementById('destination').textContent = 'Now, paste here';
+    document.execCommand('selectAll', false, null);
+
+    document.querySelector('button').style.display = 'none';
+    source.style.display = 'none';
+
+    document.execCommand('paste', false, null);
+}
+
+successfullyParsed = true;
+
+</script>
+<div id="container">
+<button _onclick_="runTest()">Copy</button><br>
+<iframe id="source" _onload_="window.testRunner && runTest()" src=""
+<div id="destination" contenteditable="true" _onpaste_="check(event)"></div>
+</div>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (222227 => 222228)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-09-19 21:50:03 UTC (rev 222228)
@@ -2225,7 +2225,6 @@
 # Failing pasteboard to triage
 editing/pasteboard/4242293-1.html [ Failure ]
 editing/pasteboard/5780697-2.html [ Failure ]
-editing/pasteboard/can-read-in-copy-and-cut-events.html [ Failure ]
 editing/pasteboard/clipboard-customData.html [ Failure ]
 editing/pasteboard/copy-backslash-with-euc.html [ Failure ]
 editing/pasteboard/copy-in-password-field.html [ Failure ]
@@ -2232,11 +2231,8 @@
 editing/pasteboard/copy-inside-h1-preserves-h1.html [ Failure ]
 editing/pasteboard/copy-text-with-backgroundcolor.html [ Failure ]
 editing/pasteboard/copy-two-pasteboard-types-both-work.html [ Failure ]
-editing/pasteboard/copy-without-selection.html [ Failure ]
 editing/pasteboard/data-transfer-items.html [ Failure ]
 editing/pasteboard/dataTransfer-setData-getData.html [ Failure ]
-editing/pasteboard/datatransfer-getdata-plaintext.html [ Failure ]
-editing/pasteboard/datatransfer-items-copy-plaintext.html [ Failure ]
 editing/pasteboard/display-block-on-spans.html [ Failure ]
 editing/pasteboard/emacs-ctrl-k-with-move.html [ Failure ]
 editing/pasteboard/emacs-ctrl-k-y-001.html [ Failure ]
@@ -2261,7 +2257,6 @@
 editing/pasteboard/paste-sanitize-crash-1.html [ Failure ]
 editing/pasteboard/paste-sanitize-crash-2.html [ Failure ]
 editing/pasteboard/paste-text-events.html [ Failure ]
-editing/pasteboard/pasting-empty-html-falls-back-to-text.html [ Failure ]
 editing/pasteboard/smart-paste-001.html [ Failure ]
 editing/pasteboard/smart-paste-002.html [ Failure ]
 editing/pasteboard/smart-paste-003.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (222227 => 222228)


--- trunk/Source/WebCore/ChangeLog	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/ChangeLog	2017-09-19 21:50:03 UTC (rev 222228)
@@ -1,3 +1,61 @@
+2017-09-19  Ryosuke Niwa  <[email protected]>
+
+        On iOS, getData can't get text set by setData during copy event
+        https://bugs.webkit.org/show_bug.cgi?id=176980
+        <rdar://problem/34453915>
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by iOS port not implementing Pasteboard::createPrivate(). Rather than implementing this in iOS,
+        replace its use for copy & paste events by StaticPasteboard Wenson added for input events. This makes read-write
+        pasteboard platform agnostic and paves the way to make writing to pasteboard in a single IPC in WebKit2.
+
+        Also fixed a bug that iOS port's Pasteboard::types returned the list of all supported types instead of ones
+        actually present in the pasteboard.
+
+        This patch also adds a vector of types to StaticPasteboard to maintain the type order.
+
+        Tests: editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html
+               editing/pasteboard/dataTransfer-types-pasting-plaintext.html
+
+        * dom/DataTransfer.cpp:
+        (WebCore::DataTransfer::createForCopyAndPaste): Make StaticPasteboard instead of a private pasteboard.
+        (WebCore::DataTransfer::createForInputEvent):
+        * editing/Editor.cpp:
+        (WebCore::dispatchClipboardEvent): Call newly added commitToPasteboard on StaticPasteboard.
+        * platform/Pasteboard.h:
+        (WebCore::Pasteboard::isStatic const):
+        * platform/PasteboardStrategy.h:
+        * platform/StaticPasteboard.cpp:
+        (WebCore::StaticPasteboard::create): Deleted.
+        (WebCore::StaticPasteboard::StaticPasteboard):
+        (WebCore::StaticPasteboard::hasData):
+        (WebCore::StaticPasteboard::types): Deleted. Now simply returns m_type.
+        (WebCore::StaticPasteboard::readString): Added.
+        (WebCore::StaticPasteboard::writeString): Added.
+        (WebCore::StaticPasteboard::clear): Added.
+        (WebCore::StaticPasteboard::commitToPasteboard): Added.
+        (isType): Added.
+        * platform/StaticPasteboard.h:
+        (WebCore::Pasteboard::isStatic const): Added.
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::createPrivate): Deleted.
+        (WebCore::Pasteboard::writePasteboard): Deleted.
+        * platform/ios/PasteboardIOS.mm:
+        (WebCore::Pasteboard::createPrivate): Deleted.
+        (WebCore::Pasteboard::writePasteboard): Deleted.
+        (WebCore::addHTMLClipboardTypesForCocoaType):
+        (WebCore::Pasteboard::types): Return the actual list of types in the pasteboard.
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::createPrivate): Deleted.
+        (WebCore::Pasteboard::writePasteboard): Deleted.
+        * platform/win/PasteboardWin.cpp:
+        (WebCore::Pasteboard::createPrivate): Deleted.
+        (WebCore::Pasteboard::writePasteboard): Deleted.
+        * platform/wpe/PasteboardWPE.cpp:
+        (WebCore::Pasteboard::createPrivate): Deleted.
+        (WebCore::Pasteboard::writePasteboard): Deleted.
+
 2017-09-19  Zalan Bujtas  <[email protected]>
 
         AXObjectCache::performDeferredCacheUpdate is called recursively through FrameView::layout. 

Modified: trunk/Source/WebCore/dom/DataTransfer.cpp (222227 => 222228)


--- trunk/Source/WebCore/dom/DataTransfer.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/dom/DataTransfer.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -74,7 +74,7 @@
 
 Ref<DataTransfer> DataTransfer::createForCopyAndPaste(StoreMode mode)
 {
-    return adoptRef(*new DataTransfer(mode, mode == StoreMode::ReadWrite ? Pasteboard::createPrivate() : Pasteboard::createForCopyAndPaste()));
+    return adoptRef(*new DataTransfer(mode, mode == StoreMode::ReadWrite ? std::make_unique<StaticPasteboard>() : Pasteboard::createForCopyAndPaste()));
 }
 
 DataTransfer::~DataTransfer()
@@ -220,8 +220,10 @@
 
 Ref<DataTransfer> DataTransfer::createForInputEvent(const String& plainText, const String& htmlText)
 {
-    TypeToStringMap typeToStringMap { { ASCIILiteral("text/plain"), plainText }, { ASCIILiteral("text/html"), htmlText } };
-    return adoptRef(*new DataTransfer(StoreMode::Readonly, StaticPasteboard::create(WTFMove(typeToStringMap)), Type::InputEvent));
+    auto pasteboard = std::make_unique<StaticPasteboard>();
+    pasteboard->writeString(ASCIILiteral("text/plain"), plainText);
+    pasteboard->writeString(ASCIILiteral("text/html"), htmlText);
+    return adoptRef(*new DataTransfer(StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent));
 }
 
 #if !ENABLE(DRAG_SUPPORT)

Modified: trunk/Source/WebCore/editing/Editor.cpp (222227 => 222228)


--- trunk/Source/WebCore/editing/Editor.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/editing/Editor.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -85,6 +85,7 @@
 #include "SimplifyMarkupCommand.h"
 #include "SpellChecker.h"
 #include "SpellingCorrectionCommand.h"
+#include "StaticPasteboard.h"
 #include "StyleProperties.h"
 #include "TelephoneNumberDetector.h"
 #include "Text.h"
@@ -345,7 +346,7 @@
     if (noDefaultProcessing && storeMode == DataTransfer::StoreMode::ReadWrite) {
         auto pasteboard = Pasteboard::createForCopyAndPaste();
         pasteboard->clear();
-        pasteboard->writePasteboard(dataTransfer->pasteboard());
+        downcast<StaticPasteboard>(dataTransfer->pasteboard()).commitToPasteboard(*pasteboard);
     }
 
     dataTransfer->makeInvalidForSecurity();

Modified: trunk/Source/WebCore/platform/Pasteboard.h (222227 => 222228)


--- trunk/Source/WebCore/platform/Pasteboard.h	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/Pasteboard.h	2017-09-19 21:50:03 UTC (rev 222228)
@@ -163,8 +163,9 @@
 #endif
 
     WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForCopyAndPaste();
-    static std::unique_ptr<Pasteboard> createPrivate(); // Temporary pasteboard. Can put data on this and then write to another pasteboard with writePasteboard.
 
+    virtual bool isStatic() const { return false; }
+
     virtual bool hasData();
     virtual Vector<String> types();
     virtual String readString(const String& type);
@@ -187,7 +188,6 @@
     virtual void writeMarkup(const String& markup);
     enum SmartReplaceOption { CanSmartReplace, CannotSmartReplace };
     virtual WEBCORE_EXPORT void writePlainText(const String&, SmartReplaceOption); // FIXME: Two separate functions would be clearer than one function with an argument.
-    virtual void writePasteboard(const Pasteboard& sourcePasteboard);
 
 #if ENABLE(DRAG_SUPPORT)
     WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForDragAndDrop();

Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (222227 => 222228)


--- trunk/Source/WebCore/platform/PasteboardStrategy.h	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h	2017-09-19 21:50:03 UTC (rev 222228)
@@ -66,7 +66,6 @@
 
     virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
     virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
-    virtual long copy(const String& fromPasteboard, const String& toPasteboard) = 0;
     virtual long setBufferForType(SharedBuffer*, const String& pasteboardType, const String& pasteboardName) = 0;
     virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0;
     virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;

Modified: trunk/Source/WebCore/platform/StaticPasteboard.cpp (222227 => 222228)


--- trunk/Source/WebCore/platform/StaticPasteboard.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/StaticPasteboard.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -28,34 +28,53 @@
 
 namespace WebCore {
 
-std::unique_ptr<StaticPasteboard> StaticPasteboard::create(TypeToStringMap&& typeToStringMap)
+StaticPasteboard::StaticPasteboard()
 {
-    return std::make_unique<StaticPasteboard>(WTFMove(typeToStringMap));
 }
 
-StaticPasteboard::StaticPasteboard(TypeToStringMap&& typeToStringMap)
-    : m_typeToStringMap(typeToStringMap)
+bool StaticPasteboard::hasData()
 {
+    return !m_stringContents.isEmpty();
 }
 
-bool StaticPasteboard::hasData()
+String StaticPasteboard::readString(const String& type)
 {
-    return !m_typeToStringMap.isEmpty();
+    if (!m_stringContents.contains(type))
+        return { };
+    return m_stringContents.get(type);
 }
 
-Vector<String> StaticPasteboard::types()
+void StaticPasteboard::writeString(const String& type, const String& value)
 {
-    Vector<String> allTypes(m_typeToStringMap.size());
-    for (auto& type : m_typeToStringMap.keys())
-        allTypes.append(type);
-    return allTypes;
+    auto result = m_stringContents.set(type, value);
+    if (result.isNewEntry)
+        m_types.append(type);
+    else {
+        m_types.removeFirst(type);
+        ASSERT(!m_types.contains(type));
+        m_types.append(type);
+    }
 }
 
-String StaticPasteboard::readString(const String& type)
+void StaticPasteboard::clear()
 {
-    if (!m_typeToStringMap.contains(type))
-        return { };
-    return m_typeToStringMap.get(type);
+    m_stringContents.clear();
+    m_types.clear();
 }
 
+void StaticPasteboard::clear(const String& type)
+{
+    if (!m_stringContents.remove(type))
+        return;
+    m_types.removeFirst(type);
+    ASSERT(!m_types.contains(type));
 }
+
+// FIXME: Copy the entire StaticPasteboard to UIProcess instead of writing each string.
+void StaticPasteboard::commitToPasteboard(Pasteboard& pasteboard)
+{
+    for (auto& type : m_types)
+        pasteboard.writeString(type, m_stringContents.get(type));
+}
+
+}

Modified: trunk/Source/WebCore/platform/StaticPasteboard.h (222227 => 222228)


--- trunk/Source/WebCore/platform/StaticPasteboard.h	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/StaticPasteboard.h	2017-09-19 21:50:03 UTC (rev 222228)
@@ -27,25 +27,26 @@
 
 #include "Pasteboard.h"
 #include <wtf/HashMap.h>
+#include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
-typedef HashMap<String, String> TypeToStringMap;
-
 class StaticPasteboard final : public Pasteboard {
 public:
-    static std::unique_ptr<StaticPasteboard> create(TypeToStringMap&&);
+    StaticPasteboard();
 
-    StaticPasteboard(TypeToStringMap&&);
+    void commitToPasteboard(Pasteboard&);
 
+    bool isStatic() const final { return true; }
+
     bool hasData() final;
-    Vector<String> types() final;
+    Vector<String> types() final { return m_types; }
     String readString(const String& type) final;
 
-    void writeString(const String&, const String&) final { }
-    void clear() final { }
-    void clear(const String&) final { }
+    void writeString(const String& type, const String& data) final;
+    void clear() final;
+    void clear(const String& type) final;
 
     void read(PasteboardPlainText&) final { }
     void read(PasteboardWebContentReader&) final { }
@@ -59,7 +60,6 @@
 
     void writeMarkup(const String&) final { }
     void writePlainText(const String&, SmartReplaceOption) final { }
-    void writePasteboard(const Pasteboard&) final { }
 
 #if ENABLE(DRAG_SUPPORT)
     void setDragImage(DragImage, const IntPoint&) final { }
@@ -66,7 +66,12 @@
 #endif
 
 private:
-    TypeToStringMap m_typeToStringMap;
+    Vector<String> m_types;
+    HashMap<String, String> m_stringContents;
 };
 
 }
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StaticPasteboard)
+    static bool isType(const WebCore::Pasteboard& pasteboard) { return pasteboard.isStatic(); }
+SPECIALIZE_TYPE_TRAITS_END()

Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (222227 => 222228)


--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -50,11 +50,6 @@
     return std::make_unique<Pasteboard>("PRIMARY");
 }
 
-std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
-{
-    return std::make_unique<Pasteboard>(SelectionData::create());
-}
-
 #if ENABLE(DRAG_SUPPORT)
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop()
 {
@@ -199,29 +194,6 @@
     writeToClipboard();
 }
 
-void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
-{
-    const auto& sourceDataObject = sourcePasteboard.selectionData();
-    m_selectionData->clearAll();
-
-    if (sourceDataObject.hasText())
-        m_selectionData->setText(sourceDataObject.text());
-    if (sourceDataObject.hasMarkup())
-        m_selectionData->setMarkup(sourceDataObject.markup());
-    if (sourceDataObject.hasURL())
-        m_selectionData->setURL(sourceDataObject.url(), sourceDataObject.urlLabel());
-    if (sourceDataObject.hasURIList())
-        m_selectionData->setURIList(sourceDataObject.uriList());
-    if (sourceDataObject.hasImage())
-        m_selectionData->setImage(sourceDataObject.image());
-    if (sourceDataObject.hasUnknownTypeData()) {
-        for (auto& it : sourceDataObject.unknownTypes())
-            m_selectionData->setUnknownTypeData(it.key, it.value);
-    }
-
-    writeToClipboard();
-}
-
 void Pasteboard::clear()
 {
     // We do not clear filenames. According to the spec: "The clearData() method

Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (222227 => 222228)


--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2017-09-19 21:50:03 UTC (rev 222228)
@@ -133,11 +133,6 @@
     return std::make_unique<Pasteboard>(changeCountForPasteboard());
 }
 
-std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
-{
-    return std::make_unique<Pasteboard>(changeCountForPasteboard());
-}
-
 void Pasteboard::write(const PasteboardWebContent& content)
 {
     platformStrategies()->pasteboardStrategy()->writeToPasteboard(content, m_pasteboardName);
@@ -174,10 +169,6 @@
     ASSERT_NOT_REACHED();
 }
 
-void Pasteboard::writePasteboard(const Pasteboard&)
-{
-}
-
 bool Pasteboard::canSmartReplace()
 {
     return false;
@@ -404,7 +395,9 @@
 static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, NSString *cocoaType)
 {
     // UTI may not do these right, so make sure we get the right, predictable result.
-    if ([cocoaType isEqualToString:(NSString *)kUTTypeText]) {
+    if ([cocoaType isEqualToString:(NSString *)kUTTypePlainText]
+        || [cocoaType isEqualToString:(NSString *)kUTTypeUTF8PlainText]
+        || [cocoaType isEqualToString:(NSString *)kUTTypeUTF16PlainText]) {
         resultTypes.add(ASCIILiteral("text/plain"));
         return;
     }
@@ -432,7 +425,8 @@
 
 Vector<String> Pasteboard::types()
 {
-    NSArray *types = supportedWebContentPasteboardTypes();
+    Vector<String> cocoaTypes;
+    platformStrategies()->pasteboardStrategy()->getTypes(cocoaTypes, m_pasteboardName);
 
     // Enforce changeCount ourselves for security. We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
@@ -440,11 +434,8 @@
         return Vector<String>();
 
     ListHashSet<String> result;
-    NSUInteger count = [types count];
-    for (NSUInteger i = 0; i < count; i++) {
-        NSString *type = [types objectAtIndex:i];
-        addHTMLClipboardTypesForCocoaType(result, type);
-    }
+    for (auto cocoaType : cocoaTypes)
+        addHTMLClipboardTypesForCocoaType(result, cocoaType);
 
     Vector<String> vector;
     copyToVector(result, vector);

Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (222227 => 222228)


--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2017-09-19 21:50:03 UTC (rev 222228)
@@ -138,11 +138,6 @@
 #pragma clang diagnostic pop
 }
 
-std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
-{
-    return std::make_unique<Pasteboard>(platformStrategies()->pasteboardStrategy()->uniqueName());
-}
-
 #if ENABLE(DRAG_SUPPORT)
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop()
 {
@@ -298,11 +293,6 @@
     writeFileWrapperAsRTFDAttachment(fileWrapper(pasteboardImage), m_pasteboardName, m_changeCount);
 }
 
-void Pasteboard::writePasteboard(const Pasteboard& pasteboard)
-{
-    m_changeCount = platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName);
-}
-
 bool Pasteboard::canSmartReplace()
 {
     Vector<String> types;

Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (222227 => 222228)


--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -99,12 +99,6 @@
     return pasteboard;
 }
 
-std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
-{
-    // Windows has no "Private pasteboard" concept.
-    return createForCopyAndPaste();
-}
-
 #if ENABLE(DRAG_SUPPORT)
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop()
 {
@@ -760,11 +754,6 @@
     }
 }
 
-void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
-{
-    notImplemented();
-}
-
 bool Pasteboard::canSmartReplace()
 { 
     return ::IsClipboardFormatAvailable(WebSmartPasteFormat);

Modified: trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp (222227 => 222228)


--- trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -37,11 +37,6 @@
     return std::make_unique<Pasteboard>();
 }
 
-std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
-{
-    return std::make_unique<Pasteboard>();
-}
-
 Pasteboard::Pasteboard()
 {
 }
@@ -127,8 +122,4 @@
     writeString("text/plain;charset=utf-8", text);
 }
 
-void Pasteboard::writePasteboard(const Pasteboard&)
-{
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebKit/ChangeLog (222227 => 222228)


--- trunk/Source/WebKit/ChangeLog	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKit/ChangeLog	2017-09-19 21:50:03 UTC (rev 222228)
@@ -1,3 +1,15 @@
+2017-09-19  Ryosuke Niwa  <[email protected]>
+
+        On iOS, getData can't get text set by setData during copy event
+        https://bugs.webkit.org/show_bug.cgi?id=176980
+        <rdar://problem/34453915>
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::copy): Deleted.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2017-09-19  Alex Christensen  <[email protected]>
 
         Expose WKPageRef as a private property on WKWebView on Mac

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (222227 => 222228)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2017-09-19 21:50:03 UTC (rev 222228)
@@ -202,13 +202,6 @@
     return value;
 }
 
-long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
-{
-    uint64_t newChangeCount;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::PasteboardCopy(fromPasteboard, toPasteboard), Messages::WebPasteboardProxy::PasteboardCopy::Reply(newChangeCount), 0);
-    return newChangeCount;
-}
-
 long WebPlatformStrategies::changeCount(const WTF::String &pasteboardName)
 {
     uint64_t changeCount;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h (222227 => 222228)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2017-09-19 21:50:03 UTC (rev 222228)
@@ -82,7 +82,6 @@
 
     long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
     long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
-    long copy(const String& fromPasteboard, const String& toPasteboard) override;
     long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override;
     long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) override;
     long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override;

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (222227 => 222228)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-19 21:50:03 UTC (rev 222228)
@@ -1,3 +1,15 @@
+2017-09-19  Ryosuke Niwa  <[email protected]>
+
+        On iOS, getData can't get text set by setData during copy event
+        https://bugs.webkit.org/show_bug.cgi?id=176980
+        <rdar://problem/34453915>
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::copy): Deleted.
+
 2017-09-18  Andy Estes  <[email protected]>
 
         [Mac] Upstream miscellaneous WebKitSystemInterface functions

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h (222227 => 222228)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2017-09-19 21:50:03 UTC (rev 222228)
@@ -81,7 +81,6 @@
 
     long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
     long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
-    long copy(const String& fromPasteboard, const String& toPasteboard) override;
     long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override;
     long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) override;
     long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override;

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm (222227 => 222228)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2017-09-19 21:47:41 UTC (rev 222227)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2017-09-19 21:50:03 UTC (rev 222228)
@@ -129,11 +129,6 @@
     return PlatformPasteboard(pasteboardName).stringForType(pasteboardType);
 }
 
-long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
-{
-    return PlatformPasteboard(toPasteboard).copy(fromPasteboard);
-}
-
 long WebPlatformStrategies::changeCount(const String &pasteboardName)
 {
     return PlatformPasteboard(pasteboardName).changeCount();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to