From 195e37954f6921e78fc9e7acdca2baa749e11778 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 10 May 2017 14:08:01 -0700 Subject: [PATCH 1/2] Allow border radii to be set via preshints --- components/style/values/generics/mod.rs | 6 ++++++ ports/geckolib/glue.rs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index c0a3823f3b0..43cf722fb7e 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -26,6 +26,12 @@ impl HasViewportPercentage for BorderRadiusSize { fn has_viewport_percentage(&self) -> bool { false } } +impl From for BorderRadiusSize { + fn from(other: L) -> Self { + Self::new(other.clone(), other) + } +} + impl BorderRadiusSize { #[inline] /// Create a new `BorderRadiusSize` for an area of given width and height. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 3de322d9d98..47d2c92b573 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1570,7 +1570,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations: use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing; use style::values::specified::BorderWidth; - use style::values::specified::length::NoCalcLength; + use style::values::specified::length::{NoCalcLength, LengthOrPercentage}; let long = get_longhand_from_id!(property); let nocalc = NoCalcLength::from_px(value); @@ -1596,6 +1596,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations: vertical: None, } ), + BorderTopLeftRadius => Box::new(LengthOrPercentage::from(nocalc).into()), + BorderTopRightRadius => Box::new(LengthOrPercentage::from(nocalc).into()), + BorderBottomLeftRadius => Box::new(LengthOrPercentage::from(nocalc).into()), + BorderBottomRightRadius => Box::new(LengthOrPercentage::from(nocalc).into()), }; write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| { decls.push(prop, Importance::Normal); From d1c3021f432bc6e265a85ad8c2ec35be665aaa83 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 10 May 2017 16:23:59 -0700 Subject: [PATCH 2/2] Make unknown pres attrs panic --- ports/geckolib/glue.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 47d2c92b573..0d318e9e032 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1441,18 +1441,14 @@ pub extern "C" fn Servo_MediaList_DeleteMedium(list: RawServoMediaListBorrowed, } macro_rules! get_longhand_from_id { - ($id:expr, $retval:expr) => { + ($id:expr) => { match PropertyId::from_nscsspropertyid($id) { Ok(PropertyId::Longhand(long)) => long, _ => { - error!("stylo: unknown presentation property with id {:?}", $id); - return $retval + panic!("stylo: unknown presentation property with id {:?}", $id); } } }; - ($id:expr) => { - get_longhand_from_id!($id, ()) - } } macro_rules! match_wrap_declared { @@ -1462,8 +1458,7 @@ macro_rules! match_wrap_declared { LonghandId::$property => PropertyDeclaration::$property($inner), )* _ => { - error!("stylo: Don't know how to handle presentation property {:?}", $longhand); - return + panic!("stylo: Don't know how to handle presentation property {:?}", $longhand); } } ) @@ -1475,7 +1470,7 @@ pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations: property: nsCSSPropertyID) -> bool { use style::properties::PropertyDeclarationId; - let long = get_longhand_from_id!(property, false); + let long = get_longhand_from_id!(property); read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| { decls.get(PropertyDeclarationId::Longhand(long)).is_some() })