mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #24360 - servo:build-box-tree, r=SimonSapin
Call BoxTreeRoot::construct from layout_thread_2020 <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24360) <!-- Reviewable:end -->
This commit is contained in:
commit
36f70f5ab1
7 changed files with 38 additions and 27 deletions
|
@ -17,7 +17,7 @@ use style::properties::ComputedValues;
|
|||
use style::selector_parser::PseudoElement;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) enum WhichPseudoElement {
|
||||
pub enum WhichPseudoElement {
|
||||
Before,
|
||||
After,
|
||||
}
|
||||
|
@ -252,24 +252,24 @@ where
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
pub(super) struct BoxSlot<'dom> {
|
||||
pub struct BoxSlot<'dom> {
|
||||
slot: Option<Arc<AtomicRefCell<Option<LayoutBox>>>>,
|
||||
marker: marker<&'dom ()>,
|
||||
}
|
||||
|
||||
impl BoxSlot<'_> {
|
||||
pub fn new(slot: Arc<AtomicRefCell<Option<LayoutBox>>>) -> Self {
|
||||
pub(crate) fn new(slot: Arc<AtomicRefCell<Option<LayoutBox>>>) -> Self {
|
||||
*slot.borrow_mut() = None;
|
||||
let slot = Some(slot);
|
||||
Self { slot, marker }
|
||||
}
|
||||
|
||||
pub fn dummy() -> Self {
|
||||
pub(crate) fn dummy() -> Self {
|
||||
let slot = None;
|
||||
Self { slot, marker }
|
||||
}
|
||||
|
||||
pub fn set(mut self, box_: LayoutBox) {
|
||||
pub(crate) fn set(mut self, box_: LayoutBox) {
|
||||
if let Some(slot) = &mut self.slot {
|
||||
*slot.borrow_mut() = Some(box_);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ impl Drop for BoxSlot<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
|
||||
pub trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
|
||||
fn is_element(self) -> bool;
|
||||
fn as_text(self) -> Option<String>;
|
||||
fn first_child(self) -> Option<Self>;
|
||||
|
|
|
@ -8,7 +8,7 @@ use atomic_refcell::AtomicRefCell;
|
|||
use servo_arc::Arc;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct LayoutDataForElement {
|
||||
pub struct LayoutDataForElement {
|
||||
pub(super) self_box: Arc<AtomicRefCell<Option<LayoutBox>>>,
|
||||
pub(super) pseudo_elements: Option<Box<PseudoElementBoxes>>,
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ mod float;
|
|||
pub mod inline;
|
||||
mod root;
|
||||
|
||||
pub use root::BoxTreeRoot;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlockFormattingContext {
|
||||
pub contents: BlockContainer,
|
||||
|
|
|
@ -22,17 +22,7 @@ use style::properties::ComputedValues;
|
|||
use style::values::computed::{Length, LengthOrAuto};
|
||||
use style_traits::CSSPixel;
|
||||
|
||||
// FIXME
|
||||
// impl crate::dom::Document {
|
||||
// pub(crate) fn layout(
|
||||
// &self,
|
||||
// viewport: crate::geom::Size<crate::geom::CssPx>,
|
||||
// ) -> Vec<Fragment> {
|
||||
// BoxTreeRoot::construct(self).layout(viewport)
|
||||
// }
|
||||
// }
|
||||
|
||||
struct BoxTreeRoot(BlockFormattingContext);
|
||||
pub struct BoxTreeRoot(BlockFormattingContext);
|
||||
|
||||
impl BoxTreeRoot {
|
||||
pub fn construct<'dom>(
|
||||
|
|
|
@ -17,19 +17,21 @@ use style::Zero;
|
|||
|
||||
pub mod context;
|
||||
pub mod data;
|
||||
pub mod dom_traversal;
|
||||
pub mod element_data;
|
||||
pub mod flow;
|
||||
pub mod fragments;
|
||||
pub mod geom;
|
||||
pub mod opaque_node;
|
||||
pub mod positioned;
|
||||
mod dom_traversal;
|
||||
mod element_data;
|
||||
mod flow;
|
||||
mod fragments;
|
||||
mod geom;
|
||||
mod opaque_node;
|
||||
mod positioned;
|
||||
pub mod query;
|
||||
pub mod replaced;
|
||||
pub mod style_ext;
|
||||
mod replaced;
|
||||
mod style_ext;
|
||||
pub mod traversal;
|
||||
pub mod wrapper;
|
||||
|
||||
pub use flow::BoxTreeRoot;
|
||||
|
||||
use crate::dom_traversal::{Contents, NodeExt};
|
||||
use crate::flow::{BlockFormattingContext, FlowChildren};
|
||||
use crate::geom::flow_relative::Vec2;
|
||||
|
|
|
@ -109,6 +109,13 @@ pub struct ServoLayoutNode<'a> {
|
|||
chain: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
// Those are supposed to be sound, but they aren't because the entire system
|
||||
// between script and layout so far has been designed to work around their
|
||||
// absence. Switching the entire thing to the inert crate infra will help.
|
||||
|
||||
unsafe impl Send for ServoLayoutNode<'_> {}
|
||||
unsafe impl Sync for ServoLayoutNode<'_> {}
|
||||
|
||||
impl<'ln> Debug for ServoLayoutNode<'ln> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(el) = self.as_element() {
|
||||
|
|
|
@ -45,6 +45,7 @@ use layout::query::{
|
|||
process_text_index_request,
|
||||
};
|
||||
use layout::traversal::RecalcStyle;
|
||||
use layout::BoxTreeRoot;
|
||||
use layout_traits::LayoutThreadFactory;
|
||||
use libc::c_void;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
@ -166,6 +167,9 @@ 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 document-specific shared lock used for author-origin stylesheets
|
||||
document_shared_lock: Option<SharedRwLock>,
|
||||
|
||||
|
@ -492,6 +496,7 @@ impl LayoutThread {
|
|||
new_animations_sender: new_animations_sender,
|
||||
_new_animations_receiver: new_animations_receiver,
|
||||
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
|
||||
box_tree_root: Default::default(),
|
||||
document_shared_lock: None,
|
||||
epoch: Cell::new(Epoch(0)),
|
||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||
|
@ -1075,6 +1080,11 @@ impl LayoutThread {
|
|||
|
||||
if token.should_traverse() {
|
||||
driver::traverse_dom(&traversal, token, None);
|
||||
|
||||
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
||||
let box_tree =
|
||||
BoxTreeRoot::construct(shared, document.root_element().unwrap().as_node());
|
||||
*self.box_tree_root.borrow_mut() = Some(box_tree);
|
||||
}
|
||||
|
||||
for element in elements_with_snapshot {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue