Commit a3c2a6f1 authored by Federico Mena Quintero's avatar Federico Mena Quintero

Remove rsvg_handle_get_geometry_sub()

It's replaced with rsvg_handle_get_geometry_for_element(), which has
clear semantics.
parent 614b7c9b
......@@ -23,7 +23,6 @@ rsvg_handle_set_base_uri
rsvg_handle_get_dimensions
rsvg_handle_get_dimensions_sub
rsvg_handle_get_position_sub
rsvg_handle_get_geometry_sub
rsvg_handle_get_geometry_for_element
rsvg_handle_has_sub
rsvg_handle_get_title
......
......@@ -208,7 +208,7 @@
* Width, in pixels, of the rendered SVG after calling the size callback
* as specified by rsvg_handle_set_size_callback().
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
/**
......@@ -217,7 +217,7 @@
* Height, in pixels, of the rendered SVG after calling the size callback
* as specified by rsvg_handle_set_size_callback().
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
/**
......@@ -226,7 +226,7 @@
* Exact width, in pixels, of the rendered SVG before calling the size callback
* as specified by rsvg_handle_set_size_callback().
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
/**
......@@ -235,7 +235,7 @@
* Exact height, in pixels, of the rendered SVG before calling the size callback
* as specified by rsvg_handle_set_size_callback().
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
/**
......@@ -295,10 +295,6 @@ extern gboolean rsvg_rust_handle_read_stream_sync (RsvgHandle *handle,
GError **error);
extern void rsvg_rust_handle_write (RsvgHandle *handle, const guchar *buf, gsize count);
extern gboolean rsvg_rust_handle_close (RsvgHandle *handle, GError **error);
extern gboolean rsvg_rust_handle_get_geometry_sub (RsvgHandle *handle,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
const char *id);
extern gboolean rsvg_rust_handle_has_sub (RsvgHandle *handle, const char *id);
extern gboolean rsvg_rust_handle_render_cairo_sub (RsvgHandle *handle,
cairo_t *cr,
......@@ -805,7 +801,7 @@ rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_dat
* Get the size of a subelement of the SVG file. Do not call from within the
* size_func callback, because an infinite loop will occur.
*
* Deprecated: 2.46. Use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*
* Since: 2.22
*/
......@@ -820,32 +816,6 @@ rsvg_handle_get_dimensions_sub (RsvgHandle *handle,
return rsvg_rust_handle_get_dimensions_sub (handle, dimension_data, id);
}
/**
* rsvg_handle_get_geometry_sub:
* @handle: A #RsvgHandle
* @ink_rect: (out)(allow-none): A place to store the SVG fragment's geometry.
* @logical_rect: (out)(allow-none): A place to store the SVG fragment's logical geometry.
* @id: (nullable): An element's id within the SVG, starting with "##", for
* example, "##layer1"; or %NULL to use the whole SVG.
*
* Get the geometry of a subelement of the SVG file.
*
* Note that unlike rsvg_handle_get_position_sub() and
* rsvg_handle_get_dimensions_sub(), this function does not call the size_func.
*
* Since: 2.46
*/
gboolean
rsvg_handle_get_geometry_sub (RsvgHandle *handle,
RsvgRectangle *ink_rect,
RsvgRectangle *logical_rect,
const char *id)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
return rsvg_rust_handle_get_geometry_sub(handle, ink_rect, logical_rect, id);
}
/**
* rsvg_handle_get_position_sub:
* @handle: A #RsvgHandle
......@@ -856,7 +826,7 @@ rsvg_handle_get_geometry_sub (RsvgHandle *handle,
* Get the position of a subelement of the SVG file. Do not call from within
* the size_func callback, because an infinite loop will occur.
*
* Deprecated: 2.46. Use rsvg_handle_get_geometry_sub() instead.
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*
* Since: 2.22
*/
......
......@@ -117,7 +117,7 @@ struct _RsvgHandle {
* individual element from rsvg_handle_get_dimensions_sub(). Please see
* the deprecation documentation for those functions.
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub().
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
struct _RsvgDimensionData {
int width;
......@@ -134,7 +134,7 @@ struct _RsvgDimensionData {
* Position of an SVG fragment from rsvg_handle_get_position_sub(). Please
* the deprecation documentation for that function.
*
* Deprecated: 2.46. Please use rsvg_handle_get_geometry_sub().
* Deprecated: 2.46. FIXME: point to deprecation documentation.
*/
struct _RsvgPositionData {
int x;
......@@ -190,21 +190,16 @@ void rsvg_handle_set_base_uri (RsvgHandle *handle, const char *base_uri)
void rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_data);
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_sub)
RSVG_DEPRECATED
gboolean rsvg_handle_get_dimensions_sub (RsvgHandle *handle,
RsvgDimensionData *dimension_data,
const char *id);
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_sub)
RSVG_DEPRECATED
gboolean rsvg_handle_get_position_sub (RsvgHandle *handle,
RsvgPositionData *position_data,
const char *id);
gboolean rsvg_handle_get_geometry_sub (RsvgHandle *handle,
RsvgRectangle *ink_rect,
RsvgRectangle *logical_rect,
const char *id);
gboolean rsvg_handle_has_sub (RsvgHandle *handle, const char *id);
typedef enum {
......
......@@ -6,7 +6,6 @@ rsvg_handle_get_base_uri
rsvg_handle_get_dimensions
rsvg_handle_get_dimensions_sub
rsvg_handle_get_position_sub
rsvg_handle_get_geometry_sub
rsvg_handle_get_pixbuf
rsvg_handle_get_pixbuf_sub
rsvg_handle_get_type
......
use std::ffi::CStr;
use std::mem;
use std::ops;
use std::path::PathBuf;
use std::ptr;
......@@ -610,46 +609,6 @@ pub unsafe extern "C" fn rsvg_rust_handle_close(
}
}
}
#[no_mangle]
pub unsafe extern "C" fn rsvg_rust_handle_get_geometry_sub(
handle: *const RsvgHandle,
out_ink_rect: *mut RsvgRectangle,
out_logical_rect: *mut RsvgRectangle,
id: *const libc::c_char,
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
let id: Option<String> = from_glib_none(id);
match rhandle.get_geometry_sub(id.as_ref().map(String::as_str)) {
Ok((ink_r, logical_r)) => {
if !out_ink_rect.is_null() {
*out_ink_rect = ink_r;
}
if !out_logical_rect.is_null() {
*out_logical_rect = logical_r;
}
true.to_glib()
}
Err(_) => {
if !out_ink_rect.is_null() {
*out_ink_rect = mem::zeroed();
}
if !out_logical_rect.is_null() {
*out_logical_rect = mem::zeroed();
}
// FIXME: return a proper error code to the public API
false.to_glib()
}
}
}
#[no_mangle]
pub unsafe extern "C" fn rsvg_rust_handle_has_sub(
handle: *const RsvgHandle,
......
......@@ -459,7 +459,7 @@ impl Handle {
}
/// Returns (ink_rect, logical_rect)
pub fn get_geometry_sub(
fn get_geometry_sub(
&self,
id: Option<&str>,
) -> Result<(RsvgRectangle, RsvgRectangle), RenderingError> {
......
......@@ -25,7 +25,6 @@ pub use crate::c_api::{
rsvg_rust_handle_get_dpi_y,
rsvg_rust_handle_get_flags,
rsvg_rust_handle_get_geometry_for_element,
rsvg_rust_handle_get_geometry_sub,
rsvg_rust_handle_get_intrinsic_dimensions,
rsvg_rust_handle_get_pixbuf_sub,
rsvg_rust_handle_get_position_sub,
......
......@@ -604,18 +604,8 @@ dimensions_and_position (void)
g_assert_cmpint (pos.x, ==, EXAMPLE_TWO_X);
g_assert_cmpint (pos.y, ==, EXAMPLE_TWO_Y);
/* TODO: test logical_rect */
RsvgRectangle ink_rect;
RsvgRectangle logical_rect;
g_assert (rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, EXAMPLE_TWO_ID));
g_assert_cmpint (ink_rect.x, ==, EXAMPLE_TWO_X);
g_assert_cmpint (ink_rect.y, ==, EXAMPLE_TWO_Y);
g_assert_cmpint (ink_rect.width, ==, EXAMPLE_TWO_W);
g_assert_cmpint (ink_rect.height, ==, EXAMPLE_TWO_H);
g_assert (!rsvg_handle_get_position_sub (handle, &pos, EXAMPLE_NONEXISTENT_ID));
g_assert (!rsvg_handle_get_dimensions_sub (handle, &dim, EXAMPLE_NONEXISTENT_ID));
g_assert (!rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, EXAMPLE_NONEXISTENT_ID));
g_object_unref (handle);
}
......
......@@ -17,11 +17,8 @@ typedef struct
gdouble y;
gdouble width;
gdouble height;
gdouble logical_width;
gdouble logical_height;
gboolean has_position;
gboolean has_dimensions;
gboolean has_logical_dimensions;
} FixtureData;
/* The following are stolen from g_assert_cmpfloat_with_epsilon() and
......@@ -47,8 +44,6 @@ test_dimensions (FixtureData *fixture)
RsvgHandle *handle;
RsvgPositionData position;
RsvgDimensionData dimension;
RsvgRectangle ink_rect;
RsvgRectangle logical_rect;
gchar *target_file;
GError *error = NULL;
......@@ -62,33 +57,20 @@ test_dimensions (FixtureData *fixture)
g_assert (rsvg_handle_has_sub (handle, fixture->id));
g_assert (rsvg_handle_get_position_sub (handle, &position, fixture->id));
g_assert (rsvg_handle_get_dimensions_sub (handle, &dimension, fixture->id));
g_assert (rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, fixture->id));
g_message ("w=%d h=%d", dimension.width, dimension.height);
} else {
rsvg_handle_get_dimensions (handle, &dimension);
rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, NULL);
}
if (fixture->has_position) {
g_assert_cmpint (fixture->x, ==, position.x);
g_assert_cmpint (fixture->y, ==, position.y);
my_assert_cmpfloat_with_epsilon (fixture->x, ink_rect.x, 0.01);
my_assert_cmpfloat_with_epsilon (fixture->y, ink_rect.y, 0.01);
}
if (fixture->has_dimensions) {
g_assert_cmpint (fixture->width, ==, dimension.width);
g_assert_cmpint (fixture->height, ==, dimension.height);
my_assert_cmpfloat_with_epsilon (fixture->width, ink_rect.width, 0.01);
my_assert_cmpfloat_with_epsilon (fixture->height, ink_rect.height, 0.01);
}
if (fixture->has_logical_dimensions) {
my_assert_cmpfloat_with_epsilon (fixture->logical_width, logical_rect.width, 0.01);
my_assert_cmpfloat_with_epsilon (fixture->logical_height, logical_rect.height, 0.01);
}
g_object_unref (handle);
......@@ -100,47 +82,37 @@ static FixtureData fixtures[] =
"/dimensions/no viewbox, width and height",
"dimensions/bug608102.svg",
NULL,
0, 0, 16, 16, 16, 16,
FALSE, TRUE, TRUE
0, 0, 16, 16,
FALSE, TRUE
},
{
"/dimensions/100% width and height",
"dimensions/bug612951.svg",
NULL,
0, 0, 47, 47.14, 44.546, 45.44,
FALSE, TRUE, TRUE
0, 0, 47, 47.14,
FALSE, TRUE
},
{
"/dimensions/viewbox only",
"dimensions/bug614018.svg",
NULL,
0, 0, 972, 546, 0, 0,
0, 0, 972, 546,
FALSE, TRUE
},
{
"/dimensions/sub/rect no unit",
"dimensions/sub-rect-no-unit.svg",
"#rect-no-unit",
0, 0, 44, 45, 0, 0,
0, 0, 44, 45,
FALSE, TRUE
},
{
"/dimensions/sub/text_position",
"dimensions/347-wrapper.svg",
"#LabelA",
80, 48.90, 0, 0, 0, 0,
80, 48.90, 0, 0,
TRUE, FALSE
},
/* FIXME: The wilber test fails, the ink_rect has the wrong size */
/*{
"/dimensions/sub/bug760112-wilber",
"dimensions/bug760112-wilber.svg",
"#g39819",
0, 0, 16, 16, 16, 16,
FALSE, TRUE, TRUE
},
*/
/* {"/dimensions/sub/rect with transform", "dimensions/bug564527.svg", "#back", 0, 0, 144, 203} */
};
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment