<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Making the web view first responder makes it scroll up"
   href="https://bugs.webkit.org/show_bug.cgi?id=157474">157474</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Making the web view first responder makes it scroll up
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Safari 9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>OS X 10.11
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>WebKit2
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>marco&#64;barisione.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Calling [aWebView.window makeFirstResponder:aWebView], in some conditions, causes the web view content to scroll up.
This seems to happen if you are making first responder a web view that is already first responder or that was first responder in the same window (without being removed from it before).

There are various ways to reproduce it in Safari (I'm using WebKit compiled by myself matching the version shipped in 10.11.5 DP 4, that is the one for version 601.6.17, but it happens with any 10.11 version I've tried):
1. Open Safari.
2. Go to gmail.com (without clicking the view) and login.
3. Scroll down (without clicking).
4. Open a new tab with the keyboard.
5. Go to the previous tab with the keyboard.
-&gt; The gmail content will have scrolled up.
If you click the view and repeat then the bug won't happen any more.

The other way is:
1. Open Safari.
2. Go to gmail.com and compose a long email (so there's a scroll bar) and make sure you have scrolled the email to the bottom.
3. Go to the URL bar
4. Move the focus back to the web view
-&gt; The email will scroll to the top.

In my app using WebKit I could reproduce it also by switching tab after clicking the view, while in Safari this doesn't happen. We discovered that this doesn't happen in Safari because, when you switch to another tab, the web view in the newly hidden tab gets removed from its super view.

This is a bug related to 10.11 as I cannot reproduce on 10.10.
Moreover, if I run WebKit compiled for 10.10 (setting MAC_OS_X_VERSION_MAJOR=101000) on 10.11, the bug doesn't happen.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>