Changeset 287959 in webkit
- Timestamp:
- Jan 12, 2022 4:00:15 PM (6 months ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/ChromeClient.h (modified) (1 diff)
-
WebCore/page/mac/ServicesOverlayController.mm (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/mac/MenuUtilities.h (modified) (2 diffs)
-
WebKit/Platform/mac/MenuUtilities.mm (modified) (4 diffs)
-
WebKit/UIProcess/PageClient.h (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit/UIProcess/mac/PageClientImplMac.h (modified) (1 diff)
-
WebKit/UIProcess/mac/WebPageProxyMac.mm (modified) (1 diff)
-
WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebKit/WebProcess/WebPage/mac/WebPageMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287954 r287959 1 2022-01-12 Megan Gardner <megan_gardner@apple.com> 2 3 Add to Contact menu item does nothing on mac. 4 https://bugs.webkit.org/show_bug.cgi?id=235154 5 6 Reviewed by Tim Horton. 7 8 Add to Context menu item for telephone numbers did not actually show the contact card. 9 This was because the delgate did not tell the menu where to display the card from, so it just failed. 10 Plumbing that information through fixes the issue. 11 12 * page/ChromeClient.h: 13 (WebCore::ChromeClient::handleTelephoneNumberClick): 14 * page/mac/ServicesOverlayController.mm: 15 (WebCore::ServicesOverlayController::handleClick): 16 1 17 2022-01-12 Wenson Hsieh <wenson_hsieh@apple.com> 2 18 -
trunk/Source/WebCore/page/ChromeClient.h
r287321 r287959 525 525 526 526 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) 527 virtual void handleTelephoneNumberClick(const String&, const IntPoint& ) { }527 virtual void handleTelephoneNumberClick(const String&, const IntPoint&, const IntRect&) { } 528 528 #endif 529 529 -
trunk/Source/WebCore/page/mac/ServicesOverlayController.mm
r286816 r287959 648 648 m_page.chrome().client().handleSelectionServiceClick(CheckedRef(m_page.focusController())->focusedOrMainFrame().selection(), selectedTelephoneNumbers, windowPoint); 649 649 } else if (highlight.type() == DataDetectorHighlight::Type::TelephoneNumber) 650 m_page.chrome().client().handleTelephoneNumberClick(plainText(highlight.range()), windowPoint );650 m_page.chrome().client().handleTelephoneNumberClick(plainText(highlight.range()), windowPoint, frameView->contentsToWindow(CheckedRef(m_page.focusController())->focusedOrMainFrame().editor().firstRectForRange(highlight.range()))); 651 651 } 652 652 -
trunk/Source/WebKit/ChangeLog
r287957 r287959 1 2022-01-12 Megan Gardner <megan_gardner@apple.com> 2 3 Add to Contact menu item does nothing on mac. 4 https://bugs.webkit.org/show_bug.cgi?id=235154 5 rdar://80213097 6 7 Reviewed by Tim Horton. 8 9 Add to Context menu item for telephone numbers did not actually show the contact card. 10 This was because the delgate did not tell the menu where to display the card from, so it just failed. 11 Plumbing that information through fixes the issue. 12 13 * Platform/mac/MenuUtilities.h: 14 * Platform/mac/MenuUtilities.mm: 15 (-[WKEmptyPresenterHighlightDelegate initWithRect:]): 16 (-[WKEmptyPresenterHighlightDelegate revealContext:rectsForItem:]): 17 (-[WKEmptyPresenterHighlightDelegate revealContext:shouldUseDefaultHighlightForItem:]): 18 (WebKit::menuForTelephoneNumber): 19 * UIProcess/PageClient.h: 20 * UIProcess/WebPageProxy.h: 21 * UIProcess/WebPageProxy.messages.in: 22 * UIProcess/mac/PageClientImplMac.h: 23 * UIProcess/mac/WebPageProxyMac.mm: 24 (WebKit::WebPageProxy::showTelephoneNumberMenu): 25 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 26 (WebKit::WebChromeClient::handleTelephoneNumberClick): 27 * WebProcess/WebCoreSupport/WebChromeClient.h: 28 * WebProcess/WebPage/WebPage.h: 29 * WebProcess/WebPage/mac/WebPageMac.mm: 30 (WebKit::WebPage::handleTelephoneNumberClick): 31 1 32 2022-01-12 J Pascoe <j_pascoe@apple.com> 2 33 -
trunk/Source/WebKit/Platform/mac/MenuUtilities.h
r204466 r287959 27 27 #define MenuUtilities_h 28 28 29 #import <WebCore/IntRect.h> 29 30 #import <wtf/text/WTFString.h> 30 31 … … 33 34 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) 34 35 NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber); 35 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber );36 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber, NSView *webView, const WebCore::IntRect&); 36 37 NSString *menuItemTitleForTelephoneNumberGroup(); 37 38 #endif -
trunk/Source/WebKit/Platform/mac/MenuUtilities.mm
r278530 r287959 45 45 46 46 @interface WKEmptyPresenterHighlightDelegate : NSObject <RVPresenterHighlightDelegate> 47 48 - (instancetype)initWithRect:(NSRect)rect; 49 50 @property NSRect rect; 51 47 52 @end 48 53 49 54 @implementation WKEmptyPresenterHighlightDelegate 50 55 56 - (instancetype)initWithRect:(NSRect)rect 57 { 58 if (!(self = [super init])) 59 return nil; 60 61 _rect = rect; 62 return self; 63 } 64 65 51 66 - (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item 52 67 { 53 return @[ ]; 68 return @[ [NSValue valueWithRect:self.rect] ]; 69 } 70 71 - (BOOL)revealContext:(RVPresentingContext *)context shouldUseDefaultHighlightForItem:(RVItem *)item 72 { 73 UNUSED_PARAM(context); 74 UNUSED_PARAM(item); 75 return NO; 54 76 } 55 77 … … 108 130 } 109 131 110 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber )132 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber, NSView *webView, const WebCore::IntRect& rect) 111 133 { 112 134 if (!PAL::isRevealFrameworkAvailable() || !PAL::isRevealCoreFrameworkAvailable()) … … 114 136 115 137 RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]); 116 auto viewForPresenter = adoptNS([[NSView alloc] init]);117 138 auto urlComponents = adoptNS([[NSURLComponents alloc] init]); 118 139 [urlComponents setScheme:@"tel"]; … … 120 141 auto item = adoptNS([PAL::allocRVItemInstance() initWithURL:[urlComponents URL] rangeInContext:NSMakeRange(0, telephoneNumber.length())]); 121 142 auto presenter = adoptNS([PAL::allocRVPresenterInstance() init]); 122 auto delegate = adoptNS([[WKEmptyPresenterHighlightDelegate alloc] init]); 123 auto context = adoptNS([PAL::allocRVPresentingContextInstance() initWithPointerLocationInView:NSZeroPoint inView:viewForPresenter.get() highlightDelegate:delegate.get()]); 143 auto delegate = adoptNS([[WKEmptyPresenterHighlightDelegate alloc] initWithRect:rect]); 144 auto context = adoptNS([PAL::allocRVPresentingContextInstance() initWithPointerLocationInView:NSZeroPoint inView:webView highlightDelegate:delegate.get()]); 145 static char wkRevealDelegateKey; 146 objc_setAssociatedObject(context.get(), &wkRevealDelegateKey, delegate.get(), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 124 147 NSArray *proposedMenuItems = [presenter menuItemsForItem:item.get() documentContext:nil presentingContext:context.get() options:nil]; 125 148 -
trunk/Source/WebKit/UIProcess/PageClient.h
r287163 r287959 433 433 434 434 virtual WebCore::DestinationColorSpace colorSpace() = 0; 435 436 virtual NSView *viewForPresentingRevealPopover() const = 0; 435 437 436 438 virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) = 0; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r287953 r287959 2299 2299 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 2300 2300 #if PLATFORM(MAC) 2301 void showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& );2301 void showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint&, const WebCore::IntRect&); 2302 2302 #endif 2303 2303 #endif -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r287321 r287959 435 435 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 436 436 #if PLATFORM(MAC) 437 ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point )437 ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point, WebCore::IntRect rect) 438 438 #endif 439 439 #endif -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r287163 r287959 230 230 NSView *activeView() const; 231 231 NSWindow *activeWindow() const; 232 NSView *viewForPresentingRevealPopover() const override { return activeView(); } 232 233 233 234 void didStartProvisionalLoadForMainFrame() override; -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r287953 r287959 543 543 544 544 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 545 void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point )546 { 547 RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber );545 void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point, const WebCore::IntRect& rect) 546 { 547 RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber, pageClient().viewForPresentingRevealPopover(), rect); 548 548 pageClient().showPlatformContextMenu(menu.get(), point); 549 549 } -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
r287321 r287959 1319 1319 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) 1320 1320 1321 void WebChromeClient::handleTelephoneNumberClick(const String& number, const IntPoint& point )1322 { 1323 m_page.handleTelephoneNumberClick(number, point );1321 void WebChromeClient::handleTelephoneNumberClick(const String& number, const IntPoint& point, const IntRect& rect) 1322 { 1323 m_page.handleTelephoneNumberClick(number, point, rect); 1324 1324 } 1325 1325 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
r287321 r287959 372 372 373 373 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) 374 void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint& ) final;374 void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&, const WebCore::IntRect&) final; 375 375 #endif 376 376 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r287953 r287959 1196 1196 1197 1197 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION) 1198 void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint& );1198 void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&, const WebCore::IntRect&); 1199 1199 void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&); 1200 1200 void handleImageServiceClick(const WebCore::IntPoint&, WebCore::Image&, bool isEditable, const WebCore::IntRect&, const String& attachmentID); -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r287953 r287959 761 761 762 762 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 763 void WebPage::handleTelephoneNumberClick(const String& number, const IntPoint& point )764 { 765 send(Messages::WebPageProxy::ShowTelephoneNumberMenu(number, point ));763 void WebPage::handleTelephoneNumberClick(const String& number, const IntPoint& point, const IntRect& rect) 764 { 765 send(Messages::WebPageProxy::ShowTelephoneNumberMenu(number, point, rect)); 766 766 } 767 767 #endif
Note: See TracChangeset
for help on using the changeset viewer.