mirror of
https://github.com/servo/servo.git
synced 2025-06-29 11:33:39 +01:00
2020: run layout after box construction
This commit is contained in:
parent
dc8be8f282
commit
e38cc1a549
4 changed files with 16 additions and 6 deletions
|
@ -27,7 +27,7 @@ mod float;
|
||||||
pub mod inline;
|
pub mod inline;
|
||||||
mod root;
|
mod root;
|
||||||
|
|
||||||
pub use root::BoxTreeRoot;
|
pub use root::{BoxTreeRoot, FragmentTreeRoot};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct BlockFormattingContext {
|
pub(crate) struct BlockFormattingContext {
|
||||||
|
|
|
@ -23,6 +23,7 @@ use style::values::computed::{Length, LengthOrAuto};
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
|
|
||||||
pub struct BoxTreeRoot(BlockFormattingContext);
|
pub struct BoxTreeRoot(BlockFormattingContext);
|
||||||
|
pub struct FragmentTreeRoot(Vec<Fragment>);
|
||||||
|
|
||||||
impl BoxTreeRoot {
|
impl BoxTreeRoot {
|
||||||
pub fn construct<'dom>(
|
pub fn construct<'dom>(
|
||||||
|
@ -95,7 +96,7 @@ fn construct_for_root_element<'dom>(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoxTreeRoot {
|
impl BoxTreeRoot {
|
||||||
fn layout(&self, viewport: geom::Size<CSSPixel>) -> Vec<Fragment> {
|
pub fn layout(&self, viewport: geom::Size<CSSPixel>) -> FragmentTreeRoot {
|
||||||
let initial_containing_block_size = Vec2 {
|
let initial_containing_block_size = Vec2 {
|
||||||
inline: Length::new(viewport.width),
|
inline: Length::new(viewport.width),
|
||||||
block: Length::new(viewport.height),
|
block: Length::new(viewport.height),
|
||||||
|
@ -125,6 +126,6 @@ impl BoxTreeRoot {
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|a| a.layout(&initial_containing_block)),
|
.map(|a| a.layout(&initial_containing_block)),
|
||||||
);
|
);
|
||||||
flow_children.fragments
|
FragmentTreeRoot(flow_children.fragments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod style_ext;
|
||||||
pub mod traversal;
|
pub mod traversal;
|
||||||
pub mod wrapper;
|
pub mod wrapper;
|
||||||
|
|
||||||
pub use flow::BoxTreeRoot;
|
pub use flow::{BoxTreeRoot, FragmentTreeRoot};
|
||||||
|
|
||||||
use crate::dom_traversal::{Contents, NodeExt};
|
use crate::dom_traversal::{Contents, NodeExt};
|
||||||
use crate::flow::{BlockFormattingContext, FlowChildren};
|
use crate::flow::{BlockFormattingContext, FlowChildren};
|
||||||
|
|
|
@ -167,8 +167,11 @@ pub struct LayoutThread {
|
||||||
/// The number of Web fonts that have been requested but not yet loaded.
|
/// The number of Web fonts that have been requested but not yet loaded.
|
||||||
outstanding_web_fonts: Arc<AtomicUsize>,
|
outstanding_web_fonts: Arc<AtomicUsize>,
|
||||||
|
|
||||||
/// The root box tree.
|
/// The root of the box tree.
|
||||||
box_tree_root: RefCell<Option<BoxTreeRoot>>,
|
box_tree_root: RefCell<Option<layout::BoxTreeRoot>>,
|
||||||
|
|
||||||
|
/// The root of the fragment tree.
|
||||||
|
fragment_tree_root: RefCell<Option<layout::FragmentTreeRoot>>,
|
||||||
|
|
||||||
/// The document-specific shared lock used for author-origin stylesheets
|
/// The document-specific shared lock used for author-origin stylesheets
|
||||||
document_shared_lock: Option<SharedRwLock>,
|
document_shared_lock: Option<SharedRwLock>,
|
||||||
|
@ -497,6 +500,7 @@ impl LayoutThread {
|
||||||
_new_animations_receiver: new_animations_receiver,
|
_new_animations_receiver: new_animations_receiver,
|
||||||
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
|
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
|
||||||
box_tree_root: Default::default(),
|
box_tree_root: Default::default(),
|
||||||
|
fragment_tree_root: Default::default(),
|
||||||
document_shared_lock: None,
|
document_shared_lock: None,
|
||||||
epoch: Cell::new(Epoch(0)),
|
epoch: Cell::new(Epoch(0)),
|
||||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||||
|
@ -1084,7 +1088,12 @@ impl LayoutThread {
|
||||||
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
||||||
let box_tree =
|
let box_tree =
|
||||||
BoxTreeRoot::construct(shared, document.root_element().unwrap().as_node());
|
BoxTreeRoot::construct(shared, document.root_element().unwrap().as_node());
|
||||||
|
let fragment_tree = box_tree.layout(Size2D::new(
|
||||||
|
self.viewport_size.width.to_f32_px(),
|
||||||
|
self.viewport_size.height.to_f32_px(),
|
||||||
|
));
|
||||||
*self.box_tree_root.borrow_mut() = Some(box_tree);
|
*self.box_tree_root.borrow_mut() = Some(box_tree);
|
||||||
|
*self.fragment_tree_root.borrow_mut() = Some(fragment_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
for element in elements_with_snapshot {
|
for element in elements_with_snapshot {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue