From 84ef0de1600458f43c58eb3e259c7ac4f690fd59 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Wed, 4 May 2016 14:51:42 +1000 Subject: [PATCH] Support max-{width,height} in geckolib. --- ports/geckolib/properties.mako.rs | 1 + ports/geckolib/values.rs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 2d291dd9618..9faf4233f61 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -362,6 +362,7 @@ impl Debug for ${style_struct.gecko_ffi_name} { predefined_types = { "LengthOrPercentage": impl_style_coord, "LengthOrPercentageOrAuto": impl_style_coord, + "LengthOrPercentageOrNone": impl_style_coord, "Number": impl_simple, "Opacity": impl_simple, } diff --git a/ports/geckolib/values.rs b/ports/geckolib/values.rs index 99bf5f6fc40..172ce193b8a 100644 --- a/ports/geckolib/values.rs +++ b/ports/geckolib/values.rs @@ -4,7 +4,7 @@ use cssparser::RGBA; use gecko_style_structs::{nsStyleUnion, nsStyleUnit}; -use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; +use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; pub trait ToGeckoStyleCoord { fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion); @@ -46,6 +46,26 @@ impl ToGeckoStyleCoord for LengthOrPercentageOrAuto { } } +impl ToGeckoStyleCoord for LengthOrPercentageOrNone { + fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) { + match *self { + LengthOrPercentageOrNone::Length(au) => { + *unit = nsStyleUnit::eStyleUnit_Coord; + unsafe { *union.mInt.as_mut() = au.0; } + }, + LengthOrPercentageOrNone::Percentage(p) => { + *unit = nsStyleUnit::eStyleUnit_Percent; + unsafe { *union.mFloat.as_mut() = p; } + }, + LengthOrPercentageOrNone::None => { + *unit = nsStyleUnit::eStyleUnit_None; + unsafe { *union.mInt.as_mut() = 0; } + }, + LengthOrPercentageOrNone::Calc(_) => unimplemented!(), + }; + } +} + pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 { (((rgba.alpha * 255.0).round() as u32) << 24) | (((rgba.blue * 255.0).round() as u32) << 16) |