I want to create custom menus that function similar to context menus, but are opened via modifier keys rather than right click. The problem is that CEF currently provides no way to query the type of the current DOM element under mouse from the browser process, so there's no way to customize the menus accordingly, nor get information necessary for actions like "Open link in new tab...".
I see three solutions:
1. When the user hits a modifier key, simulate a right click event in order to get information about the DOM element under mouse from a ContextMenuParams object, then suppress the context menu and show a custom menu instead. This has the side effect of stealing focus which would then need to be reset after, but seems like the only thing that could possibly work without setting up custom IPC between the browser and renderer processes.
2. Use JavaScript to set up an event listener for mouseover events, and inside the listener callback, push information about the DOM element to the renderer process, which then gets forwarded to the browser process. Similar to what already happens in the sample project with FocusNodeChanged event. This would have the advantage of the element type being known before the user hits the menu, so there's no delay in determining what menu actions to generate. However, there doesn't seem to be a way to send information from a JavaScript callback to the renderer process directly, so this might not even be possible.
3. Set up an event listener like in 2, but instead of pushing events to the browser process, set some global variable in JavaScript that represents the current element under mouse. Then when a user hits a modifier key, use a CefV8Context in the renderer process to query the global variable to find out its type and any other information needed for the custom menus, then send it to the browser process via IPC.
Are there any better methods, or better ways to execute these methods? I'm not keen on 1 since it's too much like sonar and would interfere with text input. 2 could be ideal but would probably require invasive changes to CEF and even Chromium to work correctly. 3 seems the most viable for now.