It is annoying that sometimes when you paste content into Microsoft Visio that WebKit sometimes zooms and scrolls.
Steps to reproduce:
The following assume you have a hardware keyboard attached and you have some content on the clipboard.
1. Visit <http://portal.office.com> and sign in.
2. Open Visio and create a new document.
3. Drag and drop a shape to the document.
4. Press the Return key to edit the label for the shape.
5. Press Command + V to paste.
Then WebKit will zoom and scroll the page such that the caret is aligned to the right edge of the page before the scrollbar. (Note if you have trouble reproducing then try changing Visio's zoom Control + + or Control + -. You can also try to do that in combination with moving the shape to be closer to the edge of the Visio document).
The expected result is that no zooming or scrolling occur on paste.
Created attachment 363934 [details]
Comment on attachment 363934 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=363934&action=review
> + isProgrammaticRefocus = !m_userIsInteracting && m_keyboardIsAttached;
I haven't considered this approach thoroughly yet, but here's a quick comment...
isProgrammaticRefocus seems like a strange name for this variable. The fact that it's always false on non-iOS platforms would imply that it's not possible to programmatically refocus an element there (which is not true!) It's also unclear to me why m_keyboardIsAttached would matter here — an element can always be programmatically focused after it already has focus, regardless of whether or not a hardware keyboard is attached. The difference seems to be whether or not programmatic focus is allowed to bring up the input view.
Is this really about whether or not programmatic focus causes the input view to be shown by default?
Don’t let the name get to you because I don’t like it too and need to think some
more about this code to figure out a) whether this approach is correct b) where the code should live (originally the whole focus due to user interaction was in WebPageIOS and and c) what the name of the variable and existing variables should be called
This bug also happens on Mac when you paste or paste with matching style. Need to try with Chrome/Firefox/Edge.