[librsvg: 26/37] NodeTSpan: make the dx/dy fields Option<Length>



commit a4de907b611a990fbb6545316f3c0d41c333cff8
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Oct 31 17:38:51 2018 -0600

    NodeTSpan: make the dx/dy fields Option<Length>
    
    Their default value was a Length of 0.0.  However, this will make it
    harder to propagate dx/dy down to chunks and spans when those
    attributes are really not specified.  So, we'll use an Option instead.

 rsvg_internals/src/text.rs | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index e883b88f..8f1a9bce 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -515,8 +515,8 @@ impl NodeTrait for NodeTRef {
 pub struct NodeTSpan {
     x: Cell<Option<Length>>,
     y: Cell<Option<Length>>,
-    dx: Cell<Length>,
-    dy: Cell<Length>,
+    dx: Cell<Option<Length>>,
+    dy: Cell<Option<Length>>,
 }
 
 impl NodeTSpan {
@@ -524,8 +524,8 @@ impl NodeTSpan {
         NodeTSpan {
             x: Cell::new(Default::default()),
             y: Cell::new(Default::default()),
-            dx: Cell::new(Length::default()),
-            dy: Cell::new(Length::default()),
+            dx: Cell::new(None),
+            dy: Cell::new(None),
         }
     }
 
@@ -554,8 +554,12 @@ impl NodeTrait for NodeTSpan {
                 Attribute::Y => self
                     .y
                     .set(parse("y", value, LengthDir::Vertical).map(Some)?),
-                Attribute::Dx => self.dx.set(parse("dx", value, LengthDir::Horizontal)?),
-                Attribute::Dy => self.dy.set(parse("dy", value, LengthDir::Vertical)?),
+                Attribute::Dx => self
+                    .dx
+                    .set(parse("dx", value, LengthDir::Horizontal).map(Some)?),
+                Attribute::Dy => self
+                    .dy
+                    .set(parse("dy", value, LengthDir::Vertical).map(Some)?),
                 _ => (),
             }
         }


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