<?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>225147</bug_id>
          
          <creation_ts>2021-04-28 03:11:03 -0700</creation_ts>
          <short_desc>[selectors] :focus-visible and contenteditable</short_desc>
          <delta_ts>2024-09-24 16:13:32 -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>CSS</component>
          <version>WebKit 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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>185859</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Manuel Rego Casasnovas">rego</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>agafvv</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1754975</commentid>
    <comment_count>0</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2021-04-28 03:11:03 -0700</bug_when>
    <thetext>This comes from a comment in a different bug:
https://bugs.webkit.org/show_bug.cgi?id=225075#c13

There we were talking about the condition in Element::shouldAlwaysHaveFocusVisibleWhenFocused().
And we were wondering if we should use isRootEditableElement() instead of isContentEditable().

I&apos;m attaching an example like this:
    &lt;style&gt;
      :focus { border: solid thick magenta; }
      :focus-visible { background: cyan; } 
    &lt;/style&gt;
    &lt;div id=&quot;wrapper&quot; contenteditable&gt;
      &lt;div&gt;Inner DIV&lt;/div&gt;
      &lt;div id=&quot;target&quot; tabindex=&quot;0&quot;&gt;Inner DIV with tabindex&lt;/div&gt;
      &lt;div&gt;Another inner DIV&lt;/div&gt;
    &lt;/div&gt;

Here the first time you click in DIV#target, the whole DIV#wrapper is focused. And the whole DIV#wrapper matches :focus-visible.
This time both isRootEditableElement() and isContentEditable() are true, because we&apos;re focusing DIV#wrapper.
The 2nd time we click in DIV#target, only DIV#target is focused, and only DIV#target matches :focus-visible.
Now isRootEditableElement() is false and isContentEditable() is true.

If we change the code to use isRootEditableElement(), then wewon&apos;t match :focus-visible in DIV#target in the 2nd click. So we&apos;ll be editing that element without matching :focus-visible which seems wrong.

Maybe the example should be different, or I&apos;m missing some other combination.

Please Ryosuke share your thoughts. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1754978</commentid>
    <comment_count>1</comment_count>
      <attachid>427250</attachid>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2021-04-28 03:28:48 -0700</bug_when>
    <thetext>Created attachment 427250
Example</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1756884</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-05-05 03:12:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/77549465&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>427250</attachid>
            <date>2021-04-28 03:28:48 -0700</date>
            <delta_ts>2021-04-28 03:28:48 -0700</delta_ts>
            <desc>Example</desc>
            <filename>focus-visible-contenteditable.html</filename>
            <type>text/html</type>
            <size>316</size>
            <attacher name="Manuel Rego Casasnovas">rego</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxzdHlsZT4KICA6Zm9jdXMgewogICAgYm9yZGVyOiBzb2xpZCB0aGlj
ayBtYWdlbnRhOwogIH0KCiAgOmZvY3VzLXZpc2libGUgewogICAgYmFja2dyb3VuZDogY3lhbjsK
ICB9CgogIGRpdiB7CiAgICBwYWRkaW5nOiAxZW07CiAgfQo8L3N0eWxlPgo8ZGl2IGlkPSJ3cmFw
cGVyIiBjb250ZW50ZWRpdGFibGU+CiAgPGRpdj5Jbm5lciBESVY8L2Rpdj4KICA8ZGl2IGlkPSJ0
YXJnZXQiIHRhYmluZGV4PSIwIj5Jbm5lciBESVYgd2l0aCB0YWJpbmRleDwvZGl2PgogIDxkaXY+
QW5vdGhlciBpbm5lciBESVY8L2Rpdj4KPC9kaXY+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>