Call BoxTreeRoot::construct from layout_thread_2020

This commit is contained in:
Anthony Ramine 2019-10-03 18:08:16 +02:00
parent 9706cd497d
commit ec74204fa0
12 changed files with 51 additions and 42 deletions

View file

@ -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,
}
@ -35,12 +35,12 @@ pub(super) enum Contents<Node> {
OfPseudoElement(Vec<PseudoElementContentItem>),
}
pub(super) enum NonReplacedContents<Node> {
pub enum NonReplacedContents<Node> {
OfElement(Node),
OfPseudoElement(Vec<PseudoElementContentItem>),
}
pub(super) enum PseudoElementContentItem {
pub enum PseudoElementContentItem {
Text(String),
Replaced(ReplacedContent),
}
@ -252,7 +252,7 @@ where
unimplemented!()
}
pub(super) struct BoxSlot<'dom> {
pub struct BoxSlot<'dom> {
slot: Option<Arc<AtomicRefCell<Option<LayoutBox>>>>,
marker: marker<&'dom ()>,
}
@ -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>;

View file

@ -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>>,
}
@ -19,7 +19,7 @@ pub(super) struct PseudoElementBoxes {
pub after: Arc<AtomicRefCell<Option<LayoutBox>>>,
}
pub(super) enum LayoutBox {
pub enum LayoutBox {
DisplayContents,
BlockLevel(Arc<BlockLevelBox>),
InlineLevel(Arc<InlineLevelBox>),

View file

@ -123,7 +123,7 @@ struct BlockContainerBuilder<'dom, 'style, Node> {
}
impl BlockContainer {
pub fn construct<'dom, 'style>(
pub(crate) fn construct<'dom, 'style>(
context: &SharedStyleContext<'style>,
block_container_style: &Arc<ComputedValues>,
contents: NonReplacedContents<impl NodeExt<'dom>>,
@ -646,7 +646,7 @@ where
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ContainsFloats {
pub enum ContainsFloats {
No,
Yes,
}

View file

@ -7,7 +7,7 @@ use servo_arc::Arc;
use style::properties::ComputedValues;
#[derive(Debug)]
pub(crate) struct FloatBox {
pub struct FloatBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext,
}

View file

@ -16,12 +16,12 @@ use style::values::computed::Length;
use style::Zero;
#[derive(Debug, Default)]
pub(crate) struct InlineFormattingContext {
pub struct InlineFormattingContext {
pub(super) inline_level_boxes: Vec<Arc<InlineLevelBox>>,
}
#[derive(Debug)]
pub(crate) enum InlineLevelBox {
pub enum InlineLevelBox {
InlineBox(InlineBox),
TextRun(TextRun),
OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox),
@ -34,7 +34,7 @@ pub(crate) enum InlineLevelBox {
}
#[derive(Debug)]
pub(crate) struct InlineBox {
pub struct InlineBox {
pub style: Arc<ComputedValues>,
pub first_fragment: bool,
pub last_fragment: bool,
@ -43,7 +43,7 @@ pub(crate) struct InlineBox {
/// https://www.w3.org/TR/css-display-3/#css-text-run
#[derive(Debug)]
pub(crate) struct TextRun {
pub struct TextRun {
pub parent_style: Arc<ComputedValues>,
pub text: String,
}

View file

@ -25,22 +25,22 @@ use style::Zero;
mod construct;
mod float;
pub mod inline;
mod root;
pub mod root;
#[derive(Debug)]
pub(crate) struct BlockFormattingContext {
pub struct BlockFormattingContext {
pub contents: BlockContainer,
pub contains_floats: bool,
}
#[derive(Debug)]
pub(crate) enum BlockContainer {
pub enum BlockContainer {
BlockLevelBoxes(Vec<Arc<BlockLevelBox>>),
InlineFormattingContext(InlineFormattingContext),
}
#[derive(Debug)]
pub(crate) enum BlockLevelBox {
pub enum BlockLevelBox {
SameFormattingContextBlock {
style: Arc<ComputedValues>,
contents: BlockContainer,

View file

@ -22,17 +22,8 @@ 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);
#[derive(Debug)]
pub struct BoxTreeRoot(BlockFormattingContext);
impl BoxTreeRoot {
pub fn construct<'dom>(

View file

@ -11,8 +11,18 @@
#[macro_use]
extern crate serde;
use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::{BlockFormattingContext, FlowChildren};
use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedFragment;
use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Direction, Position, WritingMode};
use servo_arc::Arc;
use std::convert::TryInto;
use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style::values::specified::box_::DisplayInside;
use style::Zero;
pub mod context;
@ -30,20 +40,11 @@ pub mod style_ext;
pub mod traversal;
pub mod wrapper;
use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::{BlockFormattingContext, FlowChildren};
use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedFragment;
use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Direction, Position, WritingMode};
use servo_arc::Arc;
use std::convert::TryInto;
use style::context::SharedStyleContext;
use style::values::specified::box_::DisplayInside;
pub use crate::flow::root::BoxTreeRoot;
/// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug)]
enum IndependentFormattingContext {
pub enum IndependentFormattingContext {
Flow(BlockFormattingContext),
// Not called FC in specs, but behaves close enough

View file

@ -13,7 +13,7 @@ use style::values::computed::{Length, LengthOrAuto, LengthPercentage, LengthPerc
use style::Zero;
#[derive(Debug)]
pub(crate) struct AbsolutelyPositionedBox {
pub struct AbsolutelyPositionedBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext,
}

View file

@ -6,7 +6,7 @@ use crate::dom_traversal::NodeExt;
use style::context::SharedStyleContext;
#[derive(Debug)]
pub(super) enum ReplacedContent {
pub enum ReplacedContent {
// Not implemented yet
}