Changeset 222228 in webkit
- Timestamp:
- Sep 19, 2017 2:50:03 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r222226 r222228 1 2017-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 On iOS, getData can't get text set by setData during copy event 4 https://bugs.webkit.org/show_bug.cgi?id=176980 5 <rdar://problem/34453915> 6 7 Reviewed by Darin Adler. 8 9 Added regression tests to make sure dataTransfer.types returns an empty list when writing to a pasteboard (copy), 10 and doesn't contain image types when pasting plain text. Unfortunately, pasting image does result in plain text 11 content being present in the pasteboard in the form of URL so we can't test that scenario. 12 13 Also removed failing expectations from a number of tests that are now passing on iOS. 14 15 * editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy-expected.txt: Added. 16 * editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html: Added. 17 * editing/pasteboard/dataTransfer-types-pasting-plaintext-expected.txt: Added. 18 * editing/pasteboard/dataTransfer-types-pasting-plaintext.html: Added. 19 * platform/ios/TestExpectations: 20 1 21 2017-09-19 Zalan Bujtas <zalan@apple.com> 2 22 -
trunk/LayoutTests/platform/ios/TestExpectations
r222225 r222228 2226 2226 editing/pasteboard/4242293-1.html [ Failure ] 2227 2227 editing/pasteboard/5780697-2.html [ Failure ] 2228 editing/pasteboard/can-read-in-copy-and-cut-events.html [ Failure ]2229 2228 editing/pasteboard/clipboard-customData.html [ Failure ] 2230 2229 editing/pasteboard/copy-backslash-with-euc.html [ Failure ] … … 2233 2232 editing/pasteboard/copy-text-with-backgroundcolor.html [ Failure ] 2234 2233 editing/pasteboard/copy-two-pasteboard-types-both-work.html [ Failure ] 2235 editing/pasteboard/copy-without-selection.html [ Failure ]2236 2234 editing/pasteboard/data-transfer-items.html [ Failure ] 2237 2235 editing/pasteboard/dataTransfer-setData-getData.html [ Failure ] 2238 editing/pasteboard/datatransfer-getdata-plaintext.html [ Failure ]2239 editing/pasteboard/datatransfer-items-copy-plaintext.html [ Failure ]2240 2236 editing/pasteboard/display-block-on-spans.html [ Failure ] 2241 2237 editing/pasteboard/emacs-ctrl-k-with-move.html [ Failure ] … … 2262 2258 editing/pasteboard/paste-sanitize-crash-2.html [ Failure ] 2263 2259 editing/pasteboard/paste-text-events.html [ Failure ] 2264 editing/pasteboard/pasting-empty-html-falls-back-to-text.html [ Failure ]2265 2260 editing/pasteboard/smart-paste-001.html [ Failure ] 2266 2261 editing/pasteboard/smart-paste-002.html [ Failure ] -
trunk/Source/WebCore/ChangeLog
r222226 r222228 1 2017-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 On iOS, getData can't get text set by setData during copy event 4 https://bugs.webkit.org/show_bug.cgi?id=176980 5 <rdar://problem/34453915> 6 7 Reviewed by Darin Adler. 8 9 The bug was caused by iOS port not implementing Pasteboard::createPrivate(). Rather than implementing this in iOS, 10 replace its use for copy & paste events by StaticPasteboard Wenson added for input events. This makes read-write 11 pasteboard platform agnostic and paves the way to make writing to pasteboard in a single IPC in WebKit2. 12 13 Also fixed a bug that iOS port's Pasteboard::types returned the list of all supported types instead of ones 14 actually present in the pasteboard. 15 16 This patch also adds a vector of types to StaticPasteboard to maintain the type order. 17 18 Tests: editing/pasteboard/dataTransfer-types-is-initially-empty-on-copy.html 19 editing/pasteboard/dataTransfer-types-pasting-plaintext.html 20 21 * dom/DataTransfer.cpp: 22 (WebCore::DataTransfer::createForCopyAndPaste): Make StaticPasteboard instead of a private pasteboard. 23 (WebCore::DataTransfer::createForInputEvent): 24 * editing/Editor.cpp: 25 (WebCore::dispatchClipboardEvent): Call newly added commitToPasteboard on StaticPasteboard. 26 * platform/Pasteboard.h: 27 (WebCore::Pasteboard::isStatic const): 28 * platform/PasteboardStrategy.h: 29 * platform/StaticPasteboard.cpp: 30 (WebCore::StaticPasteboard::create): Deleted. 31 (WebCore::StaticPasteboard::StaticPasteboard): 32 (WebCore::StaticPasteboard::hasData): 33 (WebCore::StaticPasteboard::types): Deleted. Now simply returns m_type. 34 (WebCore::StaticPasteboard::readString): Added. 35 (WebCore::StaticPasteboard::writeString): Added. 36 (WebCore::StaticPasteboard::clear): Added. 37 (WebCore::StaticPasteboard::commitToPasteboard): Added. 38 (isType): Added. 39 * platform/StaticPasteboard.h: 40 (WebCore::Pasteboard::isStatic const): Added. 41 * platform/gtk/PasteboardGtk.cpp: 42 (WebCore::Pasteboard::createPrivate): Deleted. 43 (WebCore::Pasteboard::writePasteboard): Deleted. 44 * platform/ios/PasteboardIOS.mm: 45 (WebCore::Pasteboard::createPrivate): Deleted. 46 (WebCore::Pasteboard::writePasteboard): Deleted. 47 (WebCore::addHTMLClipboardTypesForCocoaType): 48 (WebCore::Pasteboard::types): Return the actual list of types in the pasteboard. 49 * platform/mac/PasteboardMac.mm: 50 (WebCore::Pasteboard::createPrivate): Deleted. 51 (WebCore::Pasteboard::writePasteboard): Deleted. 52 * platform/win/PasteboardWin.cpp: 53 (WebCore::Pasteboard::createPrivate): Deleted. 54 (WebCore::Pasteboard::writePasteboard): Deleted. 55 * platform/wpe/PasteboardWPE.cpp: 56 (WebCore::Pasteboard::createPrivate): Deleted. 57 (WebCore::Pasteboard::writePasteboard): Deleted. 58 1 59 2017-09-19 Zalan Bujtas <zalan@apple.com> 2 60 -
trunk/Source/WebCore/dom/DataTransfer.cpp
r222025 r222228 75 75 Ref<DataTransfer> DataTransfer::createForCopyAndPaste(StoreMode mode) 76 76 { 77 return adoptRef(*new DataTransfer(mode, mode == StoreMode::ReadWrite ? Pasteboard::createPrivate() : Pasteboard::createForCopyAndPaste()));77 return adoptRef(*new DataTransfer(mode, mode == StoreMode::ReadWrite ? std::make_unique<StaticPasteboard>() : Pasteboard::createForCopyAndPaste())); 78 78 } 79 79 … … 221 221 Ref<DataTransfer> DataTransfer::createForInputEvent(const String& plainText, const String& htmlText) 222 222 { 223 TypeToStringMap typeToStringMap { { ASCIILiteral("text/plain"), plainText }, { ASCIILiteral("text/html"), htmlText } }; 224 return adoptRef(*new DataTransfer(StoreMode::Readonly, StaticPasteboard::create(WTFMove(typeToStringMap)), Type::InputEvent)); 223 auto pasteboard = std::make_unique<StaticPasteboard>(); 224 pasteboard->writeString(ASCIILiteral("text/plain"), plainText); 225 pasteboard->writeString(ASCIILiteral("text/html"), htmlText); 226 return adoptRef(*new DataTransfer(StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent)); 225 227 } 226 228 -
trunk/Source/WebCore/editing/Editor.cpp
r221960 r222228 86 86 #include "SpellChecker.h" 87 87 #include "SpellingCorrectionCommand.h" 88 #include "StaticPasteboard.h" 88 89 #include "StyleProperties.h" 89 90 #include "TelephoneNumberDetector.h" … … 346 347 auto pasteboard = Pasteboard::createForCopyAndPaste(); 347 348 pasteboard->clear(); 348 pasteboard->writePasteboard(dataTransfer->pasteboard());349 downcast<StaticPasteboard>(dataTransfer->pasteboard()).commitToPasteboard(*pasteboard); 349 350 } 350 351 -
trunk/Source/WebCore/platform/Pasteboard.h
r221900 r222228 164 164 165 165 WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForCopyAndPaste(); 166 static std::unique_ptr<Pasteboard> createPrivate(); // Temporary pasteboard. Can put data on this and then write to another pasteboard with writePasteboard. 166 167 virtual bool isStatic() const { return false; } 167 168 168 169 virtual bool hasData(); … … 188 189 enum SmartReplaceOption { CanSmartReplace, CannotSmartReplace }; 189 190 virtual WEBCORE_EXPORT void writePlainText(const String&, SmartReplaceOption); // FIXME: Two separate functions would be clearer than one function with an argument. 190 virtual void writePasteboard(const Pasteboard& sourcePasteboard);191 191 192 192 #if ENABLE(DRAG_SUPPORT) -
trunk/Source/WebCore/platform/PasteboardStrategy.h
r222113 r222228 67 67 virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0; 68 68 virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0; 69 virtual long copy(const String& fromPasteboard, const String& toPasteboard) = 0;70 69 virtual long setBufferForType(SharedBuffer*, const String& pasteboardType, const String& pasteboardName) = 0; 71 70 virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0; -
trunk/Source/WebCore/platform/StaticPasteboard.cpp
r207841 r222228 29 29 namespace WebCore { 30 30 31 std::unique_ptr<StaticPasteboard> StaticPasteboard::create(TypeToStringMap&& typeToStringMap) 32 { 33 return std::make_unique<StaticPasteboard>(WTFMove(typeToStringMap)); 34 } 35 36 StaticPasteboard::StaticPasteboard(TypeToStringMap&& typeToStringMap) 37 : m_typeToStringMap(typeToStringMap) 31 StaticPasteboard::StaticPasteboard() 38 32 { 39 33 } … … 41 35 bool StaticPasteboard::hasData() 42 36 { 43 return !m_typeToStringMap.isEmpty(); 44 } 45 46 Vector<String> StaticPasteboard::types() 47 { 48 Vector<String> allTypes(m_typeToStringMap.size()); 49 for (auto& type : m_typeToStringMap.keys()) 50 allTypes.append(type); 51 return allTypes; 37 return !m_stringContents.isEmpty(); 52 38 } 53 39 54 40 String StaticPasteboard::readString(const String& type) 55 41 { 56 if (!m_ typeToStringMap.contains(type))42 if (!m_stringContents.contains(type)) 57 43 return { }; 58 return m_typeToStringMap.get(type); 44 return m_stringContents.get(type); 45 } 46 47 void StaticPasteboard::writeString(const String& type, const String& value) 48 { 49 auto result = m_stringContents.set(type, value); 50 if (result.isNewEntry) 51 m_types.append(type); 52 else { 53 m_types.removeFirst(type); 54 ASSERT(!m_types.contains(type)); 55 m_types.append(type); 56 } 57 } 58 59 void StaticPasteboard::clear() 60 { 61 m_stringContents.clear(); 62 m_types.clear(); 63 } 64 65 void StaticPasteboard::clear(const String& type) 66 { 67 if (!m_stringContents.remove(type)) 68 return; 69 m_types.removeFirst(type); 70 ASSERT(!m_types.contains(type)); 71 } 72 73 // FIXME: Copy the entire StaticPasteboard to UIProcess instead of writing each string. 74 void StaticPasteboard::commitToPasteboard(Pasteboard& pasteboard) 75 { 76 for (auto& type : m_types) 77 pasteboard.writeString(type, m_stringContents.get(type)); 59 78 } 60 79 -
trunk/Source/WebCore/platform/StaticPasteboard.h
r212239 r222228 28 28 #include "Pasteboard.h" 29 29 #include <wtf/HashMap.h> 30 #include <wtf/Vector.h> 30 31 #include <wtf/text/StringHash.h> 31 32 32 33 namespace WebCore { 33 34 34 typedef HashMap<String, String> TypeToStringMap;35 36 35 class StaticPasteboard final : public Pasteboard { 37 36 public: 38 static std::unique_ptr<StaticPasteboard> create(TypeToStringMap&&);37 StaticPasteboard(); 39 38 40 StaticPasteboard(TypeToStringMap&&); 39 void commitToPasteboard(Pasteboard&); 40 41 bool isStatic() const final { return true; } 41 42 42 43 bool hasData() final; 43 Vector<String> types() final ;44 Vector<String> types() final { return m_types; } 44 45 String readString(const String& type) final; 45 46 46 void writeString(const String& , const String&) final { }47 void clear() final { }48 void clear(const String& ) final { }47 void writeString(const String& type, const String& data) final; 48 void clear() final; 49 void clear(const String& type) final; 49 50 50 51 void read(PasteboardPlainText&) final { } … … 60 61 void writeMarkup(const String&) final { } 61 62 void writePlainText(const String&, SmartReplaceOption) final { } 62 void writePasteboard(const Pasteboard&) final { }63 63 64 64 #if ENABLE(DRAG_SUPPORT) … … 67 67 68 68 private: 69 TypeToStringMap m_typeToStringMap; 69 Vector<String> m_types; 70 HashMap<String, String> m_stringContents; 70 71 }; 71 72 72 73 } 74 75 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StaticPasteboard) 76 static bool isType(const WebCore::Pasteboard& pasteboard) { return pasteboard.isStatic(); } 77 SPECIALIZE_TYPE_TRAITS_END() -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r221063 r222228 51 51 } 52 52 53 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()54 {55 return std::make_unique<Pasteboard>(SelectionData::create());56 }57 58 53 #if ENABLE(DRAG_SUPPORT) 59 54 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop() … … 196 191 m_selectionData->setMarkup(pasteboardContent.markup); 197 192 m_selectionData->setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete); 198 199 writeToClipboard();200 }201 202 void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)203 {204 const auto& sourceDataObject = sourcePasteboard.selectionData();205 m_selectionData->clearAll();206 207 if (sourceDataObject.hasText())208 m_selectionData->setText(sourceDataObject.text());209 if (sourceDataObject.hasMarkup())210 m_selectionData->setMarkup(sourceDataObject.markup());211 if (sourceDataObject.hasURL())212 m_selectionData->setURL(sourceDataObject.url(), sourceDataObject.urlLabel());213 if (sourceDataObject.hasURIList())214 m_selectionData->setURIList(sourceDataObject.uriList());215 if (sourceDataObject.hasImage())216 m_selectionData->setImage(sourceDataObject.image());217 if (sourceDataObject.hasUnknownTypeData()) {218 for (auto& it : sourceDataObject.unknownTypes())219 m_selectionData->setUnknownTypeData(it.key, it.value);220 }221 193 222 194 writeToClipboard(); -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r222176 r222228 134 134 } 135 135 136 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()137 {138 return std::make_unique<Pasteboard>(changeCountForPasteboard());139 }140 141 136 void Pasteboard::write(const PasteboardWebContent& content) 142 137 { … … 173 168 // URLs. 174 169 ASSERT_NOT_REACHED(); 175 }176 177 void Pasteboard::writePasteboard(const Pasteboard&)178 {179 170 } 180 171 … … 405 396 { 406 397 // UTI may not do these right, so make sure we get the right, predictable result. 407 if ([cocoaType isEqualToString:(NSString *)kUTTypeText]) { 398 if ([cocoaType isEqualToString:(NSString *)kUTTypePlainText] 399 || [cocoaType isEqualToString:(NSString *)kUTTypeUTF8PlainText] 400 || [cocoaType isEqualToString:(NSString *)kUTTypeUTF16PlainText]) { 408 401 resultTypes.add(ASCIILiteral("text/plain")); 409 402 return; … … 433 426 Vector<String> Pasteboard::types() 434 427 { 435 NSArray *types = supportedWebContentPasteboardTypes(); 428 Vector<String> cocoaTypes; 429 platformStrategies()->pasteboardStrategy()->getTypes(cocoaTypes, m_pasteboardName); 436 430 437 431 // Enforce changeCount ourselves for security. We check after reading instead of before to be … … 441 435 442 436 ListHashSet<String> result; 443 NSUInteger count = [types count]; 444 for (NSUInteger i = 0; i < count; i++) { 445 NSString *type = [types objectAtIndex:i]; 446 addHTMLClipboardTypesForCocoaType(result, type); 447 } 437 for (auto cocoaType : cocoaTypes) 438 addHTMLClipboardTypesForCocoaType(result, cocoaType); 448 439 449 440 Vector<String> vector; -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r221900 r222228 139 139 } 140 140 141 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()142 {143 return std::make_unique<Pasteboard>(platformStrategies()->pasteboardStrategy()->uniqueName());144 }145 146 141 #if ENABLE(DRAG_SUPPORT) 147 142 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop() … … 297 292 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(pasteboardImage.dataInWebArchiveFormat.get(), WebArchivePboardType, m_pasteboardName); 298 293 writeFileWrapperAsRTFDAttachment(fileWrapper(pasteboardImage), m_pasteboardName, m_changeCount); 299 }300 301 void Pasteboard::writePasteboard(const Pasteboard& pasteboard)302 {303 m_changeCount = platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName);304 294 } 305 295 -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r221063 r222228 100 100 } 101 101 102 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()103 {104 // Windows has no "Private pasteboard" concept.105 return createForCopyAndPaste();106 }107 108 102 #if ENABLE(DRAG_SUPPORT) 109 103 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop() … … 759 753 ::CloseClipboard(); 760 754 } 761 }762 763 void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)764 {765 notImplemented();766 755 } 767 756 -
trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp
r216497 r222228 34 34 35 35 std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste() 36 {37 return std::make_unique<Pasteboard>();38 }39 40 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()41 36 { 42 37 return std::make_unique<Pasteboard>(); … … 128 123 } 129 124 130 void Pasteboard::writePasteboard(const Pasteboard&)131 {132 }133 134 125 } // namespace WebCore -
trunk/Source/WebKit/ChangeLog
r222212 r222228 1 2017-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 On iOS, getData can't get text set by setData during copy event 4 https://bugs.webkit.org/show_bug.cgi?id=176980 5 <rdar://problem/34453915> 6 7 Reviewed by Darin Adler. 8 9 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 10 (WebKit::WebPlatformStrategies::copy): Deleted. 11 * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 12 1 13 2017-09-19 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r221275 r222228 203 203 } 204 204 205 long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)206 {207 uint64_t newChangeCount;208 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::PasteboardCopy(fromPasteboard, toPasteboard), Messages::WebPasteboardProxy::PasteboardCopy::Reply(newChangeCount), 0);209 return newChangeCount;210 }211 212 205 long WebPlatformStrategies::changeCount(const WTF::String &pasteboardName) 213 206 { -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h
r221275 r222228 83 83 long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; 84 84 long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; 85 long copy(const String& fromPasteboard, const String& toPasteboard) override;86 85 long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override; 87 86 long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) override; -
trunk/Source/WebKitLegacy/mac/ChangeLog
r222150 r222228 1 2017-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 On iOS, getData can't get text set by setData during copy event 4 https://bugs.webkit.org/show_bug.cgi?id=176980 5 <rdar://problem/34453915> 6 7 Reviewed by Darin Adler. 8 9 * WebCoreSupport/WebPlatformStrategies.h: 10 * WebCoreSupport/WebPlatformStrategies.mm: 11 (WebPlatformStrategies::copy): Deleted. 12 1 13 2017-09-18 Andy Estes <aestes@apple.com> 2 14 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h
r221275 r222228 82 82 long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; 83 83 long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; 84 long copy(const String& fromPasteboard, const String& toPasteboard) override;85 84 long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override; 86 85 long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) override; -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm
r221275 r222228 130 130 } 131 131 132 long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)133 {134 return PlatformPasteboard(toPasteboard).copy(fromPasteboard);135 }136 137 132 long WebPlatformStrategies::changeCount(const String &pasteboardName) 138 133 {
Note: See TracChangeset
for help on using the changeset viewer.