[54] [[Web]] では、[[利用者]]によって特に操作対象として選択された状態の[[要素]]その他のオブジェクトを[DFN[[RUBYB[フォーカス]@en[focus]]]]を持つといいます。

* 仕様書

[REFS[
- [41] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2014-01-13 23:42:08 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#focus>
]REFS]

* 定義

[50] 一般に [[GUI]] システムは[[窓]]や[[制御子]]などの[[ウィジェット]]のうちいずれかが「[[フォーカス]]」
を持つこととし、[[キーボード]]等の入力をその[[ウィジェット]]に対して送信します。 [[CUI]] 
の[[対話的]]アプリケーションも同様の概念を持っているのが一般的です。 [[Web]]
における[[フォーカス]]はこれらの仕組みを利用して、あるいは模倣して実装されることが想定しています。

[51] システム全体に複数の[[窓]]や[[プロセス]]があったり、その内の [[Webブラウザー]]の中でも[[窓]]や[[タブ]]が複数あったり、
メニューやボタンなど[[閲覧文脈]]以外の [[UI]] 要素が存在したりします。いずれにせよ、そうした[[最上位閲覧文脈]]より外側の部分の
([[Webページ]]側から感知し得ない) 範囲における[[フォーカス]]は「[[システムフォーカス]]」
と呼ばれています。

[52] 更にそれぞれの[[閲覧文脈]]の内部には色々な[[要素]]や[[フォーム制御子]]等の[[要素]]よりも細かい操作単位が存在しています。
そうした[[閲覧文脈]]内のものが[[フォーカス]]を持つことができますが、何も[[フォーカス]]されていない状態もあり得ます。

[48] [[最上位閲覧文脈]]が[[システムフォーカス]]を有しているかとその[[最上位閲覧文脈]]内の[[要素]]が[[フォーカス]]を持っているかは独立していなければ[['''なりません''']]。
[SRC[>>41]] 従って影に隠れている[[窓]]や[[タブ]]に表示されている[[文書]]であっても、いずれかの[[要素]]が[[フォーカス]]を持っている可能性があります。

;; [53] 言い換えると [[Page Visibility]] と[[フォーカス]]の有無は独立しています。

[49] ある[[最上位閲覧文脈]]内には [CODE(HTMLe)@en[[[iframe]]]] などで埋め込まれた別の[[閲覧文脈]]が含まれていることがあります。
[[子閲覧文脈]]が[[フォーカス]]されているときは、その[[閲覧文脈包含子]]もまた[[フォーカス]]されていなければ[['''なりません''']]
[SRC[>>41]]。ですから [CODE(HTMLe)@en[[[iframe]]]] [[要素]]の中に表示されている[[要素]]が[[フォーカス]]を持っているなら、
[CODE(HTMLe)@en[[[iframe]]]] [[要素]]もまた[[フォーカス]]を持つこととなります。

[47] [[フォーカス]]は[[閲覧文脈]]や [CODE(DOMi)@en[[[Document]]]] ごとに個別に管理しても[['''構いません''']]し、
[[最上位閲覧文脈]]ごとに一つだけとしても[['''構いません''']]。どうするかは[[プラットフォームの慣習]]に従う[['''べきです''']]。
[SRC[>>41]]

* キーイベントの処理

[80] [[フォーカス]]と[[キーイベント]]の関係は、[[キーイベント]]を参照。

* [CODE(CSS)@en[:focus]] 擬似クラス

[12] [DFN[[CODE(CSS)@en[[[:focus]]]]]] [[擬似クラス]]は、[[焦点]]を持っている[[要素]]に適用されます
[SRC[>>11]]。

** 仕様書

[REFS[
- [11] [CITE@en[Selectors Level 3]] ([TIME[2011-09-29 22:16:17 +09:00]] 版) <http://www.w3.org/TR/selectors/#the-user-action-pseudo-classes-hover-act>
- [63] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2014-02-19 22:39:17 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#selector-focus>
]REFS]

** 意味

[13] [CODE(CSS)@en[[[:focus]]]] は[[フォーカス]]を持っている[[要素]]に適用されます。
[[フォーカス]]を持っている[[要素]]は、[[鍵盤イベント]]や[[マウスイベント]]、その他の入力を受け付けます。
[SRC[>>11]]

[14] [[文書言語]]や[[実装]]はどの[[要素]]に [CODE(CSS)@en[[[:focus]]]] が適用されるかを制限するかもしれません。
[SRC[>>11]]

[64] [DFN[[RUBYB[[[[VAR[要素]]が[F[フォーカスを持つ]]]]]@en[element has the focus]]]]とは、
次のことをいいます。 [SRC[>>63]]

- [122] 次の''すべて''を満たす:
-- [65] [VAR[要素]]の[F[最上位閲覧文脈]]が[F[[[システムフォーカス]]を持つ]]
-- [66] [VAR[要素]]の[F[[[閲覧文脈包含子]]である]]が''[[偽]]''
-- [123] 次の''いずれか''を満たす:
--- [67] [VAR[要素]]が[VAR[要素]]の[[[F[最上位閲覧文脈]]の[F[現在フォーカスされている領域]]]]の[F[フォーカス鎖]]に含まれる
--- [124] [VAR[要素]]の[F[影根]]が [CODE[null]] で''なく''、
ある[[要素が[F[フォーカスを持つ]]]]のであってその[F[根]]が [VAR[要素]]の[F[影根]]である


** 歴史

*** CSS2

[REFS[
- [26] [CITE@en[Selectors]] ([TIME[1998-03-25 23:00:31 +09:00]] 版) <http://www.w3.org/TR/1998/PR-CSS2-19980324/selector.html#dynamic-pseudo-classes>
- [15] [CITE@en[Selectors]] ([TIME[2011-06-07 22:09:52 +09:00]] 版) <http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes>
]REFS]

[16] [CODE(CSS)@en[[[:focus]]]] は >>26 で追加されました。

*** CSS UI

[17] 古い [[CSS UI]] の仕様は [CODE(CSS)@en['[[user-input]]: enabled']] な[[要素]]にだけ [CODE(CSS)@en[[[:focus]]]]
が適用される、と改訂していましたが、この仕様は放棄されて現在に引き継がれていないようです。
>>25 の次の [[CR]] で削除されています。

[REFS[
- [18] [CITE[User Interface Enhancements]] ([TIME[1999-09-16 05:07:02 +09:00]] 版) <http://www.w3.org/TR/1999/WD-css3-userint-19990916#pseudo-active>
- [19] [CITE@en[User Interface for CSS3]] ([TIME[2000-06-23 03:09:21 +09:00]] 版) <http://www.w3.org/TR/2000/WD-css3-userint-20000216#pseudo-active>
- [22] [CITE@en[CSS3 module: W3C Selectors]] ([TIME[2000-04-11 01:57:05 +09:00]] 版) <http://www.w3.org/TR/2000/WD-css3-selectors-20000410#useraction-pseudos>
- [24] [CITE@en[CSS3 module: W3C Selectors]] ([TIME[2000-10-06 02:05:50 +09:00]] 版) <http://www.w3.org/TR/2000/WD-css3-selectors-20001005/#useraction-pseudos>
- [25] [CITE@en[CSS3 module: W3C Selectors]] ([TIME[2001-01-29 23:57:00 +09:00]] 版) <http://www.w3.org/TR/2001/WD-css3-selectors-20010126/#useraction-pseudos>
]REFS]

[28] その後は単に[[選択子3]]を参照するだけになっています。
[REFS[
- [29] [CITE@en[CSS Basic User Interface Module Level 3 (CSS3 UI)]] ([[Tantek Çelik]] 著, [TIME[2012-01-13 20:03:30 +09:00]] 版) <http://www.w3.org/TR/2012/WD-css3-ui-20120117/#pseudo-classes>
]REFS]

[23] [[Web Controls 1.0]] は [[CSS UI]] を更に拡張して[[Webアプリケーション]]が状態を制御できるようにする構想を持っていました。

[REFS[
- [21] [CITE@en-GB-hixie[Web Applications Markup Language 1.0]]
( ([TIME[2004-04-08 02:39:12 +09:00]] 版))
<http://hixie.ch/specs/html/apps/web-apps-1#pseudo-classes>
- [20] [CITE@en-GB-hixie[Web Controls 1.0]]
( ([TIME[2004-11-09 08:49:52 +09:00]] 版))
<http://www.whatwg.org/specs/web-controls/current-work/#pseudo-classes>
]REFS]

*** HTML Standard

[62] 2014年の [[HTML Standard]] における[[フォーカス]]全体の改訂の一環として [CODE(CSS)@en[[[:focus]]]] の定義も明確化されました。

[REFS[
- [61] [CITE@en[Web Applications 1.0 r8478     Revamp how focus is defined, to actually handle things we've ignored before, like viewports and scrollable regions]] ([TIME[2014-02-20 07:39:00 +09:00]] 版) <http://html5.org/tools/web-apps-tracker?from=8477&to=8478>
]REFS]

* 歴史

** 焦点 (HTML4)

[1] [Q[HTML 文書では、[[要素]]は活性化してその仕事を行うために利用者から[DFN[焦点]]を受取らなければなりません。例えば、利用者は [CODE(HTMLe)[[[a]]]] 要素で指定されたリンクをたどるためにリンクを活性化しなければなりません。同様に、利用者は文章を入力するためには [CODE(HTMLe)[[[textarea]]]] に焦点を与えなければなりません。]<IW:HTML4:"interact/forms.html#focus">]

というのが HTML における[DFN[[RUBYB[焦点] [focus]]]]です。
フォームの章で規定されており、フォーム[[制御子]]に関して特に重要な意味を持ちますが、
[CODE(HTMLe)[a]] 要素が例に挙げられている通り、フォーム特有の概念ではないようです。

[REFS[
- [2] [[HTML 4]]
-- [CITE[17.11 focusGiving focus to an element]]
<http://www.w3.org/TR/html4/interact/forms.html#focus>
]REFS]

[3] 要素に焦点を与える方法は幾つもあります [SRC[HTML 4]]。
- 指示装置で要素を指定する。
- 鍵盤である要素から次の要素に移動する。
-- 著者は、[DFN[タブ順]] (要素が焦点を受取る順) を指定できる ([CODE(HTMLa)[[[tabindex]]]])。
-- 要素は、ひとたび選択されれば、何か他の打鍵で活性化できるかもしれない。
- アクセス鍵 ([CODE(HTMLa)[[[accesskey]]]]) によって要素を選択する。
-- [Q[鍵盤近道]]とか[Q[鍵盤アクセス子]]とか言うこともある。

仕様書にはちゃんと書いてありませんが、当然、
どのような方法が利用可能であるかや、具体的にどう操作するかは、
その UA や使用する環境その他に大きく左右されることになります。
特に、多くの利用者界面システムは元々[Q[焦点]]のような概念を持っていますから、
普通 UA はその概念の元で表示した HTML 文書を操作できるようにしています。

[4] HTML 4 仕様書は[Q[[RUBYB[活性化] [activate]]]]と[Q[[RUBYB[焦点] [focus]]]]についての概念が少々混乱しているように見受けられます。
[Q[焦点]]は 17.11 節で
[Q[an element must receive [DFN[focus]] from the user in order to become active and perform its tasks]<IW:HTML4:"interact/forms.html#focus">]
と定義されています。つまり、焦点を受取ると要素は活性になり、
定められた仕事を行います。

それでは焦点を受取ることと活性化が実際上同じなのかと思うと、
次の 17.11.1 節の[Q[[RUBYB[タブ順序] [tabbing order]]]]と矛盾します。
[Q[The tabbing order defines the order in which elements will receive focus when navigated by the user via the keyboard.]<http://www.w3.org/TR/html4/interact/forms.html#didx-tabbing_order>]
ですから、タブ移動は焦点移動です。
しかし、 [Q[users must activate a link specified by the [CODE(HTMLe)[A]] element in order to follow the specified link]<http://www.w3.org/TR/html4/interact/forms.html#focus>]
ですから、焦点受領と活性化が同じことであるなら、
リンクにタブ移動すると他の頁に飛ばされてしまいます。そのような解釈は不適切でしょう。

また、 Note として、
[Q[The actual key sequence that causes tabbing navigation or element activation depends on the configuration of the user agent (e.g., the "tab" key is used for navigation and the "enter" key is used to activate a selected element).]<http://www.w3.org/TR/html4/interact/forms.html#tabbing-navigation>]
とあります。どうやら、[Q[タブ navigation]] と[Q[要素活性化]]の2つの操作があるようです。
[Q[タブ順序]]の定義より、前者が焦点を受取ることと解するのが自然でしょう。
また、 [Q[tabbing navigation]] の結果要素は[Q[選択]]されるようです。
17.11 節にも、タブで要素を選択してから活性化するというようなことが同じような感じで書かれています。

ここまでで、どうやら少なくてもタブ移動に関しては、焦点の移動と活性化は別の操作であり、
焦点を受取る (選択する) と活性化できるらしいことが分かりました
(最初の定義に少々疑問が残りますが)。では、更に読み進めて、 17.11.2 節
([CODE(HTMLa)[accesskey]]) をみてみましょう。

> Pressing an access key assigned to an element gives focus to the element. The action that occurs when an element receives focus depends on the element. For example, when a user activates a link defined by the [CODE(HTMLe)[A]] element, the user agent generally follows the link. When a user activates a radio button, the user agent changes the value of the radio button. When the user activates a text field, it allows input, etc.

[Q[アクセス鍵を押すと要素は焦点を受取ります。焦点を受取った際の挙動は要素依存です。]]
ここまで最初の2文は何ら問題ありません。ところが、次の [Q[For example]]
以降が、なぜか突然活性化の話題になっています。
ここに書かれえているラジオ・ボタンや文章入力の挙動は焦点を受取った時の挙動として実装しても問題はなさそうですが、
リンクを飛んでしまうのは困ります。

更に、次の段落では例を挙げつつ [Q[Typing the access key gives focus to the label which in turn gives it to the associated control. The user may then enter text into the [CODE(HTMLe)[INPUT]] area.]<http://www.w3.org/TR/html4/interact/forms.html#idx-focus-2>]
と言っています。仕様書著者の脳内 UA では、
文章入力欄が焦点を受取ると既に利用者が入力可能な状態になっているようです。
また、その次の [CODE(HTMLe)[a]] 要素の例では、
[Q[Typing this access key takes the user to another document]<http://www.w3.org/TR/html4/interact/forms.html#idx-focus-2>]
とされています。ここでも、アクセス鍵を打鍵しただけでリンクは活性化して飛んでいくようです。

というわけで、どうやら、[Q[焦点を受取る]] ([Q[要素を選択する]])
ことと[Q[活性化する]]ことは、同時に起こることもあれば別々に起こることもある、
とでもまとめるしかなさそうです。

[5] 実際の UA は、 [CODE(HTMLe)[a]] によるリンクや押しボタン制御子に関連付けられたアクセス鍵を打鍵した時に焦点を受取るだけのものもあれば、
活性化してしまうものもあります。そのような実装の違いも、
仕様書の分かりにくい記述のせいかもしれません。 
(あるいは仕様書が混乱しているのは当時の実装のせいかもしれません。)

[6]
[Q[活性]]というのが既存の GUI システム類で[Q[焦点]]に近い意味でも使われているのも混乱の原因かも。

** 属性集合 [CODE(XML)[%focus;]] (XHTML 1.0)

[7] [[XHTML 1.0]] では[[焦点]]を得られる[[要素]]の[[焦点]]に関する[[属性]]を[[引数実体]]
[DFN[[CODE(XML)[%focus;]]]] で定義しています。

[REFS[
- [8] [[XHTML 1.0]]
-- [CSECTION[A.1.1. XHTML-1.0-Strict]]
<http://www.w3.org/TR/2002/REC-xhtml1-20020801/dtds.html#dtdentry_xhtml1-strict.dtd_focus>
-- [CSECTION[A.1.2. XHTML-1.0-Transitional]]
<http://www.w3.org/TR/2002/REC-xhtml1-20020801/dtds.html#dtdentry_xhtml1-transitional.dtd_focus>
-- [CSECTION[A.1.3. XHTML-1.0-Frameset]]
<http://www.w3.org/TR/2002/REC-xhtml1-20020801/dtds.html#dtdentry_xhtml1-frameset.dtd_focus>
]REFS]

[9] 
,属性名,属性値,既定値,説明,状態,出典
,[CODE(HTMLa)[[[accesskey]]]],[CODE(XML)[%[[Character]];]],,,W3C 勧告,[XHTML 1.0]
,[CODE(HTMLa)[[[onblur]]]],[CODE(XML)[%[[Script]];]],,焦点喪失時,W3C 勧告,[XHTML 1.0]
,[CODE(HTMLa)[[[onfocus]]]],[CODE(XML)[%[[Script]];]],,焦点受領時,W3C 勧告,[XHTML 1.0]
,[CODE(HTMLa)[[[tabindex]]]],[CODE(XML)[%[[Number]];]],,[[タブ付け順序]],W3C 勧告,[XHTML 1.0]

* メモ

[10] [CITE@en[Web Applications 1.0 r5911     Define when the platform-specific focusing behavior happens relative to focus events, etc.]]
( ([TIME[2011-02-19 09:26:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5910&to=5911>


[27] [CITE@en[Web Applications 1.0 r6876     Clarify what is focused in the iframe's owner document when an iframe's child document is focused.]]
( ([TIME[2011-12-17 05:53:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=6875&to=6876>

[30] [CITE@en[Web Applications 1.0 r7458     Make UA-provided focusable controls that are part of other elements be focusable.]]
( ([TIME[2012-10-13 03:03:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7457&to=7458>

[31] [CITE@en[Web Applications 1.0 r7459 Allow even more flexibility in deciding what's focusable.]]
( ([TIME[2012-10-13 03:05:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7458&to=7459>

[32] [CITE@en[Web Applications 1.0 r7498     Another attempt at defining tabindex, :disabled, what can be focused, etc.]]
( ([TIME[2012-11-02 08:07:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7497&to=7498>

[33] [CITE@en[WICD Core 1.0]]
( ([TIME[2010-08-17 16:51:00 +09:00]] 版))
<http://www.w3.org/TR/WICD/#focus-handling>

[34] [CITE@en[WICD Mobile 1.0]]
( ([TIME[2010-08-17 16:50:39 +09:00]] 版))
<http://www.w3.org/TR/WICDMobile/#focus-navigation-model>

[35] [CITE[''''''[''''''whatwg'''''']'''''' Should scrollbars move focus?]]
( ([TIME[2012-12-29 16:15:33 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038478.html>

[36] [CITE@en-US[XBL 2.0]]
( ([TIME[2012-05-03 02:23:03 +09:00]] 版))
<http://dev.w3.org/2006/xbl2/Overview.html#the-focus-domfocusin-blur-and-domfocusou>

[37] [CITE@en[Web Applications 1.0 r8323     Make the fragment identifier handling rules match browsers better]]
( ([TIME[2013-12-03 08:55:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8322&to=8323>

[38] [CITE[IRC logs: freenode / #whatwg / 20131209]]
( ([TIME[2013-12-10 20:49:20 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20131209#l-812>

[39] [CITE@en[Bug 23475 – <dialog>: Clarify how <dialog> elements can be given "window focus"]]
( ([TIME[2013-12-14 10:07:54 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=23475>

[40] [CITE@en[Web Applications 1.0 r8338     Make <dialog> autofocus the first focusable control if there isn't one with autofocus=''.]]
( ([TIME[2013-12-11 07:09:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8337&to=8338>

[55] [CITE[IRC logs: freenode / #whatwg / 20140115]]
( ([TIME[2014-01-16 20:18:06 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140115>

[56] [CITE@en[Bug 23475 – <dialog>: Clarify how <dialog> elements can be given "window focus"]]
( ([TIME[2014-01-17 23:29:38 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=23475>

[57] [CITE@en-US[Accessible Rich Internet Applications (WAI-ARIA) 1.0]]
( ([TIME[2014-01-14 16:21:51 +09:00]] 版))
<http://www.w3.org/WAI/PF/aria/complete#host_general_focus>

[58] [CITE@en-US[XML Binding Language (XBL) 2.0]]
( ([TIME[2007-03-16 22:20:16 +09:00]] 版))
<http://www.w3.org/TR/2007/CR-xbl-20070316/#the-focus>

[59] [CITE[IRC logs: freenode / #whatwg / 20140219]]
( ([TIME[2014-02-20 21:02:47 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140219>

[60] [CITE@en[Web Applications 1.0 r8478     Revamp how focus is defined, to actually handle things we've ignored before, like viewports and scrollable regions]]
( ([TIME[2014-02-20 07:39:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8477&to=8478>

[68] [CITE@en-US[Techniques for WCAG 2.0]]
( ([TIME[2014-03-11 23:08:17 +09:00]] 版))
<http://www.w3.org/TR/2014/NOTE-WCAG20-TECHS-20140311/complete.html#G107>

[69] [CITE@en-US[Notifications API Standard]]
( ([TIME[2014-02-11 16:20:34 +09:00]] 版))
<http://notifications.spec.whatwg.org/#activating-a-notification>

[70] [CITE@en[Web Applications 1.0 r8621     Spec relatedTarget for focus and blur]]
( ([TIME[2014-05-09 05:13:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8620&to=8621>

[71] [CITE@en[Clarify window.focus() note somewhat. · 357b2aa · whatwg/notifications]]
( ([TIME[2014-09-25 02:35:24 +09:00]] 版))
<https://github.com/whatwg/notifications/commit/357b2aa00f9a328f8e545264296834f672922e01>

[72] [CITE@en[Web Applications 1.0 r8810     Try to match browsers better around focus.]]
( ([TIME[2014-09-25 03:54:00 +09:00]] 版))
<https://html5.org/r/8810>

[73] [CITE@en[Bug 24720 – <dialog>: New <dialog>- and focus-related APIs]]
( ([TIME[2014-09-30 04:39:08 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=24720>

[74] [CITE@en[Web Applications 1.0 r8845  Define how focus sequential navigation works in slightly more detail; make navigating to an unfocusable control lead to the viewport being refocused.]]
( ([TIME[2014-11-07 10:09:00 +09:00]] 版))
<https://html5.org/r/8845>

[75] [CITE@en-US[<a> - HTML (HyperText Markup Language) | MDN]]
( ([TIME[2014-10-26 22:34:13 +09:00]] 版))
<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Clicking_and_focus>

[76] [CITE@en-US[csswg: changeset 14820:2539f118cb22]]
( ([TIME[2014-11-27 22:51:47 +09:00]] 版))
<https://dvcs.w3.org/hg/csswg/rev/2539f118cb221178eeeb0e27c377e78b2feeb650>

[77] [CITE[Better Focus Navigation for Shadow DOM - Google ドキュメント]]
( ([TIME[2015-01-16 11:45:53 +09:00]] 版))
<https://docs.google.com/document/d/1k93Ez6yNSyWQDtGjdJJqTBPmljk9l2WS3JTe5OHHB50/edit#>

[78] [CITE[Tabindex Focus Navigation Explainer - Google ドキュメント]]
([TIME[2015-02-03 11:23:28 +09:00]] 版)
<https://docs.google.com/document/d/1k93Ez6yNSyWQDtGjdJJqTBPmljk9l2WS3JTe5OHHB50/edit#heading=h.qjtlohzbc5ms>

[FIG(quote)[
[FIGCAPTION[
[79] [CITE@en[Re: Making ARIA and native HTML play better together]]
([[Maciej Stachowiak]] 著, [TIME[2015-05-12 11:34:28 +09:00]] 版)
<https://lists.w3.org/Archives/Public/public-webapps/2015AprJun/0626.html>
]FIGCAPTION]

> <input type=button> is not keyboard-focusable on Safari for Mac but it is mouse-focusable. Likewise in Safari on iOS (both if you connect a physical keyboard, and if you use the onscreen focus-cycle arrows in navigation view).

]FIG]

[FIG(quote)[
[FIGCAPTION[
[42] [CITE[IRC logs: freenode / #whatwg / 20150728]]
([TIME[2015-07-29 12:39:16 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20150728>
]FIGCAPTION]

> 
> # '''['''12:59''']''' <annevk> MikeSmith: in some browsers anyway you can get blur events fired when a focused element is removed from the tree
> # '''['''12:59''']''' <annevk> MikeSmith: same for focusout and there should be some trick for getting that with focusin/focus

]FIG]


[43] [CITE@en[Replace Focus section with a reference to HTML's focus processing model. · w3c/svgwg@6997e03]]
([TIME[2016-02-06 12:31:21 +09:00]] 版)
<https://github.com/w3c/svgwg/commit/6997e031b59eaf4ca39a3d645dbdb1dfc6dbc47c>

[44] [CITE@en[Don't repeat events defined in other specs. · w3c/svgwg@ba6ff23]]
([TIME[2016-02-06 12:33:59 +09:00]] 版)
<https://github.com/w3c/svgwg/commit/ba6ff23e1e90914465633294eebc091f6065e0d6>

[45] [CITE@en[Fix #559: require focus movement on scrolling to a fragment ID · whatwg/html@414bee7]]
([TIME[2016-02-25 11:39:54 +09:00]] 版)
<https://github.com/whatwg/html/commit/414bee7380eef0aa4487c44e2008eef6dcfb9ee4>

[46] [CITE@en[Fix #744: clarify control groups and control group owner objects · whatwg/html@9194856]]
([TIME[2016-03-01 11:35:40 +09:00]] 版)
<https://github.com/whatwg/html/commit/9194856d7b5a91aa910640e5686048317924e7aa>

[81] [CITE@en[Don't unset the sequential focus navigation starting point · whatwg/html@b466ad7]]
([TIME[2016-03-05 11:14:36 +09:00]] 版)
<https://github.com/whatwg/html/commit/b466ad7ce49676873ddade4c473b7c983803bfd4>

[82] [CITE@en[Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7]]
([TIME[2016-03-20 18:14:58 +09:00]] 版)
<https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd>

[83] [CITE@en[Editorial: clarify change events on unfocusing · whatwg/html@86f7aa6]]
([TIME[2016-04-13 11:54:10 +09:00]] 版)
<https://github.com/whatwg/html/commit/86f7aa620dbcbc837e217ae36be99808fc7eb34a>

[84] [CITE@en[Be more precise about nested and discarded browsing contexts]]
([[domenic]]著, [TIME[2016-07-20 22:58:49 +09:00]])
<https://github.com/whatwg/html/commit/39118df640ad4a3f03f164fb5ffe0a56316297be>

[85] [CITE@en[Stop overriding UIEvent's detail attribute]]
([[annevk]]著, [TIME[2016-10-25 19:00:16 +09:00]])
<https://github.com/whatwg/html/commit/bd3239b5b38a157a61cb570df5c80ad1dbc2b9d4>

[86] [CITE@en[Clarify and add some examples around focus]]
([[domenic]]著, [TIME[2016-11-03 04:45:57 +09:00]])
<https://github.com/whatwg/html/commit/deb83668390151a2cf242c24dd9d68509860e77a>

[87] [CITE@en[Add note on Shadow DOM behavior about dialog focusing steps. by TakayoshiKochi · Pull Request #2394 · whatwg/html]]
([TIME[2017-04-04 17:37:21 +09:00]])
<https://github.com/whatwg/html/pull/2394>

[88] [CITE@en[Add mitigation strategy for skimming attacks when focus is lost. (#213)]]
([[tobie]]著, [TIME[2017-05-30 21:39:04 +09:00]])
<https://github.com/w3c/sensors/commit/d6f537f740ee964f9bbb8a5d3a0fd661a69ea205>

[89] [CITE@en[Use the has focus steps algorithm. (#225)]]
([[tobie]]著, [TIME[2017-05-30 23:34:33 +09:00]])
<https://github.com/w3c/sensors/commit/ff03ece7d9abdfb0e2d83ed906a24ccd667b19fa>

[90] [CITE@en[Calling focus() on non-focusable HTMLElement should log a warning to the console · Issue #2772 · whatwg/html]]
([TIME[2017-06-20 16:38:10 +09:00]])
<https://github.com/whatwg/html/issues/2772>

[91] [CITE@en[155566 - Calling focus() on non-focusable HTMLElement should log a warning to the console - chromium - Monorail]]
([TIME[2017-06-20 16:38:23 +09:00]])
<https://bugs.chromium.org/p/chromium/issues/detail?id=155566>

[92] [CITE@en['''['''selectors''']''' Fix definition of :focus]]
([[frivoal]]著, [TIME[2017-08-17 19:32:18 +09:00]])
<https://github.com/w3c/csswg-drafts/commit/b8dd5b9e8196b210f50e2bf0d72cfaf2b519a45f>

[93] [CITE@en['''['''selectors''']''' propagation of the :focus pseudo · Issue #1240 · w3c/csswg-drafts]]
([TIME[2017-08-18 14:03:05 +09:00]])
<https://github.com/w3c/csswg-drafts/issues/1240>

[94] [CITE@en[Mark focus events composed]]
([[annevk]]著, [TIME[2018-03-02 17:20:50 +09:00]])
<https://github.com/whatwg/html/commit/84d96dfd816f5e6f229df0558ce10af26482bfc5>

[95] [CITE@en[Make focus events composed · Issue #3511 · whatwg/html]]
([TIME[2018-03-03 12:43:00 +09:00]])
<https://github.com/whatwg/html/issues/3511>

[96] [CITE@en[Mark focus events composed by annevk · Pull Request #3512 · whatwg/html]]
([TIME[2018-03-03 12:43:34 +09:00]])
<https://github.com/whatwg/html/pull/3512>

[97] [CITE@en[Queue a task to run all the autofocusing steps]]
([[domenic]]著, [TIME[2018-03-07 14:32:39 +09:00]])
<https://github.com/whatwg/html/commit/185190cac859144cfcd78248b906f3adae1f0594>

[98] [CITE@en[Autofocus has weird racy behavior · Issue #3467 · whatwg/html]]
([TIME[2018-03-08 15:24:44 +09:00]])
<https://github.com/whatwg/html/issues/3467>

[99] [CITE@en[Queue a task to run all the autofocusing steps by domenic · Pull Request #3488 · whatwg/html]]
([TIME[2018-03-08 15:26:36 +09:00]])
<https://github.com/whatwg/html/pull/3488>

[100] [CITE@en[New in Chrome 64  |  Web  |  Google Developers]]
([TIME[2018-03-06 04:54:20 +09:00]])
<https://developers.google.com/web/updates/2018/01/nic64>

[101] [CITE@en[Remove the concept of "dialog group"]]
([[TakayoshiKochi]]著, [TIME[2018-03-15 16:09:59 +09:00]])
<https://github.com/whatwg/html/commit/a4bb3465c86896b95b7d66c1e9047e8a313c7212>

[102] [CITE@en[Remove the concept of "dialog group" by TakayoshiKochi · Pull Request #3566 · whatwg/html]]
([TIME[2018-03-17 17:39:11 +09:00]])
<https://github.com/whatwg/html/pull/3566>

[103] [CITE@en[Add HTMLOrSVGElement interface mixin]]
([[annevk]]著, [TIME[2018-03-23 19:30:45 +09:00]])
<https://github.com/whatwg/html/commit/81e82437a7ef1ee37d4ce2b5a982bc297d5b58b1>

[104] [CITE@en[Move dataset from HTMLElement to a mixin shared with SVGElement · Issue #3471 · whatwg/html]]
([TIME[2018-03-24 17:58:48 +09:00]])
<https://github.com/whatwg/html/issues/3471>

[105] [CITE@en[Add HTMLOrSVGElement interface mixin by annevk · Pull Request #3543 · whatwg/html]]
([TIME[2018-03-24 18:04:08 +09:00]])
<https://github.com/whatwg/html/pull/3543>

[106] [CITE@en[Add HTMLOrSVGElement mixn]]
([[dstorey]]著, [TIME[2018-04-18 09:31:56 +09:00]])
<https://github.com/w3c/svgwg/commit/bf070f6e46face7169561d4ea7dae45b93210dfb>

[107] [CITE@en[Remove "control group" concept from the focus model]]
([[TakayoshiKochi]]著, [TIME[2018-05-15 00:27:08 +09:00]])
<https://github.com/whatwg/html/commit/90a60b2a0dc740b8b0093b07ca0a41e70ba8d83a>

[108] [CITE@en[Should <dialog> actually create a "control group" for focus? · Issue #2171 · whatwg/html]]
([TIME[2018-05-15 14:29:42 +09:00]])
<https://github.com/whatwg/html/issues/2171>

[109] [CITE@en[Remove "control group" concept from HTML by TakayoshiKochi · Pull Request #3647 · whatwg/html]]
([TIME[2018-05-15 14:32:23 +09:00]])
<https://github.com/whatwg/html/pull/3647>

[110] [CITE@en[Remove sentences about documents with no focusable area]]
([[TakayoshiKochi]]著, [TIME[2018-07-12 05:15:52 +09:00]])
<https://github.com/whatwg/html/commit/b2ff9c7292daefc034c5adca1c32727b1fac28ff>

[111] [CITE@en[Probably-wrong focus requirement · Issue #3675 · whatwg/html]]
([TIME[2018-07-13 16:07:15 +09:00]])
<https://github.com/whatwg/html/issues/3675>

[112] [CITE@en[Remove sentences about document with no focusable area by TakayoshiKochi · Pull Request #3798 · whatwg/html]]
([TIME[2018-07-13 16:07:32 +09:00]])
<https://github.com/whatwg/html/pull/3798>

[113] [CITE@en[focus() on a non-focusable legend delegates focus in WebKit/Chromium · Issue #3950 · whatwg/html]]
([TIME[2018-10-14 17:52:22 +09:00]])
<https://github.com/whatwg/html/issues/3950>


[114] 
[CODE[iframe]] の1つ前に[[フォーカス]]がある状態で[[タブ]]を押すと、
[CODE[iframe]]
内の最初の[[フォーカス可能]]な要素に[[フォーカス]]が移ります。
ところが、
いつからか、
[[Chrome]]
で 
[CODE[iframe]]
に
[CODE[[[sandbox]]=[[allow-same-origin]]]]
の許可がないとき
([CODE[iframe]] 内が本来[[同じ起源]]の場合)、
[CODE[iframe]]
に[[フォーカス]]があるもののその中には[[フォーカス]]がない状態を経由し、
もう1回[[タブ]]を押すとやっと最初の[[フォーカス可能]]な要素に移動するようになってしまいました。
[CODE[iframe]] 内が[[同じ起源]]でないときは
[CODE[[[sandbox]]=[[allow-same-origin]]]]
を指定しても[[同じ起源]]にならないためか、
回避できません。
([CODE[sandbox]] がなければ[[同じ起源]]でなくてもそもそもそうはならず回避できます。)
またこれは[[利用者]]が一旦手動で [[user activation]]
していれば回避できます。
[TIME[2019-11-29T03:28:59.900Z]]



[115] [CITE@en[Tweak shadow host focus delegation]]
([[rakina]]著, [TIME[2019-10-29 06:13:10 +09:00]])
<https://github.com/whatwg/html/commit/3bbb870127a6e048f9afadcacca88b78dba6dced>

[116] [CITE@en[Don't delegate focus when the shadow host is an ancestor of the currently focused area by rakina · Pull Request #5039 · whatwg/html]]
([TIME[2020-05-14 12:49:40 +09:00]])
<https://github.com/whatwg/html/pull/5039>

[117] [CITE@en[Should host with `delegatesFocus` true keep the previous focused element focused if it's a shadow-including descendant of the host? · Issue #840 · w3c/webcomponents]]
([TIME[2020-05-14 12:50:00 +09:00]])
<https://github.com/w3c/webcomponents/issues/840>

[118] [CITE@en[Add delegatesFocus to attachShadow and flag to ShadowRoot]]
([[rakina]]著, [TIME[2019-09-24 15:13:00 +09:00]])
<https://github.com/whatwg/dom/commit/4cf85efcbc22cc25a0917ceb18deac8b8f3e9246>

[119] [CITE@en[Upstream `delegatesFocus` property of ShadowRootInit from W3C spec. · Issue #367 · whatwg/dom]]
([TIME[2020-05-14 13:39:55 +09:00]])
<https://github.com/whatwg/dom/issues/367>

[120] [CITE@en[Add delegatesFocus init to attachShadow and flag to ShadowRoot by rakina · Pull Request #768 · whatwg/dom]]
([TIME[2020-05-14 13:40:14 +09:00]])
<https://github.com/whatwg/dom/pull/768>

[121] [CITE@en[Add shadow host considerations for the :focus selector]]
([[rakina]]著, [TIME[2019-09-24 15:25:35 +09:00]])
<https://github.com/whatwg/html/commit/500f4fe4bda775ca12d5082c405580b714030d7c>

[125] [CITE@en[Add shadow host considerations for the :focus selector]]
([[rakina]]著, [TIME[2019-09-24 15:25:35 +09:00]])
<https://github.com/whatwg/html/commit/500f4fe4bda775ca12d5082c405580b714030d7c>

[126] [CITE@en[Add shadow host consideration for :focus selector by rakina · Pull Request #4731 · whatwg/html]]
([TIME[2020-05-14 13:51:02 +09:00]])
<https://github.com/whatwg/html/pull/4731>

[127] [CITE@en[Update sequential focus navigation to include shadow trees]]
([[rakina]]著, [TIME[2019-06-26 17:30:32 +09:00]])
<https://github.com/whatwg/html/commit/d19d9632020824b827dff54c1ce9125f546aab25>

[128] [CITE@en[Update sequential focus navigation to include shadow trees by rakina · Pull Request #4735 · whatwg/html]]
([TIME[2020-05-14 13:54:09 +09:00]])
<https://github.com/whatwg/html/pull/4735>

[129] [CITE@en[Define different types of focusability]]
([[rakina]]著, [TIME[2019-07-16 11:39:59 +09:00]])
<https://github.com/whatwg/html/commit/1ab7c860732d8a1c144ebb86bd08c90f1be7b958>

[130] [CITE@en[Define different types of "focusable" & remove "tabindex focus flag" by rakina · Pull Request #4768 · whatwg/html]]
([TIME[2020-05-14 13:59:19 +09:00]])
<https://github.com/whatwg/html/pull/4768>

[131] [CITE@en["The tabIndex IDL attribute must reflect the val..." · Issue #1786 · whatwg/html]]
([TIME[2020-07-14 14:47:11 +09:00]])
<https://github.com/whatwg/html/issues/1786>

[132] [CITE@en[Clarify "focusable" in the context of tabIndex IDL attribute · Issue #4464 · whatwg/html]]
([TIME[2020-07-14 14:50:44 +09:00]])
<https://github.com/whatwg/html/issues/4464>

[133] [CITE@en[Handle delegates focus in the focusing steps]]
([[rakina]]著, [TIME[2019-10-16 15:46:58 +09:00]])
<https://github.com/whatwg/html/commit/133607f19d5bd4e554c2106f36ee70c6a67cbb5d>

[134] [CITE@en[Upstream focus navigation behavior for `delegatesFocus` from W3C spec. · Issue #2013 · whatwg/html]]
([TIME[2020-07-14 14:59:17 +09:00]])
<https://github.com/whatwg/html/issues/2013>

[135] [CITE@en[Handle shadow host with delegatesFocus=true in focusing steps (click focus + focus()) by rakina · Pull Request #4796 · whatwg/html]]
([TIME[2020-07-14 15:00:15 +09:00]])
<https://github.com/whatwg/html/pull/4796>

[136] [CITE@en[Make autofocus="" work with delegatesFocus and <area>]]
([[tkent-google]], [TIME[2019-11-12 01:44:20 +09:00]], [TIME[2021-03-16T07:25:37.000Z]])
<https://github.com/whatwg/html/commit/bcd5d619063c809f297c1b8dfd13146ee2993371>

[137] [CITE@en[delegatesFocus doesn't work well with autofocus · Issue #5027 · whatwg/html]]
([TIME[2021-03-16T07:26:14.000Z]])
<https://github.com/whatwg/html/issues/5027>

[138] [CITE@en[focus: autofocus should work with shadow hosts with delegatesFocus an… by tkent-google · Pull Request #5059 · whatwg/html]]
([TIME[2021-03-16T07:26:57.000Z]])
<https://github.com/whatwg/html/pull/5059>

[139] [CITE@en[Fix "get the focusable area"]]
([[bicknellr]], [TIME[2019-12-12 03:45:57 +09:00]], [TIME[2021-03-17T08:21:26.000Z]])
<https://github.com/whatwg/html/commit/1e920001839f255bf5ea3ba687b74457188246ed>

[140] [CITE@en[Fix references to undefined 'new focus target' in 'get the focusable area'. by bicknellr · Pull Request #5143 · whatwg/html]]
([TIME[2021-03-17T08:21:37.000Z]])
<https://github.com/whatwg/html/pull/5143>

[141] [CITE@en[Editorial: clarify which document of a/which top-level browsing context]]
([[annevk]], [TIME[2019-11-20 18:40:38 +09:00]], [TIME[2021-03-17T09:56:21.000Z]])
<https://github.com/whatwg/html/commit/3e1874e9e8c9390b875fada425e383b81581b556>

[142] [CITE@en[What does the definite article mean in the "has focus steps"? · Issue #2523 · whatwg/html]]
([TIME[2021-03-17T09:56:33.000Z]])
<https://github.com/whatwg/html/issues/2523>

[143] [CITE@en[Editorial: clarify which document of a top-level browsing context by annevk · Pull Request #5093 · whatwg/html]]
([TIME[2021-03-17T09:57:04.000Z]])
<https://github.com/whatwg/html/pull/5093>

[144] [CITE@en[The WHATWG Blog — Focusing on focus]], [TIME[2021-10-09T05:50:04.000Z]] <https://blog.whatwg.org/focusing-on-focus>

[145] [CITE@en[Editorial: nested browsing context is a member, not a type]]
([[annevk]], [TIME[2019-11-27 02:46:03 +09:00]], [TIME[2022-01-18T09:07:13.000Z]])
<https://github.com/whatwg/html/commit/6b737bbc428facf34ec3728c0912cf9e172d0ea4>