<?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>311553</bug_id>
          
          <creation_ts>2026-04-06 01:13:18 -0700</creation_ts>
          <short_desc>SVG getStartPositionOfChar/getEndPositionOfChar should not include dominant-baseline shift in returned position</short_desc>
          <delta_ts>2026-04-17 08:08:18 -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>SVG</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=311597</see_also>
    
    <see_also>https://github.com/web-platform-tests/wpt/pull/59318</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>
          
          <blocked>297455</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2197183</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-04-06 01:13:18 -0700</bug_when>
    <thetext>getStartPositionOfChar() and getEndPositionOfChar() return positions that include the dominant-baseline shift baked into the SVG text fragment y-coordinate. Chrome and Firefox return positions without the baseline shift, reflecting the y attribute value rather than the visual rendering position.

The issue is in SVGTextLayoutEngine.cpp where the baseline shift from dominant-baseline is applied to the fragment y-position (line 603: y -= baselineShift) and stored in the fragment (line 635: fragment.y = y). The SVGTextQuery API reads directly from fragment.y, so it returns the shifted position.

The fix is to store the baseline shift separately in SVGTextFragment and apply it only during painting, not in the stored position. This makes the query APIs return the correct unshifted position matching Chrome/Firefox behavior.

  Related: Bug 297455 (dominant-baseline inheritance fix exposes this issue more broadly)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2197184</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-06 01:13:34 -0700</bug_when>
    <thetext>&lt;rdar://problem/174145885&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2197194</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-04-06 02:11:27 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/62106</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2201484</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-17 07:01:45 -0700</bug_when>
    <thetext>Committed 311450@main (48ca57667b1e): &lt;https://commits.webkit.org/311450@main&gt;

Reviewed commits have been landed. Closing PR #62106 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2201511</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-04-17 08:08:18 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/59318</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>