Webkit sometimes store the UA shadow DOM of <input> element as previously focused elements, which fails focus restoration if input changes type. There should be a common method to get the "exposed" focused element, and it should be used to store the previously focused element. It should also be used here as well (in FrameView.cpp): https://github.com/WebKit/WebKit/commit/a728674047d7d348157d6e313ddcb9d9662c48c5 (the issue was that the code was trying to get the scroll margin of the UA shadow DOM instead of the input itself)
<rdar://problem/105855994>