<?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>327412</bug_id>
          
          <creation_ts>2026-10-13 09:21:10 -0700</creation_ts>
          <short_desc>[GTK][WPE] Input method delete-surrounding is documented in characters but counts UTF-16 code units</short_desc>
          <delta_ts>2026-10-19 05:35:21 -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>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=205716</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=326817</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=250208</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=327414</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=327694</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="Fujii Hironori">fujii</assigned_to>
          <cc>alex</cc>
    
    <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>fujii</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2263252</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Pena">spena</who>
    <bug_when>2026-10-13 09:21:10 -0700</bug_when>
    <thetext>The delete-surrounding signal of WebKitInputMethodContext and WPEInputMethodContext documents offset and n_chars as characters. WebPage::deleteSurrounding() counts UTF-16 code units, and has done since the signal was added (bug 205716). The two only differ outside the Basic Multilingual Plane, for example with emoji. With the caret after &quot;a😀&quot;:

- delete-surrounding(-1, 1) deletes nothing: it covers half of the emoji&apos;s surrogate pair.
- delete-surrounding(-2, 2) deletes the emoji.

A delete that would start before the text depends on the code units too: after &quot;a😀&quot;, (-4, 4) deletes nothing; after &quot;aa😀&quot;, it deletes everything.

Two more behaviours are not documented, and input methods rely on them:

- The offset is counted from the start of the selection, and the delete can reach into the selection.
- A count of 0 moves the caret by offset.

Input method code in use counts in different units. wpe-android forwards Android&apos;s counts, which are UTF-16 code units, and we know of at least one other embedder that counts UTF-16 code units. The Wayland text-input-v1 backend converts to code points. The text-input-v3 backend passes bytes (bug 326818).

Proposal: document UTF-16 code units, the selection start and the zero-count caret move. That matches what WebKit does today and changes no behaviour. Then make the Wayland backends convert to UTF-16 code units. Changing the behaviour to code points would break the embedders that count UTF-16 code units.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2265926</commentid>
    <comment_count>1</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2026-10-18 22:38:00 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/77486</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2265982</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-10-19 05:35:17 -0700</bug_when>
    <thetext>Committed 324121@main (c8f1f0f55c5f): &lt;https://commits.webkit.org/324121@main&gt;

Reviewed commits have been landed. Closing PR #77486 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>