<?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>240834</bug_id>
          
          <creation_ts>2022-05-23 15:38:37 -0700</creation_ts>
          <short_desc>Confusing inconsistencies when programmatically applying edit commands to `display:none` elements</short_desc>
          <delta_ts>2022-05-24 10:30:16 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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 name="Tim Horton">thorton</reporter>
          <assigned_to name="Tim Horton">thorton</assigned_to>
          <cc>ap</cc>
    
    <cc>koivisto</cc>
    
    <cc>ntim</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1871328</commentid>
    <comment_count>0</comment_count>
      <attachid>459689</attachid>
    <who name="Tim Horton">thorton</who>
    <bug_when>2022-05-23 15:38:37 -0700</bug_when>
    <thetext>Created attachment 459689
repro case

See attached test case. WebKit has an odd behavior where if you try to `insertText` into a contenteditable display:none element, it rejects the editing command, but if you try to do the same into a *child* of the contenteditable display:none element, it works.

*Also* interestingly, while the other browser engines behave internally consistently, they do not agree about the correct behavior:

Blink rejects the editing command in both cases.
Gecko allows the editing command in both cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871329</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2022-05-23 15:40:31 -0700</bug_when>
    <thetext>I believe the root of the inconsistency in WebKit is the `display: none` check in computeEditabilityFromComputedStyle, which only checks the style of the immediate starting node, not whether or not you&apos;re in a `display: none` subtree.

However, I&apos;m not sure which of the more-consistent behaviors to align us with :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871351</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2022-05-23 16:53:02 -0700</bug_when>
    <thetext>I *think* that Antti introduced this in https://trac.webkit.org/changeset/160966/webkit</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871356</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2022-05-23 17:14:16 -0700</bug_when>
    <thetext>https://bugs.webkit.org/show_bug.cgi?id=133371 suggests that display:none things should be editable.

Humorously, while https://trac.webkit.org/changeset/160966/webkit progressed bug 133371 in the case where you&apos;re querying isContentEditable on a child of the display:hidden element, it still says NO if you query *exactly* the display:hidden element.

Also, both Chrome and Firefox say isContentEditable=true for all elements (the direct display:none element and the children). I believe that the fact that Chrome doesn&apos;t allow editing in my original test case does not have to do with editability, but rather with selection behavior in display:none, so not necessarily related to this bug.

All of this together, plus the fact that changing this only affects a single test, makes me think that aligning on the Firefox behavior is the way to go. I&apos;m going to prepare a patch to do so. Please shout if you disagree!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871360</commentid>
    <comment_count>4</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-05-23 17:25:43 -0700</bug_when>
    <thetext>display:none shouldn&apos;t affect the result of isContentEditable but I don&apos;t think the rest of editing code can deal with the display:none content. If there aren&apos;t any editing tests that rely on this, then either approach sounds okay for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871407</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2022-05-23 21:02:42 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/964</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871528</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-05-24 10:29:42 -0700</bug_when>
    <thetext>Committed r294753 (250921@main): &lt;https://commits.webkit.org/250921@main&gt;

Reviewed commits have been landed. Closing PR #964 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871529</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-05-24 10:30:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/93843189&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>459689</attachid>
            <date>2022-05-23 15:38:37 -0700</date>
            <delta_ts>2022-05-23 15:38:37 -0700</delta_ts>
            <desc>repro case</desc>
            <filename>span.html</filename>
            <type>text/html</type>
            <size>687</size>
            <attacher name="Tim Horton">thorton</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUw+CjxodG1sPgo8c3R5bGU+CnAgeyBkaXNwbGF5OiBpbmxpbmUtYmxvY2s7
IH0KPC9zdHlsZT4KPGJvZHk+CiAgICBFZGl0aW5nIHdhcyA8cCBjb250ZW50ZWRpdGFibGUgaWQ9
InRhcmdldEEiPnJlamVjdGVkPC9wPiAoZGlyZWN0IGRpc3BsYXk6bm9uZSk8YnIvPgogICAgPHAg
Y29udGVudGVkaXRhYmxlIGlkPSJ0YXJnZXRCIj5FZGl0aW5nIHdhcyA8c3BhbiBpZD0icmVwbGFj
ZW1lbnRCIj5yZWplY3RlZDwvc3Bhbj4uPC9wPiAocGFyZW50IGRpc3BsYXk6bm9uZSkKPHNjcmlw
dD4KZnVuY3Rpb24gdHJ5VG9FZGl0KHRhcmdldCwgcmVwbGFjZW1lbnQpIHsKICAgIHZhciB0YXJn
ZXQgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCh0YXJnZXQpOwogICAgZG9jdW1lbnQuZ2V0U2Vs
ZWN0aW9uKCkuc2VsZWN0QWxsQ2hpbGRyZW4oZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQocmVwbGFj
ZW1lbnQpKTsKICAgIHRhcmdldC5zdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgZG9jdW1lbnQu
ZXhlY0NvbW1hbmQoImluc2VydFRleHQiLCBmYWxzZSwgImFsbG93ZWQiKTsKICAgIHRhcmdldC5z
dHlsZS5kaXNwbGF5ID0gIiI7Cn0KdHJ5VG9FZGl0KCJ0YXJnZXRBIiwgInRhcmdldEEiKTsKdHJ5
VG9FZGl0KCJ0YXJnZXRCIiwgInJlcGxhY2VtZW50QiIpOwo8L3NjcmlwdD4KPC9ib2R5Pgo8L2h0
bWw+
</data>

          </attachment>
      

    </bug>

</bugzilla>