Changeset 251765 in webkit
- Timestamp:
- Oct 29, 2019 9:14:39 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 26 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251764 r251765 1 2019-10-29 Andy Estes <aestes@apple.com> 2 3 [Quick Look] Clean up LegacyPreviewLoaderClients 4 https://bugs.webkit.org/show_bug.cgi?id=203472 5 6 Reviewed by Brady Eidson. 7 8 * loader/ios/LegacyPreviewLoader.mm: 9 (WebCore::LegacyPreviewLoader::didReceiveBuffer): 10 * platform/network/ios/LegacyPreviewLoaderClient.h: 11 (WebCore::LegacyPreviewLoaderClient::didReceiveBuffer): 12 (WebCore::LegacyPreviewLoaderClient::didReceiveDataArray): Deleted. 13 1 14 2019-10-29 Said Abou-Hallawa <sabouhallawa@apple.com> 2 15 -
trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.mm
r251623 r251765 72 72 m_originalData->append(buffer); 73 73 m_converter->updateMainResource(); 74 m_client->didReceive DataArray((__bridge CFArrayRef)buffer.createNSDataArray().get());74 m_client->didReceiveBuffer(buffer); 75 75 return true; 76 76 } -
trunk/Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h
r251488 r251765 32 32 namespace WebCore { 33 33 34 class SharedBuffer; 35 34 36 class LegacyPreviewLoaderClient : public RefCounted<LegacyPreviewLoaderClient> { 35 37 public: 36 38 virtual ~LegacyPreviewLoaderClient() = default; 37 virtual void didReceive DataArray(CFArrayRef) { }39 virtual void didReceiveBuffer(const SharedBuffer&) { } 38 40 virtual void didFinishLoading() { } 39 41 virtual void didFail() { } -
trunk/Source/WebKit/ChangeLog
r251762 r251765 1 2019-10-29 Andy Estes <aestes@apple.com> 2 3 [Quick Look] Clean up LegacyPreviewLoaderClients 4 https://bugs.webkit.org/show_bug.cgi?id=203472 5 6 Reviewed by Brady Eidson. 7 8 Replaced QuickLookDocumentData with ShareableResource. 9 10 Removed messages WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame and 11 WebPage::DidReceivePasswordForQuickLookDocument, replacing them with async message 12 WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame. 13 14 * Shared/ios/QuickLookDocumentData.cpp: Removed. 15 * Shared/ios/QuickLookDocumentData.h: Removed. 16 * SourcesCocoa.txt: 17 * UIProcess/API/APILoaderClient.h: 18 * UIProcess/API/APINavigationClient.h: 19 (API::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame): 20 * UIProcess/Cocoa/NavigationState.h: 21 * UIProcess/Cocoa/NavigationState.mm: 22 (WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame): 23 * UIProcess/ProvisionalPageProxy.cpp: 24 (WebKit::ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame): 25 (WebKit::ProvisionalPageProxy::didReceiveMessage): 26 (WebKit::ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted. 27 * UIProcess/ProvisionalPageProxy.h: 28 * UIProcess/WebPageProxy.h: 29 * UIProcess/WebPageProxy.messages.in: 30 * UIProcess/ios/WebPageProxyIOS.mm: 31 (WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame): 32 (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame): 33 (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared): 34 (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted. 35 (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared): Deleted. 36 * WebKit.xcodeproj/project.pbxproj: 37 * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp: 38 (WebKit::WebPreviewLoaderClient::WebPreviewLoaderClient): 39 (WebKit::WebPreviewLoaderClient::didReceiveBuffer): 40 (WebKit::WebPreviewLoaderClient::didFinishLoading): 41 (WebKit::WebPreviewLoaderClient::didFail): 42 (WebKit::WebPreviewLoaderClient::didRequestPassword): 43 (WebKit::passwordCallbacks): Deleted. 44 (WebKit::WebPreviewLoaderClient::~WebPreviewLoaderClient): Deleted. 45 (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Deleted. 46 (WebKit::WebPreviewLoaderClient::didReceivePassword): Deleted. 47 * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h: 48 * WebProcess/WebPage/WebPage.h: 49 * WebProcess/WebPage/WebPage.messages.in: 50 * WebProcess/WebPage/ios/WebPageIOS.mm: 51 (WebKit::WebPage::didStartLoadForQuickLookDocumentInMainFrame): 52 (WebKit::WebPage::didFinishLoadForQuickLookDocumentInMainFrame): 53 (WebKit::WebPage::requestPasswordForQuickLookDocumentInMainFrame): 54 (WebKit::WebPage::didReceivePasswordForQuickLookDocument): Deleted. 55 1 56 2019-10-29 Jiewen Tan <jiewen_tan@apple.com> 2 57 -
trunk/Source/WebKit/Platform/SharedMemory.cpp
r251764 r251765 1 1 /* 2 * Copyright (C) 201 4Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #i fndef QuickLookDocumentData_h27 # define QuickLookDocumentData_h26 #include "config.h" 27 #include "SharedMemory.h" 28 28 29 #include <wtf/RetainPtr.h> 30 #include <wtf/Vector.h> 31 32 namespace IPC { 33 class Decoder; 34 class Encoder; 35 } 29 #include <WebCore/SharedBuffer.h> 36 30 37 31 namespace WebKit { 38 32 39 class QuickLookDocumentData { 40 public: 41 void append(CFDataRef); 42 CFDataRef decodedData() const; 43 bool isEmpty() const; 44 void clear(); 45 void encode(IPC::Encoder&) const; 46 static bool decode(IPC::Decoder&, QuickLookDocumentData&); 33 using namespace WebCore; 47 34 48 private: 49 Vector<RetainPtr<CFDataRef>, 1> m_data; 50 }; 35 RefPtr<SharedMemory> SharedMemory::copyBuffer(const SharedBuffer& buffer) 36 { 37 if (buffer.isEmpty()) 38 return nullptr; 39 40 auto sharedMemory = allocate(buffer.size()); 41 if (!sharedMemory) 42 return nullptr; 43 44 char* const sharedMemoryPtr = reinterpret_cast<char*>(sharedMemory->data()); 45 size_t position = 0; 46 while (buffer.size() > position) { 47 auto data = buffer.getSomeData(position); 48 auto result = memcpy(sharedMemoryPtr + position, data.data(), data.size()); 49 ASSERT_UNUSED(result, result == sharedMemoryPtr + position); 50 position += data.size(); 51 } 52 53 return sharedMemory; 54 } 55 51 56 } // namespace WebKit 52 53 #endif // QuickLookDocumentData_h -
trunk/Source/WebKit/Platform/SharedMemory.h
r249335 r251765 43 43 class Decoder; 44 44 class Encoder; 45 } 46 47 namespace WebCore { 48 class SharedBuffer; 45 49 } 46 50 … … 98 102 static RefPtr<SharedMemory> allocate(size_t); 99 103 static RefPtr<SharedMemory> create(void*, size_t, Protection); 104 static RefPtr<SharedMemory> copyBuffer(const WebCore::SharedBuffer&); 100 105 static RefPtr<SharedMemory> map(const Handle&, Protection); 101 106 #if USE(UNIX_DOMAIN_SOCKETS) -
trunk/Source/WebKit/Sources.txt
r251547 r251765 97 97 Platform/Logging.cpp @no-unify 98 98 Platform/Module.cpp @no-unify 99 Platform/SharedMemory.cpp @no-unify 99 100 100 101 // TODO: We should unify these files once GTK's PluginProcess2 is removed. -
trunk/Source/WebKit/SourcesCocoa.txt
r251600 r251765 174 174 Shared/ios/NativeWebMouseEventIOS.mm 175 175 Shared/ios/NativeWebTouchEventIOS.mm 176 Shared/ios/QuickLookDocumentData.cpp177 176 Shared/ios/WebAutocorrectionData.mm 178 177 Shared/ios/WebIconUtilities.mm -
trunk/Source/WebKit/UIProcess/API/APILoaderClient.h
r248762 r251765 39 39 namespace WebKit { 40 40 class AuthenticationChallengeProxy; 41 class QuickLookDocumentData;42 41 class WebBackForwardListItem; 43 42 class WebFrameProxy; -
trunk/Source/WebKit/UIProcess/API/APINavigationClient.h
r251220 r251765 50 50 class ResourceRequest; 51 51 class ResourceResponse; 52 class SharedBuffer; 52 53 struct SecurityOriginData; 53 54 } … … 55 56 namespace WebKit { 56 57 class AuthenticationChallengeProxy; 57 class QuickLookDocumentData;58 58 class WebBackForwardListItem; 59 59 class WebFramePolicyListenerProxy; … … 110 110 #if USE(QUICK_LOOK) 111 111 virtual void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) { } 112 virtual void didFinishLoadForQuickLookDocumentInMainFrame(const Web Kit::QuickLookDocumentData&) { }112 virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) { } 113 113 #endif 114 114 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h
r251220 r251765 123 123 #if USE(QUICK_LOOK) 124 124 void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) override; 125 void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&) override;125 void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) override; 126 126 #endif 127 127 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r251220 r251765 84 84 #endif 85 85 86 #if USE(QUICK_LOOK)87 #import "QuickLookDocumentData.h"88 #endif89 90 86 namespace WebKit { 91 87 using namespace WebCore; … … 1084 1080 } 1085 1081 1086 void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)1082 void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer) 1087 1083 { 1088 1084 if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame) … … 1093 1089 return; 1094 1090 1095 [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame: (NSData *)data.decodedData()];1091 [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:buffer.createNSData().get()]; 1096 1092 } 1097 1093 #endif -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
r251585 r251765 355 355 356 356 #if USE(QUICK_LOOK) 357 void ProvisionalPageProxy:: didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName)358 { 359 m_page. didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName);357 void ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler) 358 { 359 m_page.requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler)); 360 360 } 361 361 #endif … … 470 470 471 471 #if USE(QUICK_LOOK) 472 if (decoder.messageName() == Messages::WebPageProxy:: DidRequestPasswordForQuickLookDocumentInMainFrame::name()) {473 IPC::handleMessage <Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame>(decoder, this, &ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame);472 if (decoder.messageName() == Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame::name()) { 473 IPC::handleMessageAsync<Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame>(connection, decoder, this, &ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame); 474 474 return; 475 475 } -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h
r251690 r251765 116 116 WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&); 117 117 #if USE(QUICK_LOOK) 118 void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);118 void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&); 119 119 #endif 120 120 #if PLATFORM(COCOA) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r251737 r251765 45 45 #include "ShareSheetCallbackID.h" 46 46 #include "ShareableBitmap.h" 47 #include "ShareableResource.h" 47 48 #include "SuspendedPageProxy.h" 48 49 #include "SyntheticEditingCommandType.h" … … 329 330 enum class UndoOrRedo : bool; 330 331 enum class WebContentMode : uint8_t; 331 332 #if USE(QUICK_LOOK)333 class QuickLookDocumentData;334 #endif335 332 336 333 typedef GenericCallback<API::Data*> DataCallback; … … 1561 1558 WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&); 1562 1559 #if USE(QUICK_LOOK) 1563 void didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&&, const String& fileName);1560 void requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&&); 1564 1561 #endif 1565 1562 #if ENABLE(CONTENT_FILTERING) … … 2053 2050 #if USE(QUICK_LOOK) 2054 2051 void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti); 2055 void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&);2056 void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);2052 void didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle&); 2053 void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&); 2057 2054 #endif 2058 2055 -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r251737 r251765 468 468 #if USE(QUICK_LOOK) 469 469 DidStartLoadForQuickLookDocumentInMainFrame(String fileName, String uti) 470 DidFinishLoadForQuickLookDocumentInMainFrame(WebKit:: QuickLookDocumentData data)471 DidRequestPasswordForQuickLookDocumentInMainFrame(String fileName)470 DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::ShareableResource::Handle resource) 471 RequestPasswordForQuickLookDocumentInMainFrame(String fileName) -> (String password) Async 472 472 #endif 473 473 -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r251676 r251765 48 48 #import "RemoteLayerTreeTransaction.h" 49 49 #import "RemoteScrollingCoordinatorProxy.h" 50 #import "ShareableResource.h" 50 51 #import "UIKitSPI.h" 51 52 #import "UserData.h" … … 1250 1251 1251 1252 #if USE(QUICK_LOOK) 1252 1253 1253 1254 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti) 1254 1255 { … … 1258 1259 } 1259 1260 1260 void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data) 1261 { 1262 m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(data); 1263 } 1264 1265 void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName) 1266 { 1267 didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName); 1268 } 1269 1270 void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&& process, const String& fileName) 1271 { 1272 pageClient().requestPasswordForQuickLookDocument(fileName, [process = WTFMove(process), webPageID = m_webPageID](const String& password) { 1273 process->send(Messages::WebPage::DidReceivePasswordForQuickLookDocument(password), webPageID); 1274 }); 1261 void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle& handle) 1262 { 1263 auto buffer = handle.tryWrapInSharedBuffer(); 1264 if (!buffer) 1265 return; 1266 1267 m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(*buffer); 1268 } 1269 1270 void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler) 1271 { 1272 requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler)); 1273 } 1274 1275 void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler) 1276 { 1277 pageClient().requestPasswordForQuickLookDocument(fileName, WTFMove(completionHandler)); 1275 1278 } 1276 1279 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r251600 r251765 1344 1344 A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1046E9F2079263100F0C5D8 /* WKPDFView.h */; }; 1345 1345 A115DC72191D82DA00DA8072 /* _WKWebViewPrintFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1346 A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };1347 1346 A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1348 1347 A13B3DA2207F39DE0090C58D /* MobileWiFiSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A13B3DA1207F39DE0090C58D /* MobileWiFiSPI.h */; }; … … 1361 1360 A1A4FE5C18DCE9FA00B5EA8A /* _WKDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */; }; 1362 1361 A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1362 A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */; }; 1363 1363 A1C512C9190656E500448914 /* WebPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebPreviewLoaderClient.h */; }; 1364 1364 A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; }; … … 1735 1735 filePatterns = "*.h"; 1736 1736 fileType = pattern.proxy; 1737 inputFiles = ( 1738 ); 1737 1739 isEditable = 1; 1738 1740 outputFiles = ( … … 4074 4076 A115DC6D191D82AB00DA8072 /* _WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKWebViewPrintFormatter.mm; sourceTree = "<group>"; }; 4075 4077 A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebViewPrintFormatter.h; sourceTree = "<group>"; }; 4076 A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = QuickLookDocumentData.cpp; path = ios/QuickLookDocumentData.cpp; sourceTree = "<group>"; };4077 A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickLookDocumentData.h; path = ios/QuickLookDocumentData.h; sourceTree = "<group>"; };4078 4078 A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSFileManagerExtras.mm; sourceTree = "<group>"; }; 4079 4079 A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSFileManagerExtras.h; sourceTree = "<group>"; }; … … 4103 4103 A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadInternal.h; sourceTree = "<group>"; }; 4104 4104 A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadDelegate.h; sourceTree = "<group>"; }; 4105 A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemory.cpp; sourceTree = "<group>"; }; 4105 4106 A1B89B92221E023300EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; }; 4106 4107 A1B9CA382246E54A003D6DCA /* WebPaymentCoordinatorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPaymentCoordinatorCocoa.mm; sourceTree = "<group>"; }; … … 6073 6074 1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */, 6074 6075 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */, 6075 A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,6076 A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */,6077 6076 4459984122833E6000E61373 /* SyntheticEditingCommandType.h */, 6078 6077 F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */, … … 8430 8429 C0E3AA451209E2BA00A49D01 /* Module.cpp */, 8431 8430 C0E3AA441209E2BA00A49D01 /* Module.h */, 8431 A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */, 8432 8432 1A24BED3120894D100FBB059 /* SharedMemory.h */, 8433 8433 ); … … 9754 9754 83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */, 9755 9755 A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */, 9756 A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */,9757 9756 57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */, 9758 9757 2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */, … … 11356 11355 41DE7C6C22278F1E00532B65 /* ServiceWorkerFetchTask.cpp in Sources */, 11357 11356 2D92A787212B6AB100F493FD /* ShareableBitmap.cpp in Sources */, 11357 A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */, 11358 11358 2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */, 11359 11359 1A334DED16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp in Sources */, -
trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp
r247786 r251765 32 32 #include "WebPageProxyMessages.h" 33 33 #include "WebProcess.h" 34 #include <WebCore/ QuickLook.h>34 #include <WebCore/SharedBuffer.h> 35 35 #include <wtf/Function.h> 36 36 #include <wtf/HashMap.h> … … 39 39 namespace WebKit { 40 40 41 using PasswordCallbackMap = HashMap<WebCore::PageIdentifier, Function<void(const String&)>>; 42 static PasswordCallbackMap& passwordCallbacks() 43 { 44 static NeverDestroyed<PasswordCallbackMap> callbackMap; 45 return callbackMap.get(); 46 } 41 using namespace WebCore; 47 42 48 WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier pageID)43 WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, PageIdentifier pageID) 49 44 : m_fileName { fileName } 50 45 , m_uti { uti } 51 46 , m_pageID { pageID } 47 , m_buffer { SharedBuffer::create() } 52 48 { 53 49 } 54 50 55 WebPreviewLoaderClient::~WebPreviewLoaderClient() 51 WebPreviewLoaderClient::~WebPreviewLoaderClient() = default; 52 53 void WebPreviewLoaderClient::didReceiveBuffer(const SharedBuffer& buffer) 56 54 { 57 passwordCallbacks().remove(m_pageID); 58 } 55 auto webPage = WebProcess::singleton().webPage(m_pageID); 56 if (!webPage) 57 return; 59 58 60 void WebPreviewLoaderClient::didReceiveDataArray(CFArrayRef dataArray) 61 { 62 if (m_data.isEmpty()) 63 WebProcess::singleton().send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti), m_pageID); 59 if (m_buffer->isEmpty()) 60 webPage->didStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti); 64 61 65 CFArrayApplyFunction(dataArray, CFRangeMake(0, CFArrayGetCount(dataArray)), [](const void* value, void* context) { 66 ASSERT(CFGetTypeID(value) == CFDataGetTypeID()); 67 static_cast<QuickLookDocumentData*>(context)->append((CFDataRef)value); 68 }, &m_data); 62 m_buffer->append(buffer); 69 63 } 70 64 71 65 void WebPreviewLoaderClient::didFinishLoading() 72 66 { 73 WebProcess::singleton().send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(m_data), m_pageID); 74 m_data.clear(); 67 auto webPage = WebProcess::singleton().webPage(m_pageID); 68 if (!webPage) 69 return; 70 71 webPage->didFinishLoadForQuickLookDocumentInMainFrame(m_buffer.get()); 72 m_buffer->clear(); 75 73 } 76 74 77 75 void WebPreviewLoaderClient::didFail() 78 76 { 79 m_ data.clear();77 m_buffer->clear(); 80 78 } 81 79 82 80 void WebPreviewLoaderClient::didRequestPassword(Function<void(const String&)>&& completionHandler) 83 81 { 84 ASSERT(!passwordCallbacks().contains(m_pageID)); 85 passwordCallbacks().add(m_pageID, WTFMove(completionHandler)); 86 WebProcess::singleton().send(Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame(m_fileName), m_pageID); 87 } 82 auto webPage = WebProcess::singleton().webPage(m_pageID); 83 if (!webPage) { 84 completionHandler({ }); 85 return; 86 } 88 87 89 void WebPreviewLoaderClient::didReceivePassword(const String& password, WebCore::PageIdentifier pageID) 90 { 91 ASSERT(passwordCallbacks().contains(pageID)); 92 if (auto completionHandler = passwordCallbacks().take(pageID)) 93 completionHandler(password); 94 else 95 RELEASE_LOG_ERROR(Loading, "Discarding a password for a page that did not request one in this process"); 88 webPage->requestPasswordForQuickLookDocumentInMainFrame(m_fileName, WTFMove(completionHandler)); 96 89 } 97 90 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h
r251488 r251765 28 28 #if USE(QUICK_LOOK) 29 29 30 #include "QuickLookDocumentData.h"31 30 #include <WebCore/LegacyPreviewLoaderClient.h> 32 31 #include <WebCore/PageIdentifier.h> … … 45 44 ~WebPreviewLoaderClient(); 46 45 47 static void didReceivePassword(const String&, WebCore::PageIdentifier);48 49 46 private: 50 47 WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier); 51 void didReceive DataArray(CFArrayRef) override;48 void didReceiveBuffer(const WebCore::SharedBuffer&) override; 52 49 void didFinishLoading() override; 53 50 void didFail() override; … … 58 55 const String m_uti; 59 56 const WebCore::PageIdentifier m_pageID; 60 QuickLookDocumentData m_data;57 Ref<WebCore::SharedBuffer> m_buffer; 61 58 }; 62 59 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r251737 r251765 1235 1235 #endif // PLATFORM(IOS_FAMILY) 1236 1236 1237 #if USE(QUICK_LOOK) 1238 void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti); 1239 void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&); 1240 void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&); 1241 #endif 1242 1237 1243 private: 1238 1244 WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&); … … 1596 1602 bool canPluginHandleResponse(const WebCore::ResourceResponse&); 1597 1603 1598 #if USE(QUICK_LOOK)1599 void didReceivePasswordForQuickLookDocument(const String&);1600 #endif1601 1602 1604 void simulateDeviceOrientationChange(double alpha, double beta, double gamma); 1603 1605 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r251737 r251765 533 533 #endif 534 534 535 #if USE(QUICK_LOOK)536 DidReceivePasswordForQuickLookDocument(String password)537 #endif538 539 535 FrameBecameRemote(WebCore::FrameIdentifier frameID, struct WebCore::GlobalFrameIdentifier remoteFrameIdentifier, struct WebCore::GlobalWindowIdentifier remoteWindowIdentifier) 540 536 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r251720 r251765 43 43 #import "RemoteLayerTreeDrawingArea.h" 44 44 #import "SandboxUtilities.h" 45 #import "SharedMemory.h" 45 46 #import "SyntheticEditingCommandType.h" 46 47 #import "TextCheckingControllerProxy.h" … … 3844 3845 } 3845 3846 3846 #if USE(QUICK_LOOK)3847 void WebPage::didReceivePasswordForQuickLookDocument(const String& password)3848 {3849 WebPreviewLoaderClient::didReceivePassword(password, m_identifier);3850 }3851 #endif3852 3853 3847 bool WebPage::platformPrefersTextLegibilityBasedZoomScaling() const 3854 3848 { … … 4079 4073 } 4080 4074 4075 #if USE(QUICK_LOOK) 4076 4077 void WebPage::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti) 4078 { 4079 send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(fileName, uti)); 4080 } 4081 4082 void WebPage::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer) 4083 { 4084 ASSERT(!buffer.isEmpty()); 4085 4086 // FIXME: In some cases, buffer conains a single segment that wraps an existing ShareableResource. 4087 // If we could create a handle from that existing resource then we could avoid this extra 4088 // allocation and copy. 4089 4090 auto sharedMemory = SharedMemory::copyBuffer(buffer); 4091 if (!sharedMemory) 4092 return; 4093 4094 ShareableResource::Handle handle; 4095 auto shareableResource = ShareableResource::create(sharedMemory.releaseNonNull(), 0, buffer.size()); 4096 if (!shareableResource->createHandle(handle)) 4097 return; 4098 4099 send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(handle)); 4100 } 4101 4102 void WebPage::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler) 4103 { 4104 sendWithAsyncReply(Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame(fileName), WTFMove(completionHandler)); 4105 } 4106 4107 #endif 4108 4081 4109 } // namespace WebKit 4082 4110 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r251630 r251765 1 2019-10-29 Andy Estes <aestes@apple.com> 2 3 [Quick Look] Clean up LegacyPreviewLoaderClients 4 https://bugs.webkit.org/show_bug.cgi?id=203472 5 6 Reviewed by Brady Eidson. 7 8 * WebCoreSupport/WebFrameLoaderClient.mm: 9 (WebFrameLoaderClient::createPreviewLoaderClient): 10 1 11 2019-10-26 Chris Lord <clord@igalia.com> 2 12 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
r251488 r251765 2207 2207 RetainPtr<NSFileHandle> m_fileHandle; 2208 2208 2209 void didReceive DataArray(CFArrayRef dataArray) override2209 void didReceiveBuffer(const WebCore::SharedBuffer& buffer) override 2210 2210 { 2211 for (NSData *data in (NSArray *)dataArray) 2211 auto dataArray = buffer.createNSDataArray(); 2212 for (NSData *data in dataArray.get()) 2212 2213 [m_fileHandle writeData:data]; 2213 2214 } -
trunk/Tools/ChangeLog
r251763 r251765 1 2019-10-29 Andy Estes <aestes@apple.com> 2 3 [Quick Look] Clean up LegacyPreviewLoaderClients 4 https://bugs.webkit.org/show_bug.cgi?id=203472 5 6 Reviewed by Brady Eidson. 7 8 Updated API tests to compare data received in 9 -_webView:didFinishLoadForQuickLookDocumentInMainFrame: with expected data. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm: 12 (readFile): 13 (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]): 14 (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): 15 (-[QuickLookDelegate verifyDownload]): 16 (TEST): 17 1 18 2019-10-29 Jonathan Bedard <jbedard@apple.com> 2 19 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm
r251223 r251765 71 71 NSUInteger _downloadFileSize; 72 72 NSUInteger _expectedFileSize; 73 RetainPtr<NSData> _expectedFileData; 73 74 RetainPtr<NSString> _expectedFileName; 74 75 RetainPtr<NSString> _expectedFileType; … … 78 79 } 79 80 80 static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType )81 static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType, RetainPtr<NSData>& fileData) 81 82 { 82 83 if (NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:fileURL.path error:nil]) … … 90 91 91 92 mimeType = adoptCF(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)typeIdentifier, kUTTagClassMIMEType)); 93 fileData = [NSData dataWithContentsOfURL:fileURL]; 92 94 } 93 95 … … 97 99 return nil; 98 100 99 readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType );101 readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType, _expectedFileData); 100 102 101 103 _responsePolicy = responsePolicy; … … 140 142 { 141 143 EXPECT_EQ(_expectedFileSize, documentData.length); 144 EXPECT_TRUE([_expectedFileData isEqualToData:documentData]); 142 145 EXPECT_FALSE(_didFinishQuickLookLoad); 143 146 EXPECT_TRUE(_didStartQuickLookLoad); … … 220 223 221 224 NSUInteger downloadFileSize; 225 RetainPtr<NSData> downloadFileData; 222 226 RetainPtr<NSString> downloadFileName; 223 227 RetainPtr<NSString> downloadFileType; 224 228 RetainPtr<NSString> downloadMIMEType; 225 readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType );229 readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType, downloadFileData); 226 230 227 231 EXPECT_EQ(_expectedFileSize, downloadFileSize); 232 EXPECT_TRUE([_expectedFileData isEqualToData:downloadFileData.get()]); 228 233 EXPECT_WK_STREQ(_expectedFileName.get(), downloadFileName.get()); 229 234 EXPECT_WK_STREQ(_expectedFileType.get(), downloadFileType.get()); … … 466 471 467 472 NSUInteger expectedFileSize; 473 RetainPtr<NSData> expectedFileData; 468 474 RetainPtr<NSString> expectedFileName; 469 475 RetainPtr<NSString> expectedFileType; 470 476 RetainPtr<NSString> expectedMIMEType; 471 readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType );477 readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType, expectedFileData); 472 478 473 479 NSDictionary *quickLookContent = mainFrame.dataSource._quickLookContent; … … 479 485 NSDictionary *fileAttributes = [NSFileManager.defaultManager attributesOfItemAtPath:filePath error:nil]; 480 486 EXPECT_EQ(expectedFileSize, [fileAttributes[NSFileSize] unsignedIntegerValue]); 487 488 EXPECT_TRUE([expectedFileData isEqualToData:[NSData dataWithContentsOfFile:filePath]]); 481 489 482 490 isDone = false;
Note: See TracChangeset
for help on using the changeset viewer.