script: Add FocusOptions argument to Element.focus and implement FocusOptions.preventScroll (#38495)

This is an implementation of the `prevent_scroll` feature in the focus
transaction system. It allows to control whether focusing an element
should prevent scrolling or not.

Spec:
https://html.spec.whatwg.org/multipage/interaction.html#dom-focusoptions-preventscroll
Testing: Existing WPT tests

Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
This commit is contained in:
Abdelrahman Hossam 2025-08-22 22:05:32 +08:00 committed by GitHub
parent 2ac8665e03
commit 176e42d36d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 95 additions and 60 deletions

View file

@ -812,6 +812,10 @@ Dictionaries = {
'derives': ['Clone', 'MallocSizeOf'],
},
'FocusOptions': {
'derives': ['Clone', 'MallocSizeOf']
},
'FontFaceDescriptors': {
'derives': ['Clone', 'MallocSizeOf']
},

View file

@ -35,7 +35,6 @@ interface HTMLElement : Element {
undefined click();
// [CEReactions]
// attribute long tabIndex;
undefined focus();
undefined blur();
// [CEReactions]
// attribute DOMString accessKey;

View file

@ -9,12 +9,17 @@
* liability, trademark and document use rules apply.
*/
dictionary FocusOptions {
boolean preventScroll = false;
// boolean focusVisible;
};
interface mixin HTMLOrSVGElement {
// [SameObject] readonly attribute DOMStringMap dataset;
attribute DOMString nonce; // intentionally no [CEReactions]
[CEReactions] attribute boolean autofocus;
// [CEReactions] attribute long tabIndex;
// undefined focus(optional FocusOptions options = {});
undefined focus(optional FocusOptions options = {});
// undefined blur();
};