<?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>23474</bug_id>
          
          <creation_ts>2009-01-22 03:53:07 -0800</creation_ts>
          <short_desc>In a designMode document, the cursor can&apos;t be moved after the last BR node if there is no text following it</short_desc>
          <delta_ts>2022-05-12 12:02:23 -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>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>http://marijn.haverbeke.nl/codemirror/jstest.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Marijn Haverbeke">marijnh+webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>almaza24map</cc>
    
    <cc>ap</cc>
    
    <cc>barbiecarrington01</cc>
    
    <cc>brantfordhousecleaning</cc>
    
    <cc>enrica</cc>
    
    <cc>jacobly</cc>
    
    <cc>jen123cruz123</cc>
    
    <cc>jparent</cc>
    
    <cc>lweintraub</cc>
    
    <cc>morrita</cc>
    
    <cc>ojan</cc>
    
    <cc>rniwa</cc>
    
    <cc>rolandsteiner</cc>
    
    <cc>tamuccuser</cc>
    
    <cc>tony</cc>
    
    <cc>wdm</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>106589</commentid>
    <comment_count>0</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2009-01-22 03:53:07 -0800</bug_when>
    <thetext>If an editable document ends in a BR node (with any amount of non-displaying nodes behind it), the cursor behaves as if the line before that BR node is the last line of the document. Other browsers allow one to move the cursor to the blank line at the end.

To reproduce, see the CodeMirror editor, which rebinds the enter key to just insert a BR node and move the cursor after it. On load (see URL) the document ends in a BR, but the cursor can&apos;t be moved to the blank line. When pressing enter, typing something, and then pressing enter again, nothing seems to happen, since the newly inserted BR creates the above situation, and the newly created line is inaccessible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>231045</commentid>
    <comment_count>1</comment_count>
      <attachid>57188</attachid>
    <who name="Jacob Lee">jacobly</who>
    <bug_when>2010-05-26 19:26:19 -0700</bug_when>
    <thetext>Created attachment 57188
Simplified CodeMirror test case

CodeMirror has long since worked around this bug. The workaround causes other problems, though, so it would be much better if the cursor behavior were fixed.

This bug also affects Google Apps Script, the editor for which is CodeMirror.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>231276</commentid>
    <comment_count>2</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2010-05-27 06:51:51 -0700</bug_when>
    <thetext>To be clear, in that test case:
1. Put the cursor after Foo.
2. Hit enter.

A BR gets inserted, but the cursor doesn&apos;t move down. I&apos;m not sure how fixable this is. The problem is that the line after the BR is not rendered because that&apos;s just how HTML rendering works. I don&apos;t think we could add a contentEditable quirk to render that line because it would break other cases. 

IE actually renders the new line in this case, so it doesn&apos;t have this problem.

Weirdly, Firefox does let you put the cursor there, but it doesn&apos;t render the line and it&apos;s in this sort of half-line position. Not sure if that&apos;s more or less broken.

Is it not enough of a workaround for codemirror to always ensure there&apos;s an extra BR at the end of the contentEditable element?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266040</commentid>
    <comment_count>3</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2010-08-18 04:28:37 -0700</bug_when>
    <thetext>&gt; Is it not enough of a workaround for codemirror to always ensure there&apos;s an extra BR at the end of the contentEditable element?

Not really. The state of the DOM tree is treated as the authoritative content of the editor by CodeMirror, and having stray cruft in there would require a lot of work-arounds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266042</commentid>
    <comment_count>4</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2010-08-18 04:39:48 -0700</bug_when>
    <thetext>I should add that BR&apos;s inserted with execCommand(&quot;insertLineBreak&quot;) do not suffer from this problem, though they are not different in any visible way. If someone can hint me at a hack, no matter how dodgy, that would allow me to switch any BR into &apos;non-ignored&apos; mode, that would already be hugely helpful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266182</commentid>
    <comment_count>5</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2010-08-18 10:01:51 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; I should add that BR&apos;s inserted with execCommand(&quot;insertLineBreak&quot;) do not suffer from this problem, though they are not different in any visible way. If someone can hint me at a hack, no matter how dodgy, that would allow me to switch any BR into &apos;non-ignored&apos; mode, that would already be hugely helpful.

execCommand(&quot;insertLineBreak&quot;) inserts two BRs in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304348</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-03 16:36:31 -0700</bug_when>
    <thetext>*** Bug 47806 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306227</commentid>
    <comment_count>7</comment_count>
    <who name="Levi Weintraub">lweintraub</who>
    <bug_when>2010-11-08 11:10:02 -0800</bug_when>
    <thetext>I feel that supporting this would be a hack. Editing is doing the proper thing and inserting the &lt;br&gt; as expected. It&apos;s a conscious layout decision to then collapse that &lt;br&gt;, and changing that layout strategy would cause all sorts of problems. Instead to support this, editing would have to be hacked to treat a single inserted &lt;br&gt; that is otherwise collapsed differently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306266</commentid>
    <comment_count>8</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2010-11-08 12:00:30 -0800</bug_when>
    <thetext>When you say &apos;editing&apos;, do you mean the script that&apos;s initializing designmode, or another webkit component? In the first case, I don&apos;t see how the script can cause the BR to behave differently. In the second case, this bug should not be closed, but moved to the right component. The BR is part of the editable document, and should be treated as such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306278</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-08 12:10:22 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; When you say &apos;editing&apos;, do you mean the script that&apos;s initializing designmode, or another webkit component? In the first case, I don&apos;t see how the script can cause the BR to behave differently. In the second case, this bug should not be closed, but moved to the right component. The BR is part of the editable document, and should be treated as such.

Editing is the WebKit component to which this bug belongs.  I agree with Levi.  In WebKit, we don&apos;t render the very last BR that isn&apos;t followed by any content for compatibility reason regardless of whether we&apos;re in editable region or not.  The correct fix is for the script to insert two BRs at the end.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306306</commentid>
    <comment_count>10</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2010-11-08 13:02:16 -0800</bug_when>
    <thetext>However, no other browser hides this trailing BR, and it&apos;d require weird, webkit-specific code to drop it from the document &apos;as the user sees it&apos;, which, in CodeMirror, is not just the saving/exporting of the content, but also iterating over the lines, keeping an undo history (I recently had to fix two bug related to this magic BR and the undo history) and several other pieces of functionality.

In short, it&apos;s your rendering engine, so you have the last word, but you&apos;re really making things difficult for client code with this behaviour.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306425</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-08 15:57:39 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; However, no other browser hides this trailing BR, and it&apos;d require weird, webkit-specific code to drop it from the document &apos;as the user sees it&apos;, which, in CodeMirror, is not just the saving/exporting of the content, but also iterating over the lines, keeping an undo history (I recently had to fix two bug related to this magic BR and the undo history) and several other pieces of functionality.

Firefox does hide BR.

&gt; In short, it&apos;s your rendering engine, so you have the last word, but you&apos;re really making things difficult for client code with this behaviour.

How about execCommand(&apos;InsertLineBreak&apos;)?  It does the right thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>306629</commentid>
    <comment_count>12</comment_count>
    <who name="Marijn Haverbeke">marijnh+webkit</who>
    <bug_when>2010-11-08 23:35:27 -0800</bug_when>
    <thetext>&gt; Firefox does hide BR.

Nope, FF works as expected, and allows the user to place his caret after the last BR.

&gt; How about execCommand(&apos;InsertLineBreak&apos;)?  It does the right thing.

As I said before, I don&apos;t want to have an extra BR in my DOM.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>57188</attachid>
            <date>2010-05-26 19:26:19 -0700</date>
            <delta_ts>2010-05-26 19:26:19 -0700</delta_ts>
            <desc>Simplified CodeMirror test case</desc>
            <filename>inner.html</filename>
            <type>text/html</type>
            <size>752</size>
            <attacher name="Jacob Lee">jacobly</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUw+CjxodG1sPgogIDxoZWFkPgogICAgPHNjcmlwdD4KCmZ1bmN0aW9uIGlu
c2VydE5ld2xpbmUoKSB7CiAgdmFyIHRvSW5zZXJ0ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgi
QlIiKTsKICB2YXIgc2VsID0gd2luZG93LmdldFNlbGVjdGlvbigpOwogIHZhciByYW5nZSA9IHNl
bC5nZXRSYW5nZUF0KDApOwogIHJhbmdlLmRlbGV0ZUNvbnRlbnRzKCk7CiAgcmFuZ2UuaW5zZXJ0
Tm9kZSh0b0luc2VydCk7CgogIC8vIE1vdmUgdGhlIGN1cnNvciB0byBhZnRlciB0aGUgaW5zZXJ0
ZWQgbm9kZS4KICB2YXIgbmV3UmFuZ2UgPSBkb2N1bWVudC5jcmVhdGVSYW5nZSgpOwogIG5ld1Jh
bmdlLnNlbGVjdE5vZGUodG9JbnNlcnQpOwogIG5ld1JhbmdlLmNvbGxhcHNlKGZhbHNlKTsKICBz
ZWwucmVtb3ZlQWxsUmFuZ2VzKCk7CiAgc2VsLmFkZFJhbmdlKG5ld1JhbmdlKTsKfQoKZnVuY3Rp
b24gZ28oKSB7CiAgZG9jdW1lbnQuYm9keS5hZGRFdmVudExpc3RlbmVyKCdrZXlkb3duJywgZnVu
Y3Rpb24oZXYpIHsKICAgIGlmIChldi5rZXlDb2RlID09IDEzKSB7CiAgICAgIGluc2VydE5ld2xp
bmUoKTsKICAgICAgZXYucHJldmVudERlZmF1bHQoKTsKICAgIH0KICB9LCBmYWxzZSk7Cn0KICAg
IDwvc2NyaXB0PgogIDwvaGVhZD4KICA8Ym9keSBjb250ZW50ZWRpdGFibGU9InRydWUiIG9ubG9h
ZD0iZ28oKSI+CiAgICA8YnI+V3JpdGUgdGhpbmdzIGhlcmUuCiAgICA8YnI+Rm9vLgogIDwvYm9k
eT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>