[librsvg: 4/10] Make structure::IntrinsicDimensions not use oriented lengths
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/10] Make structure::IntrinsicDimensions not use oriented lengths
- Date: Wed, 13 Nov 2019 03:38:36 +0000 (UTC)
commit 0046257ae3ab0e7b25d8042b09b815911731078f
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 12 18:20:35 2019 -0600
Make structure::IntrinsicDimensions not use oriented lengths
This lets us avoid exporting LengthTrait.
librsvg/c_api.rs | 6 +++---
librsvg_crate/src/lib.rs | 6 +++---
rsvg_internals/src/length.rs | 2 ++
rsvg_internals/src/lib.rs | 2 +-
rsvg_internals/src/structure.rs | 8 ++++----
5 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index 8392fdfc..6d6592e5 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -34,7 +34,7 @@ use glib_sys;
use gobject_sys::{self, GEnumValue, GFlagsValue};
use rsvg_internals::{
- rsvg_log, set_gerror, DefsLookupErrorKind, Dpi, Handle, IntrinsicDimensions, LengthTrait,
+ rsvg_log, set_gerror, DefsLookupErrorKind, Dpi, Handle, IntrinsicDimensions,
LoadOptions, LoadingError, RenderingError, RsvgDimensionData, RsvgLength, RsvgPositionData,
RsvgRectangle, RsvgSizeFunc, SharedImageSurface, SizeCallback, SurfaceType, RSVG_ERROR_FAILED,
};
@@ -1270,8 +1270,8 @@ pub unsafe extern "C" fn rsvg_rust_handle_get_intrinsic_dimensions(
.get_intrinsic_dimensions()
.unwrap_or_else(|_| panic!("API called out of order"));
- let w = d.width.map(|l| l.to_length());
- let h = d.height.map(|l| l.to_length());
+ let w = d.width;
+ let h = d.height;
let r = d.vbox.map(RsvgRectangle::from);
set_out_param(out_has_width, out_width, &w);
diff --git a/librsvg_crate/src/lib.rs b/librsvg_crate/src/lib.rs
index f84aa604..53a68030 100644
--- a/librsvg_crate/src/lib.rs
+++ b/librsvg_crate/src/lib.rs
@@ -97,7 +97,7 @@ use std::path::Path;
use gio::{Cancellable, FileExt};
-use rsvg_internals::{Dpi, Handle, LengthTrait, LoadOptions};
+use rsvg_internals::{Dpi, Handle, LoadOptions};
pub use rsvg_internals::{
DefsLookupErrorKind,
@@ -402,8 +402,8 @@ impl<'a> CairoRenderer<'a> {
let d = self.handle.0.get_intrinsic_dimensions();
IntrinsicDimensions {
- width: d.width.map(|l| l.to_length()),
- height: d.height.map(|l| l.to_length()),
+ width: d.width,
+ height: d.height,
vbox: d.vbox.map(|v| cairo::Rectangle {
x: v.x,
y: v.y,
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index 64b3f59e..3d802126 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -214,6 +214,7 @@ macro_rules! define_length_type {
}
impl $name {
+ #[allow(unused)]
pub fn new(length: f64, unit: LengthUnit) -> Self {
$name(Length::new(length, unit))
}
@@ -230,6 +231,7 @@ macro_rules! define_length_type {
/// ```
///
/// [`check_nonnegative`]: #method.check_nonnegative
+ #[allow(unused)]
pub fn from_cssparser(parser: &mut Parser<'_, '_>) -> Result<Self, ValueErrorKind> {
Ok($name(Length::from_cssparser(parser)?))
}
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index 1d48eec1..4e77b4df 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -55,7 +55,7 @@ pub use crate::handle::{
Handle, LoadOptions, RsvgDimensionData, RsvgPositionData, RsvgSizeFunc, SizeCallback,
};
-pub use crate::length::{Length, LengthUnit, LengthTrait, RsvgLength};
+pub use crate::length::{Length, LengthUnit, RsvgLength};
pub use crate::rect::IRect;
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index e8989506..0a894eb5 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -87,8 +87,8 @@ impl NodeTrait for Switch {
/// Intrinsic dimensions of an SVG document fragment
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct IntrinsicDimensions {
- pub width: Option<LengthHorizontal>,
- pub height: Option<LengthVertical>,
+ pub width: Option<Length>,
+ pub height: Option<Length>,
pub vbox: Option<ViewBox>,
}
@@ -130,8 +130,8 @@ impl Svg {
pub fn get_intrinsic_dimensions(&self) -> IntrinsicDimensions {
IntrinsicDimensions {
- width: self.w,
- height: self.h,
+ width: self.w.map(|l| l.to_length()),
+ height: self.h.map(|l| l.to_length()),
vbox: self.vbox,
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]