Skip to content

Commit

Permalink
Split layout_2020/flexbox.rs into modules
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jun 10, 2020
1 parent dcd25a0 commit dd0d6a2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use super::{FlexContainer, FlexLevelBox};
use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
use crate::dom_traversal::{
BoxSlot, Contents, NodeAndStyleInfo, NodeExt, NonReplacedContents, TraversalHandler,
};
use crate::element_data::LayoutBox;
use crate::formatting_contexts::{IndependentFormattingContext, IndependentLayout};
use crate::formatting_contexts::IndependentFormattingContext;
use crate::fragments::Tag;
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
use crate::positioned::AbsolutelyPositionedBox;
use crate::sizing::{BoxContentSizes, ContentSizes, ContentSizesRequest};
use crate::style_ext::DisplayGeneratingBox;
use crate::ContainingBlock;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use std::borrow::Cow;
use style::values::computed::Length;
use style::values::specified::text::TextDecorationLine;
use style::Zero;

// FIXME: `min-width: auto` is not zero: https://drafts.csswg.org/css-flexbox/#min-size-auto

#[derive(Debug, Serialize)]
pub(crate) struct FlexContainer {
children: Vec<ArcRefCell<FlexLevelBox>>,
}

#[derive(Debug, Serialize)]
pub(crate) enum FlexLevelBox {
FlexItem(IndependentFormattingContext),
OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>),
}

impl FlexContainer {
pub fn construct<'dom>(
Expand Down Expand Up @@ -230,23 +215,3 @@ where
FlexContainer { children }
}
}

impl FlexContainer {
pub(crate) fn layout(
&self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> IndependentLayout {
// FIXME
let _ = layout_context;
let _ = positioning_context;
let _ = containing_block;
let _ = tree_rank;
IndependentLayout {
fragments: Vec::new(),
content_block_size: Length::zero(),
}
}
}
33 changes: 33 additions & 0 deletions components/layout_2020/flexbox/layout.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use super::FlexContainer;
use crate::context::LayoutContext;
use crate::formatting_contexts::IndependentLayout;
use crate::positioned::PositioningContext;
use crate::ContainingBlock;
use style::values::computed::Length;
use style::Zero;

// FIXME: `min-width: auto` is not zero: https://drafts.csswg.org/css-flexbox/#min-size-auto

impl FlexContainer {
pub(crate) fn layout(
&self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> IndependentLayout {
// FIXME
let _ = layout_context;
let _ = positioning_context;
let _ = containing_block;
let _ = tree_rank;
IndependentLayout {
fragments: Vec::new(),
content_block_size: Length::zero(),
}
}
}
21 changes: 21 additions & 0 deletions components/layout_2020/flexbox/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::cell::ArcRefCell;
use crate::formatting_contexts::IndependentFormattingContext;
use crate::positioned::AbsolutelyPositionedBox;

mod construct;
mod layout;

#[derive(Debug, Serialize)]
pub(crate) struct FlexContainer {
children: Vec<ArcRefCell<FlexLevelBox>>,
}

#[derive(Debug, Serialize)]
pub(crate) enum FlexLevelBox {
FlexItem(IndependentFormattingContext),
OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>),
}

0 comments on commit dd0d6a2

Please sign in to comment.