mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Distinguish cached inline_content_sizes()
from uncached ones (#34595)
Several structs and enums had a `inline_content_sizes()` method, but it wasn't clear which ones would try to cache the result, and which ones would always compute it. Therefore, this performs some clarifying renaming: - Cached ones stay as `inline_content_sizes()` - Uncached ones become `compute_inline_content_sizes()` Also, to simplify calls to `LayoutBoxBase::inline_content_sizes()`, `compute_inline_content_sizes()` is moved into a new trait. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
874e106924
commit
f7e2ec3a0f
9 changed files with 152 additions and 125 deletions
|
@ -29,7 +29,7 @@ use crate::context::LayoutContext;
|
|||
use crate::dom::NodeExt;
|
||||
use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment};
|
||||
use crate::geom::{LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize, Size};
|
||||
use crate::sizing::{ContentSizes, InlineContentSizesResult};
|
||||
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
|
||||
use crate::style_ext::{AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBM};
|
||||
use crate::{ConstraintSpace, ContainingBlock, SizeConstraint};
|
||||
|
||||
|
@ -278,29 +278,6 @@ impl ReplacedContents {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn inline_content_sizes(
|
||||
&self,
|
||||
_: &LayoutContext,
|
||||
constraint_space: &ConstraintSpace,
|
||||
) -> InlineContentSizesResult {
|
||||
let get_inline_fallback_size = || {
|
||||
let writing_mode = constraint_space.writing_mode;
|
||||
self.flow_relative_natural_size(writing_mode)
|
||||
.inline
|
||||
.unwrap_or_else(|| Self::flow_relative_default_object_size(writing_mode).inline)
|
||||
};
|
||||
let inline_content_size = self.content_size(
|
||||
Direction::Inline,
|
||||
constraint_space.preferred_aspect_ratio,
|
||||
&|| constraint_space.block_size,
|
||||
&get_inline_fallback_size,
|
||||
);
|
||||
InlineContentSizesResult {
|
||||
sizes: inline_content_size.into(),
|
||||
depends_on_block_constraints: constraint_space.preferred_aspect_ratio.is_some(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_fragments(
|
||||
&self,
|
||||
style: &ServoArc<ComputedValues>,
|
||||
|
@ -606,6 +583,31 @@ impl ReplacedContents {
|
|||
}
|
||||
}
|
||||
|
||||
impl ComputeInlineContentSizes for ReplacedContents {
|
||||
fn compute_inline_content_sizes(
|
||||
&self,
|
||||
_: &LayoutContext,
|
||||
constraint_space: &ConstraintSpace,
|
||||
) -> InlineContentSizesResult {
|
||||
let get_inline_fallback_size = || {
|
||||
let writing_mode = constraint_space.writing_mode;
|
||||
self.flow_relative_natural_size(writing_mode)
|
||||
.inline
|
||||
.unwrap_or_else(|| Self::flow_relative_default_object_size(writing_mode).inline)
|
||||
};
|
||||
let inline_content_size = self.content_size(
|
||||
Direction::Inline,
|
||||
constraint_space.preferred_aspect_ratio,
|
||||
&|| constraint_space.block_size,
|
||||
&get_inline_fallback_size,
|
||||
);
|
||||
InlineContentSizesResult {
|
||||
sizes: inline_content_size.into(),
|
||||
depends_on_block_constraints: constraint_space.preferred_aspect_ratio.is_some(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn try_to_parse_image_data_url(string: &str) -> Option<Url> {
|
||||
if !string.starts_with("data:") {
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue