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

Link to the HTML spec's "has focus steps". #143

Merged
merged 6 commits into from
May 25, 2021
Merged

Link to the HTML spec's "has focus steps". #143

merged 6 commits into from
May 25, 2021

Conversation

mfalken
Copy link
Member

@mfalken mfalken commented May 20, 2021

This clarifies what "currently focused" means.


Preview | Diff

This clarifies what "currently focused" means.
@mfalken
Copy link
Member Author

mfalken commented May 20, 2021

@domenic @garykac can you review this? More context at WICG/nav-speculation#55

@@ -1171,7 +1171,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
handlers) and data can be accessed in the absence of a user provided gesture.

To help prevent abuse, this API <em>must not</em> be available unless the script
is executing in the context of the currently focused document.
is executing in the context of a document that [=has focus steps|has focus=].
Copy link

Choose a reason for hiding this comment

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

Documents don't have focus. Specific elements inside them, or focusable areas, have focus.

Is this supposed to be about the browsing context having system focus?

Copy link

@domenic domenic left a comment

Choose a reason for hiding this comment

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

LGTM, although ideally this would be in the actual algorithms instead of a magic patch at a distance from the privacy section of the spec. (That's a preexisting problem though, and not really in scope for you to fix...)

@mfalken
Copy link
Member Author

mfalken commented May 20, 2021

Thanks. I believe the original intent of the text is about system focus. I'm not sure about one thing. Document.hasFocus() exists and uses https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps which looked convenient as it checks for system focus in the first step. I'm not sure if the other steps are needed. I just changed it to use system focus directly. Do you know what is going on here?

@domenic
Copy link

domenic commented May 20, 2021

The other steps handle iframe nesting cases. If you call document.hasFocus() inside an iframe, then this is true if:

  • The iframe itself has focus within its parent (times N if it's multiply nested)
  • The top-level BC has system focus

In non-iframe cases, target's BC = target's BC's TLBC, so candidate = target so the loop quits immediately.

@mfalken
Copy link
Member Author

mfalken commented May 20, 2021

I see. I wonder if the Clipboard spec also wants to disallow the API in iframes that don't have focus. In that case, would returning to "has focus steps" be better?

@domenic
Copy link

domenic commented May 21, 2021

Yes, that's a good point. Although you could make an argument for either behavior, probably the clipboard API spec authors intended the document.hasFocus() behavior.

I apologize for not reading your original PR closer. I think I assumed "has focus steps" was a link to https://html.spec.whatwg.org/#focused, but it's document-specific. So we should probably revert to your original.

@mfalken
Copy link
Member Author

mfalken commented May 21, 2021

No worries, I returned to "has focus steps" then. @garykac does this look good to you?

@mfalken
Copy link
Member Author

mfalken commented May 24, 2021

No worries, I returned to "has focus steps" then. @garykac does this look good to you?

Sorry somehow I didn't realize @domenic has write access. I was assuming only the editors do. If you think it's OK I'm happy if you merge it. For the build error, I also have sent #147.

@domenic
Copy link

domenic commented May 24, 2021

Oh weird, I have write access, strange... I'd love it if we could get an editor to sign off before I touch anything though :).

@garykac
Copy link
Member

garykac commented May 25, 2021

Adding links like this is great because it will make the (eventual) conversion to a more algorithmic spec easier. Thanks!

@garykac garykac merged commit f53cc06 into w3c:main May 25, 2021
github-actions bot added a commit that referenced this pull request May 25, 2021
SHA: f53cc06
Reason: push, by @garykac

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mfalken added a commit to mfalken/alternate-loading-modes that referenced this pull request May 31, 2021
domenic pushed a commit to WICG/nav-speculation that referenced this pull request Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants