From 614da6b4a166def7dfb522ada92ad535283ae608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 25 Sep 2017 16:03:40 +0200 Subject: [PATCH] style: Simplify paint-order gecko-related code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We share value representation, so there's no reason to do this in a more complex way. MozReview-Commit-ID: BITfCPqTkal Signed-off-by: Emilio Cobos Álvarez --- components/style/properties/gecko.mako.rs | 43 ++--------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 33fe7cd5af0..c8116a975ec 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -5060,51 +5060,14 @@ clip-path <%self:impl_trait style_struct_name="InheritedSVG" skip_longhands="paint-order stroke-dasharray -moz-context-properties"> pub fn set_paint_order(&mut self, v: longhands::paint_order::computed_value::T) { - use self::longhands::paint_order; - - if v.0 == 0 { - self.gecko.mPaintOrder = structs::NS_STYLE_PAINT_ORDER_NORMAL as u8; - } else { - let mut order = 0; - - for pos in 0..3 { - let geckoval = match v.bits_at(pos) { - paint_order::FILL => structs::NS_STYLE_PAINT_ORDER_FILL as u8, - paint_order::STROKE => structs::NS_STYLE_PAINT_ORDER_STROKE as u8, - paint_order::MARKERS => structs::NS_STYLE_PAINT_ORDER_MARKERS as u8, - _ => unreachable!(), - }; - order |= geckoval << (pos * structs::NS_STYLE_PAINT_ORDER_BITWIDTH as u8); - } - - self.gecko.mPaintOrder = order; - } + self.gecko.mPaintOrder = v.0; } ${impl_simple_copy('paint_order', 'mPaintOrder')} pub fn clone_paint_order(&self) -> longhands::paint_order::computed_value::T { - use self::longhands::paint_order::{COUNT, FILL, MARKERS, NORMAL, SHIFT, STROKE}; - use self::longhands::paint_order::computed_value::T; - - if self.gecko.mPaintOrder == structs::NS_STYLE_PAINT_ORDER_NORMAL as u8 { - return T(NORMAL); - } - - const PAINT_ORDER_BITWIDTH: u8 = structs::NS_STYLE_PAINT_ORDER_BITWIDTH as u8; - let mask = (1 << PAINT_ORDER_BITWIDTH) - 1; - let mut order = 0; - for pos in 0..COUNT { - let value = - match (self.gecko.mPaintOrder >> pos * PAINT_ORDER_BITWIDTH & mask) as u32 { - structs::NS_STYLE_PAINT_ORDER_FILL => FILL, - structs::NS_STYLE_PAINT_ORDER_STROKE => STROKE, - structs::NS_STYLE_PAINT_ORDER_MARKERS => MARKERS, - _ => unreachable!(), - }; - order |= value << (pos * SHIFT); - }; - T(order) + use properties::longhands::paint_order::computed_value::T; + T(self.gecko.mPaintOrder) } pub fn set_stroke_dasharray(&mut self, v: longhands::stroke_dasharray::computed_value::T) {