mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Compute content sizes lazily in layout 2020
This commit is contained in:
parent
ba5568a0a6
commit
235df94f2e
11 changed files with 176 additions and 247 deletions
|
@ -18,11 +18,13 @@ use crate::fragments::{
|
|||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
|
||||
use crate::replaced::ReplacedContent;
|
||||
use crate::sizing::{self, ContentSizes};
|
||||
use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin};
|
||||
use crate::ContainingBlock;
|
||||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||
use rayon_croissant::ParallelIteratorExt;
|
||||
use servo_arc::Arc;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto};
|
||||
use style::Zero;
|
||||
|
@ -132,6 +134,29 @@ impl BlockContainer {
|
|||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn inline_content_sizes(
|
||||
&self,
|
||||
layout_context: &LayoutContext,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> ContentSizes {
|
||||
match &self {
|
||||
Self::BlockLevelBoxes(boxes) => {
|
||||
let mut content_sizes = ContentSizes::zero();
|
||||
for box_ in boxes {
|
||||
content_sizes.max_assign(
|
||||
&box_
|
||||
.borrow_mut()
|
||||
.inline_content_sizes(layout_context, containing_block_writing_mode),
|
||||
);
|
||||
}
|
||||
content_sizes
|
||||
},
|
||||
Self::InlineFormattingContext(context) => {
|
||||
context.inline_content_sizes(layout_context, containing_block_writing_mode)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn layout_block_level_children(
|
||||
|
@ -350,6 +375,28 @@ impl BlockLevelBox {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn inline_content_sizes(
|
||||
&mut self,
|
||||
layout_context: &LayoutContext,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> ContentSizes {
|
||||
match self {
|
||||
Self::SameFormattingContextBlock {
|
||||
style, contents, ..
|
||||
} => sizing::outer_inline(style, containing_block_writing_mode, || {
|
||||
contents.inline_content_sizes(layout_context, style.writing_mode)
|
||||
}),
|
||||
Self::Independent(independent) => {
|
||||
independent.outer_inline(layout_context, containing_block_writing_mode)
|
||||
},
|
||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) => ContentSizes::zero(),
|
||||
BlockLevelBox::OutOfFlowFloatBox(_box_) => {
|
||||
// TODO: Actually implement that.
|
||||
ContentSizes::zero()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum NonReplacedContents<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue