[librsvg: 1/2] Use specified width/height as inner SVG viewport by default
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/2] Use specified width/height as inner SVG viewport by default
- Date: Fri, 15 Oct 2021 01:21:51 +0000 (UTC)
commit b587892cf882e8bd0910b1ee7c570280fd1dad41
Author: Michael Howell <michael notriddle com>
Date: Thu Oct 14 12:49:32 2021 -0700
Use specified width/height as inner SVG viewport by default
Fixes #788
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/607>
src/structure.rs | 8 ++++++--
.../reftests/bugs/788-inner-svg-viewbox-ref.png | Bin 0 -> 362 bytes
.../reftests/bugs/788-inner-svg-viewbox.svg | 21 +++++++++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/structure.rs b/src/structure.rs
index 77cc49eb..3cc8ac46 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -208,7 +208,7 @@ impl Svg {
let is_measuring_toplevel_svg = !has_parent && draw_ctx.is_measuring();
- let (viewport, vbox) = if is_measuring_toplevel_svg || has_parent {
+ let (viewport, vbox) = if is_measuring_toplevel_svg {
// We are obtaining the toplevel SVG's geometry. This means, don't care about the
// DrawingCtx's viewport, just use the SVG's intrinsic dimensions and see how far
// it wants to extend.
@@ -216,7 +216,11 @@ impl Svg {
} else {
(
// The client's viewport overrides the toplevel's x/y/w/h viewport
- draw_ctx.toplevel_viewport(),
+ if has_parent {
+ svg_viewport
+ } else {
+ draw_ctx.toplevel_viewport()
+ },
// Use our viewBox if available, or try to derive one from
// the intrinsic dimensions.
self.vbox.or_else(|| {
diff --git a/tests/fixtures/reftests/bugs/788-inner-svg-viewbox-ref.png
b/tests/fixtures/reftests/bugs/788-inner-svg-viewbox-ref.png
new file mode 100644
index 00000000..93349f98
Binary files /dev/null and b/tests/fixtures/reftests/bugs/788-inner-svg-viewbox-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/788-inner-svg-viewbox.svg
b/tests/fixtures/reftests/bugs/788-inner-svg-viewbox.svg
new file mode 100644
index 00000000..25029f61
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/788-inner-svg-viewbox.svg
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" fill="#FFFFFF" height="62px" version="1.1" viewBox="0 0 164 62"
width="164px">
+ <defs>
+ <clipPath id="clip"><rect height="100%" width="100%" x="0" y="0"/></clipPath>
+ </defs>
+ <g clip-path="url(#clip)">
+ <g style="text-anchor:middle" transform="translate(72)">
+ <linearGradient id="BOX" x1="100%" x2="100%" y1="100%" y2="0">
+ <stop offset="0" style="stop-color:#2E2E2E"/>
+ <stop offset="1" style="stop-color:#676769"/>
+ </linearGradient>
+
+ <g transform="translate(-148)">
+ <svg height="45%" width="22px" x="100%" y="3.33%">
+ <rect fill="url(#BOX)" height="100%" width="100%"/>
+ <rect fill="green" x="50%" y="72%" width="4px" height="4px">3</rect>
+ </svg>
+ </g>
+ </g>
+ </g>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]