mirror of
https://github.com/servo/servo
synced 2026-04-26 01:25:32 +02:00
Servo has a lot of comments like this: ```rust // https://example-spec.com/#do-the-thing fn do_the_thing() {} ``` and I keep turning these into doc comments whenever I'm working close to one of them. Doing so allows me to hover over a function call in an IDE and open its specification without having to jump to the function definition first. This change fixes all of these comments at once. This was done using `find components -name '*.rs' -exec perl -i -0777 -pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`. Note that these comments should be doc comments even within trait `impl` blocks, because rustdoc will use them as fallback documentation when the method definition on the trait does not have documentation. Testing: Comments only, no testing required Preparation for https://github.com/servo/servo/pull/39552 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
45 lines
1.6 KiB
Rust
45 lines
1.6 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 crate::dom::element::Element;
|
|
use crate::dom::event::Event;
|
|
use crate::dom::eventtarget::EventTarget;
|
|
use crate::dom::html::htmlinputelement::InputActivationState;
|
|
use crate::script_runtime::CanGc;
|
|
|
|
/// Trait for elements with defined activation behavior
|
|
pub(crate) trait Activatable {
|
|
fn as_element(&self) -> ∈
|
|
|
|
// 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, _can_gc: CanGc) -> Option<InputActivationState> {
|
|
None
|
|
}
|
|
|
|
/// <https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior>
|
|
fn legacy_canceled_activation_behavior(
|
|
&self,
|
|
_state_before: Option<InputActivationState>,
|
|
_can_gc: CanGc,
|
|
) {
|
|
}
|
|
|
|
// 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, event: &Event, target: &EventTarget, can_gc: CanGc);
|
|
|
|
/// <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);
|
|
}
|
|
}
|