mirror of
https://github.com/servo/servo.git
synced 2025-06-29 03:23:41 +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;
|
||||
mod root;
|
||||
|
||||
pub use root::BoxTreeRoot;
|
||||
pub use root::{BoxTreeRoot, FragmentTreeRoot};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlockFormattingContext {
|
||||
|
|
|
@ -23,6 +23,7 @@ use style::values::computed::{Length, LengthOrAuto};
|
|||
use style_traits::CSSPixel;
|
||||
|
||||
pub struct BoxTreeRoot(BlockFormattingContext);
|
||||
pub struct FragmentTreeRoot(Vec<Fragment>);
|
||||
|
||||
impl BoxTreeRoot {
|
||||
pub fn construct<'dom>(
|
||||
|
@ -95,7 +96,7 @@ fn construct_for_root_element<'dom>(
|
|||
}
|
||||
|
||||
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 {
|
||||
inline: Length::new(viewport.width),
|
||||
block: Length::new(viewport.height),
|
||||
|
@ -125,6 +126,6 @@ impl BoxTreeRoot {
|
|||
.par_iter()
|
||||
.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 wrapper;
|
||||
|
||||
pub use flow::BoxTreeRoot;
|
||||
pub use flow::{BoxTreeRoot, FragmentTreeRoot};
|
||||
|
||||
use crate::dom_traversal::{Contents, NodeExt};
|
||||
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.
|
||||
outstanding_web_fonts: Arc<AtomicUsize>,
|
||||
|
||||
/// The root box tree.
|
||||
box_tree_root: RefCell<Option<BoxTreeRoot>>,
|
||||
/// The root of the box tree.
|
||||
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
|
||||
document_shared_lock: Option<SharedRwLock>,
|
||||
|
@ -497,6 +500,7 @@ impl LayoutThread {
|
|||
_new_animations_receiver: new_animations_receiver,
|
||||
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
|
||||
box_tree_root: Default::default(),
|
||||
fragment_tree_root: Default::default(),
|
||||
document_shared_lock: None,
|
||||
epoch: Cell::new(Epoch(0)),
|
||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||
|
@ -1084,7 +1088,12 @@ impl LayoutThread {
|
|||
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
||||
let box_tree =
|
||||
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.fragment_tree_root.borrow_mut() = Some(fragment_tree);
|
||||
}
|
||||
|
||||
for element in elements_with_snapshot {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue