Changeset 278414 in webkit
- Timestamp:
- Jun 3, 2021, 12:40:00 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/Cocoa/WebViewImpl.mm (modified) (3 diffs)
-
UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
UIProcess/WebPageProxy.h (modified) (2 diffs)
-
UIProcess/mac/WKImageExtractionPreviewController.h (modified) (2 diffs)
-
UIProcess/mac/WKImageExtractionPreviewController.mm (modified) (2 diffs)
-
UIProcess/mac/WebPageProxyMac.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r278412 r278414 1 2021-06-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Image extraction preview panel should automatically close when the web view is unparented 4 https://bugs.webkit.org/show_bug.cgi?id=226588 5 rdar://77062762 6 7 Reviewed by Tim Horton. 8 9 Refactor some logic for presenting the preview panel. See below for more details. 10 11 * UIProcess/Cocoa/WebViewImpl.mm: 12 (WebKit::WebViewImpl::handleProcessSwapOrExit): 13 (WebKit::WebViewImpl::viewDidMoveToWindow): 14 15 When the web view is removed from the view hierarchy (i.e. when the view is moved to a `nil` window), call into 16 `closeSharedPreviewPanelIfNecessary` to dismiss the shared preview panel if we're currently controlling its 17 presentation for the purposes of image extraction. 18 19 (WebKit::WebViewImpl::beginPreviewPanelControl): 20 (WebKit::WebViewImpl::endPreviewPanelControl): 21 22 Add more plumbing into WebPageProxy to begin and end preview panel control; this allows us to avoid having to 23 expose a separate method to reset WebPageProxy's `m_imageExtractionPreviewController` and call it from 24 WebViewImpl. 25 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::didCommitLoadForFrame): 28 29 Additionally call into `closeSharedPreviewPanelIfNecessary` when committing main frame navigation. We also 30 refactor a bit of logic here so that we fold several pieces of similar "reset" logic into a single if statement. 31 32 * UIProcess/WebPageProxy.h: 33 * UIProcess/mac/WKImageExtractionPreviewController.h: 34 * UIProcess/mac/WKImageExtractionPreviewController.mm: 35 (-[WKImageExtractionPreviewController beginControl:]): 36 (-[WKImageExtractionPreviewController endControl:]): 37 (-[WKImageExtractionPreviewController closePanelIfNecessary]): 38 (-[WKImageExtractionPreviewController isControlling:]): 39 40 Move logic for assigning, removing, and checking the QLPreviewPanel's `-delegate` and `-dataSource` into helper 41 methods on WKImageExtractionPreviewController. Doing this allows us to consolidate more of the QuickLookUI- 42 specific logic inside WKImageExtractionPreviewController and WebPageProxy, but also (and more importantly) 43 prevents us from having to `#import <pal/spi/mac/QuickLookMacSPI.h>` inside `WebPageProxyMac.mm`, which results 44 in nullability errors when calling into `-[NSApplication stopSpeaking:]`. 45 46 * UIProcess/mac/WebPageProxyMac.mm: 47 (WebKit::WebPageProxy::beginPreviewPanelControl): 48 (WebKit::WebPageProxy::endPreviewPanelControl): 49 (WebKit::WebPageProxy::closeSharedPreviewPanelIfNecessary): 50 1 51 2021-06-03 Chris Fleizach <cfleizach@apple.com> 2 52 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r278253 r278414 1518 1518 { 1519 1519 dismissContentRelativeChildWindowsWithAnimation(true); 1520 m_page->closeSharedPreviewPanelIfNecessary(); 1520 1521 1521 1522 notifyInputContextAboutDiscardedComposition(); … … 2398 2399 2399 2400 dismissContentRelativeChildWindowsWithAnimation(false); 2401 m_page->closeSharedPreviewPanelIfNecessary(); 2400 2402 2401 2403 if (m_immediateActionGestureRecognizer) { … … 5725 5727 void WebViewImpl::beginPreviewPanelControl(QLPreviewPanel *panel) 5726 5728 { 5727 #if ENABLE(IMAGE_EXTRACTION) 5728 auto controller = m_page->imageExtractionPreviewController(); 5729 if (!controller) 5730 return; 5731 5732 panel.dataSource = controller; 5733 panel.delegate = controller; 5734 #else 5735 UNUSED_PARAM(panel); 5736 #endif 5729 m_page->beginPreviewPanelControl(panel); 5737 5730 } 5738 5731 5739 5732 void WebViewImpl::endPreviewPanelControl(QLPreviewPanel *panel) 5740 5733 { 5741 #if ENABLE(IMAGE_EXTRACTION) 5742 auto controller = m_page->imageExtractionPreviewController(); 5743 if (!controller) 5744 return; 5745 5746 if (panel.dataSource == controller) 5747 panel.dataSource = nil; 5748 5749 if (panel.delegate == controller) 5750 panel.delegate = nil; 5751 5752 m_page->resetImageExtractionPreview(); 5753 #else 5754 UNUSED_PARAM(panel); 5755 #endif 5734 m_page->endPreviewPanelControl(panel); 5756 5735 } 5757 5736 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r278394 r278414 4883 4883 m_navigationClient->didCommitLoadForFrame(*this, WTFMove(request), WTFMove(frameInfo)); 4884 4884 } 4885 if (frame->isMainFrame()) { 4885 4886 #if ENABLE(ATTACHMENT_ELEMENT) 4886 if (frame->isMainFrame())4887 4887 invalidateAllAttachments(); 4888 4888 #endif 4889 4890 4889 #if ENABLE(REMOTE_INSPECTOR) 4891 if (frame->isMainFrame())4892 4890 remoteInspectorInformationDidChange(); 4893 4891 #endif 4892 #if USE(APPKIT) 4893 closeSharedPreviewPanelIfNecessary(); 4894 #endif 4895 } 4894 4896 4895 4897 #if ENABLE(MEDIA_SESSION_COORDINATOR) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r278394 r278414 230 230 OBJC_CLASS NSTextAlternatives; 231 231 OBJC_CLASS NSView; 232 OBJC_CLASS QLPreviewPanel; 232 233 OBJC_CLASS WKQLThumbnailLoadOperation; 233 234 OBJC_CLASS WKWebView; … … 1913 1914 #if ENABLE(IMAGE_EXTRACTION) && ENABLE(CONTEXT_MENUS) 1914 1915 void handleContextMenuRevealImage(); 1915 void resetImageExtractionPreview(); 1916 #endif 1917 1918 #if USE(APPKIT) 1919 void beginPreviewPanelControl(QLPreviewPanel *); 1920 void endPreviewPanelControl(QLPreviewPanel *); 1921 void closeSharedPreviewPanelIfNecessary(); 1916 1922 #endif 1917 1923 -
trunk/Source/WebKit/UIProcess/mac/WKImageExtractionPreviewController.h
r277903 r278414 28 28 #if PLATFORM(MAC) && ENABLE(IMAGE_EXTRACTION) 29 29 30 #import < pal/spi/mac/QuickLookMacSPI.h>30 #import <Foundation/Foundation.h> 31 31 32 32 namespace WebKit { … … 34 34 } 35 35 36 @interface WKImageExtractionPreviewController : NSObject <QLPreviewPanelDelegate, QLPreviewPanelDataSource> 36 @class QLPreviewPanel; 37 38 @interface WKImageExtractionPreviewController : NSObject 37 39 - (instancetype)initWithPage:(WebKit::WebPageProxy&)page imageData:(NSData *)data title:(NSString *)title imageURL:(NSURL *)imageURL; 40 - (void)beginControl:(QLPreviewPanel *)panel; 41 - (BOOL)isControlling:(QLPreviewPanel *)panel; 42 - (void)endControl:(QLPreviewPanel *)panel; 43 - (void)closePanelIfNecessary; 38 44 @end 39 45 -
trunk/Source/WebKit/UIProcess/mac/WKImageExtractionPreviewController.mm
r277903 r278414 33 33 #import <wtf/RetainPtr.h> 34 34 35 @interface WKImageExtractionPreviewController () <QLPreviewPanelDelegate, QLPreviewPanelDataSource> 36 @end 37 35 38 @implementation WKImageExtractionPreviewController { 36 39 RetainPtr<QLItem> _item; … … 55 58 56 59 return self; 60 } 61 62 - (void)beginControl:(QLPreviewPanel *)panel 63 { 64 panel.dataSource = self; 65 panel.delegate = self; 66 } 67 68 - (void)endControl:(QLPreviewPanel *)panel 69 { 70 if (panel.dataSource == self) 71 panel.dataSource = nil; 72 73 if (panel.delegate == self) 74 panel.delegate = nil; 75 } 76 77 - (void)closePanelIfNecessary 78 { 79 if (!PAL::isQuickLookUIFrameworkAvailable() || ![PAL::getQLPreviewPanelClass() sharedPreviewPanelExists]) 80 return; 81 82 if (auto panel = [PAL::getQLPreviewPanelClass() sharedPreviewPanel]; [self isControlling:panel]) 83 [panel close]; 84 } 85 86 - (BOOL)isControlling:(QLPreviewPanel *)panel 87 { 88 return panel.dataSource == self && panel.delegate == self; 57 89 } 58 90 -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r278253 r278414 46 46 #import "TextChecker.h" 47 47 #import "WKBrowsingContextControllerInternal.h" 48 #import "WKImageExtractionPreviewController.h" 48 49 #import "WKSharingServicePickerDelegate.h" 49 50 #import "WebContextMenuProxyMac.h" … … 720 721 } 721 722 723 void WebPageProxy::beginPreviewPanelControl(QLPreviewPanel *panel) 724 { 725 #if ENABLE(IMAGE_EXTRACTION) 726 [m_imageExtractionPreviewController beginControl:panel]; 727 #endif 728 } 729 730 void WebPageProxy::endPreviewPanelControl(QLPreviewPanel *panel) 731 { 732 #if ENABLE(IMAGE_EXTRACTION) 733 if (auto controller = std::exchange(m_imageExtractionPreviewController, nil)) 734 [controller endControl:panel]; 735 #endif 736 } 737 738 void WebPageProxy::closeSharedPreviewPanelIfNecessary() 739 { 740 #if ENABLE(IMAGE_EXTRACTION) 741 [m_imageExtractionPreviewController closePanelIfNecessary]; 742 #endif 743 } 744 722 745 } // namespace WebKit 723 746
Note:
See TracChangeset
for help on using the changeset viewer.