[librsvg: 2/3] Remove ClipMode::ClipToVbox, it is not used anywhere




commit e3aaec5a619352f7640d5a30c4970067550bf61a
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Aug 26 21:01:27 2022 -0500

    Remove ClipMode::ClipToVbox, it is not used anywhere
    
    Commit 62f31feec7 mentions
    https://www.w3.org/TR/SVG11/masking.html#AutoClipAtViewportNotViewBox
    - but now I think I misunderstood it.  If one wishes to clip to the
    viewBox, that version of the spec mentions setting the `clip` property
    to the same bounds as the viewBox.
    
    However, the `clip` property is deprecated (Appendix A: The deprecated
    clip property)- https://drafts.fxtf.org/css-masking/#clip-property and
    librsvg never implemented it anyway.  Looks like we'll have to
    implement that appendix, or use clip-path instead.
    
    Also, the clip mode was passed around as Option<ClipMode> - reduce it
    to an enum with two cases (more legible than a boolean), and remove
    the Option.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/737>

 src/drawing_ctx.rs | 23 ++++++++---------------
 src/structure.rs   |  5 +++--
 2 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 7ba1c015b..836f434fc 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -108,9 +108,7 @@ pub struct FontOptions {
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub enum ClipMode {
     ClipToViewport,
-
-    // FIXME: this is not used anymore!?
-    ClipToVbox,
+    NoClip,
 }
 
 /// Set path on the cairo context, or clear it.
@@ -488,9 +486,9 @@ impl DrawingCtx {
         vbox: Option<ViewBox>,
         viewport: Rect,
         preserve_aspect_ratio: AspectRatio,
-        clip_mode: Option<ClipMode>,
+        clip_mode: ClipMode,
     ) -> Option<ViewParams> {
-        if let Some(ClipMode::ClipToViewport) = clip_mode {
+        if let ClipMode::ClipToViewport = clip_mode {
             clip_to_rectangle(&self.cr, &viewport);
         }
 
@@ -517,12 +515,6 @@ impl DrawingCtx {
             .map(|t| {
                 self.cr.transform(t.into());
 
-                if let Some(vbox) = vbox {
-                    if let Some(ClipMode::ClipToVbox) = clip_mode {
-                        clip_to_rectangle(&self.cr, &*vbox);
-                    }
-                }
-
                 let top_viewport = self.get_top_viewport();
 
                 self.push_viewport(Viewport {
@@ -1364,9 +1356,9 @@ impl DrawingCtx {
             || image.overflow == Overflow::Visible)
             && image.aspect.is_slice()
         {
-            Some(ClipMode::ClipToViewport)
+            ClipMode::ClipToViewport
         } else {
-            None
+            ClipMode::NoClip
         };
 
         // The bounding box for <image> is decided by the values of the image's x, y, w, h
@@ -1694,10 +1686,11 @@ impl DrawingCtx {
             let symbol = borrow_element_as!(child, Symbol);
             let symbol_values = elt.get_computed_values();
 
+            // FIXME: do we need to look at preserveAspectRatio.slice, like in draw_image()?
             let clip_mode = if !symbol_values.is_overflow() {
-                Some(ClipMode::ClipToViewport)
+                ClipMode::ClipToViewport
             } else {
-                None
+                ClipMode::NoClip
             };
 
             let stacking_ctx = StackingContext::new(
diff --git a/src/structure.rs b/src/structure.rs
index cfc8cbcd0..da42551a2 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -226,10 +226,11 @@ impl Svg {
 
         let has_parent = node.parent().is_some();
 
+        // FIXME: do we need to look at preserveAspectRatio.slice, like in DrawingCtx::draw_image()?
         let clip_mode = if !values.is_overflow() && has_parent {
-            Some(ClipMode::ClipToViewport)
+            ClipMode::ClipToViewport
         } else {
-            None
+            ClipMode::NoClip
         };
 
         let svg_viewport = self.get_viewport(&params, values, !has_parent);


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