-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Update autofocus processing algorithm #4763
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great; this seems to meet all the requirements from linked threads, and generally be a more sensible and user-friendly model.
Most of my suggestions are nits, but some are about clarifications where I'm not 100% sure I understood the intent.
source
Outdated
</p></li> | ||
</ol> | ||
|
||
<li><p>If <var>element</var> is a <span>focusable area</span>, then set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to break the three things down into 1. 2. 3.
It may also be good to add a note about when something might reach this step while not being a focusable area. (E.g. it became hidden.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: Added a sub-<ol>.
Added a note <p>. Actually, we add any element with autofocus attribute to candidates list without checking focusable area or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let's get some tests written so we can see how this compares to Gecko/WebKit behavior, i.e. how much of a change this would be for them. I still remain hopeful that even without that, they'll chime in to let us know if the algorithm makes sense.
source
Outdated
|
||
<li> | ||
<p>If <var>topDocument</var>'s <span data-x="focused area of the document">focused area</span> | ||
is not <var>topDocument</var> itself, or <var>topDocument</var>'s <span>target element</span> is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found checking 'target element' of a document was not helpful because it is set asynchronously and an autofocus element can get focus before setting 'target element'. I'd like to change "document's target element is not null" to " document's URL's fragment is not empty".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url's fragment may change too during page load. But I guess that isn't really an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that URL fragment is empty, a user indicated a specific scroll position, and the user doesn't want to change focused element by autofocus
attribute.
However I have never heard complain about it. I think we can address it later if web developers complain.
Test PR: web-platform-tests/wpt#17929 |
source
Outdated
@@ -91156,6 +91241,11 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> { | |||
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, update the | |||
rendering or user interface of that <code>Document</code> and its <span | |||
data-x="concept-document-bc">browsing context</span> to reflect the current state.</p></li> | |||
|
|||
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, <span>flush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind this position? So far it seems most things go before rAF callbacks, except intersection observer. So I would normally put this before...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because 'focusable area' check needs style computation, and 'focusing steps' needs layout result. I'd like to put this step after finishing rendering in order to avoid an additional style computation and layout caused by 'flush autofocus candidates' steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes sense. Can you add a source code comment (<!-- ... -->
), or maybe a <p class="note">
, explaining this? I'm not sure whether a <p class="note">
makes sense because the spec doesn't talk about style computation/etc., but at least a source code comment would help future spec editors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I added a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit concerned about this. We do want to have done style computation, but do we want to have done painting? Focusing things will generally scroll to them and whatnot. Will that just get picked up on the next tick of the rendering loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, "after paint" timing is better for kicking the flush steps.
I couldn't find places better than here in the HTML specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally seems reasonable to me. @smaug---, thoughts?
source
Outdated
@@ -91156,6 +91241,11 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> { | |||
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, update the | |||
rendering or user interface of that <code>Document</code> and its <span | |||
data-x="concept-document-bc">browsing context</span> to reflect the current state.</p></li> | |||
|
|||
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, <span>flush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit concerned about this. We do want to have done style computation, but do we want to have done painting? Focusing things will generally scroll to them and whatnot. Will that just get picked up on the next tick of the rendering loop?
I feel like we're getting close to merging this. According to the test results, the new behavior doesn't match any browser exactly, but instead is an attempt to take advantage of the fact that browsers are not interoperable, in order to produce a good, reasonable specification that matches some union of their behaviors and meets user expectations. @bzbarsky, would you like us to hold off for @smaug----'s review? Also another attempt at pinging @rniwa, as he's been helpful and active reviewing other focus stuff recently. |
I'm going to look at this soon. I'm finishing up my work to update WebKit's |
source
Outdated
|
||
<li><p>If <span data-x="concept-document-url">URL</span>'s | ||
<span data-x="concept-url-fragment">fragment</span> of any <code>Document</code> in | ||
<var>inclusiveAncestorDocuments</var> is not empty, then <span>continue</span>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just because of it is hard to see the context here, worth to check 'continue' makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
candidates contains elements from various frames. So inclusiveAncestorDocuemnts for the next element in candidates may be different.
- Run focusing steps after an animation frame - Don't autofocus if the top-level document has focused area - Don't autofocus if one of ancestor document has :target element. This fixes whatwg#3551 and whatwg#4645
…tofocus candidates'
- Add top-level browsing context identification check
81b2976
to
59ef44d
Compare
Rebased on ToT. |
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929 UltraBlame original commit: 99752f25f5f5ed857cc819607882fdb49e2d0509
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929 UltraBlame original commit: 99752f25f5f5ed857cc819607882fdb49e2d0509
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929 UltraBlame original commit: 99752f25f5f5ed857cc819607882fdb49e2d0509
autofocus candidates</span> for that <code>Document</code> if its | ||
<span data-x="concept-document-bc">browsing context</span> is a | ||
<span>top-level browsing context</span>.</p></li> | ||
<!-- The above step is placed just after 'update the rendering' step in order to avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right. We've already marked the painting time. Why are we focusing an element and potentially arbitrary author scripts for arbitrary amount of time?
Also, "update the rendering or user interface of that Document and its browsing context to reflect the current state." updates the painting of the document. If we had focused an element, there is a good chance, the focus ring may should be drawn around the newly focused element. Yet autofocusing step being after this rendering update would mean that it would necessarily be one frame / rAF later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking this in #4992.
This fixes #3551 and #4645
(See WHATWG Working Mode: Changes for more details.)
/interaction.html ( diff )
/webappapis.html ( diff )