<?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>198603</bug_id>
          
          <creation_ts>2019-06-06 01:21:52 -0700</creation_ts>
          <short_desc>select all in contenteditable selects only text content</short_desc>
          <delta_ts>2019-06-13 04:49:01 -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>Safari 12</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.14</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></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>k.litwinowicz</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>megan_gardner</cc>
    
    <cc>oq9pscb02</cc>
    
    <cc>rniwa</cc>
    
    <cc>vepomoc</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1542325</commentid>
    <comment_count>0</comment_count>
      <attachid>371479</attachid>
    <who name="">k.litwinowicz</who>
    <bug_when>2019-06-06 01:21:52 -0700</bug_when>
    <thetext>Created attachment 371479
Html to reproduce the issue

Steps to reproduce the problem:
1. Create and open html file with following content, or use attached one:
`&lt;div class=&quot;editor&quot; contenteditable=&quot;true&quot;&gt;&lt;div&gt;foo&lt;/div&gt;&lt;/div&gt;`
2. Focus editable div.
3. Select all, you can either use keystroke, contextmenu or call `document.execCommand( &apos;selectall&apos; )`.
4. Inspect selection ranges in console: `document.getSelection().getRangeAt( 0 )`

What is the expected behavior?
According to https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
&gt; selectAll
&gt; Selects all of the content of the editable region.

Range start/end container is div#editable
startOffset = 0;
endOffset = 1;
`&lt;div class=&quot;editor&quot; contenteditable=&quot;true&quot;&gt;[&lt;div&gt;foo&lt;/div&gt;]&lt;/div&gt;`

What went wrong?
Range start/end container is text node inside nested div
startOffset = 0
endOffset = 1
`&lt;div class=&quot;editor&quot; contenteditable=&quot;true&quot;&gt;&lt;div&gt;{foo}&lt;/div&gt;&lt;/div&gt;`

This is troublesome for users of rich text editors, as copied data doesn&apos;t match to all content of an editable.
Edge and Firefox works as expected.

Same issue in Chrome:
https://bugs.chromium.org/p/chromium/issues/detail?id=931285</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542437</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-06-06 09:33:05 -0700</bug_when>
    <thetext>&lt;rdar://problem/51486602&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542547</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-06-06 13:50:24 -0700</bug_when>
    <thetext>*** Bug 34377 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542549</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-06-06 13:51:08 -0700</bug_when>
    <thetext>This stems from the fact WebKit always canonicalizes the selection end points before doing any editing operations. The bug 15256 is also caused by this behavior.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>371479</attachid>
            <date>2019-06-06 01:21:52 -0700</date>
            <delta_ts>2019-06-06 01:21:52 -0700</delta_ts>
            <desc>Html to reproduce the issue</desc>
            <filename>test (1).html</filename>
            <type>text/html</type>
            <size>182</size>
            <attacher>k.litwinowicz</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+Cgk8bWV0YSBjaGFyc2V0PSJV
VEYtOCI+Cgk8dGl0bGU+VGl0bGU8L3RpdGxlPgo8L2hlYWQ+Cjxib2R5PgoKPGRpdiBpZD0iZWRp
dGFibGUiIGNvbnRlbnRlZGl0YWJsZT0idHJ1ZSI+PGRpdj5Gb288L2Rpdj48L2Rpdj4KCjwvYm9k
eT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>