<?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>61310</bug_id>
          
          <creation_ts>2011-05-23 14:34:37 -0700</creation_ts>
          <short_desc>keypress doesn&apos;t fire for the first key down event when contenteditable is set by an event handler</short_desc>
          <delta_ts>2011-06-10 21:29:55 -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>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>38696</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cshu</cc>
    
    <cc>darin</cc>
    
    <cc>enrica</cc>
    
    <cc>leviw</cc>
    
    <cc>morrita</cc>
    
    <cc>swivelgames</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>408309</commentid>
    <comment_count>0</comment_count>
      <attachid>94490</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-23 14:34:37 -0700</bug_when>
    <thetext>Created attachment 94490
demo

When contenteditable is set true in an event handler of click event, the first key down does not fire keypress event in the editable root.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408337</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-23 14:54:34 -0700</bug_when>
    <thetext>Mn... it seems like the problem isn&apos;t really that WebKit not firing keypress event but rather that WebKit renderers caret in the editable region even though it doesn&apos;t have a focus.

On Firefox 3.6 and Internet Explorer 9, focus is never set on the editable element and the caret is never drawn.  Only when the user clicks for the second time, they start rendering caret.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408396</commentid>
    <comment_count>2</comment_count>
      <attachid>94504</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-23 15:32:57 -0700</bug_when>
    <thetext>Created attachment 94504
work in progress

This work-in-progress patch will make WebKit not to render a caret inside an editable region if it&apos;s not focused.  But I&apos;m not sure if this is what a user would expect because the editable element is focused when a user modifies selection by pressing arrow keys or other means.  This is glitch caused by https://bugs.webkit.org/show_bug.cgi?id=38696.

Any opinions / suggestions as to what to do here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408400</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-05-23 15:38:33 -0700</bug_when>
    <thetext>I do not have a suggestion, but I have an edge case to consider.

When conteneditable is set on body (or presumably when designMode is on), the body does not get a focus highlight, but is of course editable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408596</commentid>
    <comment_count>4</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-05-23 20:27:02 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Created an attachment (id=94504) [details]
&gt; work in progress
&gt; 
&gt; This work-in-progress patch will make WebKit not to render a caret inside an editable region if it&apos;s not focused.  But I&apos;m not sure if this is what a user would expect because the editable element is focused when a user modifies selection by pressing arrow keys or other means.  This is glitch caused by https://bugs.webkit.org/show_bug.cgi?id=38696.
&gt; 
&gt; Any opinions / suggestions as to what to do here?
According to the demo, we can input the first character even if we don&apos;t render the caret.
Is that right? If so, it&apos;s strange for me, even if your wip change itself makes sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408597</commentid>
    <comment_count>5</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-05-23 20:28:03 -0700</bug_when>
    <thetext>&gt; According to the demo, we can input the first character even if we don&apos;t render the caret.
&gt; Is that right? If so, it&apos;s strange for me, even if your wip change itself makes sense.
I noticed that is another bug which is filed as Bug 38696.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408601</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-23 20:33:14 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #2)
&gt; &gt; Any opinions / suggestions as to what to do here?
&gt; According to the demo, we can input the first character even if we don&apos;t render the caret.
&gt; Is that right? If so, it&apos;s strange for me, even if your wip change itself makes sense.

I agree.  It&apos;s definitely a strange behavior. Maybe this bug needs to be blocked by the bug 38696.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408808</commentid>
    <comment_count>7</comment_count>
    <who name="Chang Shu">cshu</who>
    <bug_when>2011-05-24 06:27:05 -0700</bug_when>
    <thetext>&gt; &gt; According to the demo, we can input the first character even if we don&apos;t render the caret.
&gt; &gt; Is that right? If so, it&apos;s strange for me, even if your wip change itself makes sense.
&gt; 
&gt; I agree.  It&apos;s definitely a strange behavior. Maybe this bug needs to be blocked by the bug 38696.

It seems we observed two issues and we do have two patches now. :) It will be good to test the build with both patches.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408960</commentid>
    <comment_count>8</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2011-05-24 10:17:05 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; It seems we observed two issues and we do have two patches now. :) It will be good to test the build with both patches.

I&apos;m slightly confused. Does the patch from 38696 fix this on its own?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408978</commentid>
    <comment_count>9</comment_count>
    <who name="Chang Shu">cshu</who>
    <bug_when>2011-05-24 10:34:33 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #7)
&gt; &gt; It seems we observed two issues and we do have two patches now. :) It will be good to test the build with both patches.
&gt; 
&gt; I&apos;m slightly confused. Does the patch from 38696 fix this on its own?

You are the author of 38696 patch and you must have the build. Can you quickly test the link above and tell us the result? :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408992</commentid>
    <comment_count>10</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2011-05-24 10:56:00 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; You are the author of 38696 patch and you must have the build. Can you quickly test the link above and tell us the result? :)

Now I understand the problem, and agree that this should be dependent upon 38696, but these patches are complimentary. With the fix in 38696, you are unable to enter a character into the newly-editable field with just one click, but the caret is still rendered.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408993</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-24 10:58:28 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #7)
&gt; &gt; It seems we observed two issues and we do have two patches now. :) It will be good to test the build with both patches.
&gt; 
&gt; I&apos;m slightly confused. Does the patch from 38696 fix this on its own?

No.  It&apos;s just that your patch would make WebKit&apos;s behavior more reasonable.  This patch stops WebKit&apos;s rendering of caret in a contenteditable element with a selection when the element doesn&apos;t have a focus.  However, due to the bug 38696, a user can still type text in the element (because focus is automatically moved to the element) and the element will be focused.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>408995</commentid>
    <comment_count>12</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-05-24 11:00:22 -0700</bug_when>
    <thetext>http://crbug.com/81783.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419149</commentid>
    <comment_count>13</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-06-10 21:29:55 -0700</bug_when>
    <thetext>*** Bug 62388 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>94490</attachid>
            <date>2011-05-23 14:34:37 -0700</date>
            <delta_ts>2011-05-23 14:34:37 -0700</delta_ts>
            <desc>demo</desc>
            <filename>editable.html</filename>
            <type>text/html</type>
            <size>159</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPGRpdiBvbmNsaWNrPSJ0aGlzLnNldEF0dHJp
YnV0ZSgnY29udGVudGVkaXRhYmxlJywgJ3RydWUnKSIgb25rZXlwcmVzcz0iYWxlcnQoJ1BBU1Mn
KSI+Y2xpY2sgYW5kIHR5cGUgaGVyZTwvZGl2Pgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>94504</attachid>
            <date>2011-05-23 15:32:57 -0700</date>
            <delta_ts>2011-05-23 15:32:57 -0700</delta_ts>
            <desc>work in progress</desc>
            <filename>wip61310</filename>
            <type>text/plain</type>
            <size>3303</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL2VkaXRpbmcvRnJhbWVTZWxlY3Rpb24uY3BwCj09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT0KLS0tIFNvdXJjZS9XZWJDb3JlL2VkaXRpbmcvRnJhbWVTZWxlY3Rpb24uY3BwCShyZXZpc2lv
biA4NzA5NikKKysrIFNvdXJjZS9XZWJDb3JlL2VkaXRpbmcvRnJhbWVTZWxlY3Rpb24uY3BwCSh3
b3JraW5nIGNvcHkpCkBAIC0xMjE0LDE5ICsxMjE0LDIzIEBACiAgICAgaWYgKFJlbmRlclZpZXcq
IHZpZXcgPSB0b1JlbmRlclZpZXcobV9mcmFtZS0+ZG9jdW1lb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XNpb24gODcwOTYpCisrKyBTb3VyY2UvV2ViQ29yZS9lZGl0aW5nL0ZyYW1lU2VsZWN0aW9u
LmgJKHdvcmtpbmcgY29weSkKQEAgLTYwLDcgKzYwLDcgQEAKICAgICBib29sIHVwZGF0ZUNhcmV0
UmVjdChEb2N1bWVudCosIGNvbnN0IFZpc2libGVQb3NpdGlvbiYgY2FyZXRQb3NpdGlvbik7CiAg
ICAgSW50UmVjdCBhYnNvbHV0ZUJvdW5kc0ZvckxvY2FsUmVjdChOb2RlKiwgY29uc3QgSW50UmVj
dCYpIGNvbnN0OwogICAgIEludFJlY3QgY2FyZXRSZXBhaW50UmVjdChOb2RlKikgY29uc3Q7Ci0g
ICAgYm9vbCBzaG91bGRSZXBhaW50Q2FyZXQoY29uc3QgUmVuZGVyVmlldyosIGJvb2wgaXNDb250
ZW50RWRpdGFibGUpIGNvbnN0OworICAgIGJvb2wgc2hvdWxkUmVwYWludENhcmV0KGNvbnN0IEZy
YW1lKiwgTm9kZSogbm9kZSkgY29uc3Q7CiAgICAgdm9pZCBwYWludENhcmV0KE5vZGUqLCBHcmFw
aGljc0NvbnRleHQqLCBpbnQgdHgsIGludCB0eSwgY29uc3QgSW50UmVjdCYgY2xpcFJlY3QpIGNv
bnN0OwogICAgIFJlbmRlck9iamVjdCogY2FyZXRSZW5kZXJlcihOb2RlKikgY29uc3Q7CiAK
</data>

          </attachment>
      

    </bug>

</bugzilla>