Copied from b/78631924
==================================================================
adjustSelectionByCharacterOffset() from Java side reached renderer FrameInputHandlerImpl::AdjustSelectionBytCharacterOffset(), Blink WebLocalFrameImpl::SelectRange() successfully updated the selection range based on Smart Selection's suggestion, and then we are trying to trigger the selection menu.
In EventHandler::ShowNonLocatedContextMenu() we got the left selection bound's middle point as the new point for MouseEvent, so far so good, but when we call ContextMenuController#ShowContextMenu(), we did another hit test to get node according to the MouseEvent location. We got a wrong node because this Email content used a weird "zoom: 0.584615;" CSS property, which probably introduced a rounding error, so the "Hotel Address" <td> tag overlaps "2720 W. Valley Blvd" <td> tag a little bit, so we got the "Hotel Address" <td> element. Since this node is not the correct one, so it has no selection, if it's a non-editable mode and there is no selection, we don't need to show selection menu. So in the end, the Java side showSelectionMenu() isn't called.
For this specific issue, I think it should be won't fix from WebView/Chrome side, since zoom CSS property is a non-standard [1], not sure if Gmail or the original sender added it, but the usage of zoom should be remove/replaced.
However this bug raised a question about our current implementation of Smart Selection. We probably want to avoid the second hit test and get the current selection directly, after that we trigger showSelectionMenu(). Imagine that we have two divs, one overlaps the other, but the content of the div below the other will trigger selection expansion according to Smart Selection, so we will have the same issue in the end. See my attached HTML file and a video to illustrate this problem.
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/zoom
|
Deleted:
no-selection-menu.mp4
911 KB
|
|
Deleted:
test2.html
263 bytes
|
Comment 1 by bugdroid1@chromium.org
, May 8 2018