<?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>23189</bug_id>
          
          <creation_ts>2009-01-08 10:17:23 -0800</creation_ts>
          <short_desc>Impossible to place caret at the start of a text node</short_desc>
          <delta_ts>2022-07-27 11:31:05 -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>HTML Editing</component>
          <version>525.x (Safari 3.2)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=15256</see_also>
          <bug_file_loc>http://www.timdown.co.uk/testcases/range.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Down">timdown</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>ayg</cc>
    
    <cc>enrica</cc>
    
    <cc>jparent</cc>
    
    <cc>karlcow</cc>
    
    <cc>michael.vm</cc>
    
    <cc>rniwa</cc>
    
    <cc>ted</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>104896</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Down">timdown</who>
    <bug_when>2009-01-08 10:17:23 -0800</bug_when>
    <thetext>In design mode, it is impossible to place the caret at the start of a text node. It is possible to create a collapsed Range at the start of a text node programmatically using JavaScript but if you add that range to the selection, the caret goes to the end of the node immediately prior to the text node, contrary to the behaviour in Firefox and Opera.

For example, for the HTML

	Some text &lt;span&gt;more text&lt;/span&gt;

you create a collapsed Range at the start of &quot;more text&quot; and add that to the selection, in Opera and Firefox you get

	Some text &lt;span&gt;|more text&lt;/span&gt;

as expected, but in WebKit you get

	Some text |&lt;span&gt;more text&lt;/span&gt;

The URL for this bug has a simple test case. Bug #15256 is a special case of this bug and mentions the general case in the comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104898</commentid>
    <comment_count>1</comment_count>
      <attachid>26527</attachid>
    <who name="Tim Down">timdown</who>
    <bug_when>2009-01-08 10:18:24 -0800</bug_when>
    <thetext>Created attachment 26527
Test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>212318</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Down">timdown</who>
    <bug_when>2010-04-14 03:57:39 -0700</bug_when>
    <thetext>Any chance of progress with this and related selection bugs?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>658680</commentid>
    <comment_count>3</comment_count>
    <who name="Ted Rust">ted</who>
    <bug_when>2012-06-27 09:55:47 -0700</bug_when>
    <thetext>I would love a resolution to this bug as well.  We are currently trying to improve the functionality of some non-editable content in a design mode area.  The first problem is if the non-editable content is the first or last element in the design mode element, it&apos;s not technically possible to get the cursor outside of the non-editable node without some DOM Range wizardry.

The second problem is that when you do have an element directly following the non-editable region, there is no way to put the cursor at the beginning of the following node -- it always falls back to the end of the non-editable node.  Similar DOM Range wizardry can magically place the cursor in the right place EXCEPT when that node is a text node and you are in a WebKit browser.

Someone please let me know a decent way to work around this and I will be much relieved.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>658710</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Down">timdown</who>
    <bug_when>2012-06-27 10:54:58 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I would love a resolution to this bug as well.  We are currently trying to improve the functionality of some non-editable content in a design mode area.  The first problem is if the non-editable content is the first or last element in the design mode element, it&apos;s not technically possible to get the cursor outside of the non-editable node without some DOM Range wizardry.
&gt; 
&gt; The second problem is that when you do have an element directly following the non-editable region, there is no way to put the cursor at the beginning of the following node -- it always falls back to the end of the non-editable node.  Similar DOM Range wizardry can magically place the cursor in the right place EXCEPT when that node is a text node and you are in a WebKit browser.
&gt; 
&gt; Someone please let me know a decent way to work around this and I will be much relieved.

It&apos;s far from decent, but you may be able to use the fact that WebKit has a special case for &lt;a&gt; elements and allows the caret to be placed at the start inside an &lt;a&gt; element. Otherwise, you could place a zero-width characters at the start of any text node in which you want to place the caret. This is also obviously deeply non-decent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>658766</commentid>
    <comment_count>5</comment_count>
    <who name="Ted Rust">ted</who>
    <bug_when>2012-06-27 12:04:56 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; It&apos;s far from decent, but you may be able to use the fact that WebKit has a special case for &lt;a&gt; elements and allows the caret to be placed at the start inside an &lt;a&gt; element. Otherwise, you could place a zero-width characters at the start of any text node in which you want to place the caret. This is also obviously deeply non-decent.

Thank you much for the reply.  I was thinking along the same lines as you -- that is, put a zero-width character in the text node first, then place the cursor and clean up the zero-width character at some indeterminate future point.  I am trying to do this on keypress, so I need to place the cursor, let the default action happen and then find some way to remove the zero-width character reliably and consistently.

Again, thanks for the speedy and helpful response.  What a pain this is to work around!!!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886707</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-26 00:03:49 -0700</bug_when>
    <thetext>&lt;rdar://problem/97590553&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886708</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-26 00:05:47 -0700</bug_when>
    <thetext>&lt;rdar://problem/97590632&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887110</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-27 11:31:05 -0700</bug_when>
    <thetext>This and the bug 15256 are basically identical problem.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>26527</attachid>
            <date>2009-01-08 10:18:24 -0800</date>
            <delta_ts>2009-01-08 10:18:24 -0800</delta_ts>
            <desc>Test case</desc>
            <filename>range.html</filename>
            <type>text/html</type>
            <size>1320</size>
            <attacher name="Tim Down">timdown</attacher>
            
              <data encoding="base64">PGh0bWw+DQoJPGhlYWQ+DQoJCTxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4NCgkJCXdp
bmRvdy5vbmxvYWQgPSBmdW5jdGlvbigpIHsNCgkJCQlkb2N1bWVudC5kZXNpZ25Nb2RlID0gIm9u
IjsNCgkJCQl3aW5kb3cuZm9jdXMoKTsNCg0KCQkJCS8vIEVuc3VyZSBjYXJldCBzaG93cyB1cA0K
CQkJCWlmICgoL3NhZmFyaS9pKS50ZXN0KG5hdmlnYXRvci51c2VyQWdlbnQpKSB7DQoJCQkJCWRv
Y3VtZW50LmRvY3VtZW50RWxlbWVudC5mb2N1cygpOyAvLyBTYWZhcmkNCgkJCQl9IGVsc2Ugew0K
CQkJCQl3aW5kb3cuZm9jdXMoKTsgLy8gT3BlcmEuDQoJCQkJfQ0KCQkJCQ0KCQkJCW1vdmVDYXJl
dCgpOw0KCQkJfQ0KCQkJDQoJCQkvLyBUaGlzIGlzIHRoZSBpbnRlcmVzdGluZyBmdW5jdGlvbg0K
CQkJZnVuY3Rpb24gbW92ZUNhcmV0KCkgew0KCQkJCXZhciBtYWluU3BhbiA9IGRvY3VtZW50Lmdl
dEVsZW1lbnRCeUlkKCJtYWluIik7DQoJCQkJDQoJCQkJLy8gQ3JlYXRlIGEgUmFuZ2UgYW5kIG1v
dmUgaXQgdG8gdGhlIHN0YXJ0IG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