Changeset 287959 in webkit


Ignore:
Timestamp:
Jan 12, 2022 4:00:15 PM (6 months ago)
Author:
Megan Gardner
Message:

Add to Contact menu item does nothing on mac.
https://bugs.webkit.org/show_bug.cgi?id=235154
Source/WebCore:

Reviewed by Tim Horton.

Add to Context menu item for telephone numbers did not actually show the contact card.
This was because the delgate did not tell the menu where to display the card from, so it just failed.
Plumbing that information through fixes the issue.

  • page/ChromeClient.h:

(WebCore::ChromeClient::handleTelephoneNumberClick):

  • page/mac/ServicesOverlayController.mm:

(WebCore::ServicesOverlayController::handleClick):

Source/WebKit:

rdar://80213097

Reviewed by Tim Horton.

Add to Context menu item for telephone numbers did not actually show the contact card.
This was because the delgate did not tell the menu where to display the card from, so it just failed.
Plumbing that information through fixes the issue.

  • Platform/mac/MenuUtilities.h:
  • Platform/mac/MenuUtilities.mm:

(-[WKEmptyPresenterHighlightDelegate initWithRect:]):
(-[WKEmptyPresenterHighlightDelegate revealContext:rectsForItem:]):
(-[WKEmptyPresenterHighlightDelegate revealContext:shouldUseDefaultHighlightForItem:]):
(WebKit::menuForTelephoneNumber):

  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/mac/PageClientImplMac.h:
  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::showTelephoneNumberMenu):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::handleTelephoneNumberClick):

  • WebProcess/WebCoreSupport/WebChromeClient.h:
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/mac/WebPageMac.mm:

(WebKit::WebPage::handleTelephoneNumberClick):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287954 r287959  
     12022-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
    1172022-01-12  Wenson Hsieh  <wenson_hsieh@apple.com>
    218
  • trunk/Source/WebCore/page/ChromeClient.h

    r287321 r287959  
    525525
    526526#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&) { }
    528528#endif
    529529
  • trunk/Source/WebCore/page/mac/ServicesOverlayController.mm

    r286816 r287959  
    648648        m_page.chrome().client().handleSelectionServiceClick(CheckedRef(m_page.focusController())->focusedOrMainFrame().selection(), selectedTelephoneNumbers, windowPoint);
    649649    } 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())));
    651651}
    652652
  • trunk/Source/WebKit/ChangeLog

    r287957 r287959  
     12022-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
    1322022-01-12  J Pascoe  <j_pascoe@apple.com>
    233
  • trunk/Source/WebKit/Platform/mac/MenuUtilities.h

    r204466 r287959  
    2727#define MenuUtilities_h
    2828
     29#import <WebCore/IntRect.h>
    2930#import <wtf/text/WTFString.h>
    3031
     
    3334#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
    3435NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber);
    35 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber);
     36RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber, NSView *webView, const WebCore::IntRect&);
    3637NSString *menuItemTitleForTelephoneNumberGroup();
    3738#endif
  • trunk/Source/WebKit/Platform/mac/MenuUtilities.mm

    r278530 r287959  
    4545
    4646@interface WKEmptyPresenterHighlightDelegate : NSObject <RVPresenterHighlightDelegate>
     47
     48- (instancetype)initWithRect:(NSRect)rect;
     49
     50@property NSRect rect;
     51
    4752@end
    4853
    4954@implementation WKEmptyPresenterHighlightDelegate
    5055
     56- (instancetype)initWithRect:(NSRect)rect
     57{
     58    if (!(self = [super init]))
     59        return nil;
     60
     61    _rect = rect;
     62    return self;
     63}
     64
     65
    5166- (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item
    5267{
    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;
    5476}
    5577
     
    108130}
    109131
    110 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber)
     132RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber, NSView *webView, const WebCore::IntRect& rect)
    111133{
    112134    if (!PAL::isRevealFrameworkAvailable() || !PAL::isRevealCoreFrameworkAvailable())
     
    114136
    115137    RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]);
    116     auto viewForPresenter = adoptNS([[NSView alloc] init]);
    117138    auto urlComponents = adoptNS([[NSURLComponents alloc] init]);
    118139    [urlComponents setScheme:@"tel"];
     
    120141    auto item = adoptNS([PAL::allocRVItemInstance() initWithURL:[urlComponents URL] rangeInContext:NSMakeRange(0, telephoneNumber.length())]);
    121142    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);
    124147    NSArray *proposedMenuItems = [presenter menuItemsForItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
    125148   
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r287163 r287959  
    433433
    434434    virtual WebCore::DestinationColorSpace colorSpace() = 0;
     435   
     436    virtual NSView *viewForPresentingRevealPopover() const = 0;
    435437
    436438    virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) = 0;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r287953 r287959  
    22992299#if ENABLE(TELEPHONE_NUMBER_DETECTION)
    23002300#if PLATFORM(MAC)
    2301     void showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint&);
     2301    void showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint&, const WebCore::IntRect&);
    23022302#endif
    23032303#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r287321 r287959  
    435435#if ENABLE(TELEPHONE_NUMBER_DETECTION)
    436436#if PLATFORM(MAC)
    437     ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point)
     437    ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point, WebCore::IntRect rect)
    438438#endif
    439439#endif
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r287163 r287959  
    230230    NSView *activeView() const;
    231231    NSWindow *activeWindow() const;
     232    NSView *viewForPresentingRevealPopover() const override { return activeView(); }
    232233
    233234    void didStartProvisionalLoadForMainFrame() override;
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r287953 r287959  
    543543
    544544#if ENABLE(TELEPHONE_NUMBER_DETECTION)
    545 void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point)
    546 {
    547     RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber);
     545void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point, const WebCore::IntRect& rect)
     546{
     547    RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber, pageClient().viewForPresentingRevealPopover(), rect);
    548548    pageClient().showPlatformContextMenu(menu.get(), point);
    549549}
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r287321 r287959  
    13191319#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
    13201320
    1321 void WebChromeClient::handleTelephoneNumberClick(const String& number, const IntPoint& point)
    1322 {
    1323     m_page.handleTelephoneNumberClick(number, point);
     1321void WebChromeClient::handleTelephoneNumberClick(const String& number, const IntPoint& point, const IntRect& rect)
     1322{
     1323    m_page.handleTelephoneNumberClick(number, point, rect);
    13241324}
    13251325
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r287321 r287959  
    372372
    373373#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;
    375375#endif
    376376
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r287953 r287959  
    11961196   
    11971197#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&);
    11991199    void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
    12001200    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  
    761761
    762762#if ENABLE(TELEPHONE_NUMBER_DETECTION)
    763 void WebPage::handleTelephoneNumberClick(const String& number, const IntPoint& point)
    764 {
    765     send(Messages::WebPageProxy::ShowTelephoneNumberMenu(number, point));
     763void WebPage::handleTelephoneNumberClick(const String& number, const IntPoint& point, const IntRect& rect)
     764{
     765    send(Messages::WebPageProxy::ShowTelephoneNumberMenu(number, point, rect));
    766766}
    767767#endif
Note: See TracChangeset for help on using the changeset viewer.