Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 6e1c1a4. rdar://122433291
REGRESSION (272869@main): Actions for QR codes sometimes fail to show up when long pressing https://bugs.webkit.org/show_bug.cgi?id=268889 rdar://122433291 Reviewed by Megan Gardner. Fix several issues in the dynamically-inserted image analysis menu item codepath below, following the changes in 272869@main; importantly, this allows long-pressing ESIM and EID QR codes to show "Add eSIM" menu items by default in WebKit apps, such as Mail. See below for more details: * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _insertDynamicImageAnalysisContextMenuItemsIfPossible]): 1. Stop looking for the "Look Up" placeholder item. Prior to 272869@main, this hidden item was immediately inserted into the menu if image analysis results were not available upon long press, and only replaced with the final image analysis menu items in the case where the client didn't explicitly remove the Look Up item (`_WKElementActionTypeRevealImage`). However, the "Look Up" item may now be added immediately (in disabled state), which replaces the placeholder item and causes us to return early from `-_insertDynamicImageAnalysisContextMenuItemsIfPossible` due to not having a placeholder to replace, even if there are MRC menu items that need to be added. Fix this by changing the `indexOfPlaceholderItem` to a single boolean flag, always inserting the dynamic items at the end of the menu, and leave out the check for the `.hidden` menu item attribute, so that we'll only withhold the MRC items in the case where the client explicitly removed the "Look Up" item (which matches existing behavior). 2. In a similar vein, it no longer makes sense to key the enablement of "Look Up" / "Copy Subject" off of whether or not the placeholder item exists, since the disabled menu item is already present; as such, we should remove this early return entirely and always enable these disabled items if necessary. 3. Lastly, only attempt to dynamically add the "Show Text" action in the case where "Show Text" wasn't already in the menu, to prevent the "Show Text" action from unnecessarily moving within the menu in the case where OCR finishes quickly for an image with results. Canonical link: https://commits.webkit.org/274222@main Identifier: 272448.534@safari-7618.1.15.10-branch
- Loading branch information