<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23854</bug_id>
          
          <creation_ts>2013-11-19 00:11:37 +0000</creation_ts>
          <short_desc>Please remove *:focus rule from html.css</short_desc>
          <delta_ts>2014-04-09 22:09:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#phrasing-content-1</bug_file_loc>
          <status_whiteboard>blocked awaiting further details from Elliott Sprehn (please remove this when replying)</status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>eric</cc>
    
    <cc>esprehn</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96481</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-11-19 00:11:37 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#phrasing-content-1
Complete: http://www.whatwg.org/c#phrasing-content-1
Referrer: 

Comment:
Please remove *:focus rule from html.css

Posted from: 2620:0:1002:1005:ae16:2dff:fe07:523b
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1707.0 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96486</commentid>
    <comment_count>1</comment_count>
    <who name="Eric Seidel">eric</who>
    <bug_when>2013-11-19 00:19:45 +0000</bug_when>
    <thetext>Currently, a naive implementation of :focus would require a browser to invalidate style on all elements every time the focus changes as it potentially could draw an outline.

We could detect the special case of :focus being defined by html.css (html5 spec) and instead do something smarter.

But we could also just fix the spec to be more specific, and have this selector only match focusable elements:

[tabindex]:focus, a[href]:focus, link[href]:focus, button:focus, input[type!=hidden]:focus, select:focus, textarea:focus, menuitem:focus, [dragable]:focus, td:focus, iframe:focus, frameset:focus {
  outline: auto;
}

Yeah, that&apos;s much more verbose.  But it&apos;s also much clearer/faster to implement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96491</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel">eric</who>
    <bug_when>2013-11-19 00:26:36 +0000</bug_when>
    <thetext>The current spec defeats an optimization I added to avoid these needless recalcs in crbug.com/315923.  Maybe other engines are smarter, but currently WebKit/Blink recalc style on the entire document every time you you focus/blur a tab, or when changing focus within a document (and the body was the previous focused node) even though the body doesn&apos;t actually draw focus.

We have a relatively large amount of CSS insantity for :focus already in blink/webkit:
http://blink.lc/blink/tree/Source/core/css/html.css#n1007
http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css#L1036</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96550</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-19 21:50:19 +0000</bug_when>
    <thetext>I don&apos;t understand. Why would you need to invalidate style on any element other than the one that used to match :focus and the one that now matches :focus?

In particular, if the rule in comment 1 would somehow invalidate fewer elements&apos; styles than the rule in comment 0, why not just implement :focus as the equivalent of :-x-focusable:focus, where :-x-focusable matches only elements that are focusable and therefore could theoretically match :focus?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96560</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2013-11-19 22:41:42 +0000</bug_when>
    <thetext>I think you forgot at least [contenteditable], summary, area[href], keygen... There&apos;s also the problem that the spec allows UAs to make basically any element focusable if it should be focusable according to platform conventions.

(Is td actually focusable?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96568</commentid>
    <comment_count>5</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-11-19 23:13:29 +0000</bug_when>
    <thetext>@hixie because if you had a:focus span { } then the span matches different rules now too, if you had a:focus + span { }. So you need to invalidate style on the descendants and the siblings (and their descendants) to deal with the rule changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96707</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-22 18:17:27 +0000</bug_when>
    <thetext>I don&apos;t understand how that affects this discussion.

The selector here is just &quot;*:focus&quot;.

Even if the selector had combinators, you don&apos;t need to invalidate anything but the descendants and following siblings and their descendants (as relevant to the selectors used) of the element that had focus before, and the element that has focus now. I don&apos;t see how changing the rule from &quot;*:focus&quot; to &quot;a:focus, b:focus, c:focus&quot; (for values of a, b, and c similar to those in comment 1 and comment 4) would need to have any implementation effect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96709</commentid>
    <comment_count>7</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-11-22 18:25:39 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #6)
&gt; I don&apos;t understand how that affects this discussion.
&gt; 
&gt; The selector here is just &quot;*:focus&quot;.
&gt; 
&gt; Even if the selector had combinators, you don&apos;t need to invalidate anything
&gt; but the descendants and following siblings and their descendants (as
&gt; relevant to the selectors used) of the element that had focus before, and
&gt; the element that has focus now. I don&apos;t see how changing the rule from
&gt; &quot;*:focus&quot; to &quot;a:focus, b:focus, c:focus&quot; (for values of a, b, and c similar
&gt; to those in comment 1 and comment 4) would need to have any implementation
&gt; effect.

Because when you blur a window the default focused element is the &lt;body&gt; so we end up recalculating the style for all elements in the whole document again. Perhaps this is a just an implementation detail.

@eseidel I think we should just switch to the list of elements in Blink to improve performance and leave the spec alone. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96720</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-22 19:10:49 +0000</bug_when>
    <thetext>I don&apos;t understand how changing the selector would affect this. The &lt;body&gt; element doesn&apos;t match :focus, so why would you be invalidating the whole document?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97947</commentid>
    <comment_count>9</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2014-01-02 21:14:39 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #8)
&gt; I don&apos;t understand how changing the selector would affect this. The &lt;body&gt;
&gt; element doesn&apos;t match :focus, so why would you be invalidating the whole
&gt; document?

I need to dig into this more, I think there may be some confusion with our implementation or the standard. I&apos;ll talk to Eric Seidel and see if we can figure out what the issue is on the web app we were observing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103642</commentid>
    <comment_count>10</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2014-04-09 22:09:02 +0000</bug_when>
    <thetext>I don&apos;t think this is a real issue. We should be able to just be smarter about it.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>