script/dom/testing/
layoutresult.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::gc::MutableHandleValue;
6use script_bindings::domstring::DOMString;
7use script_bindings::reflector::Reflector;
8
9use crate::dom::bindings::codegen::Bindings::ServoTestUtilsBinding::LayoutResultMethods;
10use crate::dom::bindings::import::base::SafeJSContext;
11use crate::dom::bindings::reflector::reflect_dom_object;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::bindings::utils::to_frozen_array;
14use crate::dom::globalscope::GlobalScope;
15use crate::script_runtime::CanGc;
16
17#[dom_struct]
18pub(crate) struct LayoutResult {
19    reflector_: Reflector,
20    phases: Vec<DOMString>,
21}
22
23impl LayoutResult {
24    pub(crate) fn new_inherited(phases: Vec<DOMString>) -> Self {
25        Self {
26            reflector_: Reflector::new(),
27            phases,
28        }
29    }
30
31    pub(crate) fn new(
32        global: &GlobalScope,
33        phases: Vec<DOMString>,
34        can_gc: CanGc,
35    ) -> DomRoot<Self> {
36        reflect_dom_object(Box::new(Self::new_inherited(phases)), global, can_gc)
37    }
38}
39
40impl LayoutResultMethods<crate::DomTypeHolder> for LayoutResult {
41    fn Phases(&self, cx: SafeJSContext, can_gc: CanGc, return_value: MutableHandleValue) {
42        to_frozen_array(&self.phases, cx, return_value, can_gc);
43    }
44}