Repository: servo/servo
File: components/script/dom/toggleevent.rs (Rust)

Code before:
use script_bindings::inheritance::Castable;
use stylo_atoms::Atom;

use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindings::ToggleEventBinding;
use crate::dom::bindings::codegen::Bindings::ToggleEventBinding::ToggleEventMethods;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::element::Element;
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::eventtarget::EventTarget;
use crate::dom::node::Node;
use crate::dom::types::Window;
use crate::script_runtime::CanGc;

#[dom_struct]
pub(crate) struct ToggleEvent {
    event: Event,
    old_state: DOMString,
    new_state: DOMString,
    source: Option<DomRoot<Element>>,
}

impl ToggleEvent {
    pub(crate) fn new_inherited(
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
    ) -> ToggleEvent {
        ToggleEvent {
            event: Event::new_inherited(),
            old_state,
            new_state,
            source,
        }
    }

    #[allow(clippy::too_many_arguments)]
    pub(crate) fn new(
        window: &Window,
        type_: Atom,
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
        can_gc: CanGc,
    ) -> DomRoot<ToggleEvent> {
        Self::new_with_proto(

Review comment (suggestion):
Nit: add spec comments to members of the struct

```suggestion
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-oldstate>
    old_state: DOMString,
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-newstate>
    new_state: DOMString,
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-source>
    source: Option<DomRoot<Element>>,
```

Code after:
use script_bindings::inheritance::Castable;
use stylo_atoms::Atom;

use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindings::ToggleEventBinding;
use crate::dom::bindings::codegen::Bindings::ToggleEventBinding::ToggleEventMethods;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::element::Element;
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::eventtarget::EventTarget;
use crate::dom::node::Node;
use crate::dom::types::Window;
use crate::script_runtime::CanGc;

#[dom_struct]
pub(crate) struct ToggleEvent {
    event: Event,
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-oldstate>
    old_state: DOMString,
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-newstate>
    new_state: DOMString,
    /// <https://html.spec.whatwg.org/multipage/#dom-toggleevent-source>
    source: Option<DomRoot<Element>>,
}

impl ToggleEvent {
    pub(crate) fn new_inherited(
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
    ) -> ToggleEvent {
        ToggleEvent {
            event: Event::new_inherited(),
            old_state,
            new_state,
            source,
        }
    }

    #[allow(clippy::too_many_arguments)]
    pub(crate) fn new(
        window: &Window,
        type_: Atom,
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,