[librsvg: 7/21] Select between the transform attribute and property in SpecifiedValues




commit 2e84c210198918d1435af62e9a2a6585e7d264f3
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Aug 18 20:16:19 2021 -0500

    Select between the transform attribute and property in SpecifiedValues
    
    We don't have a way to select a parsing mode, so we'll just use two
    different code paths for each parser.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/576>

 src/properties.rs | 17 +++++++++--------
 src/transform.rs  |  7 +++++++
 2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/properties.rs b/src/properties.rs
index 7f8878e2..54458c90 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -93,9 +93,7 @@ pub struct SpecifiedValues {
     indices: [u8; PropertyId::UnsetProperty as usize],
     props: Vec<ParsedProperty>,
 
-    // TODO for madds: the following field will go away once the machinery for properties
-    // actually knows about the transform property.
-    transform: Transform,
+    transform: Option<Transform>,
 }
 
 impl Default for SpecifiedValues {
@@ -104,7 +102,7 @@ impl Default for SpecifiedValues {
             // this many elements, with the same value
             indices: [PropertyId::UnsetProperty.as_u8(); PropertyId::UnsetProperty as usize],
             props: Vec::new(),
-            transform: Default::default(),
+            transform: None,
         }
     }
 }
@@ -248,7 +246,6 @@ macro_rules! make_properties {
                 $nonprop_field: $nonprop_name,
             )+
 
-            // TODO for madds: this will go away
             transform: Transform,
         }
 
@@ -639,8 +636,12 @@ impl SpecifiedValues {
         compute!(XmlLang, xml_lang);
         compute!(XmlSpace, xml_space);
 
-        // TODO for madds: this will go away
-        computed.transform = self.transform;
+        computed.transform = self.transform.unwrap_or_else(|| {
+            match self.get_property(PropertyId::TransformProperty) {
+                ParsedProperty::TransformProperty(SpecifiedValue::Specified(ref t)) => t.to_transform(),
+                _ => Transform::identity(),
+            }
+        });
     }
 
     pub fn is_overflow(&self) -> bool {
@@ -750,7 +751,7 @@ impl SpecifiedValues {
                     // a better way to distinguish attributes whose values have different
                     // grammars than properties.
                     let transform = Transform::parse_str(value).unwrap_or_else(|_| Transform::default());
-                    self.transform = transform;
+                    self.transform = Some(transform);
                 }
 
                 expanded_name!(xml "lang") => {
diff --git a/src/transform.rs b/src/transform.rs
index 3cf097ce..91e359e1 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -37,6 +37,13 @@ impl Property for TransformProperty {
     }
 }
 
+impl TransformProperty {
+    pub fn to_transform(&self) -> Transform {
+        // TODO for madds - compose the individual functions here into a single matrix
+        Transform::identity()
+    }
+}
+
 // https://www.w3.org/TR/css-transforms-1/#typedef-transform-function
 #[derive(Debug, Clone, PartialEq)]
 pub enum TransformFunction {


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