<?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>271694</bug_id>
          
          <creation_ts>2024-03-26 00:07:07 -0700</creation_ts>
          <short_desc>MouseEvent offsetX and offsetY should be relative to padding edge</short_desc>
          <delta_ts>2026-01-12 11:06:58 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>UI Events</component>
          <version>Other</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=218117</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jonathan Heathcote">mail</reporter>
          <assigned_to name="Ahmad Saleem">ahmad.saleem792</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>karlcow</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2023862</commentid>
    <comment_count>0</comment_count>
      <attachid>470601</attachid>
    <who name="Jonathan Heathcote">mail</who>
    <bug_when>2024-03-26 00:07:07 -0700</bug_when>
    <thetext>Created attachment 470601
Demo showing mouse offset coordinates from MouseMove on an element with a thick border.

Observed in Epiphany 45.3 on Arch Linux.

MouseEvent events include offsetX and offsetY values which should be relative to the border box of the event target (see spec: https://drafts.csswg.org/cssom-view/#dom-mouseevent-offsetx). In WebKit, however, offsetX/Y coordinates appear to be relative to the border box.

The attached demo page shows the clientX/Y values when the mouse is moved over a div. When moving the mouse over the thick black border, negative values should be shown (see Firefox and Chromium for correct examples) however positive values are shown instead in WebKit.

NB: this appears to be similar (but different) to bug #218117 (MouseEvent.offsetX/Y returns wrong value for inline elements) since this issue relates to block elements and it seems coordinates come relative to the border box, not the padding box.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2023935</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2024-03-26 08:51:33 -0700</bug_when>
    <thetext>Reproduces in Safari too</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2025319</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-04-02 00:08:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/125763807&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2025649</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-03 03:49:51 -0700</bug_when>
    <thetext>Our implementation:

https://searchfox.org/wubkat/rev/2f857be7d42f00feb7b59870709310154181a774/Source/WebCore/dom/MouseRelatedEvent.cpp#183

Blink:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/events/mouse_event.cc;l=452;drc=2827c7359e94610318802bff2cd4e4d8256cd215</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2170504</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-01-08 18:19:09 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/56304</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2171244</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-01-12 11:06:55 -0800</bug_when>
    <thetext>Committed 305479@main (2a4ece3e4b02): &lt;https://commits.webkit.org/305479@main&gt;

Reviewed commits have been landed. Closing PR #56304 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>470601</attachid>
            <date>2024-03-26 00:07:07 -0700</date>
            <delta_ts>2024-03-26 00:07:07 -0700</delta_ts>
            <desc>Demo showing mouse offset coordinates from MouseMove on an element with a thick border.</desc>
            <filename>demo.html</filename>
            <type>text/html</type>
            <size>325</size>
            <attacher name="Jonathan Heathcote">mail</attacher>
            
              <data encoding="base64">PHN0eWxlPgogICN0YXJnZXQgewogICAgd2lkdGg6IDMwMHB4OwogICAgaGVpZ2h0OiAzMDBweDsK
ICAgIAogICAgYm9yZGVyOiAyMHB4IHNvbGlkIGJsYWNrOwogICAgbWFyZ2luOiA0MHB4OwogICAg
cGFkZGluZzogNDBweDsKICB9Cjwvc3R5bGU+Cgo8ZGl2IGlkPSJ0YXJnZXQiPjwvZGl2PgoKPHNj
cmlwdD4KICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgidGFyZ2V0IikuYWRkRXZlbnRMaXN0ZW5l
cigibW91c2Vtb3ZlIiwgZXZ0ID0+IHsKICAgIHRhcmdldC5pbm5lclRleHQgPSBgJHtldnQub2Zm
c2V0WH0sICR7ZXZ0Lm9mZnNldFl9YDsKICB9KTsKPC9zY3JpcHQ+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>