mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Rename MozLength to Size, and MaxLength to MaxSize.
MozLength is not a very descriptive name. If we're going to use it in both Gecko and Servo we may as well name it something more accurate. I would've chosen `ContentSize` per CSS2[1][2] if it wasn't a lie in presence of box-sizing. I don't have better ideas than `Size`, given that. [1]: https://drafts.csswg.org/css2/visudet.html#propdef-width [2]: https://drafts.csswg.org/css2/box.html#content-width Differential Revision: https://phabricator.services.mozilla.com/D19280
This commit is contained in:
parent
7ed6b9d3ce
commit
c2819365f0
26 changed files with 280 additions and 333 deletions
|
@ -11,10 +11,8 @@ use std::cmp::{max, min};
|
|||
use std::fmt;
|
||||
use style::logical_geometry::{LogicalMargin, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::MaxLength;
|
||||
use style::values::computed::{
|
||||
LengthPercentageOrAuto, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto,
|
||||
};
|
||||
use style::values::computed::MaxSize;
|
||||
use style::values::computed::{LengthPercentageOrAuto, Size};
|
||||
|
||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -137,15 +135,17 @@ impl MarginCollapseInfo {
|
|||
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
||||
may_collapse_through = may_collapse_through &&
|
||||
match fragment.style().content_block_size() {
|
||||
NonNegativeLengthPercentageOrAuto::Auto => true,
|
||||
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||
Size::Auto => true,
|
||||
Size::LengthPercentage(ref lp) => {
|
||||
lp.is_definitely_zero() ||
|
||||
lp.maybe_to_used_value(containing_block_size).is_none()
|
||||
},
|
||||
};
|
||||
|
||||
if may_collapse_through {
|
||||
if fragment.style().min_block_size().is_definitely_zero() {
|
||||
if fragment.style.min_block_size().is_auto() ||
|
||||
fragment.style().min_block_size().is_definitely_zero()
|
||||
{
|
||||
FinalMarginState::MarginsCollapseThrough
|
||||
} else {
|
||||
// If the fragment has non-zero min-block-size, margins may not
|
||||
|
@ -498,13 +498,10 @@ impl MaybeAuto {
|
|||
/// Receive an optional container size and return used value for width or height.
|
||||
///
|
||||
/// `style_length`: content size as given in the CSS.
|
||||
pub fn style_length(
|
||||
style_length: NonNegativeLengthPercentageOrAuto,
|
||||
container_size: Option<Au>,
|
||||
) -> MaybeAuto {
|
||||
pub fn style_length(style_length: Size, container_size: Option<Au>) -> MaybeAuto {
|
||||
match style_length {
|
||||
NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
||||
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||
Size::Auto => MaybeAuto::Auto,
|
||||
Size::LengthPercentage(ref lp) => {
|
||||
MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size))
|
||||
},
|
||||
}
|
||||
|
@ -571,17 +568,20 @@ impl SizeConstraint {
|
|||
/// Create a `SizeConstraint` for an axis.
|
||||
pub fn new(
|
||||
container_size: Option<Au>,
|
||||
min_size: NonNegativeLengthPercentage,
|
||||
max_size: MaxLength,
|
||||
min_size: Size,
|
||||
max_size: MaxSize,
|
||||
border: Option<Au>,
|
||||
) -> SizeConstraint {
|
||||
let mut min_size = min_size
|
||||
.maybe_to_used_value(container_size)
|
||||
.unwrap_or(Au(0));
|
||||
let mut min_size = match min_size {
|
||||
Size::Auto => Au(0),
|
||||
Size::LengthPercentage(ref lp) => {
|
||||
lp.maybe_to_used_value(container_size).unwrap_or(Au(0))
|
||||
},
|
||||
};
|
||||
|
||||
let mut max_size = match max_size {
|
||||
MaxLength::None => None,
|
||||
MaxLength::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size),
|
||||
MaxSize::None => None,
|
||||
MaxSize::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size),
|
||||
};
|
||||
|
||||
// Make sure max size is not smaller than min size.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue