Skip to content
Permalink
Browse files

style: Avoid manual paint-order glue code.

  • Loading branch information...
emilio committed Aug 21, 2019
1 parent 14c7e13 commit 432b417d989b1b53c4e27da5b2dc3a35f53a0b1c
Showing with 6 additions and 16 deletions.
  1. +1 −12 components/style/properties/gecko.mako.rs
  2. +5 −4 components/style/values/specified/svg.rs
@@ -2599,18 +2599,7 @@ clip-path
</%self:impl_trait>

<%self:impl_trait style_struct_name="InheritedSVG"
skip_longhands="paint-order stroke-dasharray">
pub fn set_paint_order(&mut self, v: longhands::paint_order::computed_value::T) {
self.gecko.mPaintOrder = v.0;
}

${impl_simple_copy('paint_order', 'mPaintOrder')}

pub fn clone_paint_order(&self) -> longhands::paint_order::computed_value::T {
use crate::properties::longhands::paint_order::computed_value::T;
T(self.gecko.mPaintOrder)
}

skip_longhands="stroke-dasharray">
pub fn set_stroke_dasharray(&mut self, v: longhands::stroke_dasharray::computed_value::T) {
use crate::gecko_bindings::structs::nsStyleSVG_STROKE_DASHARRAY_CONTEXT as CONTEXT_VALUE;
use crate::values::generics::svg::SVGStrokeDashArray;
@@ -106,13 +106,13 @@ pub enum PaintOrder {
}

/// Number of non-normal components
const PAINT_ORDER_COUNT: u8 = 3;
pub const PAINT_ORDER_COUNT: u8 = 3;

/// Number of bits for each component
const PAINT_ORDER_SHIFT: u8 = 2;
pub const PAINT_ORDER_SHIFT: u8 = 2;

/// Mask with above bits set
const PAINT_ORDER_MASK: u8 = 0b11;
pub const PAINT_ORDER_MASK: u8 = 0b11;

/// The specified value is tree `PaintOrder` values packed into the
/// bitfields below, as a six-bit field, of 3 two-bit pairs
@@ -135,6 +135,7 @@ const PAINT_ORDER_MASK: u8 = 0b11;
ToResolvedValue,
ToShmem,
)]
#[repr(transparent)]
pub struct SVGPaintOrder(pub u8);

impl SVGPaintOrder {
@@ -146,7 +147,7 @@ impl SVGPaintOrder {
/// Get variant of `paint-order`
pub fn order_at(&self, pos: u8) -> PaintOrder {
// Safe because PaintOrder covers all possible patterns.
unsafe { ::std::mem::transmute((self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK) }
unsafe { std::mem::transmute((self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK) }
}
}

0 comments on commit 432b417

Please sign in to comment.
You can’t perform that action at this time.