[librsvg] Length.normalize(): Take a ViewParams, not a whole DrawingCtx



commit a3c86930125c17b7a23f3236db9cdfa9fd0e00cb
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 3 14:38:25 2018 -0500

    Length.normalize(): Take a ViewParams, not a whole DrawingCtx
    
    This decouples Length from DrawingCtx.  This should make some testing
    easier, and starts to make it easier how to encapsulate all of the
    current viewport's parameters.

 rsvg_internals/src/drawing_ctx.rs     | 15 ++++++++---
 rsvg_internals/src/filters/context.rs | 12 +++++----
 rsvg_internals/src/font_props.rs      |  4 +--
 rsvg_internals/src/gradient.rs        | 22 +++++++++-------
 rsvg_internals/src/image.rs           | 10 ++++---
 rsvg_internals/src/length.rs          | 38 ++++++++++++---------------
 rsvg_internals/src/marker.rs          | 17 ++++++++----
 rsvg_internals/src/mask.rs            | 10 ++++---
 rsvg_internals/src/pattern.rs         | 10 ++++---
 rsvg_internals/src/shapes.rs          | 49 ++++++++++++++++++++---------------
 rsvg_internals/src/structure.rs       | 20 ++++++++------
 rsvg_internals/src/text.rs            | 31 ++++++++++++++--------
 12 files changed, 140 insertions(+), 98 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index ce54ce92..2bc1c162 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -179,6 +179,9 @@ impl<'a> DrawingCtx<'a> {
         }
     }
 
+    // FIXME: the result of this is only valid within a
+    // push_view_box() / pop_view_box() pair.  How do we make this
+    // safe?
     pub fn get_view_params(&self) -> ViewParams {
         ViewParams {
             dpi_x: self.dpi_x,
@@ -586,19 +589,23 @@ impl<'a> DrawingCtx<'a> {
     }
 
     fn setup_cr_for_stroke(&self, cr: &cairo::Context, values: &ComputedValues) {
-        cr.set_line_width(values.stroke_width.0.normalize(values, self));
+        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));
 
         if let StrokeDasharray(Dasharray::Array(ref dashes)) = values.stroke_dasharray {
-            let normalized_dashes: Vec<f64> =
-                dashes.iter().map(|l| l.normalize(values, self)).collect();
+            let normalized_dashes: Vec<f64> = dashes
+                .iter()
+                .map(|l| l.normalize(values, &params))
+                .collect();
 
             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, self);
+                let offset = values.stroke_dashoffset.0.normalize(values, &params);
                 cr.set_dash(&normalized_dashes, offset);
             } else {
                 cr.set_dash(&[], 0.0);
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index b7c5a66f..98c5eb50 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -139,11 +139,13 @@ fn compute_effects_region(
             height: filter.height.get().get_unitless(),
         }
     } else {
+        let params = draw_ctx.get_view_params();
+
         cairo::Rectangle {
-            x: filter.x.get().normalize(values, draw_ctx),
-            y: filter.y.get().normalize(values, draw_ctx),
-            width: filter.width.get().normalize(values, draw_ctx),
-            height: filter.height.get().normalize(values, draw_ctx),
+            x: filter.x.get().normalize(values, &params),
+            y: filter.y.get().normalize(values, &params),
+            width: filter.width.get().normalize(values, &params),
+            height: filter.height.get().normalize(values, &params),
         }
     };
 
@@ -450,7 +452,7 @@ impl FilterContext {
             rv
         } else {
             f(Box::new(|length: &Length| {
-                length.normalize(values, draw_ctx)
+                length.normalize(values, &draw_ctx.get_view_params())
             }))
         }
     }
diff --git a/rsvg_internals/src/font_props.rs b/rsvg_internals/src/font_props.rs
index 0f6a6d86..c15c8825 100644
--- a/rsvg_internals/src/font_props.rs
+++ b/rsvg_internals/src/font_props.rs
@@ -68,7 +68,7 @@ impl FontSizeSpec {
     }
 
     pub fn normalize(&self, values: &ComputedValues, draw_ctx: &DrawingCtx) -> f64 {
-        self.value().normalize(values, draw_ctx)
+        self.value().normalize(values, &draw_ctx.get_view_params())
     }
 }
 
@@ -203,7 +203,7 @@ impl LetterSpacingSpec {
     }
 
     pub fn normalize(&self, values: &ComputedValues, draw_ctx: &DrawingCtx) -> f64 {
-        self.value().normalize(values, draw_ctx)
+        self.value().normalize(values, &draw_ctx.get_view_params())
     }
 }
 
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 114882b2..ea1186f6 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -506,11 +506,13 @@ fn set_linear_gradient_on_pattern(
             draw_ctx.push_view_box(1.0, 1.0);
         }
 
+        let params = draw_ctx.get_view_params();
+
         let mut pattern = cairo::LinearGradient::new(
-            x1.as_ref().unwrap().normalize(values, draw_ctx),
-            y1.as_ref().unwrap().normalize(values, draw_ctx),
-            x2.as_ref().unwrap().normalize(values, draw_ctx),
-            y2.as_ref().unwrap().normalize(values, draw_ctx),
+            x1.as_ref().unwrap().normalize(values, &params),
+            y1.as_ref().unwrap().normalize(values, &params),
+            x2.as_ref().unwrap().normalize(values, &params),
+            y2.as_ref().unwrap().normalize(values, &params),
         );
 
         if units == GradientUnits(CoordUnits::ObjectBoundingBox) {
@@ -586,11 +588,13 @@ fn set_radial_gradient_on_pattern(
             draw_ctx.push_view_box(1.0, 1.0);
         }
 
-        let n_cx = cx.as_ref().unwrap().normalize(values, draw_ctx);
-        let n_cy = cy.as_ref().unwrap().normalize(values, draw_ctx);
-        let n_r = r.as_ref().unwrap().normalize(values, draw_ctx);
-        let n_fx = fx.as_ref().unwrap().normalize(values, draw_ctx);
-        let n_fy = fy.as_ref().unwrap().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let n_cx = cx.as_ref().unwrap().normalize(values, &params);
+        let n_cy = cy.as_ref().unwrap().normalize(values, &params);
+        let n_r = r.as_ref().unwrap().normalize(values, &params);
+        let n_fx = fx.as_ref().unwrap().normalize(values, &params);
+        let n_fy = fy.as_ref().unwrap().normalize(values, &params);
 
         let (new_fx, new_fy) = fix_focus_point(n_fx, n_fy, n_cx, n_cy, n_r);
 
diff --git a/rsvg_internals/src/image.rs b/rsvg_internals/src/image.rs
index d5952c0b..ea32205e 100644
--- a/rsvg_internals/src/image.rs
+++ b/rsvg_internals/src/image.rs
@@ -115,10 +115,12 @@ impl NodeTrait for NodeImage {
         let values = cascaded.get();
 
         if let Some(ref surface) = *self.surface.borrow() {
-            let x = self.x.get().normalize(values, draw_ctx);
-            let y = self.y.get().normalize(values, draw_ctx);
-            let w = self.w.get().normalize(values, draw_ctx);
-            let h = self.h.get().normalize(values, draw_ctx);
+            let params = draw_ctx.get_view_params();
+
+            let x = self.x.get().normalize(values, &params);
+            let y = self.y.get().normalize(values, &params);
+            let w = self.w.get().normalize(values, &params);
+            let h = self.h.get().normalize(values, &params);
 
             draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
                 let aspect = self.aspect.get();
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index 7fe2bcf4..c812d568 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -1,7 +1,7 @@
 use cssparser::{Parser, Token};
 use std::f64::consts::*;
 
-use drawing_ctx::DrawingCtx;
+use drawing_ctx::ViewParams;
 use error::*;
 use parsers::Parse;
 use parsers::ParseError;
@@ -94,25 +94,23 @@ impl Length {
         }
     }
 
-    pub fn normalize(&self, values: &ComputedValues, draw_ctx: &DrawingCtx) -> f64 {
+    pub fn normalize(&self, values: &ComputedValues, params: &ViewParams) -> f64 {
         match self.unit {
             LengthUnit::Default => self.length,
 
-            LengthUnit::Percent => {
-                let (width, height) = draw_ctx.get_view_box_size();
-
-                match self.dir {
-                    LengthDir::Horizontal => self.length * width,
-                    LengthDir::Vertical => self.length * height,
-                    LengthDir::Both => self.length * viewport_percentage(width, height),
+            LengthUnit::Percent => match self.dir {
+                LengthDir::Horizontal => self.length * params.view_box_width,
+                LengthDir::Vertical => self.length * params.view_box_height,
+                LengthDir::Both => {
+                    self.length * viewport_percentage(params.view_box_width, params.view_box_height)
                 }
-            }
+            },
 
-            LengthUnit::FontEm => self.length * font_size_from_values(values, draw_ctx),
+            LengthUnit::FontEm => self.length * font_size_from_values(values, params),
 
-            LengthUnit::FontEx => self.length * font_size_from_values(values, draw_ctx) / 2.0,
+            LengthUnit::FontEx => self.length * font_size_from_values(values, params) / 2.0,
 
-            LengthUnit::Inch => font_size_from_inch(self.length, self.dir, draw_ctx),
+            LengthUnit::Inch => font_size_from_inch(self.length, self.dir, params),
         }
     }
 
@@ -225,23 +223,21 @@ impl Length {
     }
 }
 
-fn font_size_from_inch(length: f64, dir: LengthDir, draw_ctx: &DrawingCtx) -> f64 {
-    let (dpi_x, dpi_y) = draw_ctx.get_dpi();
-
+fn font_size_from_inch(length: f64, dir: LengthDir, params: &ViewParams) -> f64 {
     match dir {
-        LengthDir::Horizontal => length * dpi_x,
-        LengthDir::Vertical => length * dpi_y,
-        LengthDir::Both => length * viewport_percentage(dpi_x, dpi_y),
+        LengthDir::Horizontal => length * params.dpi_x,
+        LengthDir::Vertical => length * params.dpi_y,
+        LengthDir::Both => length * viewport_percentage(params.dpi_x, params.dpi_y),
     }
 }
 
-fn font_size_from_values(values: &ComputedValues, draw_ctx: &DrawingCtx) -> f64 {
+fn font_size_from_values(values: &ComputedValues, params: &ViewParams) -> f64 {
     let v = &values.font_size.0.value();
 
     match v.unit {
         LengthUnit::Default => v.length,
 
-        LengthUnit::Inch => font_size_from_inch(v.length, v.dir, draw_ctx),
+        LengthUnit::Inch => font_size_from_inch(v.length, v.dir, params),
 
         LengthUnit::Percent | LengthUnit::FontEm | LengthUnit::FontEx => {
             unreachable!("ComputedValues can't have a relative font size")
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index 7c22ac6b..47022cf3 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -130,8 +130,10 @@ impl NodeMarker {
         let cascaded = node.get_cascaded_values();
         let values = cascaded.get();
 
-        let marker_width = self.width.get().normalize(&values, draw_ctx);
-        let marker_height = self.height.get().normalize(&values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let marker_width = self.width.get().normalize(&values, &params);
+        let marker_height = self.height.get().normalize(&values, &params);
 
         if marker_width.approx_eq_cairo(&0.0) || marker_height.approx_eq_cairo(&0.0) {
             // markerWidth or markerHeight set to 0 disables rendering of the element
@@ -174,9 +176,11 @@ impl NodeMarker {
             draw_ctx.push_view_box(marker_width, marker_height);
         }
 
+        let params = draw_ctx.get_view_params();
+
         affine.translate(
-            -self.ref_x.get().normalize(&values, draw_ctx),
-            -self.ref_y.get().normalize(&values, draw_ctx),
+            -self.ref_x.get().normalize(&values, &params),
+            -self.ref_y.get().normalize(&values, &params),
         );
 
         cr.set_matrix(affine);
@@ -683,7 +687,10 @@ pub fn render_markers_for_path_builder(
     values: &ComputedValues,
     clipping: bool,
 ) -> Result<(), RenderingError> {
-    let line_width = values.stroke_width.0.normalize(values, draw_ctx);
+    let line_width = values
+        .stroke_width
+        .0
+        .normalize(values, &draw_ctx.get_view_params());
 
     if line_width.approx_eq_cairo(&0.0) {
         return Ok(());
diff --git a/rsvg_internals/src/mask.rs b/rsvg_internals/src/mask.rs
index 83fd158f..f0ede8d1 100644
--- a/rsvg_internals/src/mask.rs
+++ b/rsvg_internals/src/mask.rs
@@ -87,10 +87,12 @@ impl NodeMask {
             draw_ctx.push_view_box(1.0, 1.0);
         }
 
-        let x = self.x.get().normalize(&values, draw_ctx);
-        let y = self.y.get().normalize(&values, draw_ctx);
-        let w = self.width.get().normalize(&values, draw_ctx);
-        let h = self.height.get().normalize(&values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let x = self.x.get().normalize(&values, &params);
+        let y = self.y.get().normalize(&values, &params);
+        let w = self.width.get().normalize(&values, &params);
+        let h = self.height.get().normalize(&values, &params);
 
         if mask_units == CoordUnits::ObjectBoundingBox {
             draw_ctx.pop_view_box();
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index cc226eb4..3c458cfb 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -272,10 +272,12 @@ fn set_pattern_on_draw_context(
         draw_ctx.push_view_box(1.0, 1.0);
     }
 
-    let pattern_x = pattern.x.unwrap().normalize(values, draw_ctx);
-    let pattern_y = pattern.y.unwrap().normalize(values, draw_ctx);
-    let pattern_width = pattern.width.unwrap().normalize(values, draw_ctx);
-    let pattern_height = pattern.height.unwrap().normalize(values, draw_ctx);
+    let params = draw_ctx.get_view_params();
+
+    let pattern_x = pattern.x.unwrap().normalize(values, &params);
+    let pattern_y = pattern.y.unwrap().normalize(values, &params);
+    let pattern_width = pattern.width.unwrap().normalize(values, &params);
+    let pattern_height = pattern.height.unwrap().normalize(values, &params);
 
     if units == PatternUnits(CoordUnits::ObjectBoundingBox) {
         draw_ctx.pop_view_box();
diff --git a/rsvg_internals/src/shapes.rs b/rsvg_internals/src/shapes.rs
index 5d8ed3ac..b393f78e 100644
--- a/rsvg_internals/src/shapes.rs
+++ b/rsvg_internals/src/shapes.rs
@@ -282,10 +282,12 @@ impl NodeTrait for NodeLine {
 
         let mut builder = PathBuilder::new();
 
-        let x1 = self.x1.get().normalize(values, draw_ctx);
-        let y1 = self.y1.get().normalize(values, draw_ctx);
-        let x2 = self.x2.get().normalize(values, draw_ctx);
-        let y2 = self.y2.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let x1 = self.x1.get().normalize(values, &params);
+        let y1 = self.y1.get().normalize(values, &params);
+        let x2 = self.x2.get().normalize(values, &params);
+        let y2 = self.y2.get().normalize(values, &params);
 
         builder.move_to(x1, y1);
         builder.line_to(x2, y2);
@@ -368,11 +370,12 @@ impl NodeTrait for NodeRect {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let x = self.x.get().normalize(values, draw_ctx);
-        let y = self.y.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
 
-        let w = self.w.get().normalize(values, draw_ctx);
-        let h = self.h.get().normalize(values, draw_ctx);
+        let x = self.x.get().normalize(values, &params);
+        let y = self.y.get().normalize(values, &params);
+        let w = self.w.get().normalize(values, &params);
+        let h = self.h.get().normalize(values, &params);
 
         let mut rx;
         let mut ry;
@@ -384,18 +387,18 @@ impl NodeTrait for NodeRect {
             }
 
             (Some(_rx), None) => {
-                rx = _rx.normalize(values, draw_ctx);
-                ry = _rx.normalize(values, draw_ctx);
+                rx = _rx.normalize(values, &params);
+                ry = _rx.normalize(values, &params);
             }
 
             (None, Some(_ry)) => {
-                rx = _ry.normalize(values, draw_ctx);
-                ry = _ry.normalize(values, draw_ctx);
+                rx = _ry.normalize(values, &params);
+                ry = _ry.normalize(values, &params);
             }
 
             (Some(_rx), Some(_ry)) => {
-                rx = _rx.normalize(values, draw_ctx);
-                ry = _ry.normalize(values, draw_ctx);
+                rx = _rx.normalize(values, &params);
+                ry = _ry.normalize(values, &params);
             }
         }
 
@@ -551,9 +554,11 @@ impl NodeTrait for NodeCircle {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let cx = self.cx.get().normalize(values, draw_ctx);
-        let cy = self.cy.get().normalize(values, draw_ctx);
-        let r = self.r.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let cx = self.cx.get().normalize(values, &params);
+        let cy = self.cy.get().normalize(values, &params);
+        let r = self.r.get().normalize(values, &params);
 
         render_ellipse(cx, cy, r, r, draw_ctx, node, values, clipping)
     }
@@ -613,10 +618,12 @@ impl NodeTrait for NodeEllipse {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let cx = self.cx.get().normalize(values, draw_ctx);
-        let cy = self.cy.get().normalize(values, draw_ctx);
-        let rx = self.rx.get().normalize(values, draw_ctx);
-        let ry = self.ry.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let cx = self.cx.get().normalize(values, &params);
+        let cy = self.cy.get().normalize(values, &params);
+        let rx = self.rx.get().normalize(values, &params);
+        let ry = self.ry.get().normalize(values, &params);
 
         render_ellipse(cx, cy, rx, ry, draw_ctx, node, values, clipping)
     }
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 9d5efde3..601de3c9 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -189,10 +189,12 @@ impl NodeTrait for NodeSvg {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let nx = self.x.get().normalize(values, draw_ctx);
-        let ny = self.y.get().normalize(values, draw_ctx);
-        let nw = self.w.get().normalize(values, draw_ctx);
-        let nh = self.h.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let nx = self.x.get().normalize(values, &params);
+        let ny = self.y.get().normalize(values, &params);
+        let nw = self.w.get().normalize(values, &params);
+        let nh = self.h.get().normalize(values, &params);
 
         let do_clip = !values.is_overflow() && node.get_parent().is_some();
 
@@ -301,8 +303,10 @@ impl NodeTrait for NodeUse {
 
         draw_ctx.increase_num_elements_rendered_through_use(1);
 
-        let nx = self.x.get().normalize(values, draw_ctx);
-        let ny = self.y.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let nx = self.x.get().normalize(values, &params);
+        let ny = self.y.get().normalize(values, &params);
 
         // If attributes ‘width’ and/or ‘height’ are not specified,
         // [...] use values of '100%' for these attributes.
@@ -313,12 +317,12 @@ impl NodeTrait for NodeUse {
             .w
             .get()
             .unwrap_or_else(|| Length::parse_str("100%", LengthDir::Horizontal).unwrap())
-            .normalize(values, draw_ctx);
+            .normalize(values, &params);
         let nh = self
             .h
             .get()
             .unwrap_or_else(|| Length::parse_str("100%", LengthDir::Vertical).unwrap())
-            .normalize(values, draw_ctx);
+            .normalize(values, &params);
 
         // width or height set to 0 disables rendering of the element
         // https://www.w3.org/TR/SVG/struct.html#UseElementWidthAttribute
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 475f80c3..0a498b44 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -91,7 +91,10 @@ impl NodeChars {
         let (width, _) = layout.get_size();
 
         let baseline = f64::from(layout.get_baseline()) / f64::from(pango::SCALE);
-        let offset = baseline + values.baseline_shift.0.normalize(values, draw_ctx);
+        let offset = baseline + values
+            .baseline_shift
+            .0
+            .normalize(values, &draw_ctx.get_view_params());
 
         if values.text_gravity_is_vertical() {
             draw_ctx.draw_pango_layout(&layout, values, *x + offset, *y, clipping)?;
@@ -157,10 +160,12 @@ impl NodeTrait for NodeText {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let mut x = self.x.get().normalize(values, draw_ctx);
-        let mut y = self.y.get().normalize(values, draw_ctx);
-        let mut dx = self.dx.get().normalize(values, draw_ctx);
-        let mut dy = self.dy.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let mut x = self.x.get().normalize(values, &params);
+        let mut y = self.y.get().normalize(values, &params);
+        let mut dx = self.dx.get().normalize(values, &params);
+        let mut dy = self.dy.get().normalize(values, &params);
 
         let anchor = values.text_anchor;
 
@@ -291,10 +296,12 @@ impl NodeTSpan {
             return true;
         }
 
+        let params = draw_ctx.get_view_params();
+
         if values.text_gravity_is_vertical() {
-            *length += self.dy.get().normalize(values, draw_ctx);
+            *length += self.dy.get().normalize(values, &params);
         } else {
-            *length += self.dx.get().normalize(values, draw_ctx);
+            *length += self.dx.get().normalize(values, &params);
         }
 
         measure_children(node, cascaded, draw_ctx, length, usetextonly)
@@ -312,8 +319,10 @@ impl NodeTSpan {
     ) -> Result<(), RenderingError> {
         let values = cascaded.get();
 
-        let mut dx = self.dx.get().normalize(values, draw_ctx);
-        let mut dy = self.dy.get().normalize(values, draw_ctx);
+        let params = draw_ctx.get_view_params();
+
+        let mut dx = self.dx.get().normalize(values, &params);
+        let mut dy = self.dy.get().normalize(values, &params);
 
         let vertical = values.text_gravity_is_vertical();
         let anchor = values.text_anchor;
@@ -321,7 +330,7 @@ impl NodeTSpan {
         let offset = anchor_offset(node, cascaded, draw_ctx, anchor, usetextonly);
 
         if let Some(self_x) = self.x.get() {
-            *x = self_x.normalize(values, draw_ctx);
+            *x = self_x.normalize(values, &params);
             if !vertical {
                 *x -= offset;
                 dx = match anchor {
@@ -334,7 +343,7 @@ impl NodeTSpan {
         *x += dx;
 
         if let Some(self_y) = self.y.get() {
-            *y = self_y.normalize(values, draw_ctx);
+            *y = self_y.normalize(values, &params);
             if vertical {
                 *y -= offset;
                 dy = match anchor {


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