Permalink
Browse files

Auto merge of #22861 - emilio:gecko-sync, r=emilio

style: Sync changes from mozilla-central.

See each individual commit for details.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22861)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Feb 10, 2019
2 parents a019ed1 + 6daebcc commit aeeaf9dda1936acc82ab039fd6fdd887e6add043
Showing with 662 additions and 792 deletions.
  1. +27 −20 components/layout/block.rs
  2. +21 −17 components/layout/display_list/background.rs
  3. +6 −4 components/layout/display_list/builder.rs
  4. +25 −16 components/layout/flex.rs
  5. +4 −4 components/layout/floats.rs
  6. +9 −5 components/layout/fragment.rs
  7. +1 −0 components/layout/lib.rs
  8. +17 −14 components/layout/model.rs
  9. +5 −7 components/layout/multicol.rs
  10. +6 −6 components/layout/table.rs
  11. +12 −8 components/layout/table_cell.rs
  12. +2 −2 components/layout/table_colgroup.rs
  13. +18 −20 components/layout/table_row.rs
  14. +11 −12 components/layout/table_wrapper.rs
  15. +4 −5 components/script/devtools.rs
  16. +35 −25 components/script/dom/element.rs
  17. +1 −0 components/script/lib.rs
  18. +48 −1 components/style/cbindgen.toml
  19. +6 −5 components/style/gecko/conversions.rs
  20. +25 −33 components/style/gecko/values.rs
  21. +4 −0 components/style/properties/cascade.rs
  22. +35 −50 components/style/properties/gecko.mako.rs
  23. +3 −1 components/style/properties/longhands/box.mako.rs
  24. +17 −31 components/style/properties/longhands/position.mako.rs
  25. +6 −8 components/style/properties/properties.mako.rs
  26. +9 −8 components/style/stylesheets/viewport_rule.rs
  27. +1 −51 components/style/values/animated/length.rs
  28. +5 −4 components/style/values/computed/background.rs
  29. +71 −158 components/style/values/computed/length.rs
  30. +1 −1 components/style/values/computed/mod.rs
  31. +6 −6 components/style/values/generics/background.rs
  32. +94 −5 components/style/values/generics/length.rs
  33. +1 −0 components/style/values/generics/mod.rs
  34. +1 −0 components/style/values/generics/rect.rs
  35. +4 −2 components/style/values/specified/background.rs
  36. +30 −59 components/style/values/specified/gecko.rs
  37. +83 −197 components/style/values/specified/length.rs
  38. +1 −1 components/style/values/specified/mod.rs
  39. +1 −1 resources/user-agent.css
  40. +6 −5 tests/unit/style/viewport.rs
@@ -67,7 +67,9 @@ use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::{LengthPercentageOrAuto, LengthPercentageOrNone};
use style::values::computed::{
LengthPercentageOrAuto, MaxLength, NonNegativeLengthPercentageOrAuto,
};

/// Information specific to floated blocks.
#[derive(Clone, Serialize)]
@@ -419,15 +421,15 @@ impl CandidateBSizeIterator {
// `min-height` and `max-height`, percentage values are ignored.

let block_size = match fragment.style.content_block_size() {
LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto,
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
MaybeAuto::from_option(lp.maybe_to_used_value(block_container_block_size))
},
};

let max_block_size = match fragment.style.max_block_size() {
LengthPercentageOrNone::None => None,
LengthPercentageOrNone::LengthPercentage(ref lp) => {
MaxLength::None => None,
MaxLength::LengthPercentage(ref lp) => {
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();

match content_block_size {
LengthPercentageOrAuto::Auto => {
NonNegativeLengthPercentageOrAuto::Auto => {
let container_size = containing_block_size?;
let (block_start, block_end) = {
let position = self.fragment.style().logical_position();
@@ -1435,7 +1437,7 @@ impl BlockFlow {
(_, _) => None,
}
},
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(containing_block_size)
},
}
@@ -1797,15 +1799,12 @@ impl BlockFlow {
.to_used_value(self.base.block_container_inline_size);
let specified_inline_size = self.fragment.style().content_inline_size();
let container_size = self.base.block_container_inline_size;
let inline_size = if let MaybeAuto::Specified(size) =
MaybeAuto::from_style(specified_inline_size, container_size)
{
match self.fragment.style().get_position().box_sizing {
let inline_size = match specified_inline_size.to_used_value(container_size) {
Some(size) => match self.fragment.style().get_position().box_sizing {
BoxSizing::BorderBox => size,
BoxSizing::ContentBox => size + self.fragment.border_padding.inline_start_end(),
}
} else {
max(min_inline_size, min(available_inline_size, max_inline_size))
},
None => max(min_inline_size, min(available_inline_size, max_inline_size)),
};
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
// page set `max-width` in order to avoid hitting floats. The search box on Google
// SERPs falls into this category.
if self.fragment.style.max_inline_size() != LengthPercentageOrNone::None {
if self.fragment.style.max_inline_size() != MaxLength::None {
return;
}

@@ -2156,9 +2155,10 @@ impl Flow for BlockFlow {
fn bubble_inline_sizes(&mut self) {
// If this block has a fixed width, just use that for the minimum and preferred 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 {
LengthPercentageOrAuto::Auto => true,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
NonNegativeLengthPercentageOrAuto::Auto => true,
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None).is_none()
},
};
@@ -2846,9 +2846,16 @@ pub trait ISizeAndMarginsComputer {
parent_flow_inline_size: Au,
shared_context: &SharedStyleContext,
) -> MaybeAuto {
MaybeAuto::from_style(
block.fragment().style().content_inline_size(),
self.containing_block_inline_size(block, parent_flow_inline_size, shared_context),
MaybeAuto::from_option(
block
.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.

use crate::display_list::border;
use crate::model::MaybeAuto;
use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
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_origin::single_value::T as BackgroundOrigin;
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::NonNegative;
use style::values::specified::background::BackgroundRepeatKeyword;
use webrender_api::BorderRadius;

@@ -60,10 +58,12 @@ fn compute_background_image_size(
None => match bg_size {
GenericBackgroundSize::Cover | GenericBackgroundSize::Contain => bounds_size,
GenericBackgroundSize::Explicit { width, height } => Size2D::new(
MaybeAuto::from_style(width.0, bounds_size.width)
.specified_or_default(bounds_size.width),
MaybeAuto::from_style(height.0, bounds_size.height)
.specified_or_default(bounds_size.height),
width
.to_used_value(bounds_size.width)
.unwrap_or(bounds_size.width),
height
.to_used_value(bounds_size.height)
.unwrap_or(bounds_size.height),
),
},
Some(own_size) => {
@@ -88,30 +88,34 @@ fn compute_background_image_size(
(
GenericBackgroundSize::Explicit {
width,
height: NonNegative(LengthPercentageOrAuto::Auto),
height: NonNegativeLengthPercentageOrAuto::Auto,
},
_,
) => {
let width = MaybeAuto::from_style(width.0, bounds_size.width)
.specified_or_default(own_size.width);
let width = width
.to_used_value(bounds_size.width)
.unwrap_or(own_size.width);
Size2D::new(width, width.scale_by(image_aspect_ratio.recip()))
},
(
GenericBackgroundSize::Explicit {
width: NonNegative(LengthPercentageOrAuto::Auto),
width: NonNegativeLengthPercentageOrAuto::Auto,
height,
},
_,
) => {
let height = MaybeAuto::from_style(height.0, bounds_size.height)
.specified_or_default(own_size.height);
let height = height
.to_used_value(bounds_size.height)
.unwrap_or(own_size.height);
Size2D::new(height.scale_by(image_aspect_ratio), height)
},
(GenericBackgroundSize::Explicit { width, height }, _) => Size2D::new(
MaybeAuto::from_style(width.0, bounds_size.width)
.specified_or_default(own_size.width),
MaybeAuto::from_style(height.0, bounds_size.height)
.specified_or_default(own_size.height),
width
.to_used_value(bounds_size.width)
.unwrap_or(own_size.width),
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();
let size = match background_size {
BackgroundSize::Explicit { width, height } => Size2D::new(
MaybeAuto::from_style(width.0, bounding_box_size.width)
.specified_or_default(bounding_box_size.width),
MaybeAuto::from_style(height.0, bounding_box_size.height)
.specified_or_default(bounding_box_size.height),
width
.to_used_value(bounding_box_size.width)
.unwrap_or(bounding_box_size.width),
height
.to_used_value(bounding_box_size.height)
.unwrap_or(bounding_box_size.height),
),
_ => bounding_box_size,
};
@@ -29,7 +29,9 @@ use style::logical_geometry::{Direction, LogicalSize};
use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage;
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;

/// 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,
/// containing block size, min constraint, and max constraint
pub fn new(
size: LengthPercentageOrAuto,
size: NonNegativeLengthPercentageOrAuto,
content_size: Option<Au>,
min: LengthPercentage,
max: LengthPercentageOrNone,
min: NonNegativeLengthPercentage,
max: MaxLength,
) -> AxisSize {
match size {
LengthPercentageOrAuto::Auto => {
NonNegativeLengthPercentageOrAuto::Auto => {
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) {
Some(length) => AxisSize::Definite(length),
None => AxisSize::Infinite,
@@ -70,17 +72,24 @@ impl AxisSize {
/// is definite after flex size resolving.
fn from_flex_basis(
flex_basis: FlexBasis,
main_length: LengthPercentageOrAuto,
main_length: NonNegativeLengthPercentageOrAuto,
containing_length: Au,
) -> MaybeAuto {
let width = match flex_basis {
GenericFlexBasis::Content => return MaybeAuto::Auto,
GenericFlexBasis::Width(width) => width,
};

match width.0 {
LengthPercentageOrAuto::Auto => MaybeAuto::from_style(main_length, containing_length),
other => MaybeAuto::from_style(other, containing_length),
let width = match width {
NonNegativeLengthPercentageOrAuto::Auto => main_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;
match direction {
Direction::Inline => {
if margin.inline_start == LengthPercentageOrAuto::Auto {
if margin.inline_start.is_auto() {
margin_count += 1;
}
if margin.inline_end == LengthPercentageOrAuto::Auto {
if margin.inline_end.is_auto() {
margin_count += 1;
}
},
Direction::Block => {
if margin.block_start == LengthPercentageOrAuto::Auto {
if margin.block_start.is_auto() {
margin_count += 1;
}
if margin.block_end == LengthPercentageOrAuto::Auto {
if margin.block_end.is_auto() {
margin_count += 1;
}
},
@@ -816,7 +825,7 @@ impl FlexFlow {
// cross size of item should equal to the line size if any auto margin exists.
// https://drafts.csswg.org/css-flexbox/#algo-cross-margins
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) {
Au(0)
} else {
@@ -830,7 +839,7 @@ impl FlexFlow {

let self_align = block.fragment.style().get_position().align_self;
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);
block.base.block_container_explicit_block_size = Some(line.cross_size);
@@ -10,7 +10,7 @@ use std::cmp::{max, min};
use std::fmt;
use style::computed_values::float::T as StyleFloat;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::values::computed::LengthPercentageOrAuto;
use style::values::computed::NonNegativeLengthPercentageOrAuto;

/// The kind of float: left or right.
#[derive(Clone, Copy, Debug, Serialize)]
@@ -549,9 +549,9 @@ impl SpeculatedFloatPlacement {
// might flow around this float.
let inline_size = flow.as_block().fragment.style.content_inline_size();
let fixed = match inline_size {
LengthPercentageOrAuto::Auto => false,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.is_definitely_zero() || lp.maybe_to_used_value(None).is_some()
NonNegativeLengthPercentageOrAuto::Auto => false,
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.0.is_definitely_zero() || lp.0.maybe_to_used_value(None).is_some()
},
};
if !fixed {
@@ -61,7 +61,9 @@ use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage;
use style::str::char_is_whitespace;
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::transform;
use webrender_api::{self, LayoutTransform};
@@ -985,8 +987,10 @@ impl Fragment {
if flags.contains(
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED,
) {
specified =
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero();
specified = style
.content_inline_size()
.to_used_value(Au(0))
.unwrap_or(Au(0));
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)) {
specified = min(specified, max)
@@ -1611,8 +1615,8 @@ impl Fragment {
SpecificFragmentInfo::Iframe(_) |
SpecificFragmentInfo::Svg(_) => {
let inline_size = match self.style.content_inline_size() {
LengthPercentageOrAuto::Auto => None,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
NonNegativeLengthPercentageOrAuto::Auto => None,
NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None)
},
};
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#![deny(unsafe_code)]
#![feature(type_alias_enum_variants)]

#[macro_use]
extern crate bitflags;
Oops, something went wrong.

0 comments on commit aeeaf9d

Please sign in to comment.