Bug 1338936 - Part 7: stylo: Support -x-span for `<col span>`; r?emilio
MozReview-Commit-ID: 6wg32flypt7
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2034,16 +2034,25 @@ fn static_assert() {
}
pub fn copy_quotes_from(&mut self, other: &Self) {
unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); }
}
</%self:impl_trait>
+<%self:impl_trait style_struct_name="Table" skip_longhands="-x-span">
+ #[allow(non_snake_case)]
+ pub fn set__x_span(&mut self, v: longhands::_x_span::computed_value::T) {
+ self.gecko.mSpan = v.0
+ }
+
+ ${impl_simple_copy('_x_span', 'mSpan')}
+</%self:impl_trait>
+
<%self:impl_trait style_struct_name="Effects"
skip_longhands="box-shadow filter">
pub fn set_box_shadow(&mut self, v: longhands::box_shadow::computed_value::T) {
use cssparser::Color;
self.gecko.mBoxShadow.replace_with_new(v.0.len() as u32);
for (servo, gecko_shadow) in v.0.into_iter()
--- a/servo/components/style/properties/longhand/table.mako.rs
+++ b/servo/components/style/properties/longhand/table.mako.rs
@@ -4,8 +4,43 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Table", inherited=False) %>
${helpers.single_keyword("table-layout", "auto fixed",
gecko_ffi_name="mLayoutStrategy", animatable=False,
spec="https://drafts.csswg.org/css-tables/#propdef-table-layout")}
+
+<%helpers:longhand name="-x-span" products="gecko"
+ spec="Internal-only (for `<col span>` pres attr)"
+ animatable="False"
+ internal="True">
+ use values::HasViewportPercentage;
+ use values::computed::ComputedValueAsSpecified;
+
+ impl ComputedValueAsSpecified for SpecifiedValue {}
+ no_viewport_percentage!(SpecifiedValue);
+ pub type SpecifiedValue = computed_value::T;
+ pub mod computed_value {
+ use std::fmt;
+ use style_traits::ToCss;
+
+ #[derive(PartialEq, Clone, Copy, Debug)]
+ pub struct T(pub i32);
+
+ impl ToCss for T {
+ fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write {
+ Ok(())
+ }
+ }
+ }
+
+ #[inline]
+ pub fn get_initial_value() -> computed_value::T {
+ computed_value::T(1)
+ }
+
+ // never parse it, only set via presentation attribute
+ fn parse(_: &ParserContext, _: &mut Parser) -> Result<SpecifiedValue, ()> {
+ Err(())
+ }
+</%helpers:longhand>
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1056,20 +1056,28 @@ pub extern "C" fn Servo_DeclarationBlock
BorderRightStyle => BorderStyle::from_gecko_keyword(value),
BorderBottomStyle => BorderStyle::from_gecko_keyword(value),
BorderLeftStyle => BorderStyle::from_gecko_keyword(value),
};
declarations.write().declarations.push((prop, Default::default()));
}
#[no_mangle]
-pub extern "C" fn Servo_DeclarationBlock_SetIntValue(_: RawServoDeclarationBlockBorrowed,
- _: nsCSSPropertyID,
- _: i32) {
- error!("stylo: Don't know how to handle integer presentation attributes (-x-span)");
+pub extern "C" fn Servo_DeclarationBlock_SetIntValue(declarations: RawServoDeclarationBlockBorrowed,
+ property: nsCSSPropertyID,
+ value: i32) {
+ use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId};
+ use style::properties::longhands::_x_span::computed_value::T as Span;
+
+ let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
+ let long = get_longhand_from_id!(property);
+ let prop = match_wrap_declared! {long,
+ XSpan => Span(value),
+ };
+ declarations.write().declarations.push((prop, Default::default()));
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: f32) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId};