/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::cell::{Cell, Ref}; use std::cmp::Ordering; use bitflags::bitflags; use embedder_traits::FocusSequenceNumber; use js::context::{JSContext, NoGC}; use js::gc::RootedGuard; use keyboard_types::{KeyboardEvent as KeyboardTypesEvent, Modifiers}; use script_bindings::cell::DomRefCell; use script_bindings::codegen::GenericBindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use script_bindings::codegen::GenericBindings::ShadowRootBinding::ShadowRootMethods; use script_bindings::codegen::GenericBindings::WindowBinding::WindowMethods; use script_bindings::inheritance::Castable; use script_bindings::root::{Dom, DomRoot}; use servo_base::id::BrowsingContextId; use servo_constellation_traits::{ RemoteFocusOperation, ScriptToConstellationMessage, SequentialFocusDirection, }; use crate::dom::bindings::root::MutNullableDom; use crate::dom::focusevent::FocusEventType; use crate::dom::node::focus::{FocusNavigationScopeOwner, FocusTrigger}; use crate::dom::types::{Element, EventTarget, FocusEvent, HTMLElement, HTMLIFrameElement, Window}; use crate::dom::{Document, Event, EventBubbles, EventCancelable, Node, NodeTraits}; use crate::realms::enter_auto_realm; /// The kind of focusable area a [`FocusableArea`] is. A [`FocusableArea`] may be click focusable, /// sequentially focusable, or both. #[derive(Clone, Copy, Debug, Default, JSTraceable, MallocSizeOf, PartialEq)] pub(crate) struct FocusableAreaKind(u8); bitflags! { impl FocusableAreaKind: u8 { /// /// /// > A focusable area is said to be click focusable if the user agent determines that it is /// > click focusable. User agents should consider focusable areas with non-null tabindex values /// > to be click focusable. const Click = 1 << 0; /// . /// /// > A focusable area is said to be sequentially focusable if it is included in its /// > Document's sequential focus navigation order and the user agent determines that it is /// > sequentially focusable. const Sequential = 1 << 1; } } /// #[derive(Clone, Default, JSTraceable, MallocSizeOf, PartialEq)] #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum FocusableArea { Node { node: Dom, kind: FocusableAreaKind, }, /// The viewport of an `