Changeset 280690 in webkit
- Timestamp:
- Aug 5, 2021 9:03:34 AM (12 months ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/Cocoa/WebViewImpl.h (modified) (2 diffs)
-
UIProcess/Cocoa/WebViewImpl.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r280689 r280690 1 2021-08-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS Monterey] Translate popover becomes detached from webpage after scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=228807 5 rdar://81540115 6 7 Reviewed by Sam Weinig. 8 9 Close the context menu translation popover in `WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly` 10 (along with all other content-relative UI) to prevent the popover from being detached from its translated text 11 upon scrolling or zooming. 12 13 * UIProcess/Cocoa/WebViewImpl.h: 14 * UIProcess/Cocoa/WebViewImpl.mm: 15 (WebKit::WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly): 16 (WebKit::WebViewImpl::handleContextMenuTranslation): 17 18 Save a weak pointer to the current translation popover when we're about to present it, and use it to force the 19 popover to `-close` when dismissing content-relative child windows. Also take this opportunity to remove some 20 staging declarations on LTUITranslationViewController that have long since landed in the macOS 12 SDK. 21 1 22 2021-08-05 Michael Catanzaro <mcatanzaro@gnome.org> 2 23 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r279988 r280690 53 53 OBJC_CLASS NSImmediateActionGestureRecognizer; 54 54 OBJC_CLASS NSMenu; 55 OBJC_CLASS NSPopover; 55 56 OBJC_CLASS NSTextInputContext; 56 57 OBJC_CLASS NSView; … … 908 909 RetainPtr<VKImageAnalyzer> m_imageAnalyzer; 909 910 #endif 911 912 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 913 WeakObjCPtr<NSPopover> m_lastContextMenuTranslationPopover; 914 #endif 910 915 }; 911 916 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r280336 r280690 151 151 #import <TranslationUIServices/LTUITranslationViewController.h> 152 152 153 @interface LTUITranslationViewController (Staging_77660675)154 @property (nonatomic, copy) void(^replacementHandler)(NSAttributedString *);155 @end156 157 153 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(TranslationUIServices) 158 154 SOFT_LINK_CLASS_OPTIONAL(TranslationUIServices, LTUITranslationViewController) … … 3721 3717 3722 3718 m_pageClient->dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeTextIgnored); 3719 3720 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 3721 [std::exchange(m_lastContextMenuTranslationPopover, nil) close]; 3722 #endif 3723 3723 } 3724 3724 … … 5780 5780 auto translationViewController = adoptNS([allocLTUITranslationViewControllerInstance() init]); 5781 5781 [translationViewController setText:adoptNS([[NSAttributedString alloc] initWithString:info.text]).get()]; 5782 if (info.mode == WebCore::TranslationContextMenuMode::Editable && [translationViewController respondsToSelector:@selector(setReplacementHandler:)]) {5782 if (info.mode == WebCore::TranslationContextMenuMode::Editable) { 5783 5783 [translationViewController setIsSourceEditable:YES]; 5784 5784 [translationViewController setReplacementHandler:[this, weakThis = makeWeakPtr(*this)](NSAttributedString *string) { … … 5806 5806 preferredEdge = aim > highlight ? NSRectEdgeMaxX : NSRectEdgeMinX; 5807 5807 5808 m_lastContextMenuTranslationPopover = popover.get(); 5808 5809 [popover showRelativeToRect:info.selectionBoundsInRootView ofView:view.get() preferredEdge:preferredEdge]; 5809 5810 }
Note: See TracChangeset
for help on using the changeset viewer.