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