Changeset 264014 in webkit
- Timestamp:
- Jul 7, 2020, 4:31:27 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/win/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/Pasteboard.h (modified) (1 diff)
-
Source/WebCore/platform/PasteboardCustomData.cpp (modified) (2 diffs)
-
Source/WebCore/platform/PasteboardCustomData.h (modified) (2 diffs)
-
Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (modified) (1 diff)
-
Source/WebCore/platform/win/ClipboardUtilitiesWin.h (modified) (1 diff)
-
Source/WebCore/platform/win/PasteboardWin.cpp (modified) (6 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferencesDefaultValues.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r264013 r264014 1 2020-07-07 Tomoki Imai <Tomoki.Imai@sony.com> 2 3 [Win] Implement Pasteboard::writeCustomData for Web Inspector Console tab 4 https://bugs.webkit.org/show_bug.cgi?id=213986 5 6 Reviewed by Fujii Hironori. 7 8 Now pasteboard tests related to custom data pass. 9 10 * platform/win/TestExpectations: 11 1 12 2020-07-07 Philippe Normand <pnormand@igalia.com> 2 13 -
trunk/LayoutTests/platform/win/TestExpectations
r264000 r264014 1187 1187 [ Debug ] editing/selection/4975120.html [ Skip ] # Debug Assertion 1188 1188 1189 # Custom pasteboard data is not supported on Windows.1190 editing/pasteboard/clipboard-customData.html [ Skip ]1191 1189 http/tests/security/clipboard/copy-paste-url-across-origin-sanitizes-url.html [ Skip ] 1192 1190 http/tests/security/clipboard/copy-paste-html-across-origin-sanitizes-html.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r264008 r264014 1 2020-07-07 Tomoki Imai <Tomoki.Imai@sony.com> 2 3 [Win] Implement Pasteboard::writeCustomData for Web Inspector Console tab 4 https://bugs.webkit.org/show_bug.cgi?id=213986 5 6 Reviewed by Fujii Hironori. 7 8 Implement Pasteboard::writeCustomData and Pasteboard::typesSafeForBindings. 9 This fixes the issue which we cannot copy text in WebInspector's Console tab. 10 11 We enable some existing testcases for pasteboard. 12 13 * platform/Pasteboard.h: 14 * platform/PasteboardCustomData.cpp: 15 (WebCore::PasteboardCustomData::fromPersistenceDecoder): Construct PasteboardCustomData from WTF::Persistence::Decoder. 16 (WebCore::PasteboardCustomData::fromSharedBuffer): Use fromPersistenceDecoder function to implement. 17 * platform/PasteboardCustomData.h: 18 * platform/win/ClipboardUtilitiesWin.cpp: 19 (WebCore::createGlobalData): Add uint8_t* variant. 20 * platform/win/ClipboardUtilitiesWin.h: 21 * platform/win/PasteboardWin.cpp: 22 (WebCore::Pasteboard::finishCreatingPasteboard): Register new clipboard format CustomDataClipboardFormat. 23 (WebCore::Pasteboard::readPasteboardCustomData): Helper function to read PasteboardCustomData from the pasteboard. 24 (WebCore::Pasteboard::typesSafeForBindings): Implemented. 25 (WebCore::Pasteboard::readOrigin): Implemented. 26 (WebCore::Pasteboard::readStringInCustomData): Implemented. 27 (WebCore::Pasteboard::writeCustomData): Implemented. 28 29 1 30 2020-07-06 Simon Fraser <simon.fraser@apple.com> 2 31 -
trunk/Source/WebCore/platform/Pasteboard.h
r262507 r264014 316 316 void writeURLToDataObject(const URL&, const String&); 317 317 void writePlainTextToDataObject(const String&, SmartReplaceOption); 318 Optional<PasteboardCustomData> readPasteboardCustomData(); 318 319 #endif 319 320 -
trunk/Source/WebCore/platform/PasteboardCustomData.cpp
r259922 r264014 93 93 } 94 94 95 PasteboardCustomData PasteboardCustomData::from SharedBuffer(const SharedBuffer& buffer)95 PasteboardCustomData PasteboardCustomData::fromPersistenceDecoder(WTF::Persistence::Decoder&& decoder) 96 96 { 97 97 constexpr unsigned maxSupportedDataSerializationVersionNumber = 1; 98 98 99 99 PasteboardCustomData result; 100 auto decoder = buffer.decoder();101 100 Optional<unsigned> version; 102 101 decoder >> version; … … 124 123 125 124 return result; 125 } 126 127 PasteboardCustomData PasteboardCustomData::fromSharedBuffer(const SharedBuffer& buffer) 128 { 129 return fromPersistenceDecoder(buffer.decoder()); 126 130 } 127 131 -
trunk/Source/WebCore/platform/PasteboardCustomData.h
r261792 r264014 30 30 #include <wtf/Variant.h> 31 31 #include <wtf/Vector.h> 32 #include <wtf/persistence/PersistentCoders.h> 32 33 #include <wtf/text/WTFString.h> 33 34 … … 62 63 WEBCORE_EXPORT Ref<SharedBuffer> createSharedBuffer() const; 63 64 WEBCORE_EXPORT static PasteboardCustomData fromSharedBuffer(const SharedBuffer&); 65 WEBCORE_EXPORT static PasteboardCustomData fromPersistenceDecoder(WTF::Persistence::Decoder&&); 64 66 65 67 String readString(const String& type) const; -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
r258869 r264014 216 216 } 217 217 218 HGLOBAL createGlobalData(const uint8_t* data, size_t length) 219 { 220 HGLOBAL vm = ::GlobalAlloc(GPTR, length + 1); 221 if (!vm) 222 return 0; 223 uint8_t* buffer = static_cast<uint8_t*>(GlobalLock(vm)); 224 memcpy(buffer, data, length); 225 buffer[length] = 0; 226 GlobalUnlock(vm); 227 return vm; 228 } 229 218 230 static String getFullCFHTML(IDataObject* data) 219 231 { -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
r238771 r264014 39 39 HGLOBAL createGlobalData(const Vector<char>&); 40 40 HGLOBAL createGlobalData(const URL& url, const String& title); 41 HGLOBAL createGlobalData(const uint8_t*, size_t); 41 42 42 43 FORMATETC* urlWFormat(); -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r262209 r264014 65 65 static UINT BookmarkClipboardFormat = 0; 66 66 static UINT WebSmartPasteFormat = 0; 67 static UINT CustomDataClipboardFormat = 0; 67 68 68 69 static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) … … 136 137 BookmarkClipboardFormat = ::RegisterClipboardFormat(L"UniformResourceLocatorW"); 137 138 WebSmartPasteFormat = ::RegisterClipboardFormat(L"WebKit Smart Paste Format"); 139 CustomDataClipboardFormat = ::RegisterClipboardFormat(L"WebKit Custom Data Format"); 138 140 } 139 141 … … 241 243 } 242 244 243 Vector<String> Pasteboard::typesSafeForBindings(const String&) 244 { 245 notImplemented(); 246 return { }; 245 Optional<PasteboardCustomData> Pasteboard::readPasteboardCustomData() 246 { 247 if (::IsClipboardFormatAvailable(CustomDataClipboardFormat) && ::OpenClipboard(m_owner)) { 248 if (HANDLE cbData = ::GetClipboardData(CustomDataClipboardFormat)) { 249 size_t size = GlobalSize(cbData); 250 auto data = static_cast<uint8_t*>(GlobalLock(cbData)); 251 auto customData = PasteboardCustomData::fromPersistenceDecoder({data, size}); 252 253 GlobalUnlock(cbData); 254 ::CloseClipboard(); 255 256 return customData; 257 } 258 ::CloseClipboard(); 259 } 260 261 return WTF::nullopt; 262 } 263 264 Vector<String> Pasteboard::typesSafeForBindings(const String& origin) 265 { 266 ListHashSet<String> domPasteboardTypes; 267 268 Optional<PasteboardCustomData> customData = readPasteboardCustomData(); 269 270 if (customData && customData->origin() == origin) { 271 for (const auto& type : customData->orderedTypes()) 272 domPasteboardTypes.add(type); 273 } 274 275 domPasteboardTypes.add("text/plain"); 276 domPasteboardTypes.add("text/uri-list"); 277 domPasteboardTypes.add("text/html"); 278 279 return copyToVector(domPasteboardTypes); 247 280 } 248 281 … … 281 314 String Pasteboard::readOrigin() 282 315 { 283 notImplemented(); 316 Optional<PasteboardCustomData> customData = readPasteboardCustomData(); 317 318 if (customData) 319 return customData->origin(); 320 284 321 return { }; 285 322 } … … 305 342 } 306 343 307 String Pasteboard::readStringInCustomData(const String&) 308 { 309 notImplemented(); 344 String Pasteboard::readStringInCustomData(const String& type) 345 { 346 Optional<PasteboardCustomData> customData = readPasteboardCustomData(); 347 348 if (customData) 349 return customData->readStringInCustomData(type); 350 310 351 return { }; 311 352 } … … 1083 1124 } 1084 1125 1085 void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>&) 1086 { 1126 void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>& data) 1127 { 1128 if (data.isEmpty() || data.size() > 1) { 1129 // We don't support more than one custom item in the clipboard. 1130 return; 1131 } 1132 1133 clear(); 1134 1135 if (::OpenClipboard(m_owner)) { 1136 const auto& customData = data.first(); 1137 customData.forEachPlatformStringOrBuffer([](auto& type, auto& stringOrBuffer) { 1138 if (WTF::holds_alternative<String>(stringOrBuffer)) { 1139 ClipboardDataType dataType = clipboardTypeFromMIMEType(type); 1140 1141 String str = WTF::get<String>(stringOrBuffer); 1142 replaceNewlinesWithWindowsStyleNewlines(str); 1143 HGLOBAL cbData = createGlobalData(str); 1144 1145 if (dataType == ClipboardDataTypeText) { 1146 if (cbData && !::SetClipboardData(CF_UNICODETEXT, cbData)) 1147 ::GlobalFree(cbData); 1148 } else if (dataType == ClipboardDataTypeURL) { 1149 if (cbData && !::SetClipboardData(BookmarkClipboardFormat, cbData)) 1150 ::GlobalFree(cbData); 1151 } else if (dataType == ClipboardDataTypeTextHTML) { 1152 if (cbData && !::SetClipboardData(HTMLClipboardFormat, cbData)) 1153 ::GlobalFree(cbData); 1154 } 1155 } 1156 }); 1157 1158 if (customData.hasSameOriginCustomData() || !customData.origin().isEmpty()) { 1159 auto sharedBuffer = customData.createSharedBuffer(); 1160 HGLOBAL cbData = createGlobalData(reinterpret_cast<const uint8_t*>(sharedBuffer->data()), sharedBuffer->size()); 1161 if (cbData && !::SetClipboardData(CustomDataClipboardFormat, cbData)) 1162 ::GlobalFree(cbData); 1163 } 1164 1165 ::CloseClipboard(); 1166 } 1087 1167 } 1088 1168 -
trunk/Source/WebKit/ChangeLog
r264008 r264014 1 2020-07-07 Tomoki Imai <Tomoki.Imai@sony.com> 2 3 [Win] Implement Pasteboard::writeCustomData for Web Inspector Console tab 4 https://bugs.webkit.org/show_bug.cgi?id=213986 5 6 Reviewed by Fujii Hironori. 7 8 * Shared/WebPreferencesDefaultValues.h: Turn DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED on for Windows 9 1 10 2020-07-06 Simon Fraser <simon.fraser@apple.com> 2 11 -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h
r263977 r264014 253 253 #endif 254 254 255 #if PLATFORM(COCOA) || PLATFORM(GTK) 255 #if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WIN) 256 256 #define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED true 257 257 #else
Note:
See TracChangeset
for help on using the changeset viewer.