mirror of
https://github.com/servo/servo
synced 2026-05-09 08:32:31 +02:00
Now `ServoTestUtils.forceLayout()` will provide the number of fragments that have been restyled and rebuilt. This will be useful to test that incremental layout works well. Testing: Adds a test using this new API --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Luke Warlow <lwarlow@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
71 lines
2.0 KiB
Rust
71 lines
2.0 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 dom_struct::dom_struct;
|
|
use js::gc::MutableHandleValue;
|
|
use script_bindings::domstring::DOMString;
|
|
use script_bindings::reflector::Reflector;
|
|
|
|
use crate::dom::bindings::codegen::Bindings::ServoTestUtilsBinding::LayoutResultMethods;
|
|
use crate::dom::bindings::import::base::SafeJSContext;
|
|
use crate::dom::bindings::reflector::reflect_dom_object;
|
|
use crate::dom::bindings::root::DomRoot;
|
|
use crate::dom::bindings::utils::to_frozen_array;
|
|
use crate::dom::globalscope::GlobalScope;
|
|
use crate::script_runtime::CanGc;
|
|
|
|
#[dom_struct]
|
|
pub(crate) struct LayoutResult {
|
|
reflector_: Reflector,
|
|
phases: Vec<DOMString>,
|
|
rebuilt_fragment_count: u32,
|
|
restyle_fragment_count: u32,
|
|
}
|
|
|
|
impl LayoutResult {
|
|
pub(crate) fn new_inherited(
|
|
phases: Vec<DOMString>,
|
|
rebuilt_fragment_count: u32,
|
|
restyle_fragment_count: u32,
|
|
) -> Self {
|
|
Self {
|
|
reflector_: Reflector::new(),
|
|
phases,
|
|
rebuilt_fragment_count,
|
|
restyle_fragment_count,
|
|
}
|
|
}
|
|
|
|
pub(crate) fn new(
|
|
global: &GlobalScope,
|
|
phases: Vec<DOMString>,
|
|
rebuilt_fragment_count: u32,
|
|
restyle_fragment_count: u32,
|
|
can_gc: CanGc,
|
|
) -> DomRoot<Self> {
|
|
reflect_dom_object(
|
|
Box::new(Self::new_inherited(
|
|
phases,
|
|
rebuilt_fragment_count,
|
|
restyle_fragment_count,
|
|
)),
|
|
global,
|
|
can_gc,
|
|
)
|
|
}
|
|
}
|
|
|
|
impl LayoutResultMethods<crate::DomTypeHolder> for LayoutResult {
|
|
fn Phases(&self, cx: SafeJSContext, can_gc: CanGc, return_value: MutableHandleValue) {
|
|
to_frozen_array(&self.phases, cx, return_value, can_gc);
|
|
}
|
|
|
|
fn RebuiltFragmentCount(&self) -> u32 {
|
|
self.rebuilt_fragment_count
|
|
}
|
|
|
|
fn RestyleFragmentCount(&self) -> u32 {
|
|
self.restyle_fragment_count
|
|
}
|
|
}
|