[librsvg: 48/90] Use a single conditional to figure out the SVG's viewport/viewBox
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 48/90] Use a single conditional to figure out the SVG's viewport/viewBox
- Date: Tue, 26 Mar 2019 19:16:06 +0000 (UTC)
commit 444a43578ac17f2f7a5bff6d5942ea130f6618ac
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Mar 15 08:59:15 2019 -0600
Use a single conditional to figure out the SVG's viewport/viewBox
rsvg_internals/src/structure.rs | 43 +++++++++++++++++------------------------
1 file changed, 18 insertions(+), 25 deletions(-)
---
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 6e51942f..77a9ff93 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -288,32 +288,25 @@ impl NodeTrait for NodeSvg {
// it wants to extend.
(svg_viewport, self.vbox.get())
} else {
- let viewport = if has_parent {
- svg_viewport
+ if has_parent {
+ (svg_viewport, self.vbox.get())
} else {
- // cairo::Rectangle {
- // x: 0.0,
- // y: 0.0,
- // width: params.view_box_width,
- // height: params.view_box_height,
- // }
- draw_ctx.toplevel_viewport()
- };
-
- let vbox = if has_parent {
- self.vbox.get()
- } else {
- self.vbox.get().or_else(|| {
- Some(ViewBox {
- x: 0.0,
- y: 0.0,
- width: svg_viewport.width,
- height: svg_viewport.height,
- })
- })
- };
-
- (viewport, vbox)
+ (
+ // The client's viewport overrides the toplevel's x/y/w/h viewport
+ draw_ctx.toplevel_viewport(),
+
+ // Use our viewBox if available, or try to derive one from
+ // the intrinsic dimensions.
+ self.vbox.get().or_else(|| {
+ Some(ViewBox {
+ x: 0.0,
+ y: 0.0,
+ width: svg_viewport.width,
+ height: svg_viewport.height,
+ })
+ }),
+ )
+ }
};
draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]