<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - For keyboard users, activating a fragment URL should transfer focus and caret to the destination"
   href="https://bugs.webkit.org/show_bug.cgi?id=116046#c33">Comment # 33</a>
              on <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - For keyboard users, activating a fragment URL should transfer focus and caret to the destination"
   href="https://bugs.webkit.org/show_bug.cgi?id=116046">bug 116046</a>
              from <span class="vcard"><a class="email" href="mailto:n_wang&#64;apple.com" title="Nan Wang &lt;n_wang&#64;apple.com&gt;"> <span class="fn">Nan Wang</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=276287&amp;action=diff" name="attach_276287" title="patch">attachment 276287</a> <a href="attachment.cgi?id=276287&amp;action=edit" title="patch">[details]</a></span>
patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=276287&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=276287&amp;action=review</a>

<span class="quote">&gt;&gt; Source/WebCore/dom/Document.cpp:3969
&gt;&gt; +        Node* nextNode = NodeTraversal::nextSkippingChildren(*node);
&gt; 
&gt; Why are we calling nextSkippingChildren here given we're moving to the container node in nodeChildrenWillBeRemoved already?</span >

Because in nodeWillBeRemoved we are moving to the previousSibling if possible. I think running ElementTraversal::previous on  nextSkippingChildren will cover both cases.
I just found a bug with this in such case: &lt;div id=&quot;container&quot;&gt;&lt;input id=&quot;removed&quot;&gt;&lt;input&gt;&lt;input&gt;&lt;/div&gt;
After removing first input, next focused element will be the last input but we want the second one. I think we should use next instead of nextSkippingChildren.

<span class="quote">&gt;&gt; Source/WebCore/dom/Document.cpp:4101
&gt;&gt; +        if (m_focusNavigationStartingNode.get() == nodeToBeRemoved) {
&gt; 
&gt; This is a very inefficient way of checking that m_focusNavigationStartingNode is getting removed.
&gt; Instead, just check &quot;m_focusNavigationStartingNode &amp;&amp; m_focusNavigationStartingNode-&gt;parentNode() == this&quot;.
&gt; Also, this code has a bug that it doesn't check the possibility that an ancestor of m_focusNavigationStartingNode is getting removed.
&gt; e.g. m_focusNavigationStartingNode is at the span in &lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt; and div is getting removed.
&gt; So we need to walk up the ancestor chain of m_focusNavigationStartingNode and check whether any of it matches this.
&gt; r- because of this bug.
&gt; Also, please add a test case for this.</span >

Good point, will handle this case.</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>