mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Rename IntrinsicSizes to ContentSizes
This commit is contained in:
parent
4e6e31a76c
commit
6a5b8337a1
3 changed files with 24 additions and 17 deletions
|
@ -9,7 +9,7 @@ use crate::formatting_contexts::IndependentFormattingContext;
|
|||
use crate::fragments::CollapsedBlockMargins;
|
||||
use crate::fragments::{AnonymousFragment, BoxFragment, Fragment, TextFragment};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::intrinsic::{outer_intrinsic_inline_sizes, IntrinsicSizes};
|
||||
use crate::sizing::{outer_inline_content_sizes, ContentSizes};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, AbsolutelyPositionedFragment};
|
||||
use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside};
|
||||
use crate::{relative_adjustement, ContainingBlock};
|
||||
|
@ -85,10 +85,10 @@ impl InlineFormattingContext {
|
|||
// Which would have to change if/when
|
||||
// `BlockContainer::construct` parallelize their construction.
|
||||
#[allow(unused)]
|
||||
pub(super) fn intrinsic_sizes(&self, layout_context: &LayoutContext) -> IntrinsicSizes {
|
||||
pub(super) fn content_sizes(&self, layout_context: &LayoutContext) -> ContentSizes {
|
||||
struct Computation {
|
||||
paragraph: IntrinsicSizes,
|
||||
current_line: IntrinsicSizes,
|
||||
paragraph: ContentSizes,
|
||||
current_line: ContentSizes,
|
||||
current_line_percentages: Percentage,
|
||||
}
|
||||
impl Computation {
|
||||
|
@ -149,13 +149,13 @@ impl InlineFormattingContext {
|
|||
InlineLevelBox::Atomic(atomic) => {
|
||||
let inner = || {
|
||||
// atomic
|
||||
// .intrinsic_inline_sizes
|
||||
// .inline_content_sizes
|
||||
// .as_ref()
|
||||
// .expect("Accessing intrinsic size that was not requested")
|
||||
// .expect("Accessing content size that was not requested")
|
||||
// .clone()
|
||||
todo!()
|
||||
};
|
||||
let (outer, pc) = outer_intrinsic_inline_sizes(&atomic.style, &inner);
|
||||
let (outer, pc) = outer_inline_content_sizes(&atomic.style, &inner);
|
||||
self.current_line.min_content += outer.min_content;
|
||||
self.current_line.max_content += outer.max_content;
|
||||
self.current_line_percentages += pc;
|
||||
|
@ -185,8 +185,8 @@ impl InlineFormattingContext {
|
|||
std::mem::replace(x, T::zero())
|
||||
}
|
||||
let mut computation = Computation {
|
||||
paragraph: IntrinsicSizes::zero(),
|
||||
current_line: IntrinsicSizes::zero(),
|
||||
paragraph: ContentSizes::zero(),
|
||||
current_line: ContentSizes::zero(),
|
||||
current_line_percentages: Percentage::zero(),
|
||||
};
|
||||
computation.traverse(layout_context, &self.inline_level_boxes);
|
||||
|
|
|
@ -14,11 +14,11 @@ mod flow;
|
|||
mod formatting_contexts;
|
||||
mod fragments;
|
||||
mod geom;
|
||||
mod intrinsic;
|
||||
mod opaque_node;
|
||||
mod positioned;
|
||||
pub mod query;
|
||||
mod replaced;
|
||||
mod sizing;
|
||||
mod style_ext;
|
||||
pub mod traversal;
|
||||
pub mod wrapper;
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
/* 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/. */
|
||||
|
||||
//! https://drafts.csswg.org/css-sizing/
|
||||
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthPercentage, Percentage};
|
||||
use style::Zero;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IntrinsicSizes {
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct ContentSizes {
|
||||
pub min_content: Length,
|
||||
pub max_content: Length,
|
||||
}
|
||||
|
||||
impl IntrinsicSizes {
|
||||
/// https://drafts.csswg.org/css-sizing/#intrinsic-sizes
|
||||
impl ContentSizes {
|
||||
pub fn zero() -> Self {
|
||||
Self {
|
||||
min_content: Length::zero(),
|
||||
|
@ -32,10 +39,10 @@ impl IntrinsicSizes {
|
|||
}
|
||||
|
||||
/// https://dbaron.org/css/intrinsic/#outer-intrinsic
|
||||
pub(crate) fn outer_intrinsic_inline_sizes(
|
||||
pub(crate) fn outer_inline_content_sizes(
|
||||
style: &ComputedValues,
|
||||
get_inner_intrinsic_sizes: &dyn Fn() -> IntrinsicSizes,
|
||||
) -> (IntrinsicSizes, Percentage) {
|
||||
get_inner_intrinsic_sizes: &dyn Fn() -> ContentSizes,
|
||||
) -> (ContentSizes, Percentage) {
|
||||
// FIXME: account for 'min-width', 'max-width', 'box-sizing'
|
||||
|
||||
let specified = style.box_size().inline;
|
||||
|
@ -44,7 +51,7 @@ pub(crate) fn outer_intrinsic_inline_sizes(
|
|||
// The (inner) min/max-content are only used for 'auto'
|
||||
let mut outer = match specified.non_auto().flatten() {
|
||||
None => get_inner_intrinsic_sizes(),
|
||||
Some(length) => IntrinsicSizes {
|
||||
Some(length) => ContentSizes {
|
||||
min_content: length,
|
||||
max_content: length,
|
||||
},
|
Loading…
Add table
Add a link
Reference in a new issue