Skip to content

Commit

Permalink
Make some of layout_2020 private
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Oct 4, 2019
1 parent ec74204 commit 1bb85ed
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 41 deletions.
10 changes: 5 additions & 5 deletions components/layout_2020/dom_traversal.rs
Expand Up @@ -35,12 +35,12 @@ pub(super) enum Contents<Node> {
OfPseudoElement(Vec<PseudoElementContentItem>),
}

pub enum NonReplacedContents<Node> {
pub(super) enum NonReplacedContents<Node> {
OfElement(Node),
OfPseudoElement(Vec<PseudoElementContentItem>),
}

pub enum PseudoElementContentItem {
pub(super) enum PseudoElementContentItem {
Text(String),
Replaced(ReplacedContent),
}
Expand Down Expand Up @@ -258,18 +258,18 @@ pub struct BoxSlot<'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_);
}
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/element_data.rs
Expand Up @@ -19,7 +19,7 @@ pub(super) struct PseudoElementBoxes {
pub after: Arc<AtomicRefCell<Option<LayoutBox>>>,
}

pub enum LayoutBox {
pub(super) enum LayoutBox {
DisplayContents,
BlockLevel(Arc<BlockLevelBox>),
InlineLevel(Arc<InlineLevelBox>),
Expand Down
4 changes: 2 additions & 2 deletions components/layout_2020/flow/construct.rs
Expand Up @@ -123,7 +123,7 @@ struct BlockContainerBuilder<'dom, 'style, Node> {
}

impl BlockContainer {
pub(crate) fn construct<'dom, 'style>(
pub fn construct<'dom, 'style>(
context: &SharedStyleContext<'style>,
block_container_style: &Arc<ComputedValues>,
contents: NonReplacedContents<impl NodeExt<'dom>>,
Expand Down Expand Up @@ -646,7 +646,7 @@ where
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ContainsFloats {
pub(crate) enum ContainsFloats {
No,
Yes,
}
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/flow/float.rs
Expand Up @@ -7,7 +7,7 @@ use servo_arc::Arc;
use style::properties::ComputedValues;

#[derive(Debug)]
pub struct FloatBox {
pub(crate) struct FloatBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext,
}
Expand Down
8 changes: 4 additions & 4 deletions components/layout_2020/flow/inline.rs
Expand Up @@ -16,12 +16,12 @@ use style::values::computed::Length;
use style::Zero;

#[derive(Debug, Default)]
pub struct InlineFormattingContext {
pub(crate) struct InlineFormattingContext {
pub(super) inline_level_boxes: Vec<Arc<InlineLevelBox>>,
}

#[derive(Debug)]
pub enum InlineLevelBox {
pub(crate) enum InlineLevelBox {
InlineBox(InlineBox),
TextRun(TextRun),
OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox),
Expand All @@ -34,7 +34,7 @@ pub enum InlineLevelBox {
}

#[derive(Debug)]
pub struct InlineBox {
pub(crate) struct InlineBox {
pub style: Arc<ComputedValues>,
pub first_fragment: bool,
pub last_fragment: bool,
Expand All @@ -43,7 +43,7 @@ pub struct InlineBox {

/// https://www.w3.org/TR/css-display-3/#css-text-run
#[derive(Debug)]
pub struct TextRun {
pub(crate) struct TextRun {
pub parent_style: Arc<ComputedValues>,
pub text: String,
}
Expand Down
10 changes: 6 additions & 4 deletions components/layout_2020/flow/mod.rs
Expand Up @@ -25,22 +25,24 @@ use style::Zero;
mod construct;
mod float;
pub mod inline;
pub mod root;
mod root;

pub use root::BoxTreeRoot;

#[derive(Debug)]
pub struct BlockFormattingContext {
pub(crate) struct BlockFormattingContext {
pub contents: BlockContainer,
pub contains_floats: bool,
}

#[derive(Debug)]
pub enum BlockContainer {
pub(crate) enum BlockContainer {
BlockLevelBoxes(Vec<Arc<BlockLevelBox>>),
InlineFormattingContext(InlineFormattingContext),
}

#[derive(Debug)]
pub enum BlockLevelBox {
pub(crate) enum BlockLevelBox {
SameFormattingContextBlock {
style: Arc<ComputedValues>,
contents: BlockContainer,
Expand Down
1 change: 0 additions & 1 deletion components/layout_2020/flow/root.rs
Expand Up @@ -22,7 +22,6 @@ use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style_traits::CSSPixel;

#[derive(Debug)]
pub struct BoxTreeRoot(BlockFormattingContext);

impl BoxTreeRoot {
Expand Down
43 changes: 22 additions & 21 deletions components/layout_2020/lib.rs
Expand Up @@ -11,40 +11,41 @@
#[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;
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 crate::flow::root::BoxTreeRoot;
pub use flow::BoxTreeRoot;

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;

/// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug)]
pub enum IndependentFormattingContext {
enum IndependentFormattingContext {
Flow(BlockFormattingContext),

// Not called FC in specs, but behaves close enough
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/positioned.rs
Expand Up @@ -13,7 +13,7 @@ use style::values::computed::{Length, LengthOrAuto, LengthPercentage, LengthPerc
use style::Zero;

#[derive(Debug)]
pub struct AbsolutelyPositionedBox {
pub(crate) struct AbsolutelyPositionedBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext,
}
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/replaced.rs
Expand Up @@ -6,7 +6,7 @@ use crate::dom_traversal::NodeExt;
use style::context::SharedStyleContext;

#[derive(Debug)]
pub enum ReplacedContent {
pub(super) enum ReplacedContent {
// Not implemented yet
}

Expand Down

0 comments on commit 1bb85ed

Please sign in to comment.