Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow border radii to be set via preshints #16800

Merged
merged 2 commits into from May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/style/values/generics/mod.rs
Expand Up @@ -26,6 +26,12 @@ impl<L> HasViewportPercentage for BorderRadiusSize<L> {
fn has_viewport_percentage(&self) -> bool { false }
}

impl<L: Clone> From<L> for BorderRadiusSize<L> {
fn from(other: L) -> Self {
Self::new(other.clone(), other)
}
}

impl<L> BorderRadiusSize<L> {
#[inline]
/// Create a new `BorderRadiusSize` for an area of given width and height.
Expand Down
19 changes: 9 additions & 10 deletions ports/geckolib/glue.rs
Expand Up @@ -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 {
Expand All @@ -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);
}
}
)
Expand All @@ -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()
})
Expand Down Expand Up @@ -1570,7 +1565,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);
Expand All @@ -1596,6 +1591,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);
Expand Down