Permalink
Browse files

Auto merge of #22352 - 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/22352)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Dec 3, 2018
2 parents d404a0c + 3ff55f9 commit 5bdea7dc1c80790a852a3fb03edfb2b8fbd403dc
Showing with 2,101 additions and 1,985 deletions.
  1. +5 −2 components/layout/display_list/builder.rs
  2. +3 −0 components/style/cbindgen.toml
  3. +44 −16 components/style/custom_properties.rs
  4. +35 −0 components/style/gecko/conversions.rs
  5. +4 −16 components/style/properties/declaration_block.rs
  6. +55 −74 components/style/properties/gecko.mako.rs
  7. +2 −1,739 components/style/properties/helpers/animated_properties.mako.rs
  8. +2 −1 components/style/properties/longhands/background.mako.rs
  9. +3 −1 components/style/properties/longhands/border.mako.rs
  10. +7 −7 components/style/properties/longhands/box.mako.rs
  11. +5 −3 components/style/properties/longhands/column.mako.rs
  12. +1 −0 components/style/properties/longhands/inherited_text.mako.rs
  13. +1 −0 components/style/properties/longhands/ui.mako.rs
  14. +20 −9 components/style/properties/properties.mako.rs
  15. +48 −0 components/style/properties/shorthands/box.mako.rs
  16. +1 −0 components/style/rule_tree/mod.rs
  17. +11 −0 components/style/values/animated/mod.rs
  18. +1,502 −0 components/style/values/animated/transform.rs
  19. +250 −1 components/style/values/computed/transform.rs
  20. +3 −26 components/style/values/generics/transform.rs
  21. +42 −0 components/style/values/specified/border.rs
  22. +50 −28 components/style/values/specified/box.rs
  23. +1 −41 components/style/values/specified/mod.rs
  24. +5 −4 components/style/values/specified/outline.rs
  25. +1 −15 components/style/values/specified/ui.rs
  26. +0 −2 tests/wpt/metadata/css/css-variables/variable-exponential-blowup.html.ini
@@ -1499,8 +1499,11 @@ impl FragmentDisplayListBuilding for Fragment {

let outline_style = match style.get_outline().outline_style {
OutlineStyle::Auto => BorderStyle::Solid,
OutlineStyle::Other(BorderStyle::None) => return,
OutlineStyle::Other(border_style) => border_style,
// FIXME(emilio): I don't think this border-style check is
// necessary, since border-style: none implies an outline-width of
// zero at computed value time.
OutlineStyle::BorderStyle(BorderStyle::None) => return,
OutlineStyle::BorderStyle(s) => s,
};

// Outlines are not accounted for in the dimensions of the border box, so adjust the
@@ -31,6 +31,7 @@ include = ["cssparser"]

[struct]
derive_eq = true
derive_neq = true

[enum]
derive_helper_methods = true
@@ -41,6 +42,8 @@ include = [
"Appearance",
"BreakBetween",
"BreakWithin",
"BorderStyle",
"OutlineStyle",
"ComputedFontStretchRange",
"ComputedFontStyleDescriptor",
"ComputedFontWeightRange",
@@ -283,18 +283,32 @@ impl VariableValue {
}
}

fn push(
fn push<'i>(
&mut self,
input: &Parser<'i, '_>,
css: &str,
css_first_token_type: TokenSerializationType,
css_last_token_type: TokenSerializationType,
) {
) -> Result<(), ParseError<'i>> {
/// Prevent values from getting terribly big since you can use custom
/// properties exponentially.
///
/// This number (1MB) is somewhat arbitrary, but silly enough that no
/// sane page would hit it. We could limit by number of total
/// substitutions, but that was very easy to work around in practice
/// (just choose a larger initial value and boom).
const MAX_VALUE_LENGTH_IN_BYTES: usize = 1024 * 1024;

if self.css.len() + css.len() > MAX_VALUE_LENGTH_IN_BYTES {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}

// This happens e.g. between two subsequent var() functions:
// `var(--a)var(--b)`.
//
// In that case, css_*_token_type is nonsensical.
if css.is_empty() {
return;
return Ok(());
}

self.first_token_type.set_if_nothing(css_first_token_type);
@@ -307,21 +321,32 @@ impl VariableValue {
self.css.push_str("/**/")
}
self.css.push_str(css);
self.last_token_type = css_last_token_type
self.last_token_type = css_last_token_type;
Ok(())
}

fn push_from(
fn push_from<'i>(
&mut self,
input: &Parser<'i, '_>,
position: (SourcePosition, TokenSerializationType),
input: &Parser,
last_token_type: TokenSerializationType,
) {
self.push(input.slice_from(position.0), position.1, last_token_type)
) -> Result<(), ParseError<'i>> {
self.push(
input,
input.slice_from(position.0),
position.1,
last_token_type,
)
}

fn push_variable(&mut self, variable: &ComputedValue) {
fn push_variable<'i>(
&mut self,
input: &Parser<'i, '_>,
variable: &ComputedValue,
) -> Result<(), ParseError<'i>> {
debug_assert!(variable.references.is_empty());
self.push(
input,
&variable.css,
variable.first_token_type,
variable.last_token_type,
@@ -727,6 +752,7 @@ fn substitute_all(custom_properties_map: &mut CustomPropertiesMap, environment:
// title=Tarjan%27s_strongly_connected_components_algorithm&oldid=801728495

/// Struct recording necessary information for each variable.
#[derive(Debug)]
struct VarInfo {
/// The name of the variable. It will be taken to save addref
/// when the corresponding variable is popped from the stack.
@@ -741,6 +767,7 @@ fn substitute_all(custom_properties_map: &mut CustomPropertiesMap, environment:
}
/// Context struct for traversing the variable graph, so that we can
/// avoid referencing all the fields multiple times.
#[derive(Debug)]
struct Context<'a> {
/// Number of variables visited. This is used as the order index
/// when we visit a new unresolved variable.
@@ -941,7 +968,7 @@ fn substitute_references_in_value<'i>(
environment,
)?;

computed_value.push_from(position, &input, last_token_type);
computed_value.push_from(&input, position, last_token_type)?;
Ok(computed_value)
}

@@ -955,8 +982,8 @@ fn substitute_references_in_value<'i>(
///
/// Return `Err(())` if `input` is invalid at computed-value time.
/// or `Ok(last_token_type that was pushed to partial_computed_value)` otherwise.
fn substitute_block<'i, 't>(
input: &mut Parser<'i, 't>,
fn substitute_block<'i>(
input: &mut Parser<'i, '_>,
position: &mut (SourcePosition, TokenSerializationType),
partial_computed_value: &mut ComputedValue,
custom_properties: &CustomPropertiesMap,
@@ -991,10 +1018,11 @@ fn substitute_block<'i, 't>(
let is_env = name.eq_ignore_ascii_case("env");

partial_computed_value.push(
input,
input.slice(position.0..before_this_token),
position.1,
last_token_type,
);
)?;
input.parse_nested_block(|input| {
// parse_var_function() / parse_env_function() ensure neither .unwrap() will fail.
let name = {
@@ -1014,7 +1042,7 @@ fn substitute_block<'i, 't>(

if let Some(v) = value {
last_token_type = v.last_token_type;
partial_computed_value.push_variable(v);
partial_computed_value.push_variable(input, v)?;
// Skip over the fallback, as `parse_nested_block` would return `Err`
// if we don't consume all of `input`.
// FIXME: Add a specialized method to cssparser to do this with less work.
@@ -1036,7 +1064,7 @@ fn substitute_block<'i, 't>(
custom_properties,
env,
)?;
partial_computed_value.push_from(position, input, last_token_type);
partial_computed_value.push_from(input, position, last_token_type)?;
}
Ok(())
})?;
@@ -1096,6 +1124,6 @@ pub fn substitute<'i>(
&custom_properties,
env,
)?;
substituted.push_from(position, &input, last_token_type);
substituted.push_from(&input, position, last_token_type)?;
Ok(substituted.css)
}
@@ -11,11 +11,13 @@
use app_units::Au;
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
use crate::gecko_bindings::structs::{self, nsStyleCoord_CalcValue};
use crate::gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use crate::stylesheets::{Origin, RulesMutateError};
use crate::values::computed::image::LineDirection;
use crate::values::computed::transform::Matrix3D;
use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use crate::values::computed::{Integer, LengthOrPercentage};
@@ -1142,3 +1144,36 @@ pub unsafe fn string_from_chars_pointer(p: *const u16) -> String {
let char_vec = slice::from_raw_parts(p, length as usize);
String::from_utf16_lossy(char_vec)
}

impl<'a> From<&'a RawGeckoGfxMatrix4x4> for Matrix3D {
fn from(m: &'a RawGeckoGfxMatrix4x4) -> Matrix3D {
Matrix3D {
m11: m[0],
m12: m[1],
m13: m[2],
m14: m[3],
m21: m[4],
m22: m[5],
m23: m[6],
m24: m[7],
m31: m[8],
m32: m[9],
m33: m[10],
m34: m[11],
m41: m[12],
m42: m[13],
m43: m[14],
m44: m[15],
}
}
}

impl From<Matrix3D> for RawGeckoGfxMatrix4x4 {
fn from(matrix: Matrix3D) -> RawGeckoGfxMatrix4x4 {
[
matrix.m11, matrix.m12, matrix.m13, matrix.m14, matrix.m21, matrix.m22, matrix.m23,
matrix.m24, matrix.m31, matrix.m32, matrix.m33, matrix.m34, matrix.m41, matrix.m42,
matrix.m43, matrix.m44,
]
}
}
@@ -462,22 +462,6 @@ impl PropertyDeclarationBlock {
return false;
}

// As a compatibility hack, specially on Android,
// don't allow to override a prefixed webkit display
// value with an unprefixed version from parsing
// code.
//
// TODO(emilio): Unship.
if let PropertyDeclaration::Display(old_display) = *slot {
use crate::properties::longhands::display::computed_value::T as display;

if let PropertyDeclaration::Display(new_display) = declaration {
if display::should_ignore_parsed_value(old_display, new_display) {
return false;
}
}
}

index_to_remove = Some(i);
break;
}
@@ -933,6 +917,10 @@ impl PropertyDeclarationBlock {
}
already_serialized.insert(shorthand.into());

if shorthand.is_legacy_shorthand() {
continue;
}

// Substep 2 & 3
let mut current_longhands = SmallVec::<[_; 10]>::new();
let mut important_count = 0;
Oops, something went wrong.

0 comments on commit 5bdea7d

Please sign in to comment.