[librsvg: 2/16] ComputedValues: make all fields private; access them through functions



commit 6abe286672c0a55d5e378faaf6f6469f503ef440
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Mar 25 11:50:23 2020 -0600

    ComputedValues: make all fields private; access them through functions
    
    This will let us generate the field values lazily and make the
    ComputedValues struct smaller.

 rsvg_internals/src/drawing_ctx.rs            | 49 ++++++++++++------------
 rsvg_internals/src/filters/context.rs        | 10 ++---
 rsvg_internals/src/filters/flood.rs          |  6 +--
 rsvg_internals/src/filters/light/lighting.rs |  6 +--
 rsvg_internals/src/filters/mod.rs            |  2 +-
 rsvg_internals/src/filters/turbulence.rs     |  2 +-
 rsvg_internals/src/font_props.rs             | 10 ++++-
 rsvg_internals/src/gradient.rs               |  6 +--
 rsvg_internals/src/length.rs                 |  2 +-
 rsvg_internals/src/marker.rs                 | 18 ++++-----
 rsvg_internals/src/properties.rs             | 29 +++++++++++---
 rsvg_internals/src/property_defs.rs          |  9 +++--
 rsvg_internals/src/text.rs                   | 56 ++++++++++++++--------------
 13 files changed, 116 insertions(+), 89 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 08e32519..da4ff71d 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -448,7 +448,7 @@ impl DrawingCtx {
             res?;
         }
 
-        let Opacity(opacity) = values.opacity;
+        let Opacity(opacity) = values.opacity();
 
         let mask = SharedImageSurface::wrap(mask_content_surface, SurfaceType::SRgb)?
             .to_mask(opacity)?
@@ -472,18 +472,21 @@ impl DrawingCtx {
             draw_fn(acquired_nodes, self)
         } else {
             self.with_saved_cr(&mut |dc| {
-                let clip_uri = values.clip_path.0.get();
-                let mask = values.mask.0.get();
+                let clip_path_value = values.clip_path();
+                let mask_value = values.mask();
+
+                let clip_uri = clip_path_value.0.get();
+                let mask = mask_value.0.get();
 
                 // The `filter` property does not apply to masks.
                 let filter =
                     if node.is_element() && node.borrow_element().get_type() == ElementType::Mask {
                         None
                     } else {
-                        values.filter.0.get()
+                        values.filter().0.get().cloned()
                     };
 
-                let UnitInterval(opacity) = values.opacity.0;
+                let UnitInterval(opacity) = values.opacity().0;
 
                 let affine_at_start = dc.get_transform();
 
@@ -544,7 +547,7 @@ impl DrawingCtx {
                         let img_surface = dc
                             .run_filter(
                                 acquired_nodes,
-                                filter_uri,
+                                &filter_uri,
                                 node,
                                 values,
                                 child_surface,
@@ -886,12 +889,12 @@ impl DrawingCtx {
     pub fn setup_cr_for_stroke(&self, cr: &cairo::Context, values: &ComputedValues) {
         let params = self.get_view_params();
 
-        cr.set_line_width(values.stroke_width.0.normalize(values, &params));
-        cr.set_miter_limit(values.stroke_miterlimit.0);
-        cr.set_line_cap(cairo::LineCap::from(values.stroke_line_cap));
-        cr.set_line_join(cairo::LineJoin::from(values.stroke_line_join));
+        cr.set_line_width(values.stroke_width().0.normalize(values, &params));
+        cr.set_miter_limit(values.stroke_miterlimit().0);
+        cr.set_line_cap(cairo::LineCap::from(values.stroke_line_cap()));
+        cr.set_line_join(cairo::LineJoin::from(values.stroke_line_join()));
 
-        if let StrokeDasharray(Dasharray::Array(ref dashes)) = values.stroke_dasharray {
+        if let StrokeDasharray(Dasharray::Array(ref dashes)) = values.stroke_dasharray() {
             let normalized_dashes: Vec<f64> = dashes
                 .iter()
                 .map(|l| l.normalize(values, &params))
@@ -900,7 +903,7 @@ impl DrawingCtx {
             let total_length = normalized_dashes.iter().fold(0.0, |acc, &len| acc + len);
 
             if total_length > 0.0 {
-                let offset = values.stroke_dashoffset.0.normalize(values, &params);
+                let offset = values.stroke_dashoffset().0.normalize(values, &params);
                 cr.set_dash(&normalized_dashes, offset);
             } else {
                 cr.set_dash(&[], 0.0);
@@ -914,7 +917,7 @@ impl DrawingCtx {
         acquired_nodes: &mut AcquiredNodes,
         values: &ComputedValues,
     ) -> Result<BoundingBox, RenderingError> {
-        cr.set_antialias(cairo::Antialias::from(values.shape_rendering));
+        cr.set_antialias(cairo::Antialias::from(values.shape_rendering()));
 
         self.setup_cr_for_stroke(cr, values);
 
@@ -924,19 +927,19 @@ impl DrawingCtx {
         // coordinate system in patterns.
         let bbox = compute_stroke_and_fill_box(cr, values);
 
-        let current_color = values.color.0;
+        let current_color = values.color().0;
 
         let res = self
             .set_source_paint_server(
                 acquired_nodes,
-                &values.fill.0,
-                values.fill_opacity.0,
+                &values.fill().0,
+                values.fill_opacity().0,
                 &bbox,
                 current_color,
             )
             .and_then(|had_paint_server| {
                 if had_paint_server {
-                    if values.stroke.0 == PaintServer::None {
+                    if values.stroke().0 == PaintServer::None {
                         cr.fill();
                     } else {
                         cr.fill_preserve();
@@ -948,8 +951,8 @@ impl DrawingCtx {
             .and_then(|_| {
                 self.set_source_paint_server(
                     acquired_nodes,
-                    &values.stroke.0,
-                    values.stroke_opacity.0,
+                    &values.stroke().0,
+                    values.stroke_opacity().0,
                     &bbox,
                     current_color,
                 )
@@ -985,10 +988,10 @@ impl DrawingCtx {
                     path.to_cairo(&cr)?;
 
                     if clipping {
-                        cr.set_fill_rule(cairo::FillRule::from(values.clip_rule));
+                        cr.set_fill_rule(cairo::FillRule::from(values.clip_rule()));
                         Ok(dc.empty_bbox())
                     } else {
-                        cr.set_fill_rule(cairo::FillRule::from(values.fill_rule));
+                        cr.set_fill_rule(cairo::FillRule::from(values.fill_rule()));
                         dc.stroke_and_fill(&cr, an, values)
                     }
                 })?;
@@ -1178,7 +1181,7 @@ impl DrawingCtx {
             let symbol = elt.get_impl::<Symbol>();
 
             let clip_mode = if !values.is_overflow()
-                || (values.overflow == Overflow::Visible
+                || (values.overflow() == Overflow::Visible
                     && child.borrow_element().get_specified_values().is_overflow())
             {
                 Some(ClipMode::ClipToVbox)
@@ -1334,7 +1337,7 @@ fn compute_stroke_and_fill_box(cr: &cairo::Context, values: &ComputedValues) ->
 
     // Bounding box for stroke
 
-    if values.stroke.0 != PaintServer::None {
+    if values.stroke().0 != PaintServer::None {
         let (x0, y0, x1, y1) = cr.stroke_extents();
         let sb = BoundingBox::new()
             .with_transform(affine)
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 0d6abea1..d1cb737e 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -292,7 +292,7 @@ impl FilterContext {
                     paint_server,
                     opacity,
                     &self.node_bbox,
-                    self.computed_from_node_being_filtered.color.0,
+                    self.computed_from_node_being_filtered.color().0,
                 )
                 .and_then(|had_paint_server| {
                     if had_paint_server {
@@ -357,8 +357,8 @@ impl FilterContext {
                 .get_paint_server_surface(
                     draw_ctx,
                     acquired_nodes,
-                    &values.fill.0,
-                    values.fill_opacity.0,
+                    &values.fill().0,
+                    values.fill_opacity().0,
                 )
                 .map_err(FilterError::CairoError)
                 .map(FilterInput::StandardInput),
@@ -367,8 +367,8 @@ impl FilterContext {
                 .get_paint_server_surface(
                     draw_ctx,
                     acquired_nodes,
-                    &values.stroke.0,
-                    values.stroke_opacity.0,
+                    &values.stroke().0,
+                    values.stroke_opacity().0,
                 )
                 .map_err(FilterError::CairoError)
                 .map(FilterInput::StandardInput),
diff --git a/rsvg_internals/src/filters/flood.rs b/rsvg_internals/src/filters/flood.rs
index 9ff8d942..69eb6ef3 100644
--- a/rsvg_internals/src/filters/flood.rs
+++ b/rsvg_internals/src/filters/flood.rs
@@ -44,11 +44,11 @@ impl FilterEffect for FeFlood {
         let cascaded = CascadedValues::new_from_node(node);
         let values = cascaded.get();
 
-        let color = match values.flood_color.0 {
-            cssparser::Color::CurrentColor => values.color.0,
+        let color = match values.flood_color().0 {
+            cssparser::Color::CurrentColor => values.color().0,
             cssparser::Color::RGBA(rgba) => rgba,
         };
-        let opacity = values.flood_opacity.0;
+        let opacity = values.flood_opacity().0;
 
         let surface = ctx.source_graphic().flood(bounds, color, opacity)?;
 
diff --git a/rsvg_internals/src/filters/light/lighting.rs b/rsvg_internals/src/filters/light/lighting.rs
index 97f51f73..9e0ba8eb 100644
--- a/rsvg_internals/src/filters/light/lighting.rs
+++ b/rsvg_internals/src/filters/light/lighting.rs
@@ -273,8 +273,8 @@ macro_rules! impl_lighting_filter {
 
                 let cascaded = CascadedValues::new_from_node(node);
                 let values = cascaded.get();
-                let lighting_color = match values.lighting_color.0 {
-                    cssparser::Color::CurrentColor => values.color.0,
+                let lighting_color = match values.lighting_color().0 {
+                    cssparser::Color::CurrentColor => values.color().0,
                     cssparser::Color::RGBA(rgba) => rgba,
                 };
 
@@ -304,7 +304,7 @@ macro_rules! impl_lighting_filter {
                 let values = cascaded.get();
                 // The generated color values are in the color space determined by
                 // color-interpolation-filters.
-                let surface_type = SurfaceType::from(values.color_interpolation_filters);
+                let surface_type = SurfaceType::from(values.color_interpolation_filters());
 
                 let mut surface = ExclusiveImageSurface::new(
                     input_surface.width(),
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index 6952a767..28023537 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -295,7 +295,7 @@ pub fn render(
                 let cascaded = CascadedValues::new_from_node(&c);
                 let values = cascaded.get();
 
-                values.color_interpolation_filters == ColorInterpolationFilters::LinearRgb
+                values.color_interpolation_filters() == ColorInterpolationFilters::LinearRgb
             };
 
             (c, linear_rgb)
diff --git a/rsvg_internals/src/filters/turbulence.rs b/rsvg_internals/src/filters/turbulence.rs
index 549332a8..5cd059a4 100644
--- a/rsvg_internals/src/filters/turbulence.rs
+++ b/rsvg_internals/src/filters/turbulence.rs
@@ -358,7 +358,7 @@ impl FilterEffect for FeTurbulence {
         let values = cascaded.get();
         // The generated color values are in the color space determined by
         // color-interpolation-filters.
-        let surface_type = SurfaceType::from(values.color_interpolation_filters);
+        let surface_type = SurfaceType::from(values.color_interpolation_filters());
 
         let mut surface = ExclusiveImageSurface::new(
             ctx.source_graphic().width(),
diff --git a/rsvg_internals/src/font_props.rs b/rsvg_internals/src/font_props.rs
index 6a0a300b..24d60087 100644
--- a/rsvg_internals/src/font_props.rs
+++ b/rsvg_internals/src/font_props.rs
@@ -34,7 +34,7 @@ impl FontSizeSpec {
     pub fn compute(&self, v: &ComputedValues) -> Self {
         let compute_points = |p| 12.0 * 1.2f64.powf(p) / POINTS_PER_INCH;
 
-        let parent = v.font_size.0.value();
+        let parent = v.font_size().0.value();
 
         // The parent must already have resolved to an absolute unit
         assert!(
@@ -231,6 +231,7 @@ impl Parse for SingleFontFamily {
 mod tests {
     use super::*;
 
+    use crate::properties::{ParsedProperty, SpecifiedValue, SpecifiedValues};
     use crate::property_defs::FontSize;
     use crate::property_macros::Property;
 
@@ -241,8 +242,13 @@ mod tests {
 
     #[test]
     fn computes_parent_relative_font_size() {
+        let mut specified = SpecifiedValues::default();
+        specified.set_parsed_property(&ParsedProperty::FontSize(SpecifiedValue::Specified(
+            FontSize::parse_str("10px").unwrap(),
+        )));
+
         let mut values = ComputedValues::default();
-        values.font_size = FontSize::parse_str("10px").unwrap();
+        specified.to_computed_values(&mut values);
 
         assert_eq!(
             FontSize::parse_str("150%").unwrap().compute(&values),
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 131e73a5..6ab3da94 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -483,12 +483,12 @@ impl UnresolvedGradient {
             } else {
                 let cascaded = CascadedValues::new_from_node(&child_node);
                 let values = cascaded.get();
-                let rgba = match values.stop_color {
-                    StopColor(cssparser::Color::CurrentColor) => values.color.0,
+                let rgba = match values.stop_color() {
+                    StopColor(cssparser::Color::CurrentColor) => values.color().0,
                     StopColor(cssparser::Color::RGBA(ref rgba)) => *rgba,
                 };
 
-                self.add_color_stop(stop.offset, rgba, values.stop_opacity.0);
+                self.add_color_stop(stop.offset, rgba, values.stop_opacity().0);
             }
         }
     }
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index a188baae..2b5d7b58 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -353,7 +353,7 @@ impl<N: Normalize> Length<N> {
 }
 
 fn font_size_from_values(values: &ComputedValues, params: &ViewParams) -> f64 {
-    let v = &values.font_size.0.value();
+    let v = &values.font_size().0.value();
 
     match v.unit {
         LengthUnit::Percent => unreachable!("ComputedValues can't have a relative font size"),
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index ee5e5b11..c69b7e56 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -624,7 +624,7 @@ pub fn render_markers_for_path(
     clipping: bool,
 ) -> Result<BoundingBox, RenderingError> {
     let line_width = values
-        .stroke_width
+        .stroke_width()
         .0
         .normalize(values, &draw_ctx.get_view_params());
 
@@ -632,11 +632,11 @@ pub fn render_markers_for_path(
         return Ok(draw_ctx.empty_bbox());
     }
 
-    let marker_start = &values.marker_start.0;
-    let marker_mid = &values.marker_mid.0;
-    let marker_end = &values.marker_end.0;
+    let marker_start = values.marker_start().0;
+    let marker_mid = values.marker_mid().0;
+    let marker_end = values.marker_end().0;
 
-    if let (&IRI::None, &IRI::None, &IRI::None) = (marker_start, marker_mid, marker_end) {
+    if let (&IRI::None, &IRI::None, &IRI::None) = (&marker_start, &marker_mid, &marker_end) {
         return Ok(draw_ctx.empty_bbox());
     }
 
@@ -644,10 +644,10 @@ pub fn render_markers_for_path(
         path_commands,
         draw_ctx.empty_bbox(),
         &mut |marker_type: MarkerType, x: f64, y: f64, computed_angle: Angle| {
-            if let &IRI::Resource(ref marker) = match marker_type {
-                MarkerType::Start => &values.marker_start.0,
-                MarkerType::Middle => &values.marker_mid.0,
-                MarkerType::End => &values.marker_end.0,
+            if let IRI::Resource(ref marker) = match marker_type {
+                MarkerType::Start => &marker_start,
+                MarkerType::Middle => &marker_mid,
+                MarkerType::End => &marker_end,
             } {
                 emit_marker_by_name(
                     draw_ctx,
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 08337538..321bda11 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -434,12 +434,21 @@ impl ComputedValues {
     }
 }
 
+/// Macro to generate the ComputedValues struct
 macro_rules! make_computed_values {
     { $($field:ident: $ty:ident,)+ } => {
         #[derive(Debug, Default, Clone)]
         pub struct ComputedValues {
             $(
-                pub $field: $ty,
+                $field: $ty,
+            )+
+        }
+
+        impl ComputedValues {
+            $(
+                pub fn $field(&self) -> $ty {
+                    self.$field.clone()
+                }
             )+
         }
     };
@@ -524,16 +533,24 @@ impl SpecifiedValues {
         }
     }
 
-    #[rustfmt::skip]
     fn set_property_expanding_shorthands(&mut self, prop: &ParsedProperty, replace: bool) {
-        use crate::properties::ParsedProperty::*;
         use crate::properties as p;
+        use crate::properties::ParsedProperty::*;
 
         if let Marker(SpecifiedValue::Specified(p::Marker(ref v))) = *prop {
             // Since "marker" is a shorthand property, we'll just expand it here
-            self.set_property(&MarkerStart(SpecifiedValue::Specified(p::MarkerStart(v.clone()))), replace);
-            self.set_property(&MarkerMid(SpecifiedValue::Specified(p::MarkerMid(v.clone()))), replace);
-            self.set_property(&MarkerEnd(SpecifiedValue::Specified(p::MarkerEnd(v.clone()))), replace);
+            self.set_property(
+                &MarkerStart(SpecifiedValue::Specified(p::MarkerStart(v.clone()))),
+                replace,
+            );
+            self.set_property(
+                &MarkerMid(SpecifiedValue::Specified(p::MarkerMid(v.clone()))),
+                replace,
+            );
+            self.set_property(
+                &MarkerEnd(SpecifiedValue::Specified(p::MarkerEnd(v.clone()))),
+                replace,
+            );
         } else {
             self.set_property(prop, replace);
         }
diff --git a/rsvg_internals/src/property_defs.rs b/rsvg_internals/src/property_defs.rs
index 3df0ba8b..e6bce856 100644
--- a/rsvg_internals/src/property_defs.rs
+++ b/rsvg_internals/src/property_defs.rs
@@ -26,17 +26,18 @@ make_property!(
             }
 
             fn compute(&self, v: &ComputedValues) -> Self {
-                let font_size = v.font_size.0.value();
+                let font_size = v.font_size().0.value();
+                let baseline_shift = v.baseline_shift();
 
                 // FIXME: this implementation has limitations:
                 // 1) we only handle 'percent' shifts, but it could also be an absolute offset
                 // 2) we should be able to normalize the lengths and add even if they have
                 //    different units, but at the moment that requires access to the draw_ctx
-                if self.0.unit != LengthUnit::Percent || v.baseline_shift.0.unit != font_size.unit {
-                    return BaselineShift(Length::<Both>::new(v.baseline_shift.0.length, 
v.baseline_shift.0.unit));
+                if self.0.unit != LengthUnit::Percent || baseline_shift.0.unit != font_size.unit {
+                    return BaselineShift(Length::<Both>::new(baseline_shift.0.length, 
baseline_shift.0.unit));
                 }
 
-                BaselineShift(Length::<Both>::new(self.0.length * font_size.length + 
v.baseline_shift.0.length, font_size.unit))
+                BaselineShift(Length::<Both>::new(self.0.length * font_size.length + 
baseline_shift.0.length, font_size.unit))
             }
         }
     },
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 84af72fb..b8264571 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -134,8 +134,8 @@ impl PositionedChunk {
         // Adjust the specified coordinates with the text_anchor
 
         let adjusted_advance = text_anchor_advance(
-            measured.values.text_anchor,
-            measured.values.writing_mode,
+            measured.values.text_anchor(),
+            measured.values.writing_mode(),
             measured.advance,
         );
 
@@ -209,7 +209,7 @@ impl MeasuredSpan {
         let w = f64::from(w) / f64::from(pango::SCALE);
         let h = f64::from(h) / f64::from(pango::SCALE);
 
-        let advance = if values.writing_mode.is_vertical() {
+        let advance = if values.writing_mode().is_vertical() {
             (0.0, w)
         } else {
             (w, 0.0)
@@ -239,7 +239,7 @@ impl PositionedSpan {
         let params = draw_ctx.get_view_params();
 
         let baseline = f64::from(layout.get_baseline()) / f64::from(pango::SCALE);
-        let baseline_shift = values.baseline_shift.0.normalize(&values, &params);
+        let baseline_shift = values.baseline_shift().0.normalize(&values, &params);
         let offset = baseline + baseline_shift;
 
         let dx = measured
@@ -251,7 +251,7 @@ impl PositionedSpan {
             .map(|l| l.normalize(&values, &params))
             .unwrap_or(0.0);
 
-        let (render_x, render_y) = if values.writing_mode.is_vertical() {
+        let (render_x, render_y) = if values.writing_mode().is_vertical() {
             (x + offset + dx, y + dy)
         } else {
             (x + dx, y - offset + dy)
@@ -289,7 +289,7 @@ impl PositionedSpan {
             };
 
             let cr = dc.get_cairo_context();
-            cr.set_antialias(cairo::Antialias::from(self.values.text_rendering));
+            cr.set_antialias(cairo::Antialias::from(self.values.text_rendering()));
             dc.setup_cr_for_stroke(&cr, &self.values);
             cr.move_to(self.rendered_position.0, self.rendered_position.1);
 
@@ -298,13 +298,13 @@ impl PositionedSpan {
                 cr.rotate(-rotation);
             }
 
-            let current_color = self.values.color.0;
+            let current_color = self.values.color().0;
 
             let res = if !clipping {
                 dc.set_source_paint_server(
                     acquired_nodes,
-                    &self.values.fill.0,
-                    self.values.fill_opacity.0,
+                    &self.values.fill().0,
+                    self.values.fill_opacity().0,
                     &bbox,
                     current_color,
                 )
@@ -325,8 +325,8 @@ impl PositionedSpan {
                 let res = if !clipping {
                     dc.set_source_paint_server(
                         acquired_nodes,
-                        &self.values.stroke.0,
-                        self.values.stroke_opacity.0,
+                        &self.values.stroke().0,
+                        self.values.stroke_opacity().0,
                         &bbox,
                         current_color,
                     )
@@ -518,7 +518,7 @@ impl Chars {
         let mut normalized = self.space_normalized.borrow_mut();
 
         if (*normalized).is_none() {
-            let mode = match values.xml_space {
+            let mode = match values.xml_space() {
                 XmlSpace::Default => XmlSpaceNormalize::Default(NormalizeDefault {
                     has_element_before: node.previous_sibling().is_some(),
                     has_element_after: node.next_sibling().is_some(),
@@ -956,15 +956,15 @@ fn create_pango_layout(
     // See the construction of the XmlLang property
     // We use "" there as the default value; this means that the language is not set.
     // If the language *is* set, we can use it here.
-    if !values.xml_lang.0.is_empty() {
-        pango_context.set_language(&pango::Language::from(&values.xml_lang));
+    if !values.xml_lang().0.is_empty() {
+        pango_context.set_language(&pango::Language::from(&values.xml_lang()));
     }
 
-    pango_context.set_base_gravity(pango::Gravity::from(values.writing_mode));
+    pango_context.set_base_gravity(pango::Gravity::from(values.writing_mode()));
 
-    match (values.unicode_bidi, values.direction) {
+    match (values.unicode_bidi(), values.direction()) {
         (UnicodeBidi::Override, _) | (UnicodeBidi::Embed, _) => {
-            pango_context.set_base_dir(pango::Direction::from(values.direction));
+            pango_context.set_base_dir(pango::Direction::from(values.direction()));
         }
 
         (_, direction) if direction != Direction::Ltr => {
@@ -972,21 +972,21 @@ fn create_pango_layout(
         }
 
         (_, _) => {
-            pango_context.set_base_dir(pango::Direction::from(values.writing_mode));
+            pango_context.set_base_dir(pango::Direction::from(values.writing_mode()));
         }
     }
 
     let mut font_desc = pango_context.get_font_description().unwrap();
-    font_desc.set_family(&(values.font_family.0).0);
-    font_desc.set_style(pango::Style::from(values.font_style));
-    font_desc.set_variant(pango::Variant::from(values.font_variant));
-    font_desc.set_weight(pango::Weight::from(values.font_weight.0));
-    font_desc.set_stretch(pango::Stretch::from(values.font_stretch));
+    font_desc.set_family(&(values.font_family().0).0);
+    font_desc.set_style(pango::Style::from(values.font_style()));
+    font_desc.set_variant(pango::Variant::from(values.font_variant()));
+    font_desc.set_weight(pango::Weight::from(values.font_weight().0));
+    font_desc.set_stretch(pango::Stretch::from(values.font_stretch()));
 
     let params = draw_ctx.get_view_params();
 
     font_desc.set_size(to_pango_units(
-        values.font_size.0.normalize(values, &params),
+        values.font_size().0.normalize(values, &params),
     ));
 
     let layout = pango::Layout::new(&pango_context);
@@ -997,21 +997,21 @@ fn create_pango_layout(
 
     attr_list.insert(
         pango::Attribute::new_letter_spacing(to_pango_units(
-            values.letter_spacing.0.normalize(values, &params),
+            values.letter_spacing().0.normalize(values, &params),
         ))
         .unwrap(),
     );
 
-    if values.text_decoration.underline {
+    if values.text_decoration().underline {
         attr_list.insert(pango::Attribute::new_underline(pango::Underline::Single).unwrap());
     }
 
-    if values.text_decoration.strike {
+    if values.text_decoration().strike {
         attr_list.insert(pango::Attribute::new_strikethrough(true).unwrap());
     }
 
     layout.set_attributes(Some(&attr_list));
-    layout.set_alignment(pango::Alignment::from(values.direction));
+    layout.set_alignment(pango::Alignment::from(values.direction()));
     layout.set_text(text);
 
     layout


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]