mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
layout: Add a LayoutBoxBase
to inline boxes (#36513)
`LayoutBoxBase` will soon contain laid out `Fragment`s of a box tree node in order to facilitate incremental layout and also layout queries. This is currently missing for inline boxes, so this change adds a `LayoutBoxBase` to them. Testing: This should not change any observable behavior, so existing WPT suites should suffice for testing. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
440739090f
commit
d46a17a487
6 changed files with 29 additions and 24 deletions
|
@ -27,8 +27,8 @@ pub(crate) struct LayoutBoxBase {
|
|||
pub base_fragment_info: BaseFragmentInfo,
|
||||
pub style: Arc<ComputedValues>,
|
||||
pub cached_inline_content_size:
|
||||
AtomicRefCell<Option<(SizeConstraint, InlineContentSizesResult)>>,
|
||||
pub cached_layout_result: AtomicRefCell<Option<CacheableLayoutResultAndInputs>>,
|
||||
AtomicRefCell<Option<Box<(SizeConstraint, InlineContentSizesResult)>>>,
|
||||
pub cached_layout_result: AtomicRefCell<Option<Box<CacheableLayoutResultAndInputs>>>,
|
||||
}
|
||||
|
||||
impl LayoutBoxBase {
|
||||
|
@ -50,7 +50,8 @@ impl LayoutBoxBase {
|
|||
layout_box: &impl ComputeInlineContentSizes,
|
||||
) -> InlineContentSizesResult {
|
||||
let mut cache = self.cached_inline_content_size.borrow_mut();
|
||||
if let Some((previous_cb_block_size, result)) = *cache {
|
||||
if let Some(cached_inline_content_size) = cache.as_ref() {
|
||||
let (previous_cb_block_size, result) = **cached_inline_content_size;
|
||||
if !result.depends_on_block_constraints ||
|
||||
previous_cb_block_size == constraint_space.block_size
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ impl LayoutBoxBase {
|
|||
}
|
||||
|
||||
let result = layout_box.compute_inline_content_sizes(layout_context, constraint_space);
|
||||
*cache = Some((constraint_space.block_size, result));
|
||||
*cache = Some(Box::new((constraint_space.block_size, result)));
|
||||
result
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue