<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - charactersAroundPosition can be wrong because it crosses editing boundaries"
   href="https://bugs.webkit.org/show_bug.cgi?id=161215#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - charactersAroundPosition can be wrong because it crosses editing boundaries"
   href="https://bugs.webkit.org/show_bug.cgi?id=161215">bug 161215</a>
              from <span class="vcard"><a class="email" href="mailto:bdakin&#64;apple.com" title="Beth Dakin &lt;bdakin&#64;apple.com&gt;"> <span class="fn">Beth Dakin</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=161215#c4">comment #4</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=287027&amp;action=diff" name="attach_287027" title="Patch">attachment 287027</a> <a href="attachment.cgi?id=287027&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=287027&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=287027&amp;action=review</a>
&gt; 
&gt; It looks like fast/dom/focus-contenteditable.html is failing on WebKit2. 
&gt; Please check that before landing it.
&gt; </span >

I investigated, and this test is going back to its pre-<a href="https://trac.webkit.org/changeset/195078">https://trac.webkit.org/changeset/195078</a> state. That change caused this test to have a different layout because it caused more layouts to happen. Now that we don’t allow the call to charactersAroundPosition() to cross editing boundaries, those layouts don’t happen, and we have the old behavior back.

<span class="quote">&gt; &gt; Source/WebCore/ChangeLog:5
&gt; &gt; +        -and corresponding-
&gt; 
&gt; I don't think we need this line.
&gt; 
&gt; &gt; Source/WebCore/ChangeLog:14
&gt; &gt; +        VisiblePosition::previous().
&gt; &gt; +        * editing/VisibleUnits.cpp:
&gt; 
&gt; We need a blank line here.
&gt; </span >

Added.

<span class="quote">&gt; &gt; LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:3
&gt; &gt; +&lt;script src=../../editing.js language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&gt; 
&gt; We don't need language &amp; type attributes.
&gt; </span >

Removed.

<span class="quote">&gt; &gt; LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:10
&gt; &gt; +    var s = window.getSelection();
&gt; 
&gt; It looks like this variable is never used.
&gt; </span >

Removed.

<span class="quote">&gt; &gt; LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:32
&gt; &gt; +&lt;div style=&quot;visibility:hidden;&quot;&gt;
&gt; &gt; +    &lt;br&gt;
&gt; &gt; +&lt;/div&gt;
&gt; &gt; +
&gt; &gt; +&lt;div style=&quot;width: 1px; height: 1px;&quot;&gt;&lt;/div&gt;
&gt; 
&gt; Do we really need these stray elements?</span >

We do!! These elements are key to reproduce the bug. When charactersAroundPosition can cross editing boundaries, this DOM structure tricks it into thinking that the &lt;br&gt; inside the hidden div is the character before the caret. And when we think a newline is the character before the caret, we don't replace the typed text with the candidate.</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>