stylo: Support lang property

This commit is contained in:
Nazım Can Altınova 2017-02-12 16:02:29 -08:00 committed by Manish Goregaokar
parent ade09844b7
commit d7941d5e35
5 changed files with 80 additions and 12 deletions

View file

@ -502,7 +502,7 @@ mod bindings {
.header(add_include("mozilla/ServoBindings.h")) .header(add_include("mozilla/ServoBindings.h"))
.hide_type("nsACString_internal") .hide_type("nsACString_internal")
.hide_type("nsAString_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 nsACString_internal = nsACString;")
.raw_line("type nsAString_internal = nsAString;") .raw_line("type nsAString_internal = nsAString;")
.whitelisted_function("Servo_.*") .whitelisted_function("Servo_.*")

View file

@ -1,6 +1,6 @@
/* automatically generated by rust-bindgen */ /* automatically generated by rust-bindgen */
pub use nsstring::{nsACString, nsAString}; pub use nsstring::{nsACString, nsAString, nsString};
type nsACString_internal = nsACString; type nsACString_internal = nsACString;
type nsAString_internal = nsAString; type nsAString_internal = nsAString;
use gecko_bindings::structs::mozilla::css::URLValue; use gecko_bindings::structs::mozilla::css::URLValue;
@ -854,6 +854,14 @@ extern "C" {
extern "C" { extern "C" {
pub fn Gecko_PropertyId_IsPrefEnabled(id: nsCSSPropertyID) -> bool; 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" { extern "C" {
pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature; pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature;
} }
@ -1451,8 +1459,7 @@ extern "C" {
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: property:
nsCSSPropertyID, nsCSSPropertyID,
value: value: *mut nsIAtom);
*const nsAString_internal);
} }
extern "C" { extern "C" {
pub fn Servo_DeclarationBlock_SetKeywordValue(declarations: pub fn Servo_DeclarationBlock_SetKeywordValue(declarations:

View file

@ -33,6 +33,8 @@ use gecko_bindings::bindings::Gecko_FontFamilyList_Clear;
use gecko_bindings::bindings::Gecko_SetCursorArrayLength; use gecko_bindings::bindings::Gecko_SetCursorArrayLength;
use gecko_bindings::bindings::Gecko_SetCursorImage; use gecko_bindings::bindings::Gecko_SetCursorImage;
use gecko_bindings::bindings::Gecko_NewCSSShadowArray; 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_SetListStyleImage;
use gecko_bindings::bindings::Gecko_SetListStyleImageNone; use gecko_bindings::bindings::Gecko_SetListStyleImageNone;
use gecko_bindings::bindings::Gecko_SetListStyleType; use gecko_bindings::bindings::Gecko_SetListStyleType;
@ -53,7 +55,7 @@ use properties::longhands;
use properties::{DeclaredValue, Importance, LonghandId}; use properties::{DeclaredValue, Importance, LonghandId};
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId}; use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
use std::mem::{transmute, zeroed}; use std::mem::{forget, transmute, zeroed};
use std::ptr; use std::ptr;
use std::sync::Arc; use std::sync::Arc;
use std::cmp; use std::cmp;
@ -1119,7 +1121,7 @@ fn static_assert() {
</%self:impl_trait> </%self:impl_trait>
<%self:impl_trait style_struct_name="Font" <%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="*"> skip_additionals="*">
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) { 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);
}
}
</%self:impl_trait> </%self:impl_trait>
<%def name="impl_copy_animation_value(ident, gecko_ffi_name)"> <%def name="impl_copy_animation_value(ident, gecko_ffi_name)">

View file

@ -761,3 +761,40 @@ ${helpers.single_keyword("font-variant-position",
} }
} }
</%helpers:longhand> </%helpers:longhand>
<%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<W>(&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<SpecifiedValue, ()> {
debug_assert!(false, "Should be set directly by presentation attributes only.");
Err(())
}
</%helpers:longhand>

View file

@ -993,14 +993,21 @@ pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations:
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(_: pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
_: property:
nsCSSPropertyID, nsCSSPropertyID,
_: value:
*const nsAString) { *mut nsIAtom) {
// use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId};
error!("stylo: Don't know how to handle ident presentation attributes (-x-lang)"); use style::properties::longhands::_x_lang::computed_value::T as Lang;
let declarations = RwLock::<PropertyDeclarationBlock>::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] #[no_mangle]