Nacre/vendor/servo-script/dom/activation.rs
astar76 0ecfd0f573 S031: root due timers in vendored servo-script (R5-01 SIGSEGV), crash-adblock regression smoke
fire_timer moved due timers into an unrooted Vec; a GC inside one callback swept
the functions of the timers still waiting. Heavy-web reruns and cargo test still pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:38:47 -06:00

50 lines
1.7 KiB
Rust

/* 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 js::context::JSContext;
use crate::dom::element::Element;
use crate::dom::event::Event;
use crate::dom::eventtarget::EventTarget;
use crate::dom::html::form_controls::htmlinputelement::InputActivationState;
/// Trait for elements with defined activation behavior
pub(crate) trait Activatable {
fn as_element(&self) -> &Element;
// Is this particular instance of the element activatable?
fn is_instance_activatable(&self) -> bool;
/// <https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior>
fn legacy_pre_activation_behavior(&self, _cx: &mut JSContext) -> Option<InputActivationState> {
None
}
/// <https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior>
fn legacy_canceled_activation_behavior(
&self,
_cx: &mut JSContext,
_state_before: Option<InputActivationState>,
) {
}
// https://dom.spec.whatwg.org/#eventtarget-activation-behavior
// event and target are used only by HTMLAnchorElement, in the case
// where the target is an <img ismap> so the href gets coordinates appended
fn activation_behavior(
&self,
cx: &mut js::context::JSContext,
event: &Event,
target: &EventTarget,
);
/// <https://html.spec.whatwg.org/multipage/#concept-selector-active>
fn enter_formal_activation_state(&self) {
self.as_element().set_active_state(true);
}
fn exit_formal_activation_state(&self) {
self.as_element().set_active_state(false);
}
}