Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify Window's focus() and blur() #4377

Merged
merged 2 commits into from
Feb 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -73675,24 +73675,34 @@ END:VCARD</pre>
<code>Document</code> object, when invoked, must return the result of running the <span>has focus
steps</span> with the <code>Document</code> object as the argument.</p>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-focus">focus()</code></dfn> method on
the <code>Window</code> object, when invoked, must run the <span>focusing steps</span> with the
<code>Window</code> object's <span>browsing context</span>. Additionally, if this <span>browsing
context</span> is a <span>top-level browsing context</span>, user agents are encouraged to trigger
some sort of notification to indicate to the user that the page is attempting to gain focus.</p>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-blur">blur()</code></dfn> method on the
<code>Window</code> object, when invoked, provides a hint to the user agent that the script
believes the user probably is not currently interested in the contents of the <span>browsing
context</span> of the <code>Window</code> object on which the method was invoked, but that the
contents might become interesting again in the future.</p>
<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-focus">focus()</code></dfn> method,
when invoked, must run these steps:</p>

<ol>
<li><p>Let <var>current</var> be this <code>Window</code> object's <span data-x="window
bc">browsing context</span>.</p></li>

<li><p>If <var>current</var> is null, then return.</p></li>

annevk marked this conversation as resolved.
Show resolved Hide resolved
<li><p>Run the <span>focusing steps</span> with <var>current</var>.</p></li>

<li><p>If <var>current</var> is a <span>top-level browsing context</span>, user agents are
encouraged to trigger some sort of notification to indicate to the user that the page is
attempting to gain focus.</p></li>
annevk marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-blur">blur()</code></dfn> method, when
invoked, provides a hint to the user agent that the script believes the user probably is not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could become a three-step algorithm.

  1. User agents should return at this point, causing the method to do nothing.
  2. If the BC is null, return.
  3. If this point is reached, then the page author has provided a hint...

Note that it does nothing in Blink (1, 2). It seems to do something in Safari, sometimes (1, 2). I couldn't untangle Gecko's mess of window-related classes enough to find the blur method implementation there.

currently interested in the contents of this <code>Window</code> object's <span data-x="window
bc">browsing context</span>, if non-null, but that the contents might become interesting again in
the future.</p>

<p>User agents are encouraged to ignore calls to this <code data-x="dom-window-blur">blur()</code>
method entirely.</p>

<p class="note">Historically, the <code data-x="dom-window-blur">focus()</code> and <code
data-x="dom-window-blur">blur()</code> methods actually affected the system-level focus of the
system widget (e.g. tab or window) that contained the <span>browsing context</span>, but hostile
system widget (e.g., tab or window) that contained the <span>browsing context</span>, but hostile
sites widely abuse this behavior to the user's detriment.</p>

<p>The <dfn><code data-x="dom-focus">focus(<var>options</var>)</code></dfn> method on elements, when
Expand Down