Skip to main content

script/dom/testing/
accessibilityupdateresult.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4use dom_struct::dom_struct;
5use js::context::JSContext;
6use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
7
8use crate::dom::bindings::codegen::Bindings::ServoTestUtilsBinding::AccessibilityUpdateResultMethods;
9use crate::dom::bindings::root::DomRoot;
10use crate::dom::globalscope::GlobalScope;
11
12#[dom_struct]
13pub(crate) struct AccessibilityUpdateResult {
14    reflector_: Reflector,
15    nodes_updated_from_dom: u32,
16    nodes_updated_from_tree: u32,
17    nodes_in_tree_update: u32,
18}
19
20impl AccessibilityUpdateResult {
21    pub(crate) fn new_inherited(
22        nodes_updated_from_dom: u32,
23        nodes_updated_from_tree: u32,
24        nodes_in_tree_update: u32,
25    ) -> Self {
26        Self {
27            reflector_: Reflector::new(),
28            nodes_updated_from_dom,
29            nodes_updated_from_tree,
30            nodes_in_tree_update,
31        }
32    }
33
34    pub(crate) fn new(
35        cx: &mut JSContext,
36        global: &GlobalScope,
37        nodes_updated_from_dom: u32,
38        nodes_updated_from_tree: u32,
39        nodes_in_tree_update: u32,
40    ) -> DomRoot<Self> {
41        reflect_dom_object_with_cx(
42            Box::new(Self::new_inherited(
43                nodes_updated_from_dom,
44                nodes_updated_from_tree,
45                nodes_in_tree_update,
46            )),
47            global,
48            cx,
49        )
50    }
51}
52
53impl AccessibilityUpdateResultMethods<crate::DomTypeHolder> for AccessibilityUpdateResult {
54    fn NodesUpdatedFromDom(&self) -> u32 {
55        self.nodes_updated_from_dom
56    }
57
58    fn NodesUpdatedFromTree(&self) -> u32 {
59        self.nodes_updated_from_tree
60    }
61
62    fn NodesInTreeUpdate(&self) -> u32 {
63        self.nodes_in_tree_update
64    }
65}