mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix servo build.
This commit is contained in:
parent
1cb235c81a
commit
6daebcc5df
18 changed files with 210 additions and 170 deletions
|
@ -67,7 +67,9 @@ use style::context::SharedStyleContext;
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::computed::{LengthPercentageOrAuto, LengthPercentageOrNone};
|
use style::values::computed::{
|
||||||
|
LengthPercentageOrAuto, MaxLength, NonNegativeLengthPercentageOrAuto,
|
||||||
|
};
|
||||||
|
|
||||||
/// Information specific to floated blocks.
|
/// Information specific to floated blocks.
|
||||||
#[derive(Clone, Serialize)]
|
#[derive(Clone, Serialize)]
|
||||||
|
@ -419,15 +421,15 @@ impl CandidateBSizeIterator {
|
||||||
// `min-height` and `max-height`, percentage values are ignored.
|
// `min-height` and `max-height`, percentage values are ignored.
|
||||||
|
|
||||||
let block_size = match fragment.style.content_block_size() {
|
let block_size = match fragment.style.content_block_size() {
|
||||||
LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
MaybeAuto::from_option(lp.maybe_to_used_value(block_container_block_size))
|
MaybeAuto::from_option(lp.maybe_to_used_value(block_container_block_size))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_block_size = match fragment.style.max_block_size() {
|
let max_block_size = match fragment.style.max_block_size() {
|
||||||
LengthPercentageOrNone::None => None,
|
MaxLength::None => None,
|
||||||
LengthPercentageOrNone::LengthPercentage(ref lp) => {
|
MaxLength::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(block_container_block_size)
|
lp.maybe_to_used_value(block_container_block_size)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1400,7 +1402,7 @@ impl BlockFlow {
|
||||||
let content_block_size = self.fragment.style().content_block_size();
|
let content_block_size = self.fragment.style().content_block_size();
|
||||||
|
|
||||||
match content_block_size {
|
match content_block_size {
|
||||||
LengthPercentageOrAuto::Auto => {
|
NonNegativeLengthPercentageOrAuto::Auto => {
|
||||||
let container_size = containing_block_size?;
|
let container_size = containing_block_size?;
|
||||||
let (block_start, block_end) = {
|
let (block_start, block_end) = {
|
||||||
let position = self.fragment.style().logical_position();
|
let position = self.fragment.style().logical_position();
|
||||||
|
@ -1435,7 +1437,7 @@ impl BlockFlow {
|
||||||
(_, _) => None,
|
(_, _) => None,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(containing_block_size)
|
lp.maybe_to_used_value(containing_block_size)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1797,15 +1799,12 @@ impl BlockFlow {
|
||||||
.to_used_value(self.base.block_container_inline_size);
|
.to_used_value(self.base.block_container_inline_size);
|
||||||
let specified_inline_size = self.fragment.style().content_inline_size();
|
let specified_inline_size = self.fragment.style().content_inline_size();
|
||||||
let container_size = self.base.block_container_inline_size;
|
let container_size = self.base.block_container_inline_size;
|
||||||
let inline_size = if let MaybeAuto::Specified(size) =
|
let inline_size = match specified_inline_size.to_used_value(container_size) {
|
||||||
MaybeAuto::from_style(specified_inline_size, container_size)
|
Some(size) => match self.fragment.style().get_position().box_sizing {
|
||||||
{
|
|
||||||
match self.fragment.style().get_position().box_sizing {
|
|
||||||
BoxSizing::BorderBox => size,
|
BoxSizing::BorderBox => size,
|
||||||
BoxSizing::ContentBox => size + self.fragment.border_padding.inline_start_end(),
|
BoxSizing::ContentBox => size + self.fragment.border_padding.inline_start_end(),
|
||||||
}
|
},
|
||||||
} else {
|
None => max(min_inline_size, min(available_inline_size, max_inline_size)),
|
||||||
max(min_inline_size, min(available_inline_size, max_inline_size))
|
|
||||||
};
|
};
|
||||||
self.base.position.size.inline = inline_size + self.fragment.margin.inline_start_end();
|
self.base.position.size.inline = inline_size + self.fragment.margin.inline_start_end();
|
||||||
|
|
||||||
|
@ -2026,7 +2025,7 @@ impl BlockFlow {
|
||||||
// If `max-width` is set, then don't perform this speculation. We guess that the
|
// If `max-width` is set, then don't perform this speculation. We guess that the
|
||||||
// page set `max-width` in order to avoid hitting floats. The search box on Google
|
// page set `max-width` in order to avoid hitting floats. The search box on Google
|
||||||
// SERPs falls into this category.
|
// SERPs falls into this category.
|
||||||
if self.fragment.style.max_inline_size() != LengthPercentageOrNone::None {
|
if self.fragment.style.max_inline_size() != MaxLength::None {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2156,9 +2155,10 @@ impl Flow for BlockFlow {
|
||||||
fn bubble_inline_sizes(&mut self) {
|
fn bubble_inline_sizes(&mut self) {
|
||||||
// If this block has a fixed width, just use that for the minimum and preferred width,
|
// If this block has a fixed width, just use that for the minimum and preferred width,
|
||||||
// rather than bubbling up children inline width.
|
// rather than bubbling up children inline width.
|
||||||
|
// FIXME(emilio): This should probably be writing-mode-aware.
|
||||||
let consult_children = match self.fragment.style().get_position().width {
|
let consult_children = match self.fragment.style().get_position().width {
|
||||||
LengthPercentageOrAuto::Auto => true,
|
NonNegativeLengthPercentageOrAuto::Auto => true,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None).is_none()
|
lp.maybe_to_used_value(None).is_none()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -2846,9 +2846,16 @@ pub trait ISizeAndMarginsComputer {
|
||||||
parent_flow_inline_size: Au,
|
parent_flow_inline_size: Au,
|
||||||
shared_context: &SharedStyleContext,
|
shared_context: &SharedStyleContext,
|
||||||
) -> MaybeAuto {
|
) -> MaybeAuto {
|
||||||
MaybeAuto::from_style(
|
MaybeAuto::from_option(
|
||||||
block.fragment().style().content_inline_size(),
|
block
|
||||||
self.containing_block_inline_size(block, parent_flow_inline_size, shared_context),
|
.fragment()
|
||||||
|
.style()
|
||||||
|
.content_inline_size()
|
||||||
|
.to_used_value(self.containing_block_inline_size(
|
||||||
|
block,
|
||||||
|
parent_flow_inline_size,
|
||||||
|
shared_context,
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,14 @@
|
||||||
// FIXME(rust-lang/rust#26264): Remove GenericBackgroundSize.
|
// FIXME(rust-lang/rust#26264): Remove GenericBackgroundSize.
|
||||||
|
|
||||||
use crate::display_list::border;
|
use crate::display_list::border;
|
||||||
use crate::model::MaybeAuto;
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
||||||
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
|
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
|
||||||
use style::computed_values::background_clip::single_value::T as BackgroundClip;
|
use style::computed_values::background_clip::single_value::T as BackgroundClip;
|
||||||
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
||||||
use style::properties::style_structs::Background;
|
use style::properties::style_structs::Background;
|
||||||
use style::values::computed::{BackgroundSize, LengthPercentageOrAuto};
|
use style::values::computed::{BackgroundSize, NonNegativeLengthPercentageOrAuto};
|
||||||
use style::values::generics::background::BackgroundSize as GenericBackgroundSize;
|
use style::values::generics::background::BackgroundSize as GenericBackgroundSize;
|
||||||
use style::values::generics::NonNegative;
|
|
||||||
use style::values::specified::background::BackgroundRepeatKeyword;
|
use style::values::specified::background::BackgroundRepeatKeyword;
|
||||||
use webrender_api::BorderRadius;
|
use webrender_api::BorderRadius;
|
||||||
|
|
||||||
|
@ -60,10 +58,12 @@ fn compute_background_image_size(
|
||||||
None => match bg_size {
|
None => match bg_size {
|
||||||
GenericBackgroundSize::Cover | GenericBackgroundSize::Contain => bounds_size,
|
GenericBackgroundSize::Cover | GenericBackgroundSize::Contain => bounds_size,
|
||||||
GenericBackgroundSize::Explicit { width, height } => Size2D::new(
|
GenericBackgroundSize::Explicit { width, height } => Size2D::new(
|
||||||
MaybeAuto::from_style(width.0, bounds_size.width)
|
width
|
||||||
.specified_or_default(bounds_size.width),
|
.to_used_value(bounds_size.width)
|
||||||
MaybeAuto::from_style(height.0, bounds_size.height)
|
.unwrap_or(bounds_size.width),
|
||||||
.specified_or_default(bounds_size.height),
|
height
|
||||||
|
.to_used_value(bounds_size.height)
|
||||||
|
.unwrap_or(bounds_size.height),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
Some(own_size) => {
|
Some(own_size) => {
|
||||||
|
@ -88,30 +88,34 @@ fn compute_background_image_size(
|
||||||
(
|
(
|
||||||
GenericBackgroundSize::Explicit {
|
GenericBackgroundSize::Explicit {
|
||||||
width,
|
width,
|
||||||
height: NonNegative(LengthPercentageOrAuto::Auto),
|
height: NonNegativeLengthPercentageOrAuto::Auto,
|
||||||
},
|
},
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
let width = MaybeAuto::from_style(width.0, bounds_size.width)
|
let width = width
|
||||||
.specified_or_default(own_size.width);
|
.to_used_value(bounds_size.width)
|
||||||
|
.unwrap_or(own_size.width);
|
||||||
Size2D::new(width, width.scale_by(image_aspect_ratio.recip()))
|
Size2D::new(width, width.scale_by(image_aspect_ratio.recip()))
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
GenericBackgroundSize::Explicit {
|
GenericBackgroundSize::Explicit {
|
||||||
width: NonNegative(LengthPercentageOrAuto::Auto),
|
width: NonNegativeLengthPercentageOrAuto::Auto,
|
||||||
height,
|
height,
|
||||||
},
|
},
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
let height = MaybeAuto::from_style(height.0, bounds_size.height)
|
let height = height
|
||||||
.specified_or_default(own_size.height);
|
.to_used_value(bounds_size.height)
|
||||||
|
.unwrap_or(own_size.height);
|
||||||
Size2D::new(height.scale_by(image_aspect_ratio), height)
|
Size2D::new(height.scale_by(image_aspect_ratio), height)
|
||||||
},
|
},
|
||||||
(GenericBackgroundSize::Explicit { width, height }, _) => Size2D::new(
|
(GenericBackgroundSize::Explicit { width, height }, _) => Size2D::new(
|
||||||
MaybeAuto::from_style(width.0, bounds_size.width)
|
width
|
||||||
.specified_or_default(own_size.width),
|
.to_used_value(bounds_size.width)
|
||||||
MaybeAuto::from_style(height.0, bounds_size.height)
|
.unwrap_or(own_size.width),
|
||||||
.specified_or_default(own_size.height),
|
height
|
||||||
|
.to_used_value(bounds_size.height)
|
||||||
|
.unwrap_or(own_size.height),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -764,10 +764,12 @@ impl Fragment {
|
||||||
get_cyclic(&style.get_background().background_size.0, i).clone();
|
get_cyclic(&style.get_background().background_size.0, i).clone();
|
||||||
let size = match background_size {
|
let size = match background_size {
|
||||||
BackgroundSize::Explicit { width, height } => Size2D::new(
|
BackgroundSize::Explicit { width, height } => Size2D::new(
|
||||||
MaybeAuto::from_style(width.0, bounding_box_size.width)
|
width
|
||||||
.specified_or_default(bounding_box_size.width),
|
.to_used_value(bounding_box_size.width)
|
||||||
MaybeAuto::from_style(height.0, bounding_box_size.height)
|
.unwrap_or(bounding_box_size.width),
|
||||||
.specified_or_default(bounding_box_size.height),
|
height
|
||||||
|
.to_used_value(bounding_box_size.height)
|
||||||
|
.unwrap_or(bounding_box_size.height),
|
||||||
),
|
),
|
||||||
_ => bounding_box_size,
|
_ => bounding_box_size,
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,9 @@ use style::logical_geometry::{Direction, LogicalSize};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::computed::flex::FlexBasis;
|
use style::values::computed::flex::FlexBasis;
|
||||||
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, LengthPercentageOrNone};
|
use style::values::computed::{
|
||||||
|
MaxLength, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto,
|
||||||
|
};
|
||||||
use style::values::generics::flex::FlexBasis as GenericFlexBasis;
|
use style::values::generics::flex::FlexBasis as GenericFlexBasis;
|
||||||
|
|
||||||
/// The size of an axis. May be a specified size, a min/max
|
/// The size of an axis. May be a specified size, a min/max
|
||||||
|
@ -45,16 +47,16 @@ impl AxisSize {
|
||||||
/// Generate a new available cross or main axis size from the specified size of the container,
|
/// Generate a new available cross or main axis size from the specified size of the container,
|
||||||
/// containing block size, min constraint, and max constraint
|
/// containing block size, min constraint, and max constraint
|
||||||
pub fn new(
|
pub fn new(
|
||||||
size: LengthPercentageOrAuto,
|
size: NonNegativeLengthPercentageOrAuto,
|
||||||
content_size: Option<Au>,
|
content_size: Option<Au>,
|
||||||
min: LengthPercentage,
|
min: NonNegativeLengthPercentage,
|
||||||
max: LengthPercentageOrNone,
|
max: MaxLength,
|
||||||
) -> AxisSize {
|
) -> AxisSize {
|
||||||
match size {
|
match size {
|
||||||
LengthPercentageOrAuto::Auto => {
|
NonNegativeLengthPercentageOrAuto::Auto => {
|
||||||
AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None))
|
AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None))
|
||||||
},
|
},
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
match lp.maybe_to_used_value(content_size) {
|
match lp.maybe_to_used_value(content_size) {
|
||||||
Some(length) => AxisSize::Definite(length),
|
Some(length) => AxisSize::Definite(length),
|
||||||
None => AxisSize::Infinite,
|
None => AxisSize::Infinite,
|
||||||
|
@ -70,7 +72,7 @@ impl AxisSize {
|
||||||
/// is definite after flex size resolving.
|
/// is definite after flex size resolving.
|
||||||
fn from_flex_basis(
|
fn from_flex_basis(
|
||||||
flex_basis: FlexBasis,
|
flex_basis: FlexBasis,
|
||||||
main_length: LengthPercentageOrAuto,
|
main_length: NonNegativeLengthPercentageOrAuto,
|
||||||
containing_length: Au,
|
containing_length: Au,
|
||||||
) -> MaybeAuto {
|
) -> MaybeAuto {
|
||||||
let width = match flex_basis {
|
let width = match flex_basis {
|
||||||
|
@ -78,9 +80,16 @@ fn from_flex_basis(
|
||||||
GenericFlexBasis::Width(width) => width,
|
GenericFlexBasis::Width(width) => width,
|
||||||
};
|
};
|
||||||
|
|
||||||
match width.0 {
|
let width = match width {
|
||||||
LengthPercentageOrAuto::Auto => MaybeAuto::from_style(main_length, containing_length),
|
NonNegativeLengthPercentageOrAuto::Auto => main_length,
|
||||||
other => MaybeAuto::from_style(other, containing_length),
|
_ => width,
|
||||||
|
};
|
||||||
|
|
||||||
|
match width {
|
||||||
|
NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
||||||
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
|
MaybeAuto::Specified(lp.to_used_value(containing_length))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,18 +233,18 @@ impl FlexItem {
|
||||||
let mut margin_count = 0;
|
let mut margin_count = 0;
|
||||||
match direction {
|
match direction {
|
||||||
Direction::Inline => {
|
Direction::Inline => {
|
||||||
if margin.inline_start == LengthPercentageOrAuto::Auto {
|
if margin.inline_start.is_auto() {
|
||||||
margin_count += 1;
|
margin_count += 1;
|
||||||
}
|
}
|
||||||
if margin.inline_end == LengthPercentageOrAuto::Auto {
|
if margin.inline_end.is_auto() {
|
||||||
margin_count += 1;
|
margin_count += 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Direction::Block => {
|
Direction::Block => {
|
||||||
if margin.block_start == LengthPercentageOrAuto::Auto {
|
if margin.block_start.is_auto() {
|
||||||
margin_count += 1;
|
margin_count += 1;
|
||||||
}
|
}
|
||||||
if margin.block_end == LengthPercentageOrAuto::Auto {
|
if margin.block_end.is_auto() {
|
||||||
margin_count += 1;
|
margin_count += 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -816,7 +825,7 @@ impl FlexFlow {
|
||||||
// cross size of item should equal to the line size if any auto margin exists.
|
// cross size of item should equal to the line size if any auto margin exists.
|
||||||
// https://drafts.csswg.org/css-flexbox/#algo-cross-margins
|
// https://drafts.csswg.org/css-flexbox/#algo-cross-margins
|
||||||
if auto_margin_count > 0 {
|
if auto_margin_count > 0 {
|
||||||
if margin.block_start == LengthPercentageOrAuto::Auto {
|
if margin.block_start.is_auto() {
|
||||||
margin_block_start = if free_space < Au(0) {
|
margin_block_start = if free_space < Au(0) {
|
||||||
Au(0)
|
Au(0)
|
||||||
} else {
|
} else {
|
||||||
|
@ -830,7 +839,7 @@ impl FlexFlow {
|
||||||
|
|
||||||
let self_align = block.fragment.style().get_position().align_self;
|
let self_align = block.fragment.style().get_position().align_self;
|
||||||
if self_align == AlignSelf::Stretch &&
|
if self_align == AlignSelf::Stretch &&
|
||||||
block.fragment.style().content_block_size() == LengthPercentageOrAuto::Auto
|
block.fragment.style().content_block_size().is_auto()
|
||||||
{
|
{
|
||||||
free_space = Au(0);
|
free_space = Au(0);
|
||||||
block.base.block_container_explicit_block_size = Some(line.cross_size);
|
block.base.block_container_explicit_block_size = Some(line.cross_size);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use std::cmp::{max, min};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::computed_values::float::T as StyleFloat;
|
use style::computed_values::float::T as StyleFloat;
|
||||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||||
use style::values::computed::LengthPercentageOrAuto;
|
use style::values::computed::NonNegativeLengthPercentageOrAuto;
|
||||||
|
|
||||||
/// The kind of float: left or right.
|
/// The kind of float: left or right.
|
||||||
#[derive(Clone, Copy, Debug, Serialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
|
@ -549,9 +549,9 @@ impl SpeculatedFloatPlacement {
|
||||||
// might flow around this float.
|
// might flow around this float.
|
||||||
let inline_size = flow.as_block().fragment.style.content_inline_size();
|
let inline_size = flow.as_block().fragment.style.content_inline_size();
|
||||||
let fixed = match inline_size {
|
let fixed = match inline_size {
|
||||||
LengthPercentageOrAuto::Auto => false,
|
NonNegativeLengthPercentageOrAuto::Auto => false,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.is_definitely_zero() || lp.maybe_to_used_value(None).is_some()
|
lp.0.is_definitely_zero() || lp.0.maybe_to_used_value(None).is_some()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if !fixed {
|
if !fixed {
|
||||||
|
|
|
@ -61,7 +61,9 @@ use style::selector_parser::RestyleDamage;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::str::char_is_whitespace;
|
use style::str::char_is_whitespace;
|
||||||
use style::values::computed::counters::ContentItem;
|
use style::values::computed::counters::ContentItem;
|
||||||
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto};
|
use style::values::computed::{
|
||||||
|
LengthPercentage, LengthPercentageOrAuto, NonNegativeLengthPercentageOrAuto,
|
||||||
|
};
|
||||||
use style::values::generics::box_::{Perspective, VerticalAlign};
|
use style::values::generics::box_::{Perspective, VerticalAlign};
|
||||||
use style::values::generics::transform;
|
use style::values::generics::transform;
|
||||||
use webrender_api::{self, LayoutTransform};
|
use webrender_api::{self, LayoutTransform};
|
||||||
|
@ -985,8 +987,10 @@ impl Fragment {
|
||||||
if flags.contains(
|
if flags.contains(
|
||||||
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED,
|
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED,
|
||||||
) {
|
) {
|
||||||
specified =
|
specified = style
|
||||||
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero();
|
.content_inline_size()
|
||||||
|
.to_used_value(Au(0))
|
||||||
|
.unwrap_or(Au(0));
|
||||||
specified = max(style.min_inline_size().to_used_value(Au(0)), specified);
|
specified = max(style.min_inline_size().to_used_value(Au(0)), specified);
|
||||||
if let Some(max) = style.max_inline_size().to_used_value(Au(0)) {
|
if let Some(max) = style.max_inline_size().to_used_value(Au(0)) {
|
||||||
specified = min(specified, max)
|
specified = min(specified, max)
|
||||||
|
@ -1611,8 +1615,8 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Svg(_) => {
|
SpecificFragmentInfo::Svg(_) => {
|
||||||
let inline_size = match self.style.content_inline_size() {
|
let inline_size = match self.style.content_inline_size() {
|
||||||
LengthPercentageOrAuto::Auto => None,
|
NonNegativeLengthPercentageOrAuto::Auto => None,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None)
|
lp.maybe_to_used_value(None)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
#![feature(type_alias_enum_variants)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
|
|
@ -11,8 +11,10 @@ use std::cmp::{max, min};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::logical_geometry::{LogicalMargin, WritingMode};
|
use style::logical_geometry::{LogicalMargin, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::LengthPercentageOrNone;
|
use style::values::computed::MaxLength;
|
||||||
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto};
|
use style::values::computed::{
|
||||||
|
LengthPercentageOrAuto, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto,
|
||||||
|
};
|
||||||
|
|
||||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -135,8 +137,8 @@ impl MarginCollapseInfo {
|
||||||
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
||||||
may_collapse_through = may_collapse_through &&
|
may_collapse_through = may_collapse_through &&
|
||||||
match fragment.style().content_block_size() {
|
match fragment.style().content_block_size() {
|
||||||
LengthPercentageOrAuto::Auto => true,
|
NonNegativeLengthPercentageOrAuto::Auto => true,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.is_definitely_zero() ||
|
lp.is_definitely_zero() ||
|
||||||
lp.maybe_to_used_value(containing_block_size).is_none()
|
lp.maybe_to_used_value(containing_block_size).is_none()
|
||||||
},
|
},
|
||||||
|
@ -496,11 +498,14 @@ impl MaybeAuto {
|
||||||
/// Receive an optional container size and return used value for width or height.
|
/// Receive an optional container size and return used value for width or height.
|
||||||
///
|
///
|
||||||
/// `style_length`: content size as given in the CSS.
|
/// `style_length`: content size as given in the CSS.
|
||||||
pub fn style_length(style_length: LengthPercentageOrAuto, container_size: Option<Au>) -> MaybeAuto {
|
pub fn style_length(
|
||||||
|
style_length: NonNegativeLengthPercentageOrAuto,
|
||||||
|
container_size: Option<Au>,
|
||||||
|
) -> MaybeAuto {
|
||||||
match style_length {
|
match style_length {
|
||||||
LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
MaybeAuto::from_option(lp.maybe_to_used_value(container_size))
|
MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,8 +571,8 @@ impl SizeConstraint {
|
||||||
/// Create a `SizeConstraint` for an axis.
|
/// Create a `SizeConstraint` for an axis.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
container_size: Option<Au>,
|
container_size: Option<Au>,
|
||||||
min_size: LengthPercentage,
|
min_size: NonNegativeLengthPercentage,
|
||||||
max_size: LengthPercentageOrNone,
|
max_size: MaxLength,
|
||||||
border: Option<Au>,
|
border: Option<Au>,
|
||||||
) -> SizeConstraint {
|
) -> SizeConstraint {
|
||||||
let mut min_size = min_size
|
let mut min_size = min_size
|
||||||
|
@ -575,10 +580,8 @@ impl SizeConstraint {
|
||||||
.unwrap_or(Au(0));
|
.unwrap_or(Au(0));
|
||||||
|
|
||||||
let mut max_size = match max_size {
|
let mut max_size = match max_size {
|
||||||
LengthPercentageOrNone::None => None,
|
MaxLength::None => None,
|
||||||
LengthPercentageOrNone::LengthPercentage(ref lp) => {
|
MaxLength::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size),
|
||||||
lp.maybe_to_used_value(container_size)
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make sure max size is not smaller than min size.
|
// Make sure max size is not smaller than min size.
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::logical_geometry::LogicalSize;
|
use style::logical_geometry::LogicalSize;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{LengthPercentageOrAuto, LengthPercentageOrNone};
|
use style::values::computed::{MaxLength, NonNegativeLengthPercentageOrAuto};
|
||||||
use style::values::generics::column::ColumnCount;
|
use style::values::generics::column::ColumnCount;
|
||||||
use style::values::Either;
|
use style::values::Either;
|
||||||
|
|
||||||
|
@ -155,16 +155,14 @@ impl Flow for MulticolFlow {
|
||||||
available_block_size: {
|
available_block_size: {
|
||||||
let style = &self.block_flow.fragment.style;
|
let style = &self.block_flow.fragment.style;
|
||||||
let size = match style.content_block_size() {
|
let size = match style.content_block_size() {
|
||||||
LengthPercentageOrAuto::Auto => None,
|
NonNegativeLengthPercentageOrAuto::Auto => None,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None)
|
lp.maybe_to_used_value(None)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let size = size.or_else(|| match style.max_block_size() {
|
let size = size.or_else(|| match style.max_block_size() {
|
||||||
LengthPercentageOrNone::None => None,
|
MaxLength::None => None,
|
||||||
LengthPercentageOrNone::LengthPercentage(ref lp) => {
|
MaxLength::LengthPercentage(ref lp) => lp.maybe_to_used_value(None),
|
||||||
lp.maybe_to_used_value(None)
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
size.unwrap_or_else(|| {
|
size.unwrap_or_else(|| {
|
||||||
|
|
|
@ -33,7 +33,7 @@ use style::logical_geometry::LogicalSize;
|
||||||
use style::properties::style_structs::Background;
|
use style::properties::style_structs::Background;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::computed::LengthPercentageOrAuto;
|
use style::values::computed::NonNegativeLengthPercentageOrAuto;
|
||||||
use style::values::CSSFloat;
|
use style::values::CSSFloat;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -301,15 +301,15 @@ impl Flow for TableFlow {
|
||||||
self.column_intrinsic_inline_sizes
|
self.column_intrinsic_inline_sizes
|
||||||
.push(ColumnIntrinsicInlineSize {
|
.push(ColumnIntrinsicInlineSize {
|
||||||
minimum_length: match *specified_inline_size {
|
minimum_length: match *specified_inline_size {
|
||||||
LengthPercentageOrAuto::Auto => Au(0),
|
NonNegativeLengthPercentageOrAuto::Auto => Au(0),
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None).unwrap_or(Au(0))
|
lp.maybe_to_used_value(None).unwrap_or(Au(0))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
percentage: match *specified_inline_size {
|
percentage: match *specified_inline_size {
|
||||||
LengthPercentageOrAuto::Auto => 0.0,
|
NonNegativeLengthPercentageOrAuto::Auto => 0.0,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.as_percentage().map_or(0.0, |p| p.0)
|
lp.0.as_percentage().map_or(0.0, |p| p.0)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
preferred: Au(0),
|
preferred: Au(0),
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::display_list::{
|
||||||
use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow};
|
use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::MaybeAuto;
|
|
||||||
use crate::table::InternalTable;
|
use crate::table::InternalTable;
|
||||||
use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance};
|
use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance};
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
|
@ -22,6 +21,7 @@ use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
|
use style::values::computed::length::NonNegativeLengthPercentageOrAuto;
|
||||||
use style::values::computed::Color;
|
use style::values::computed::Color;
|
||||||
use style::values::generics::box_::VerticalAlign;
|
use style::values::generics::box_::VerticalAlign;
|
||||||
use style::values::specified::BorderStyle;
|
use style::values::specified::BorderStyle;
|
||||||
|
@ -162,8 +162,12 @@ impl TableCellFlow {
|
||||||
// Call after block size calculation
|
// Call after block size calculation
|
||||||
pub fn total_block_size(&mut self) -> Au {
|
pub fn total_block_size(&mut self) -> Au {
|
||||||
// TODO: Percentage block-size
|
// TODO: Percentage block-size
|
||||||
let specified = MaybeAuto::from_style(self.fragment().style().content_block_size(), Au(0))
|
let specified = self
|
||||||
.specified_or_zero();
|
.fragment()
|
||||||
|
.style()
|
||||||
|
.content_block_size()
|
||||||
|
.to_used_value(Au(0))
|
||||||
|
.unwrap_or(Au(0));
|
||||||
specified + self.fragment().border_padding.block_start_end()
|
specified + self.fragment().border_padding.block_start_end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,11 +202,11 @@ impl Flow for TableCellFlow {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.block_flow.bubble_inline_sizes_for_block(true);
|
self.block_flow.bubble_inline_sizes_for_block(true);
|
||||||
let specified_inline_size = MaybeAuto::from_style(
|
let specified_inline_size = match self.block_flow.fragment.style().content_inline_size() {
|
||||||
self.block_flow.fragment.style().content_inline_size(),
|
NonNegativeLengthPercentageOrAuto::Auto => Au(0),
|
||||||
Au(0),
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => lp.to_used_value(Au(0)),
|
||||||
)
|
};
|
||||||
.specified_or_zero();
|
|
||||||
if self
|
if self
|
||||||
.block_flow
|
.block_flow
|
||||||
.base
|
.base
|
||||||
|
|
|
@ -14,7 +14,7 @@ use euclid::Point2D;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::logical_geometry::LogicalSize;
|
use style::logical_geometry::LogicalSize;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::LengthPercentageOrAuto;
|
use style::values::computed::NonNegativeLengthPercentageOrAuto;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl crate::flow::HasBaseFlow for TableColGroupFlow {}
|
unsafe impl crate::flow::HasBaseFlow for TableColGroupFlow {}
|
||||||
|
@ -34,7 +34,7 @@ pub struct TableColGroupFlow {
|
||||||
/// The specified inline-sizes of table columns. (We use `LengthPercentageOrAuto` here in
|
/// The specified inline-sizes of table columns. (We use `LengthPercentageOrAuto` here in
|
||||||
/// lieu of `ColumnInlineSize` because column groups do not establish minimum or preferred
|
/// lieu of `ColumnInlineSize` because column groups do not establish minimum or preferred
|
||||||
/// inline sizes.)
|
/// inline sizes.)
|
||||||
pub inline_sizes: Vec<LengthPercentageOrAuto>,
|
pub inline_sizes: Vec<NonNegativeLengthPercentageOrAuto>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableColGroupFlow {
|
impl TableColGroupFlow {
|
||||||
|
|
|
@ -15,7 +15,6 @@ use crate::flow::{
|
||||||
use crate::flow_list::MutFlowListIterator;
|
use crate::flow_list::MutFlowListIterator;
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::MaybeAuto;
|
|
||||||
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
|
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
|
||||||
use crate::table_cell::{CollapsedBordersForCell, TableCellFlow};
|
use crate::table_cell::{CollapsedBordersForCell, TableCellFlow};
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
|
@ -30,7 +29,7 @@ use style::computed_values::border_spacing::T as BorderSpacing;
|
||||||
use style::computed_values::border_top_style::T as BorderStyle;
|
use style::computed_values::border_top_style::T as BorderStyle;
|
||||||
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
|
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{Color, LengthPercentageOrAuto};
|
use style::values::computed::{Color, NonNegativeLengthPercentageOrAuto};
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl crate::flow::HasBaseFlow for TableRowFlow {}
|
unsafe impl crate::flow::HasBaseFlow for TableRowFlow {}
|
||||||
|
@ -208,16 +207,15 @@ impl TableRowFlow {
|
||||||
&mut max_block_size,
|
&mut max_block_size,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut block_size = max_block_size;
|
|
||||||
// TODO: Percentage block-size
|
// TODO: Percentage block-size
|
||||||
block_size = match MaybeAuto::from_style(
|
let block_size = self
|
||||||
self.block_flow.fragment.style().content_block_size(),
|
.block_flow
|
||||||
Au(0),
|
.fragment
|
||||||
) {
|
.style()
|
||||||
MaybeAuto::Auto => block_size,
|
.content_block_size()
|
||||||
MaybeAuto::Specified(value) => max(value, block_size),
|
.to_used_value(Au(0))
|
||||||
};
|
.unwrap_or(max_block_size);
|
||||||
block_size
|
max(block_size, max_block_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assign_block_size_to_self_and_children(
|
pub fn assign_block_size_to_self_and_children(
|
||||||
|
@ -431,23 +429,23 @@ impl Flow for TableRowFlow {
|
||||||
let child_base = kid.mut_base();
|
let child_base = kid.mut_base();
|
||||||
let child_column_inline_size = ColumnIntrinsicInlineSize {
|
let child_column_inline_size = ColumnIntrinsicInlineSize {
|
||||||
minimum_length: match child_specified_inline_size {
|
minimum_length: match child_specified_inline_size {
|
||||||
LengthPercentageOrAuto::Auto => None,
|
NonNegativeLengthPercentageOrAuto::Auto => None,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None)
|
lp.0.maybe_to_used_value(None)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.unwrap_or(child_base.intrinsic_inline_sizes.minimum_inline_size),
|
.unwrap_or(child_base.intrinsic_inline_sizes.minimum_inline_size),
|
||||||
percentage: match child_specified_inline_size {
|
percentage: match child_specified_inline_size {
|
||||||
LengthPercentageOrAuto::Auto => 0.0,
|
NonNegativeLengthPercentageOrAuto::Auto => 0.0,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.as_percentage().map_or(0.0, |p| p.0)
|
lp.0.as_percentage().map_or(0.0, |p| p.0)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
preferred: child_base.intrinsic_inline_sizes.preferred_inline_size,
|
preferred: child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||||
constrained: match child_specified_inline_size {
|
constrained: match child_specified_inline_size {
|
||||||
LengthPercentageOrAuto::Auto => false,
|
NonNegativeLengthPercentageOrAuto::Auto => false,
|
||||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
lp.maybe_to_used_value(None).is_some()
|
lp.0.maybe_to_used_value(None).is_some()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,7 @@ use style::computed_values::{position, table_layout};
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::logical_geometry::{LogicalRect, LogicalSize};
|
use style::logical_geometry::{LogicalRect, LogicalSize};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::LengthPercentageOrAuto;
|
use style::values::computed::NonNegativeLengthPercentageOrAuto;
|
||||||
use style::values::CSSFloat;
|
use style::values::CSSFloat;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
|
@ -201,7 +201,7 @@ impl TableWrapperFlow {
|
||||||
// says "the basic idea is the same as the shrink-to-fit width that CSS2.1 defines". So we
|
// says "the basic idea is the same as the shrink-to-fit width that CSS2.1 defines". So we
|
||||||
// just use the shrink-to-fit inline size.
|
// just use the shrink-to-fit inline size.
|
||||||
let available_inline_size = match self.block_flow.fragment.style().content_inline_size() {
|
let available_inline_size = match self.block_flow.fragment.style().content_inline_size() {
|
||||||
LengthPercentageOrAuto::Auto => {
|
NonNegativeLengthPercentageOrAuto::Auto => {
|
||||||
self.block_flow
|
self.block_flow
|
||||||
.get_shrink_to_fit_inline_size(available_inline_size) -
|
.get_shrink_to_fit_inline_size(available_inline_size) -
|
||||||
table_border_padding
|
table_border_padding
|
||||||
|
@ -840,12 +840,8 @@ fn initial_computed_inline_size(
|
||||||
preferred_width_of_all_columns: Au,
|
preferred_width_of_all_columns: Au,
|
||||||
table_border_padding: Au,
|
table_border_padding: Au,
|
||||||
) -> MaybeAuto {
|
) -> MaybeAuto {
|
||||||
let inline_size_from_style = MaybeAuto::from_style(
|
match block.fragment.style.content_inline_size() {
|
||||||
block.fragment.style.content_inline_size(),
|
NonNegativeLengthPercentageOrAuto::Auto => {
|
||||||
containing_block_inline_size,
|
|
||||||
);
|
|
||||||
match inline_size_from_style {
|
|
||||||
MaybeAuto::Auto => {
|
|
||||||
if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size
|
if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size
|
||||||
{
|
{
|
||||||
MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding)
|
MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding)
|
||||||
|
@ -855,10 +851,13 @@ fn initial_computed_inline_size(
|
||||||
MaybeAuto::Auto
|
MaybeAuto::Auto
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MaybeAuto::Specified(inline_size_from_style) => MaybeAuto::Specified(max(
|
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
|
||||||
inline_size_from_style - table_border_padding,
|
let used = lp.to_used_value(containing_block_inline_size);
|
||||||
minimum_width_of_all_columns,
|
MaybeAuto::Specified(max(
|
||||||
)),
|
used - table_border_padding,
|
||||||
|
minimum_width_of_all_columns,
|
||||||
|
))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ use js::rust::wrappers::ObjectClassName;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::str;
|
use std::str;
|
||||||
use style::properties::longhands::{margin_bottom, margin_left, margin_right, margin_top};
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -178,10 +177,10 @@ fn determine_auto_margins(window: &Window, node: &Node) -> AutoMargins {
|
||||||
let style = window.style_query(node.to_trusted_node_address()).unwrap();
|
let style = window.style_query(node.to_trusted_node_address()).unwrap();
|
||||||
let margin = style.get_margin();
|
let margin = style.get_margin();
|
||||||
AutoMargins {
|
AutoMargins {
|
||||||
top: margin.margin_top == margin_top::computed_value::T::Auto,
|
top: margin.margin_top.is_auto(),
|
||||||
right: margin.margin_right == margin_right::computed_value::T::Auto,
|
right: margin.margin_right.is_auto(),
|
||||||
bottom: margin.margin_bottom == margin_bottom::computed_value::T::Auto,
|
bottom: margin.margin_bottom.is_auto(),
|
||||||
left: margin.margin_left == margin_left::computed_value::T::Auto,
|
left: margin.margin_left.is_auto(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -718,9 +718,11 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size));
|
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Width(specified::LengthPercentageOrAuto::LengthPercentage(
|
PropertyDeclaration::Width(
|
||||||
specified::LengthPercentage::Length(value),
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
)),
|
specified::LengthPercentage::Length(value),
|
||||||
|
)),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,20 +747,22 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
match width {
|
match width {
|
||||||
LengthOrPercentageOrAuto::Auto => {},
|
LengthOrPercentageOrAuto::Auto => {},
|
||||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||||
let width_value = specified::LengthPercentageOrAuto::LengthPercentage(
|
let width_value =
|
||||||
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
);
|
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
|
||||||
|
));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Width(width_value),
|
PropertyDeclaration::Width(width_value),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrAuto::Length(length) => {
|
LengthOrPercentageOrAuto::Length(length) => {
|
||||||
let width_value = specified::LengthPercentageOrAuto::LengthPercentage(
|
let width_value =
|
||||||
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
specified::AbsoluteLength::Px(length.to_f32_px()),
|
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
|
||||||
)),
|
specified::AbsoluteLength::Px(length.to_f32_px()),
|
||||||
);
|
)),
|
||||||
|
));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Width(width_value),
|
PropertyDeclaration::Width(width_value),
|
||||||
|
@ -779,20 +783,22 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
match height {
|
match height {
|
||||||
LengthOrPercentageOrAuto::Auto => {},
|
LengthOrPercentageOrAuto::Auto => {},
|
||||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||||
let height_value = specified::LengthPercentageOrAuto::LengthPercentage(
|
let height_value =
|
||||||
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
);
|
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
|
||||||
|
));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Height(height_value),
|
PropertyDeclaration::Height(height_value),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrAuto::Length(length) => {
|
LengthOrPercentageOrAuto::Length(length) => {
|
||||||
let height_value = specified::LengthPercentageOrAuto::LengthPercentage(
|
let height_value =
|
||||||
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
specified::AbsoluteLength::Px(length.to_f32_px()),
|
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
|
||||||
)),
|
specified::AbsoluteLength::Px(length.to_f32_px()),
|
||||||
);
|
)),
|
||||||
|
));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Height(height_value),
|
PropertyDeclaration::Height(height_value),
|
||||||
|
@ -819,9 +825,11 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols));
|
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Width(specified::LengthPercentageOrAuto::LengthPercentage(
|
PropertyDeclaration::Width(
|
||||||
specified::LengthPercentage::Length(value),
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
)),
|
specified::LengthPercentage::Length(value),
|
||||||
|
)),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,9 +851,11 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
));
|
));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::Height(specified::LengthPercentageOrAuto::LengthPercentage(
|
PropertyDeclaration::Height(
|
||||||
specified::LengthPercentage::Length(value),
|
specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
)),
|
specified::LengthPercentage::Length(value),
|
||||||
|
)),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
#![feature(try_from)]
|
#![feature(try_from)]
|
||||||
|
#![feature(type_alias_enum_variants)]
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![doc = "The script crate contains all matters DOM."]
|
#![doc = "The script crate contains all matters DOM."]
|
||||||
|
|
|
@ -14,8 +14,9 @@ use style::parser::ParserContext;
|
||||||
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
||||||
use style::stylesheets::viewport_rule::*;
|
use style::stylesheets::viewport_rule::*;
|
||||||
use style::stylesheets::{CssRuleType, Origin, Stylesheet, StylesheetInDocument};
|
use style::stylesheets::{CssRuleType, Origin, Stylesheet, StylesheetInDocument};
|
||||||
|
use style::values::generics::length::LengthPercentageOrAuto::{self, Auto};
|
||||||
|
use style::values::generics::NonNegative;
|
||||||
use style::values::specified::LengthPercentage;
|
use style::values::specified::LengthPercentage;
|
||||||
use style::values::specified::LengthPercentageOrAuto::{self, Auto};
|
|
||||||
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
||||||
use style::values::specified::ViewportPercentageLength::Vw;
|
use style::values::specified::ViewportPercentageLength::Vw;
|
||||||
use style_traits::viewport::*;
|
use style_traits::viewport::*;
|
||||||
|
@ -97,14 +98,14 @@ macro_rules! assert_decl_len {
|
||||||
|
|
||||||
macro_rules! viewport_length {
|
macro_rules! viewport_length {
|
||||||
($value:expr, px) => {
|
($value:expr, px) => {
|
||||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(
|
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
LengthPercentage::Length(NoCalcLength::from_px($value)),
|
LengthPercentage::Length(NoCalcLength::from_px($value)),
|
||||||
))
|
)))
|
||||||
};
|
};
|
||||||
($value:expr, vw) => {
|
($value:expr, vw) => {
|
||||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(
|
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(NonNegative(
|
||||||
LengthPercentage::Length(ViewportPercentage(Vw($value))),
|
LengthPercentage::Length(ViewportPercentage(Vw($value))),
|
||||||
))
|
)))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue