mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
layout: Cache content block size contributions (#33964)
This is the first part of caching intermediary layout during flexbox layout. A later change will try to reuse these layouts, when possible, for actual item layout and re-layout due to stretching. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
7015e0fb5f
commit
01c9ecfe01
3 changed files with 57 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
|||
* 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 app_units::Au;
|
||||
use geom::{FlexAxis, MainStartCrossStart};
|
||||
use serde::Serialize;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
|
@ -112,9 +113,17 @@ pub(crate) enum FlexLevelBox {
|
|||
OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct FlexItemBox {
|
||||
independent_formatting_context: IndependentFormattingContext,
|
||||
#[serde(skip)]
|
||||
cached_layout: ArcRefCell<Option<FlexItemLayoutCache>>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for FlexItemBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("FlexItemBox")
|
||||
}
|
||||
}
|
||||
|
||||
impl FlexItemBox {
|
||||
|
@ -126,3 +135,20 @@ impl FlexItemBox {
|
|||
self.independent_formatting_context.base_fragment_info()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FlexItemLayoutCacheDescriptor {
|
||||
containing_block_inline_size: Au,
|
||||
content_block_size: Au,
|
||||
}
|
||||
|
||||
impl FlexItemLayoutCacheDescriptor {
|
||||
fn compatible_with_size(&self, inline: Au) -> bool {
|
||||
inline == self.containing_block_inline_size
|
||||
}
|
||||
}
|
||||
|
||||
/// A cache to avoid multiple layouts during flexbox layout.
|
||||
struct FlexItemLayoutCache {
|
||||
descriptor: FlexItemLayoutCacheDescriptor,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue