aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-22 15:11:25 -0400
committerGitHub <noreply@github.com>2018-09-22 15:11:25 -0400
commitd2a79b39c50d5817dac8d964849b88028fcb972b (patch)
tree7f219547539d120d5937562512e4be0dd78b0833
parent7287ea4c858ebd5633565879e0ec7470fe7993dc (diff)
parent285ea1fc5bd3b7fd9e29d4e4a6676383b1c95065 (diff)
downloadservo-d2a79b39c50d5817dac8d964849b88028fcb972b.tar.gz
servo-d2a79b39c50d5817dac8d964849b88028fcb972b.zip
Auto merge of #21787 - emilio:gecko-sync, r=emilio
style: Sync changes from mozilla-central. See each individual commit for details. https://bugzilla.mozilla.org/show_bug.cgi?id=1493435 <!-- 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/21787) <!-- Reviewable:end -->
-rw-r--r--components/style/properties/gecko.mako.rs44
-rw-r--r--components/style/properties/longhands/inherited_ui.mako.rs21
-rw-r--r--components/style/properties/longhands/svg.mako.rs1
-rw-r--r--components/style/properties/shorthands/box.mako.rs12
-rw-r--r--components/style/values/computed/font.rs23
-rw-r--r--components/style/values/computed/ui.rs3
-rw-r--r--components/style/values/generics/ui.rs24
-rw-r--r--components/style/values/specified/image.rs14
-rw-r--r--components/style/values/specified/svg_path.rs32
-rw-r--r--components/style/values/specified/ui.rs18
-rw-r--r--tests/wpt/metadata/css/cssom/overflow-serialization.html.ini4
-rw-r--r--tests/wpt/metadata/css/cssom/shorthand-values.html.ini3
12 files changed, 160 insertions, 39 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 1de99ec16f1..2275316bf72 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -5304,7 +5304,7 @@ clip-path
</%self:impl_trait>
<%self:impl_trait style_struct_name="InheritedUI"
- skip_longhands="cursor">
+ skip_longhands="cursor scrollbar-color">
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
use style_traits::cursor::CursorKind;
@@ -5450,6 +5450,48 @@ clip-path
longhands::cursor::computed_value::T { images, keyword }
}
+
+ pub fn set_scrollbar_color(&mut self, v: longhands::scrollbar_color::computed_value::T) {
+ use gecko_bindings::structs::StyleComplexColor;
+ use values::generics::ui::ScrollbarColor;
+ match v {
+ ScrollbarColor::Auto => {
+ self.gecko.mScrollbarFaceColor = StyleComplexColor::auto();
+ self.gecko.mScrollbarTrackColor = StyleComplexColor::auto();
+ }
+ ScrollbarColor::Colors { thumb, track } => {
+ self.gecko.mScrollbarFaceColor = thumb.into();
+ self.gecko.mScrollbarTrackColor = track.into();
+ }
+ }
+ }
+
+ pub fn copy_scrollbar_color_from(&mut self, other: &Self) {
+ self.gecko.mScrollbarFaceColor = other.gecko.mScrollbarFaceColor;
+ self.gecko.mScrollbarTrackColor = other.gecko.mScrollbarTrackColor;
+ }
+
+ pub fn reset_scrollbar_color(&mut self, other: &Self) {
+ self.copy_scrollbar_color_from(other);
+ }
+
+ pub fn clone_scrollbar_color(&self) -> longhands::scrollbar_color::computed_value::T {
+ use gecko_bindings::structs::StyleComplexColor_Tag as Tag;
+ use values::generics::ui::ScrollbarColor;
+ debug_assert!(
+ (self.gecko.mScrollbarFaceColor.mTag == Tag::eAuto) ==
+ (self.gecko.mScrollbarTrackColor.mTag == Tag::eAuto),
+ "Whether the two colors are `auto` should match",
+ );
+ if self.gecko.mScrollbarFaceColor.mTag == Tag::eAuto {
+ ScrollbarColor::Auto
+ } else {
+ ScrollbarColor::Colors {
+ thumb: self.gecko.mScrollbarFaceColor.into(),
+ track: self.gecko.mScrollbarTrackColor.into(),
+ }
+ }
+ }
</%self:impl_trait>
<%self:impl_trait style_struct_name="Column"
diff --git a/components/style/properties/longhands/inherited_ui.mako.rs b/components/style/properties/longhands/inherited_ui.mako.rs
index 0b2b590cf7f..6bdd0ff51b5 100644
--- a/components/style/properties/longhands/inherited_ui.mako.rs
+++ b/components/style/properties/longhands/inherited_ui.mako.rs
@@ -67,24 +67,15 @@ ${helpers.predefined_type(
products="gecko",
)}
-// Only scrollbar-face-color and scrollbar-track-color are added here.
-// These two are the only common parts of scrollbar among Windows and
-// macOS. We may or may not want to provide other properties to allow
-// finer-grain control.
-//
-// NOTE The syntax in spec is currently `normal | <color>`, but I think
-// reusing `auto | <color>` as `caret-color` makes more sense. See
-// https://github.com/w3c/csswg-drafts/issues/2660
-% for part in ["face", "track"]:
${helpers.predefined_type(
- "scrollbar-%s-color" % part,
- "ColorOrAuto",
- "Either::Second(Auto)",
- spec="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color-properties",
+ "scrollbar-color",
+ "ui::ScrollbarColor",
+ "Default::default()",
+ spec="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color",
gecko_pref="layout.css.scrollbar-colors.enabled",
- animation_value_type="ColorOrAuto",
+ animation_value_type="ScrollbarColor",
+ boxed=True,
ignored_when_colors_disabled=True,
enabled_in="chrome",
products="gecko",
)}
-% endfor
diff --git a/components/style/properties/longhands/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs
index 36105247676..acdb809135f 100644
--- a/components/style/properties/longhands/svg.mako.rs
+++ b/components/style/properties/longhands/svg.mako.rs
@@ -183,6 +183,7 @@ ${helpers.predefined_type(
"ImageLayer",
"Either::First(None_)",
initial_specified_value="Either::First(None_)",
+ parse_method="parse_with_cors_anonymous",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image",
vector=True,
products="gecko",
diff --git a/components/style/properties/shorthands/box.mako.rs b/components/style/properties/shorthands/box.mako.rs
index 960e608cea7..3886c7d2d3c 100644
--- a/components/style/properties/shorthands/box.mako.rs
+++ b/components/style/properties/shorthands/box.mako.rs
@@ -7,7 +7,7 @@
<%helpers:shorthand
name="overflow"
flags="SHORTHAND_IN_GETCS"
- sub_properties="overflow-y overflow-x"
+ sub_properties="overflow-x overflow-y"
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow"
>
use properties::longhands::overflow_x::parse as parse_overflow;
@@ -52,9 +52,9 @@
}
}
% endif
- let overflow_y = parse_overflow(context, input)?;
- let overflow_x =
- input.try(|i| parse_overflow(context, i)).unwrap_or(overflow_y);
+ let overflow_x = parse_overflow(context, input)?;
+ let overflow_y =
+ input.try(|i| parse_overflow(context, i)).unwrap_or(overflow_x);
Ok(expanded! {
overflow_x: overflow_x,
overflow_y: overflow_y,
@@ -63,10 +63,10 @@
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
- self.overflow_y.to_css(dest)?;
+ self.overflow_x.to_css(dest)?;
if self.overflow_x != self.overflow_y {
dest.write_char(' ')?;
- self.overflow_x.to_css(dest)?;
+ self.overflow_y.to_css(dest)?;
}
Ok(())
}
diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs
index 2c3d2853e5c..4cb8f7a7bdf 100644
--- a/components/style/values/computed/font.rs
+++ b/components/style/values/computed/font.rs
@@ -483,16 +483,19 @@ impl SingleFontFamily {
FontFamilyType::eFamily_fantasy => SingleFontFamily::Generic(atom!("fantasy")),
FontFamilyType::eFamily_moz_fixed => SingleFontFamily::Generic(atom!("-moz-fixed")),
FontFamilyType::eFamily_named => {
- let name = Atom::from(&*family.mName);
+ let name = unsafe { Atom::from_raw(family.mName.mRawPtr) };
SingleFontFamily::FamilyName(FamilyName {
name,
syntax: FamilyNameSyntax::Identifiers,
})
},
- FontFamilyType::eFamily_named_quoted => SingleFontFamily::FamilyName(FamilyName {
- name: (&*family.mName).into(),
- syntax: FamilyNameSyntax::Quoted,
- }),
+ FontFamilyType::eFamily_named_quoted => {
+ let name = unsafe { Atom::from_raw(family.mName.mRawPtr) };
+ SingleFontFamily::FamilyName(FamilyName {
+ name,
+ syntax: FamilyNameSyntax::Quoted,
+ })
+ },
_ => panic!("Found unexpected font FontFamilyType"),
}
}
@@ -538,9 +541,15 @@ impl Hash for FontFamilyList {
where
H: Hasher,
{
+ use string_cache::WeakAtom;
+
for name in self.0.mNames.iter() {
name.mType.hash(state);
- name.mName.hash(state);
+ if !name.mName.mRawPtr.is_null() {
+ unsafe {
+ WeakAtom::new(name.mName.mRawPtr).hash(state);
+ }
+ }
}
}
}
@@ -552,7 +561,7 @@ impl PartialEq for FontFamilyList {
return false;
}
for (a, b) in self.0.mNames.iter().zip(other.0.mNames.iter()) {
- if a.mType != b.mType || &*a.mName != &*b.mName {
+ if a.mType != b.mType || a.mName.mRawPtr != b.mName.mRawPtr {
return false;
}
}
diff --git a/components/style/values/computed/ui.rs b/components/style/values/computed/ui.rs
index 5307f79a38e..40f1a378cc9 100644
--- a/components/style/values/computed/ui.rs
+++ b/components/style/values/computed/ui.rs
@@ -20,3 +20,6 @@ pub type Cursor = generics::Cursor<CursorImage>;
/// A computed value for item of `image cursors`.
pub type CursorImage = generics::CursorImage<ComputedImageUrl, Number>;
+
+/// A computed value for `scrollbar-color` property.
+pub type ScrollbarColor = generics::ScrollbarColor<Color>;
diff --git a/components/style/values/generics/ui.rs b/components/style/values/generics/ui.rs
index bef1926bc90..73f050bb12a 100644
--- a/components/style/values/generics/ui.rs
+++ b/components/style/values/generics/ui.rs
@@ -67,3 +67,27 @@ impl<ImageUrl: ToCss, Number: ToCss> ToCss for CursorImage<ImageUrl, Number> {
Ok(())
}
}
+
+/// A generic value for `scrollbar-color` property.
+///
+/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
+#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
+ SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
+pub enum ScrollbarColor<Color> {
+ /// `auto`
+ Auto,
+ /// `<color>{2}`
+ Colors {
+ /// First `<color>`, for color of the scrollbar thumb.
+ thumb: Color,
+ /// Second `<color>`, for color of the scrollbar track.
+ track: Color,
+ }
+}
+
+impl<Color> Default for ScrollbarColor<Color> {
+ #[inline]
+ fn default() -> Self {
+ ScrollbarColor::Auto
+ }
+}
diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs
index 1b080816e83..b1a611846a8 100644
--- a/components/style/values/specified/image.rs
+++ b/components/style/values/specified/image.rs
@@ -33,6 +33,20 @@ use values::specified::url::SpecifiedImageUrl;
/// A specified image layer.
pub type ImageLayer = Either<None_, Image>;
+impl ImageLayer {
+ /// This is a specialization of Either with an alternative parse
+ /// method to provide anonymous CORS headers for the Image url fetch.
+ pub fn parse_with_cors_anonymous<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>,
+ ) -> Result<Self, ParseError<'i>> {
+ if let Ok(v) = input.try(|i| None_::parse(context, i)) {
+ return Ok(Either::First(v));
+ }
+ Image::parse_with_cors_anonymous(context, input).map(Either::Second)
+ }
+}
+
/// Specified values for an image according to CSS-IMAGES.
/// <https://drafts.csswg.org/css-images/#image-values>
pub type Image = generic::Image<Gradient, MozImageRect, SpecifiedImageUrl>;
diff --git a/components/style/values/specified/svg_path.rs b/components/style/values/specified/svg_path.rs
index 5d397558d25..3f1fdc39d97 100644
--- a/components/style/values/specified/svg_path.rs
+++ b/components/style/values/specified/svg_path.rs
@@ -13,7 +13,7 @@ use std::slice;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use style_traits::values::SequenceWriter;
use values::CSSFloat;
-use values::animated::{Animate, Procedure};
+use values::animated::{Animate, Procedure, ToAnimatedZero};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
/// The SVG path data.
@@ -198,9 +198,7 @@ pub enum PathCommand {
rx: CSSFloat,
ry: CSSFloat,
angle: CSSFloat,
- #[animation(constant)]
large_arc_flag: ArcFlag,
- #[animation(constant)]
sweep_flag: ArcFlag,
point: CoordPair,
absolute: IsAbsolute,
@@ -538,6 +536,34 @@ impl ToCss for ArcFlag {
}
}
+impl Animate for ArcFlag {
+ #[inline]
+ fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
+ (self.0 as i32)
+ .animate(&(other.0 as i32), procedure)
+ .map(|v| ArcFlag(v > 0))
+ }
+}
+
+impl ComputeSquaredDistance for ArcFlag {
+ #[inline]
+ fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
+ (self.0 as i32).compute_squared_distance(&(other.0 as i32))
+ }
+}
+
+impl ToAnimatedZero for ArcFlag {
+ #[inline]
+ fn to_animated_zero(&self) -> Result<Self, ()> {
+ // The 2 ArcFlags in EllipticalArc determine which one of the 4 different arcs will be
+ // used. (i.e. From 4 combinations). In other words, if we change the flag, we get a
+ // different arc. Therefore, we return *self.
+ // https://svgwg.org/svg2-draft/paths.html#PathDataEllipticalArcCommands
+ Ok(*self)
+ }
+}
+
+
/// SVG Path parser.
struct PathParser<'a> {
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,
diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs
index 7dc1e0fe1d3..c9c5c0a8414 100644
--- a/components/style/values/specified/ui.rs
+++ b/components/style/values/specified/ui.rs
@@ -122,3 +122,21 @@ impl From<MozForceBrokenImageIcon> for u8 {
}
}
}
+
+/// A specified value for `scrollbar-color` property
+pub type ScrollbarColor = generics::ScrollbarColor<Color>;
+
+impl Parse for ScrollbarColor {
+ fn parse<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>,
+ ) -> Result<Self, ParseError<'i>> {
+ if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
+ return Ok(generics::ScrollbarColor::Auto);
+ }
+ Ok(generics::ScrollbarColor::Colors {
+ thumb: Color::parse(context, input)?,
+ track: Color::parse(context, input)?,
+ })
+ }
+}
diff --git a/tests/wpt/metadata/css/cssom/overflow-serialization.html.ini b/tests/wpt/metadata/css/cssom/overflow-serialization.html.ini
deleted file mode 100644
index 3a51b8caa02..00000000000
--- a/tests/wpt/metadata/css/cssom/overflow-serialization.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[overflow-serialization.html]
- [CSSOM - Overflow shorthand serialization]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/css/cssom/shorthand-values.html.ini b/tests/wpt/metadata/css/cssom/shorthand-values.html.ini
index 427f39aa3e7..e0b5a48bdb5 100644
--- a/tests/wpt/metadata/css/cssom/shorthand-values.html.ini
+++ b/tests/wpt/metadata/css/cssom/shorthand-values.html.ini
@@ -29,6 +29,3 @@
[The serialization of list-style-type: circle; list-style-position: inside; list-style-image: initial; should be canonical.]
expected: FAIL
- [The serialization of overflow-x: scroll; overflow-y: hidden; should be canonical.]
- expected: FAIL
-