diff options
author | Federico Mena Quintero <federico@gnome.org> | 2022-08-26 21:01:27 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2022-08-26 21:11:35 -0500 |
commit | e3aaec5a619352f7640d5a30c4970067550bf61a (patch) | |
tree | 281e2794c18750ee5a1efb3b3d6dd25dcdbdfd36 | |
parent | a1b134bf0a4c6ad884d3ae88a0767563ea68a438 (diff) | |
download | librsvg-e3aaec5a619352f7640d5a30c4970067550bf61a.tar.gz |
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>
-rw-r--r-- | src/drawing_ctx.rs | 23 | ||||
-rw-r--r-- | src/structure.rs | 5 |
2 files changed, 11 insertions, 17 deletions
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs index 7ba1c015..836f434f 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 cfc8cbcd..da42551a 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(¶ms, values, !has_parent); |