Changeset 277196 in webkit
- Timestamp:
- May 7, 2021, 1:28:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 24 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Headers.cmake (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (8 diffs)
-
WebCore/loader/EmptyClients.cpp (modified) (1 diff)
-
WebCore/page/ContextMenuClient.h (modified) (2 diffs)
-
WebCore/page/ContextMenuController.cpp (modified) (2 diffs)
-
WebCore/page/TranslationContextMenuInfo.h (added)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (modified) (1 diff)
-
WebKit/UIProcess/Cocoa/WebViewImpl.h (modified) (2 diffs)
-
WebKit/UIProcess/Cocoa/WebViewImpl.mm (modified) (6 diffs)
-
WebKit/UIProcess/PageClient.h (modified) (2 diffs)
-
WebKit/UIProcess/WebPageProxy.h (modified) (2 diffs)
-
WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit/UIProcess/mac/PageClientImplMac.h (modified) (1 diff)
-
WebKit/UIProcess/mac/PageClientImplMac.mm (modified) (1 diff)
-
WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h (modified) (1 diff)
-
WebKit/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm (modified) (2 diffs)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
WebKit/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
-
WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.h (modified) (1 diff)
-
WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm (modified) (1 diff)
-
WebKitLegacy/mac/WebView/WebView.mm (modified) (4 diffs)
-
WebKitLegacy/mac/WebView/WebViewInternal.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r277177 r277196 1 2021-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Set the -isSourceEditable property when presenting webpage translation popup 4 https://bugs.webkit.org/show_bug.cgi?id=225515 5 <rdar://problem/77658040> 6 7 Reviewed by Tim Horton. 8 9 Set `-[LTUITranslationViewController isSourceEditable]` to `YES` when showing the context menu for editable 10 content. Instead of plumbing another boolean flag through `ContextMenuClient` and into the client layers through 11 `handleTranslation()`, we roll all of the webpage translation context menu parameters into a single object 12 (`TranslationContextMenuInfo`), including a new flag indicating whether or not the translation controller should 13 be shown in "editable" mode. 14 15 * Headers.cmake: 16 * WebCore.xcodeproj/project.pbxproj: 17 * loader/EmptyClients.cpp: 18 * page/ContextMenuClient.h: 19 * page/ContextMenuController.cpp: 20 (WebCore::ContextMenuController::contextMenuItemSelected): 21 * page/TranslationContextMenuInfo.h: Added. 22 23 Pull the translated text string, selection bounds, menu location, and the new mode flag into a separate struct. 24 25 (WebCore::TranslationContextMenuInfo::encode const): 26 (WebCore::TranslationContextMenuInfo::decode): 27 1 28 2021-05-07 Chris Dumez <cdumez@apple.com> 2 29 -
trunk/Source/WebCore/Headers.cmake
r276951 r277196 946 946 page/TextDirectionSubmenuInclusionBehavior.h 947 947 page/TextIndicator.h 948 page/TranslationContextMenuInfo.h 948 949 page/UserContentController.h 949 950 page/UserContentProvider.h -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r277024 r277196 5339 5339 F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F48223121E386E240066FC79 /* AbstractPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5340 5340 F482434B260C33060022497C /* ImageOverlayController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4824348260C32F10022497C /* ImageOverlayController.h */; }; 5341 F48570A52644C76D00C05F71 /* TranslationContextMenuInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F48570A42644C76D00C05F71 /* TranslationContextMenuInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5341 5342 F48B7D5325C341E6009E75DD /* ImageExtractionResult.h in Headers */ = {isa = PBXBuildFile; fileRef = F48B7D5225C341E6009E75DD /* ImageExtractionResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5342 5343 F48D2A6C215623B400C6752B /* FontShadow.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A6A215623B400C6752B /* FontShadow.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 16797 16798 F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = DumpEditingHistory.js; path = Scripts/DumpEditingHistory.js; sourceTree = "<group>"; }; 16798 16799 F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = EditingHistoryUtil.js; path = Scripts/EditingHistoryUtil.js; sourceTree = "<group>"; }; 16800 F48570A42644C76D00C05F71 /* TranslationContextMenuInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TranslationContextMenuInfo.h; sourceTree = "<group>"; }; 16799 16801 F48B7D5225C341E6009E75DD /* ImageExtractionResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageExtractionResult.h; sourceTree = "<group>"; }; 16800 16802 F48D2A6A215623B400C6752B /* FontShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.h; sourceTree = "<group>"; }; … … 22518 22520 2D4F96F11A1ECC240098BF88 /* TextIndicator.cpp */, 22519 22521 2D4F96F21A1ECC240098BF88 /* TextIndicator.h */, 22522 F48570A42644C76D00C05F71 /* TranslationContextMenuInfo.h */, 22520 22523 F4E1965F21F26E4E00285078 /* UndoItem.cpp */, 22521 22524 2ECDBAD521D8906300F00ECD /* UndoItem.h */, … … 31427 31430 49E912AB0EFAC906009D0CAF /* Animation.h in Headers */, 31428 31431 71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */, 31429 449D864F2640C9C5000122DE /* HighlightVisibility.h in Headers */,31430 31432 71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */, 31431 31433 319848011A1D817B00A13318 /* AnimationEvent.h in Headers */, … … 32646 32648 CDCFABBD18C0AF78006F8450 /* HighlightData.h in Headers */, 32647 32649 4430D00D2575A8A50046D401 /* HighlightRegister.h in Headers */, 32650 449D864F2640C9C5000122DE /* HighlightVisibility.h in Headers */, 32648 32651 BC94D1540C275C8B006BC617 /* History.h in Headers */, 32649 32652 97DCE20210807C750057D394 /* HistoryController.h in Headers */, … … 34884 34887 4998AED213FB224D0090B1AA /* ScriptedAnimationController.h in Headers */, 34885 34888 08A484780E5272C500C3FE76 /* ScriptElement.h in Headers */, 34886 E4D86E6D2640394C00B62425 /* StyleScopeOrdinal.h in Headers */,34887 34889 E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */, 34888 34890 E11C9D9B0EB3681200E409DB /* ScriptExecutionContext.h in Headers */, … … 35200 35202 0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */, 35201 35203 E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */, 35204 E4D86E6D2640394C00B62425 /* StyleScopeOrdinal.h in Headers */, 35202 35205 4A4F48AA16B0DFC000EDBB29 /* StyleScopeRuleSets.h in Headers */, 35203 35206 F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */, … … 35538 35541 E17B491616A9B094001C8839 /* TransitionEvent.h in Headers */, 35539 35542 49E911D20EF86D47009D0CAF /* TranslateTransformOperation.h in Headers */, 35543 F48570A52644C76D00C05F71 /* TranslationContextMenuInfo.h in Headers */, 35540 35544 854FE7370A2297BE0058D7AD /* Traversal.h in Headers */, 35541 35545 37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */, -
trunk/Source/WebCore/loader/EmptyClients.cpp
r276448 r277196 121 121 122 122 #if HAVE(TRANSLATION_UI_SERVICES) 123 void handleTranslation(const String&, const IntRect&, const IntPoint&) final { }123 void handleTranslation(const TranslationContextMenuInfo&) final { } 124 124 #endif 125 125 -
trunk/Source/WebCore/page/ContextMenuClient.h
r276252 r277196 36 36 class IntRect; 37 37 38 #if HAVE(TRANSLATION_UI_SERVICES) 39 struct TranslationContextMenuInfo; 40 #endif 41 38 42 class ContextMenuClient { 39 43 public: … … 49 53 50 54 #if HAVE(TRANSLATION_UI_SERVICES) 51 virtual void handleTranslation(const String&, const IntRect&, const IntPoint&) = 0;55 virtual void handleTranslation(const TranslationContextMenuInfo&) = 0; 52 56 #endif 53 57 -
trunk/Source/WebCore/page/ContextMenuController.cpp
r276871 r277196 64 64 #include "Settings.h" 65 65 #include "TextIterator.h" 66 #include "TranslationContextMenuInfo.h" 66 67 #include "TypingCommand.h" 67 68 #include "UserTypingGestureIndicator.h" … … 528 529 #if HAVE(TRANSLATION_UI_SERVICES) 529 530 if (auto view = makeRefPtr(frame->view())) { 530 auto selectionBounds = view->contentsToRootView(enclosingIntRect(frame->selection().selectionBounds())); 531 auto location = view->contentsToRootView(m_context.hitTestResult().roundedPointInInnerNodeFrame()); 532 m_client.handleTranslation(m_context.hitTestResult().selectedText(), selectionBounds, location); 531 m_client.handleTranslation({ 532 m_context.hitTestResult().selectedText(), 533 view->contentsToRootView(enclosingIntRect(frame->selection().selectionBounds())), 534 view->contentsToRootView(m_context.hitTestResult().roundedPointInInnerNodeFrame()), 535 m_context.hitTestResult().isContentEditable() ? TranslationContextMenuMode::Editable : TranslationContextMenuMode::NonEditable, 536 }); 533 537 } 534 538 #endif -
trunk/Source/WebKit/ChangeLog
r277172 r277196 1 2021-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Set the -isSourceEditable property when presenting webpage translation popup 4 https://bugs.webkit.org/show_bug.cgi?id=225515 5 <rdar://problem/77658040> 6 7 Reviewed by Tim Horton. 8 9 See WebCore/ChangeLog for more details. 10 11 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 12 (WebKit::WebPageProxy::handleContextMenuTranslation): 13 * UIProcess/Cocoa/WebViewImpl.h: 14 * UIProcess/Cocoa/WebViewImpl.mm: 15 (WebKit::WebViewImpl::handleContextMenuTranslation): 16 * UIProcess/PageClient.h: 17 * UIProcess/WebPageProxy.h: 18 * UIProcess/WebPageProxy.messages.in: 19 * UIProcess/mac/PageClientImplMac.h: 20 * UIProcess/mac/PageClientImplMac.mm: 21 (WebKit::PageClientImpl::handleContextMenuTranslation): 22 * WebProcess/WebCoreSupport/WebContextMenuClient.h: 23 * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm: 24 (WebKit::WebContextMenuClient::handleTranslation): 25 * WebProcess/WebPage/WebPage.cpp: 26 (WebKit::WebPage::handleContextMenuTranslation): 27 * WebProcess/WebPage/WebPage.h: 28 1 29 2021-05-07 Carlos Garnacho <carlosg@gnome.org> 2 30 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r276947 r277196 627 627 } 628 628 629 void WebPageProxy::handleContextMenuTranslation(const String& text, const WebCore::IntRect& boundsInView, const WebCore::IntPoint& locationInView)630 { 631 return pageClient().handleContextMenuTranslation( text, boundsInView, locationInView);629 void WebPageProxy::handleContextMenuTranslation(const TranslationContextMenuInfo& info) 630 { 631 return pageClient().handleContextMenuTranslation(info); 632 632 } 633 633 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r276621 r277196 97 97 struct ShareDataWithParsedURL; 98 98 99 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 100 struct TranslationContextMenuInfo; 101 #endif 102 99 103 #if ENABLE(IMAGE_EXTRACTION) 100 104 struct ImageExtractionResult; … … 649 653 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 650 654 bool canHandleContextMenuTranslation() const; 651 void handleContextMenuTranslation(const String& text, const WebCore::IntRect& boundsInView, const WebCore::IntPoint& menuLocation);655 void handleContextMenuTranslation(const WebCore::TranslationContextMenuInfo&); 652 656 #endif 653 657 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r276621 r277196 108 108 #import <WebCore/TextAlternativeWithRange.h> 109 109 #import <WebCore/TextUndoInsertionMarkupMac.h> 110 #import <WebCore/TranslationContextMenuInfo.h> 110 111 #import <WebCore/WebActionDisablingCALayerDelegate.h> 111 112 #import <WebCore/WebCoreCALayerExtras.h> … … 146 147 #import <TranslationUIServices/LTUITranslationViewController.h> 147 148 149 @interface LTUITranslationViewController (Staging_77660675) 150 @property (nonatomic, copy) void(^replacementHandler)(NSAttributedString *); 151 @end 152 148 153 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(TranslationUIServices) 149 154 SOFT_LINK_CLASS_OPTIONAL(TranslationUIServices, LTUITranslationViewController) … … 5587 5592 } 5588 5593 5589 void WebViewImpl::handleContextMenuTranslation(const String& text, const IntRect& boundsInView, const IntPoint& menuLocation)5594 void WebViewImpl::handleContextMenuTranslation(const TranslationContextMenuInfo& info) 5590 5595 { 5591 5596 if (!canHandleContextMenuTranslation()) { … … 5596 5601 auto view = m_view.get(); 5597 5602 auto translationViewController = adoptNS([allocLTUITranslationViewControllerInstance() init]); 5598 auto textToTranslate = adoptNS([[NSAttributedString alloc] initWithString:text]); 5599 [translationViewController setText:textToTranslate.get()]; 5603 [translationViewController setText:adoptNS([[NSAttributedString alloc] initWithString:info.text]).get()]; 5604 if (info.mode == WebCore::TranslationContextMenuMode::Editable && [translationViewController respondsToSelector:@selector(setReplacementHandler:)]) { 5605 [translationViewController setIsSourceEditable:YES]; 5606 [translationViewController setReplacementHandler:[this, weakThis = makeWeakPtr(*this)](NSAttributedString *string) { 5607 if (weakThis) 5608 insertText(string.string); 5609 }]; 5610 } 5611 5600 5612 if (NSEqualSizes([translationViewController preferredContentSize], NSZeroSize)) 5601 5613 [translationViewController setPreferredContentSize:NSMakeSize(400, 400)]; … … 5609 5621 5610 5622 NSRectEdge preferredEdge; 5611 auto aim = menuLocation.x();5612 auto highlight = boundsInView.center().x();5623 auto aim = info.locationInRootView.x(); 5624 auto highlight = info.selectionBoundsInRootView.center().x(); 5613 5625 if (aim == highlight) 5614 5626 preferredEdge = [view userInterfaceLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft ? NSRectEdgeMinX : NSRectEdgeMaxX; … … 5616 5628 preferredEdge = aim > highlight ? NSRectEdgeMaxX : NSRectEdgeMinX; 5617 5629 5618 [popover showRelativeToRect: boundsInView ofView:view.get() preferredEdge:preferredEdge];5630 [popover showRelativeToRect:info.selectionBoundsInRootView ofView:view.get() preferredEdge:preferredEdge]; 5619 5631 } 5620 5632 -
trunk/Source/WebKit/UIProcess/PageClient.h
r277097 r277196 127 127 struct PromisedAttachmentInfo; 128 128 #endif 129 130 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 131 struct TranslationContextMenuInfo; 132 #endif 129 133 } 130 134 … … 618 622 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 619 623 virtual bool canHandleContextMenuTranslation() const = 0; 620 virtual void handleContextMenuTranslation(const String& text, const WebCore::IntRect& boundsInView, const WebCore::IntPoint& menuLocation) = 0;624 virtual void handleContextMenuTranslation(const WebCore::TranslationContextMenuInfo&) = 0; 621 625 #endif 622 626 }; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r277097 r277196 109 109 #include <WebCore/TextGranularity.h> 110 110 #include <WebCore/TextManipulationController.h> 111 #include <WebCore/TranslationContextMenuInfo.h> 111 112 #include <WebCore/UserInterfaceLayoutDirection.h> 112 113 #include <WebCore/ViewportArguments.h> … … 1912 1913 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 1913 1914 bool canHandleContextMenuTranslation() const; 1914 void handleContextMenuTranslation(const String& text, const WebCore::IntRect& boundsInView, const WebCore::IntPoint& locationInView);1915 void handleContextMenuTranslation(const WebCore::TranslationContextMenuInfo&); 1915 1916 #endif 1916 1917 -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r277045 r277196 229 229 230 230 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 231 HandleContextMenuTranslation( String text, WebCore::IntRect boundsInView, WebCore::IntPoint locationInView)231 HandleContextMenuTranslation(struct WebCore::TranslationContextMenuInfo info) 232 232 #endif 233 233 -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r275491 r277196 284 284 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 285 285 bool canHandleContextMenuTranslation() const override; 286 void handleContextMenuTranslation(const String&, const WebCore::IntRect&, const WebCore::IntPoint&) override;286 void handleContextMenuTranslation(const WebCore::TranslationContextMenuInfo&) override; 287 287 #endif 288 288 -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r275491 r277196 1023 1023 } 1024 1024 1025 void PageClientImpl::handleContextMenuTranslation(const String& text, const IntRect& boundsInView, const WebCore::IntPoint& menuLocation)1026 { 1027 m_impl->handleContextMenuTranslation( text, boundsInView, menuLocation);1025 void PageClientImpl::handleContextMenuTranslation(const TranslationContextMenuInfo& info) 1026 { 1027 m_impl->handleContextMenuTranslation(info); 1028 1028 } 1029 1029 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h
r276181 r277196 58 58 59 59 #if HAVE(TRANSLATION_UI_SERVICES) 60 void handleTranslation(const String&, const WebCore::IntRect& selectionBoundsInRootView, const WebCore::IntPoint& locationInRootView) final;60 void handleTranslation(const WebCore::TranslationContextMenuInfo&) final; 61 61 #endif 62 62 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
r276181 r277196 38 38 #import <WebCore/Page.h> 39 39 #import <WebCore/TextIndicator.h> 40 #import <WebCore/TranslationContextMenuInfo.h> 40 41 #import <wtf/text/WTFString.h> 41 42 … … 97 98 #if HAVE(TRANSLATION_UI_SERVICES) 98 99 99 void WebContextMenuClient::handleTranslation(const String& text, const IntRect& bounds, const IntPoint& location)100 void WebContextMenuClient::handleTranslation(const WebCore::TranslationContextMenuInfo& info) 100 101 { 101 m_page->send(Messages::WebPageProxy::HandleContextMenuTranslation( text, bounds, location));102 m_page->send(Messages::WebPageProxy::HandleContextMenuTranslation(info)); 102 103 } 103 104 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r277045 r277196 245 245 #include <WebCore/SubstituteData.h> 246 246 #include <WebCore/TextIterator.h> 247 #include <WebCore/TranslationContextMenuInfo.h> 247 248 #include <WebCore/UserContentURLPattern.h> 248 249 #include <WebCore/UserGestureIndicator.h> … … 7572 7573 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 7573 7574 7574 void WebPage::handleContextMenuTranslation(const String& text, const IntRect& boundsInView, const IntPoint& locationInView)7575 { 7576 send(Messages::WebPageProxy::HandleContextMenuTranslation( text, boundsInView, locationInView));7575 void WebPage::handleContextMenuTranslation(const TranslationContextMenuInfo& info) 7576 { 7577 send(Messages::WebPageProxy::HandleContextMenuTranslation(info)); 7577 7578 } 7578 7579 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r277097 r277196 248 248 class HTMLAttachmentElement; 249 249 #endif 250 251 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 252 struct TranslationContextMenuInfo; 253 #endif 250 254 } 251 255 … … 1397 1401 1398 1402 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 1399 void handleContextMenuTranslation(const String& text, const WebCore::IntRect& selectionBoundsInView, const WebCore::IntPoint& menuLocationInView);1403 void handleContextMenuTranslation(const WebCore::TranslationContextMenuInfo&); 1400 1404 #endif 1401 1405 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r276982 r277196 1 2021-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Set the -isSourceEditable property when presenting webpage translation popup 4 https://bugs.webkit.org/show_bug.cgi?id=225515 5 <rdar://problem/77658040> 6 7 Reviewed by Tim Horton. 8 9 See WebCore/ChangeLog for more details. 10 11 * WebCoreSupport/WebContextMenuClient.h: 12 * WebCoreSupport/WebContextMenuClient.mm: 13 (WebContextMenuClient::handleTranslation): 14 * WebView/WebView.mm: 15 (-[WebView _handleContextMenuTranslation:]): 16 (-[WebView _handleContextMenuTranslation:selectionBounds:menuLocation:]): Deleted. 17 * WebView/WebViewInternal.h: 18 1 19 2021-05-04 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.h
r276181 r277196 69 69 70 70 #if HAVE(TRANSLATION_UI_SERVICES) 71 void handleTranslation(const String&, const WebCore::IntRect& selectionBoundsInRootView, const WebCore::IntPoint& locationInRootView) final;71 void handleTranslation(const WebCore::TranslationContextMenuInfo&) final; 72 72 #endif 73 73 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm
r276899 r277196 150 150 #if HAVE(TRANSLATION_UI_SERVICES) 151 151 152 void WebContextMenuClient::handleTranslation(const String& text, const IntRect& selectionBoundsInRootView, const IntPoint& locationInRootView)153 { 154 [m_webView _handleContextMenuTranslation: text selectionBounds:selectionBoundsInRootView menuLocation:locationInRootView];152 void WebContextMenuClient::handleTranslation(const TranslationContextMenuInfo& info) 153 { 154 [m_webView _handleContextMenuTranslation:info]; 155 155 } 156 156 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r276982 r277196 216 216 #import <WebCore/TextResourceDecoder.h> 217 217 #import <WebCore/ThreadCheck.h> 218 #import <WebCore/TranslationContextMenuInfo.h> 218 219 #import <WebCore/UTIRegistry.h> 219 220 #import <WebCore/UserAgent.h> … … 352 353 #if HAVE(TRANSLATION_UI_SERVICES) 353 354 #import <TranslationUIServices/LTUITranslationViewController.h> 355 356 @interface LTUITranslationViewController (Staging_77660675) 357 @property (nonatomic, copy) void(^replacementHandler)(NSAttributedString *); 358 @end 354 359 355 360 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(TranslationUIServices) … … 9639 9644 } 9640 9645 9641 - (void)_handleContextMenuTranslation:(const String&)text selectionBounds:(const WebCore::IntRect&)selectionBoundsInRootView menuLocation:(const WebCore::IntPoint&)locationInRootView9646 - (void)_handleContextMenuTranslation:(const WebCore::TranslationContextMenuInfo&)info 9642 9647 { 9643 9648 if (!WebView._canHandleContextMenuTranslation) { … … 9647 9652 9648 9653 auto translationViewController = adoptNS([allocLTUITranslationViewControllerInstance() init]); 9649 [translationViewController setText:adoptNS([[NSAttributedString alloc] initWithString:text]).get()]; 9650 9651 auto convertedSelectionBounds = [self _convertRectFromRootView:selectionBoundsInRootView]; 9652 auto convertedMenuLocation = [self _convertPointFromRootView:locationInRootView]; 9654 [translationViewController setText:adoptNS([[NSAttributedString alloc] initWithString:info.text]).get()]; 9655 if (info.mode == WebCore::TranslationContextMenuMode::Editable && [translationViewController respondsToSelector:@selector(setReplacementHandler:)]) { 9656 [translationViewController setIsSourceEditable:YES]; 9657 [translationViewController setReplacementHandler:[weakSelf = WeakObjCPtr<WebView>(self)](NSAttributedString *string) { 9658 auto strongSelf = weakSelf.get(); 9659 [strongSelf insertText:string.string]; 9660 }]; 9661 } 9662 9663 auto convertedSelectionBounds = [self _convertRectFromRootView:info.selectionBoundsInRootView]; 9664 auto convertedMenuLocation = [self _convertPointFromRootView:info.locationInRootView]; 9653 9665 9654 9666 auto popover = adoptNS([[NSPopover alloc] init]); -
trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h
r276220 r277196 66 66 struct DictationAlternative; 67 67 struct DictionaryPopupInfo; 68 69 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 70 struct TranslationContextMenuInfo; 71 #endif 68 72 } 69 73 … … 160 164 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS) 161 165 @property (class, nonatomic, readonly) BOOL _canHandleContextMenuTranslation; 162 - (void)_handleContextMenuTranslation:(const String&)text selectionBounds:(const WebCore::IntRect&)boundsInView menuLocation:(const WebCore::IntPoint&)menuLocation;166 - (void)_handleContextMenuTranslation:(const WebCore::TranslationContextMenuInfo&)info; 163 167 #endif 164 168
Note:
See TracChangeset
for help on using the changeset viewer.