stylo: Add necessary stubbed-out bindings for ServoSpecifiedValues

This commit is contained in:
Manish Goregaokar 2017-02-12 16:02:29 -08:00 committed by Manish Goregaokar
parent 180f2af5e8
commit 31945c287f
3 changed files with 158 additions and 54 deletions

View file

@ -584,6 +584,7 @@ mod bindings {
"nsStyleVisibility", "nsStyleVisibility",
"nsStyleXUL", "nsStyleXUL",
"nsTimingFunction", "nsTimingFunction",
"nscolor",
"nscoord", "nscoord",
"nsresult", "nsresult",
"Loader", "Loader",

View file

@ -159,6 +159,7 @@ use gecko_bindings::structs::nsStyleXUL;
unsafe impl Send for nsStyleXUL {} unsafe impl Send for nsStyleXUL {}
unsafe impl Sync for nsStyleXUL {} unsafe impl Sync for nsStyleXUL {}
use gecko_bindings::structs::nsTimingFunction; use gecko_bindings::structs::nsTimingFunction;
use gecko_bindings::structs::nscolor;
use gecko_bindings::structs::nscoord; use gecko_bindings::structs::nscoord;
use gecko_bindings::structs::nsresult; use gecko_bindings::structs::nsresult;
use gecko_bindings::structs::Loader; use gecko_bindings::structs::Loader;
@ -1440,11 +1441,68 @@ extern "C" {
nsCSSPropertyID); nsCSSPropertyID);
} }
extern "C" { extern "C" {
pub fn Servo_DeclarationBlock_AddPresValue(declarations: pub fn Servo_DeclarationBlock_PropertyIsSet(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID)
-> bool;
}
extern "C" {
pub fn Servo_DeclarationBlock_SetIdentStringValue(declarations:
RawServoDeclarationBlockBorrowed,
property:
nsCSSPropertyID,
value:
*const nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetKeywordValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: i32);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetIntValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: i32);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetPixelValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: f32);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetPercentValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: f32);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetAutoValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, property: nsCSSPropertyID);
css_value: }
nsCSSValueBorrowedMut); extern "C" {
pub fn Servo_DeclarationBlock_SetCurrentColor(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetColorValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: nscolor);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetFontFamily(declarations:
RawServoDeclarationBlockBorrowed,
value:
*const nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations:
RawServoDeclarationBlockBorrowed);
} }
extern "C" { extern "C" {
pub fn Servo_CSSSupports2(name: *const nsACString_internal, pub fn Servo_CSSSupports2(name: *const nsACString_internal,

View file

@ -36,7 +36,7 @@ use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSet
use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed}; use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong}; use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong}; use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
use style::gecko_bindings::bindings::{nsACString, nsCSSValueBorrowedMut, nsAString}; use style::gecko_bindings::bindings::{nsACString, nsAString};
use style::gecko_bindings::bindings::Gecko_AnimationAppendKeyframe; use style::gecko_bindings::bindings::Gecko_AnimationAppendKeyframe;
use style::gecko_bindings::bindings::RawGeckoAnimationValueListBorrowedMut; use style::gecko_bindings::bindings::RawGeckoAnimationValueListBorrowedMut;
use style::gecko_bindings::bindings::RawGeckoElementBorrowed; use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
@ -952,58 +952,103 @@ pub extern "C" fn Servo_DeclarationBlock_RemovePropertyById(declarations: RawSer
remove_property(declarations, get_property_id_from_nscsspropertyid!(property, ())) remove_property(declarations, get_property_id_from_nscsspropertyid!(property, ()))
} }
macro_rules! get_longhand_from_id {
($id:expr, $retval:expr) => {
match PropertyId::from_nscsspropertyid($id) {
Ok(PropertyId::Longhand(long)) => long,
_ => {
error!("stylo: unknown presentation property with id {:?}", $id);
return $retval
}
}
}
}
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_AddPresValue(declarations: RawServoDeclarationBlockBorrowed, pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations:
property: nsCSSPropertyID, RawServoDeclarationBlockBorrowed,
css_value: nsCSSValueBorrowedMut) { property: nsCSSPropertyID)
use style::gecko::values::convert_nscolor_to_rgba; -> bool {
use style::properties::{DeclaredValue, LonghandId, PropertyDeclaration, PropertyId, longhands}; use style::properties::PropertyDeclarationId;
use style::values::specified;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
let prop = PropertyId::from_nscsspropertyid(property); let long = get_longhand_from_id!(property, false);
declarations.read().get(PropertyDeclarationId::Longhand(long)).is_some()
}
let long = match prop { #[no_mangle]
Ok(PropertyId::Longhand(long)) => long, pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(_:
_ => { RawServoDeclarationBlockBorrowed,
warn!("stylo: unknown presentation property with id {:?}", property); _:
return nsCSSPropertyID,
} _:
}; *const nsAString) {
let decl = match long { //
LonghandId::FontSize => { error!("stylo: Don't know how to handle ident presentation attributes (-x-lang)");
if let Some(int) = css_value.integer() { }
PropertyDeclaration::FontSize(DeclaredValue::Value(
longhands::font_size::SpecifiedValue( #[no_mangle]
specified::LengthOrPercentage::Length( pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(_:
specified::NoCalcLength::from_font_size_int(int as u8) RawServoDeclarationBlockBorrowed,
) _: nsCSSPropertyID,
) _: i32) {
))
} else { }
warn!("stylo: got unexpected non-integer value for font-size presentation attribute");
return #[no_mangle]
} pub extern "C" fn Servo_DeclarationBlock_SetIntValue(_: RawServoDeclarationBlockBorrowed,
} _: nsCSSPropertyID,
LonghandId::Color => { _: i32) {
if let Some(color) = css_value.color_value() { error!("stylo: Don't know how to handle integer presentation attributes (-x-span)");
PropertyDeclaration::Color(DeclaredValue::Value( }
specified::CSSRGBA {
parsed: convert_nscolor_to_rgba(color), #[no_mangle]
authored: None pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(_:
} RawServoDeclarationBlockBorrowed,
)) _: nsCSSPropertyID,
} else { _: f32) {
warn!("stylo: got unexpected non-integer value for color presentation attribute");
return }
}
} #[no_mangle]
_ => { pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(_:
warn!("stylo: cannot handle longhand {:?} from presentation attribute", long); RawServoDeclarationBlockBorrowed,
return _: nsCSSPropertyID,
} _: f32) {
};
declarations.write().declarations.push((decl, Importance::Normal)); }
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(_:
RawServoDeclarationBlockBorrowed,
_: nsCSSPropertyID) {
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(_:
RawServoDeclarationBlockBorrowed,
_: nsCSSPropertyID) {
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetColorValue(_:
RawServoDeclarationBlockBorrowed,
_: nsCSSPropertyID,
_: structs::nscolor) {
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(_:
RawServoDeclarationBlockBorrowed,
_: *const nsAString) {
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(_:
RawServoDeclarationBlockBorrowed) {
} }