Make some of layout_2020 private

This commit is contained in:
Simon Sapin 2019-10-04 17:51:05 +02:00
parent ec74204fa0
commit 1bb85ed05b
10 changed files with 43 additions and 41 deletions

View file

@ -35,12 +35,12 @@ pub(super) enum Contents<Node> {
OfPseudoElement(Vec<PseudoElementContentItem>), OfPseudoElement(Vec<PseudoElementContentItem>),
} }
pub enum NonReplacedContents<Node> { pub(super) enum NonReplacedContents<Node> {
OfElement(Node), OfElement(Node),
OfPseudoElement(Vec<PseudoElementContentItem>), OfPseudoElement(Vec<PseudoElementContentItem>),
} }
pub enum PseudoElementContentItem { pub(super) enum PseudoElementContentItem {
Text(String), Text(String),
Replaced(ReplacedContent), Replaced(ReplacedContent),
} }
@ -258,18 +258,18 @@ pub struct BoxSlot<'dom> {
} }
impl BoxSlot<'_> { 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; *slot.borrow_mut() = None;
let slot = Some(slot); let slot = Some(slot);
Self { slot, marker } Self { slot, marker }
} }
pub fn dummy() -> Self { pub(crate) fn dummy() -> Self {
let slot = None; let slot = None;
Self { slot, marker } 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 { if let Some(slot) = &mut self.slot {
*slot.borrow_mut() = Some(box_); *slot.borrow_mut() = Some(box_);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -22,7 +22,6 @@ use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto}; use style::values::computed::{Length, LengthOrAuto};
use style_traits::CSSPixel; use style_traits::CSSPixel;
#[derive(Debug)]
pub struct BoxTreeRoot(BlockFormattingContext); pub struct BoxTreeRoot(BlockFormattingContext);
impl BoxTreeRoot { impl BoxTreeRoot {

View file

@ -11,6 +11,27 @@
#[macro_use] #[macro_use]
extern crate serde; extern crate serde;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style::Zero;
pub mod context;
pub mod data;
mod dom_traversal;
mod element_data;
mod flow;
mod fragments;
mod geom;
mod opaque_node;
mod positioned;
pub mod query;
mod replaced;
mod style_ext;
pub mod traversal;
pub mod wrapper;
pub use flow::BoxTreeRoot;
use crate::dom_traversal::{Contents, NodeExt}; use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::{BlockFormattingContext, FlowChildren}; use crate::flow::{BlockFormattingContext, FlowChildren};
use crate::geom::flow_relative::Vec2; use crate::geom::flow_relative::Vec2;
@ -20,31 +41,11 @@ use crate::style_ext::{ComputedValuesExt, Direction, Position, WritingMode};
use servo_arc::Arc; use servo_arc::Arc;
use std::convert::TryInto; use std::convert::TryInto;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style::values::specified::box_::DisplayInside; use style::values::specified::box_::DisplayInside;
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;
pub mod query;
pub mod replaced;
pub mod style_ext;
pub mod traversal;
pub mod wrapper;
pub use crate::flow::root::BoxTreeRoot;
/// https://drafts.csswg.org/css-display/#independent-formatting-context /// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug)] #[derive(Debug)]
pub enum IndependentFormattingContext { enum IndependentFormattingContext {
Flow(BlockFormattingContext), Flow(BlockFormattingContext),
// Not called FC in specs, but behaves close enough // 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; use style::Zero;
#[derive(Debug)] #[derive(Debug)]
pub struct AbsolutelyPositionedBox { pub(crate) struct AbsolutelyPositionedBox {
pub style: Arc<ComputedValues>, pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext, pub contents: IndependentFormattingContext,
} }

View file

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