<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 - Spell check not updated if moving with caret by modifying the selection"
   href="https://bugs.webkit.org/show_bug.cgi?id=168779">168779</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Spell check not updated if moving with caret by modifying the selection
          </td>
        </tr>

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

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

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </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>HTML Editing
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tpopela&#64;redhat.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>cgarcia&#64;igalia.com, mcatanzaro&#64;igalia.com, rniwa&#64;webkit.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=302512" name="attach_302512" title="test case">attachment 302512</a> <a href="attachment.cgi?id=302512&amp;action=edit" title="test case">[details]</a></span>
test case

To describe the problem imagine that you are creating an advanced WYSIWYG editor based on contenteditable. You are modifying the DOM directly (as some of the document's execCommand methods are not sufficient for you) and at some point the spell check for the element is lost. The suggested method (until <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/forceSpellCheck">https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/forceSpellCheck</a> is ready and implemented in WebKit) is to move the caret to the beginning of the element and then by modifying the selection, moving the caret to the end of the element (that's what the attached test case is doing) forces the spell check to be renewed. To speak precisely it forced as after the <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Changing selection shouldn't synchronously update editor UI components"
   href="show_bug.cgi?id=129024">bug 129024</a> the spell checking is now done async. Now, if we are moving the caret in a loop then the spell check is scheduled inside Editor::respondToChangedSelection() and we move the caret to the next work, but inside Editor::respondToChangedSelection() the spell check for the current word under caret is skipped as there is an active timer - <a href="https://trac.webkit.org/browser/trunk/Source/WebCore/editing/Editor.cpp?rev=212884#L3303">https://trac.webkit.org/browser/trunk/Source/WebCore/editing/Editor.cpp?rev=212884#L3303</a>.

The question is how is the application supposed to refresh the spell check? In Chromium the test case works as expected. In Firefox they are renewing the spell check automatically (if spellcheck=&quot;true&quot; is presented). The test case works in WebKit if I add a call to Editor::updateEditorUINowIfScheduled() if the timer is active, but that's not a solution as that's basically reverting the <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Changing selection shouldn't synchronously update editor UI components"
   href="show_bug.cgi?id=129024">bug 129024</a>. It also works if I'm moving the caret after 1 ms (set through setTimeout()), but that's not a solution as well.

Ryosuke do you have any idea (as you are the one who introduced that change)?</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>