diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 23361cc1734..de60fe615be 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -502,7 +502,7 @@ mod bindings { .header(add_include("mozilla/ServoBindings.h")) .hide_type("nsACString_internal") .hide_type("nsAString_internal") - .raw_line("pub use nsstring::{nsACString, nsAString};") + .raw_line("pub use nsstring::{nsACString, nsAString, nsString};") .raw_line("type nsACString_internal = nsACString;") .raw_line("type nsAString_internal = nsAString;") .whitelisted_function("Servo_.*") diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index e79b7f47dd3..b0a043ead46 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1,6 +1,6 @@ /* automatically generated by rust-bindgen */ -pub use nsstring::{nsACString, nsAString}; +pub use nsstring::{nsACString, nsAString, nsString}; type nsACString_internal = nsACString; type nsAString_internal = nsAString; use gecko_bindings::structs::mozilla::css::URLValue; @@ -854,6 +854,14 @@ extern "C" { extern "C" { pub fn Gecko_PropertyId_IsPrefEnabled(id: nsCSSPropertyID) -> bool; } +extern "C" { + pub fn Gecko_nsStyleFont_SetLang(font: *mut nsStyleFont, + atom: *mut nsIAtom); +} +extern "C" { + pub fn Gecko_nsStyleFont_CopyLangFrom(aFont: *mut nsStyleFont, + aSource: *const nsStyleFont); +} extern "C" { pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature; } @@ -1451,8 +1459,7 @@ extern "C" { RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID, - value: - *const nsAString_internal); + value: *mut nsIAtom); } extern "C" { pub fn Servo_DeclarationBlock_SetKeywordValue(declarations: diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 66606530fc9..ca8dbd7a65e 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -33,6 +33,8 @@ use gecko_bindings::bindings::Gecko_FontFamilyList_Clear; use gecko_bindings::bindings::Gecko_SetCursorArrayLength; use gecko_bindings::bindings::Gecko_SetCursorImage; use gecko_bindings::bindings::Gecko_NewCSSShadowArray; +use gecko_bindings::bindings::Gecko_nsStyleFont_SetLang; +use gecko_bindings::bindings::Gecko_nsStyleFont_CopyLangFrom; use gecko_bindings::bindings::Gecko_SetListStyleImage; use gecko_bindings::bindings::Gecko_SetListStyleImageNone; use gecko_bindings::bindings::Gecko_SetListStyleType; @@ -53,7 +55,7 @@ use properties::longhands; use properties::{DeclaredValue, Importance, LonghandId}; use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId}; use std::fmt::{self, Debug}; -use std::mem::{transmute, zeroed}; +use std::mem::{forget, transmute, zeroed}; use std::ptr; use std::sync::Arc; use std::cmp; @@ -1119,7 +1121,7 @@ fn static_assert() { <%self:impl_trait style_struct_name="Font" - skip_longhands="font-family font-size font-size-adjust font-weight font-synthesis" + skip_longhands="font-family font-size font-size-adjust font-weight font-synthesis -x-lang" skip_additionals="*"> pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) { @@ -1228,6 +1230,21 @@ fn static_assert() { } } + #[allow(non_snake_case)] + pub fn set__x_lang(&mut self, v: longhands::_x_lang::computed_value::T) { + let ptr = v.0.as_ptr(); + forget(v); + unsafe { + Gecko_nsStyleFont_SetLang(&mut self.gecko, ptr); + } + } + + #[allow(non_snake_case)] + pub fn copy__x_lang_from(&mut self, other: &Self) { + unsafe { + Gecko_nsStyleFont_CopyLangFrom(&mut self.gecko, &other.gecko); + } + } <%def name="impl_copy_animation_value(ident, gecko_ffi_name)"> diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index d605bda6bb2..a860e61ef8f 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -761,3 +761,40 @@ ${helpers.single_keyword("font-variant-position", } } + +<%helpers:longhand name="-x-lang" products="gecko" animatable="False" internal="True" + spec="Internal (not web-exposed)" + internal="True"> + use values::HasViewportPercentage; + use values::computed::ComputedValueAsSpecified; + pub use self::computed_value::T as SpecifiedValue; + + impl ComputedValueAsSpecified for SpecifiedValue {} + no_viewport_percentage!(SpecifiedValue); + + pub mod computed_value { + use Atom; + use std::fmt; + use style_traits::ToCss; + + impl ToCss for T { + fn to_css(&self, _: &mut W) -> fmt::Result where W: fmt::Write { + Ok(()) + } + } + + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct T(pub Atom); + } + + #[inline] + pub fn get_initial_value() -> computed_value::T { + computed_value::T(atom!("")) + } + + pub fn parse(_context: &ParserContext, _input: &mut Parser) -> Result { + debug_assert!(false, "Should be set directly by presentation attributes only."); + Err(()) + } + diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 1b71829b54a..5964aa3a2f2 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -993,14 +993,21 @@ pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations: } #[no_mangle] -pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(_: +pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations: RawServoDeclarationBlockBorrowed, - _: + property: nsCSSPropertyID, - _: - *const nsAString) { - // - error!("stylo: Don't know how to handle ident presentation attributes (-x-lang)"); + value: + *mut nsIAtom) { + use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::longhands::_x_lang::computed_value::T as Lang; + + let declarations = RwLock::::as_arc(&declarations); + let long = get_longhand_from_id!(property); + let prop = match_wrap_declared! { long, + XLang => Lang(Atom::from(value)), + }; + declarations.write().declarations.push((prop, Default::default())); } #[no_mangle]