Bug 210462 - Web Inspector: WI.ContextMenu.createFromEvent doesn't work with keydown event
Summary: Web Inspector: WI.ContextMenu.createFromEvent doesn't work with keydown event
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-13 15:34 PDT by Nikita Vasilyev
Modified: 2020-04-13 15:34 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2020-04-13 15:34:34 PDT
Here is one instance where it's needed: bug 210447: Web Inspector: AXI: tabs should be focusable when navigating by pressing Tab.

Currently, InspectorFrontendHost::dispatchEventAsContextMenuEvent only takes mouse events.

WebCore/inspector/InspectorFrontendHost.cpp:

```
void InspectorFrontendHost::dispatchEventAsContextMenuEvent(Event& event)
{
#if ENABLE(CONTEXT_MENUS) && USE(ACCESSIBILITY_CONTEXT_MENUS)
    if (!is<MouseEvent>(event))
        return;

    auto& mouseEvent = downcast<MouseEvent>(event);
    auto& frame = *downcast<Node>(mouseEvent.target())->document().frame();
    m_frontendPage->contextMenuController().showContextMenuAt(frame, roundedIntPoint(mouseEvent.absoluteLocation()));
    ...
```

Quick search for `absoluteLocation` showed me WebCore/dom/MouseRelatedEvent.h:

    // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
    // usable with RenderObject::absoluteToLocal).
    const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }

Keyboard events currently don't have this method.

---

It would be more future-proof to have a method to show context menu for given x and y coordinates instead of the mouse event.