<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>326817</bug_id>
          
          <creation_ts>2026-10-08 07:37:57 -0700</creation_ts>
          <short_desc>[WPE] Wayland text-input-v1 pre-edit cursor and styling offsets are bytes, but are used as characters</short_desc>
          <delta_ts>2026-10-13 09:22:19 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WPE WebKit</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=326573</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=326818</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=327412</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Pena">spena</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2260719</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Pena">spena</who>
    <bug_when>2026-10-08 07:37:57 -0700</bug_when>
    <thetext>The text-input-v1 preedit_cursor event gives the cursor position in bytes from the start of the pre-edit text, and a negative index means no cursor is shown. The preedit_styling event gives index and length in bytes too. WPEInputMethodContextWaylandV1 passes them on unchanged, as the pre-edit cursor offset and as underline ranges, which are both counted in characters.

With text that is not ASCII, the cursor position and the underlines are wrong. A negative cursor index becomes a very large unsigned offset; it only ends up at the end of the pre-edit because WebKit clamps it there.

The styling events arrive before the preedit_string event they apply to, so the conversion has to happen once the text is known, in get_preedit_string.

Found by reading the code and the protocol; not reproduced yet. Bug 326573 is the same problem in text-input-v3 (which was reproduced)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>