Share more pasteboard code between iOS and macOS and remove dependency on Settings
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Sep 2017 10:31:05 +0000 (10:31 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Sep 2017 10:31:05 +0000 (10:31 +0000)
commita71a2b23980d41d14883ef59166c8bb37830f73f
tree414f2cff66df797dc52cbdf1f8546d138d01bbfa
parent6a146b6987c531160952080f35a0d3687e007a93
Share more pasteboard code between iOS and macOS and remove dependency on Settings
https://bugs.webkit.org/show_bug.cgi?id=177700

Reviewed by Wenson Hsieh.

Moved more code from PasteboardIOS.mm and PasteboardMac.mm into PasteboardCocoa.mm to share code.

This patch also removes the layering violation inadvertently introduced in r222595 whereby which
Pasteboard code depends on Settings. To do this, this patch splits readStringForBindings is into
readString and readStringInCustomData and typesForBindings into typesSafeForBindings and
typesForLegacyUnsafeBindings, and moves the logic to decide whether a given type or string is read
off of the native pasteboard entry or our custom data entry is moved to DataTransfer.

No new tests since there should be no behavioral change.

* dom/DataTransfer.cpp:
(WebCore::DataTransfer::getData const): Moved the code to decide whether string is
read off of custom data or native pasteboard from readStringForBindings.
(WebCore::DataTransfer::types const): Ditto from typesForBindings.
* platform/Pasteboard.cpp:
(WebCore::Pasteboard::isSafeTypeForDOMToReadAndWrite): Moved into Pasteboard.
* platform/Pasteboard.h:
* platform/StaticPasteboard.cpp:
(WebCore::StaticPasteboard::readString): Renamed from readStringForBindings.
(WebCore::StaticPasteboard::readStringInCustomData): Added.
(WebCore::StaticPasteboard::writeString):
* platform/StaticPasteboard.h:
* platform/cocoa/PasteboardCocoa.mm:
(WebCore::Pasteboard::typesSafeForBindings): Extracted out of typesForBindings in PasteboardIOS.mm
and PasteboardMac.mm.
(WebCore::Pasteboard::typesForLegacyUnsafeBindings): Ditto.
(WebCore::Pasteboard::readString): Ditto.
(WebCore::Pasteboard::readStringInCustomData): Ditto.
(WebCore::Pasteboard::writeCustomData): Moved here from PasteboardIOS.mm and PasteboardCocoa.mm.
(WebCore::Pasteboard::changeCount const): Ditto.
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::typesSafeForBindings): Added.
(WebCore::Pasteboard::typesForLegacyUnsafeBindings): Renamed from readStringForBindings.
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::readStringInCustomData): Added.
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::writeCustomData): Moved to PasteboardCocoa.mm.
(WebCore::Pasteboard::changeCount const): Ditto.
(WebCore::Pasteboard::readPlatformValueAsString): Moved into Pasteboard.
(WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType): Ditto.
(WebCore::Pasteboard::readStringForBindings): Moved to PasteboardCocoa.mm.
(WebCore::Pasteboard::typesForBindings): Ditto.
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::changeCount const): Moved to PasteboardCocoa.mm.
(WebCore::Pasteboard::writeCustomData): Ditto.
(WebCore::Pasteboard::readPlatformValueAsString): Moved into Pasteboard.
(WebCore::Pasteboard::readStringForBindings): Moved to PasteboardCocoa.mm.
(WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType): Moved into Pasteboard.
(WebCore::Pasteboard::typesForBindings): Moved to PasteboardCocoa.mm.
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::typesSafeForBindings): Added.
(WebCore::Pasteboard::typesForLegacyUnsafeBindings): Renamed from readStringForBindings.
(WebCore::Pasteboard::readString): Renamed from readStringForBindings.
(WebCore::Pasteboard::readStringInCustomData): Added.
* platform/wpe/PasteboardWPE.cpp:
(WebCore::Pasteboard::typesSafeForBindings): Added.
(WebCore::PasteboardtypesForLegacyUnsafeBindings): Renamed from readStringForBindings.
(WebCore::Pasteboard::readString): Renamed from readStringForBindings.
(WebCore::Pasteboard::readStringInCustomData): Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@222680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/DataTransfer.cpp
Source/WebCore/editing/wpe/EditorWPE.cpp
Source/WebCore/platform/Pasteboard.cpp
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/StaticPasteboard.cpp
Source/WebCore/platform/StaticPasteboard.h
Source/WebCore/platform/cocoa/PasteboardCocoa.mm
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebCore/platform/win/PasteboardWin.cpp
Source/WebCore/platform/wpe/PasteboardWPE.cpp