[librsvg: 13/19] Move the implementation of get_position_sub to c_api
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/19] Move the implementation of get_position_sub to c_api
- Date: Wed, 29 Apr 2020 01:32:50 +0000 (UTC)
commit 6ccfd58a05150c515208bb2f958f813965fad7ff
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Apr 24 20:16:03 2020 -0500
Move the implementation of get_position_sub to c_api
librsvg/c_api.rs | 18 +++++++++++++++++-
rsvg_internals/src/handle.rs | 24 ------------------------
2 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index 0eb4c0e0..2f45cd80 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -721,8 +721,24 @@ impl CHandle {
fn get_position_sub(&self, id: Option<&str>) -> Result<RsvgPositionData, RenderingError> {
let handle = self.get_handle_ref()?;
let inner = self.inner.borrow();
+
+ if id.is_none() {
+ return Ok(RsvgPositionData { x: 0, y: 0 });
+ }
+
handle
- .get_position_sub(id, inner.dpi, &inner.size_callback, inner.is_testing)
+ .get_geometry_sub(id, inner.dpi, inner.is_testing)
+ .and_then(|(ink_r, _)| {
+ let width = ink_r.width().round() as libc::c_int;
+ let height = ink_r.height().round() as libc::c_int;
+
+ inner.size_callback.call(width, height);
+
+ Ok(RsvgPositionData {
+ x: ink_r.x0 as libc::c_int,
+ y: ink_r.y0 as libc::c_int,
+ })
+ })
.map_err(warn_on_invalid_id)
}
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index c6d9396e..1219ea12 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -206,30 +206,6 @@ impl Handle {
}
}
- pub fn get_position_sub(
- &self,
- id: Option<&str>,
- dpi: Dpi,
- size_callback: &SizeCallback,
- is_testing: bool,
- ) -> Result<RsvgPositionData, RenderingError> {
- if id.is_none() {
- return Ok(RsvgPositionData { x: 0, y: 0 });
- }
-
- let (ink_r, _) = self.get_geometry_sub(id, dpi, is_testing)?;
-
- let width = ink_r.width().round() as libc::c_int;
- let height = ink_r.height().round() as libc::c_int;
-
- size_callback.call(width, height);
-
- Ok(RsvgPositionData {
- x: ink_r.x0 as libc::c_int,
- y: ink_r.y0 as libc::c_int,
- })
- }
-
/// Returns (ink_rect, logical_rect)
fn get_node_geometry_with_viewport(
&self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]