Bug 1367275 - Part 4: stylo: Support -moz-context-properties; r?xidorn
MozReview-Commit-ID: 6eNeT6v8Nl6
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1719,16 +1719,31 @@ Gecko_nsStyleSVG_SetDashArrayLength(nsSt
}
void
Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* aDst, const nsStyleSVG* aSrc)
{
aDst->mStrokeDasharray = aSrc->mStrokeDasharray;
}
+void
+Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* aSvg, uint32_t aLen)
+{
+ aSvg->mContextProps.Clear();
+ aSvg->mContextProps.SetLength(aLen);
+}
+
+void
+Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst, const nsStyleSVG* aSrc)
+{
+ aDst->mContextProps = aSrc->mContextProps;
+ aDst->mContextPropsBits = aSrc->mContextPropsBits;
+}
+
+
css::URLValue*
Gecko_NewURLValue(ServoBundledURI aURI)
{
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
return url.forget().take();
}
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(css::URLValue, CSSURLValue);
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -437,16 +437,18 @@ void Gecko_CopyFiltersFrom(nsStyleEffect
void Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* effects, ServoBundledURI uri);
void Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* dest, const nsStyleSVGPaint* src);
void Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* paint, ServoBundledURI uri);
void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* paint);
void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
+void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
+void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst, const nsStyleSVG* src);
mozilla::css::URLValue* Gecko_NewURLValue(ServoBundledURI uri);
NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::URLValue, CSSURLValue);
NS_DECL_THREADSAFE_FFI_REFCOUNTING(RawGeckoURLExtraData, URLExtraData);
void Gecko_FillAllBackgroundLists(nsStyleImageLayers* layers, uint32_t max_len);
void Gecko_FillAllMaskLists(nsStyleImageLayers* layers, uint32_t max_len);
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -1118,16 +1118,24 @@ extern "C" {
pub fn Gecko_nsStyleSVG_SetDashArrayLength(svg: *mut nsStyleSVG,
len: u32);
}
extern "C" {
pub fn Gecko_nsStyleSVG_CopyDashArray(dst: *mut nsStyleSVG,
src: *const nsStyleSVG);
}
extern "C" {
+ pub fn Gecko_nsStyleSVG_SetContextPropertiesLength(svg: *mut nsStyleSVG,
+ len: u32);
+}
+extern "C" {
+ pub fn Gecko_nsStyleSVG_CopyContextProperties(dst: *mut nsStyleSVG,
+ src: *const nsStyleSVG);
+}
+extern "C" {
pub fn Gecko_NewURLValue(uri: ServoBundledURI) -> *mut URLValue;
}
extern "C" {
pub fn Gecko_AddRefCSSURLValueArbitraryThread(aPtr: *mut URLValue);
}
extern "C" {
pub fn Gecko_ReleaseCSSURLValueArbitraryThread(aPtr: *mut URLValue);
}
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4042,17 +4042,17 @@ clip-path
T::exclude => structs::NS_STYLE_MASK_COMPOSITE_EXCLUDE as u8,
}
</%self:simple_image_array_property>
<% impl_shape_source("clip_path", "mClipPath") %>
</%self:impl_trait>
<%self:impl_trait style_struct_name="InheritedSVG"
- skip_longhands="paint-order stroke-dasharray"
+ skip_longhands="paint-order stroke-dasharray -moz-context-properties"
skip_additionals="*">
pub fn set_paint_order(&mut self, v: longhands::paint_order::computed_value::T) {
use self::longhands::paint_order;
if v.0 == 0 {
self.gecko.mPaintOrder = structs::NS_STYLE_PAINT_ORDER_NORMAL as u8;
} else {
let mut order = 0;
@@ -4110,16 +4110,44 @@ clip-path
vec.push(Either::Second(LengthOrPercentage::Percentage(p))),
CoordDataValue::Calc(calc) =>
vec.push(Either::Second(LengthOrPercentage::Calc(calc.into()))),
_ => unreachable!(),
}
}
longhands::stroke_dasharray::computed_value::T(vec)
}
+
+ #[allow(non_snake_case)]
+ pub fn set__moz_context_properties<I>(&mut self, v: I)
+ where I: IntoIterator<Item = longhands::_moz_context_properties::computed_value::single_value::T>,
+ I::IntoIter: ExactSizeIterator
+ {
+ let v = v.into_iter();
+ unsafe {
+ bindings::Gecko_nsStyleSVG_SetContextPropertiesLength(&mut self.gecko, v.len() as u32);
+ }
+
+ self.gecko.mContextPropsBits = 0;
+ for (mut gecko, servo) in self.gecko.mContextProps.iter_mut().zip(v) {
+ if servo.0 == atom!("fill") {
+ self.gecko.mContextPropsBits |= structs::NS_STYLE_CONTEXT_PROPERTY_FILL as u8;
+ } else if servo.0 == atom!("stroke") {
+ self.gecko.mContextPropsBits |= structs::NS_STYLE_CONTEXT_PROPERTY_STROKE as u8;
+ }
+ unsafe { gecko.set_raw_from_addrefed::<structs::nsIAtom>(servo.0.into_addrefed()) }
+ }
+ }
+
+ #[allow(non_snake_case)]
+ pub fn copy__moz_context_properties_from(&mut self, other: &Self) {
+ unsafe {
+ bindings::Gecko_nsStyleSVG_CopyContextProperties(&mut self.gecko, &other.gecko);
+ }
+ }
</%self:impl_trait>
<%self:impl_trait style_struct_name="Color"
skip_longhands="*">
pub fn set_color(&mut self, v: longhands::color::computed_value::T) {
let result = convert_rgba_to_nscolor(&v);
${set_gecko_property("mColor", "result")}
}
--- a/servo/components/style/properties/longhand/inherited_svg.mako.rs
+++ b/servo/components/style/properties/longhand/inherited_svg.mako.rs
@@ -264,8 +264,33 @@
}
}
no_viewport_percentage!(SpecifiedValue);
impl ComputedValueAsSpecified for SpecifiedValue { }
</%helpers:longhand>
+<%helpers:vector_longhand name="-moz-context-properties"
+ animation_value_type="none"
+ products="gecko"
+ spec="Nonstandard (Internal-only)"
+ internal="True"
+ allow_empty="True">
+ use values::CustomIdent;
+ use values::computed::ComputedValueAsSpecified;
+
+ no_viewport_percentage!(SpecifiedValue);
+
+ impl ComputedValueAsSpecified for SpecifiedValue { }
+
+ pub type SpecifiedValue = CustomIdent;
+
+ pub mod computed_value {
+ pub type T = super::SpecifiedValue;
+ }
+
+
+ pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
+ let i = input.expect_ident()?;
+ CustomIdent::from_ident(i, &["all", "none", "auto"])
+ }
+</%helpers:vector_longhand>