[lasem] svg_svg_element: ignore x and y for outermost svg.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] svg_svg_element: ignore x and y for outermost svg.
- Date: Sat, 14 Aug 2010 09:09:29 +0000 (UTC)
commit f58f776f5c4c336574b42beb615d432b75e6d548
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sat Aug 14 11:08:51 2010 +0200
svg_svg_element: ignore x and y for outermost svg.
src/lsmdomnode.h | 2 +-
src/lsmsvgsvgelement.c | 22 +++++++++---
test/svg/misc/undo-128-d-sodipodi.svg | 63 +++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 6 deletions(-)
---
diff --git a/src/lsmdomnode.h b/src/lsmdomnode.h
index 477197a..b82255d 100644
--- a/src/lsmdomnode.h
+++ b/src/lsmdomnode.h
@@ -72,7 +72,7 @@ struct _LsmDomNodeClass {
void (*set_node_value) (LsmDomNode* self, const char* new_value);
LsmDomNodeType (*get_node_type) (LsmDomNode* self);
#if 0
- LsmDomNodeList* (*get_child_nodes) (LsmDomNode* self);
+ LsmDomNodeList* (*get_child_nodes) (LsmDomNode* self);
LsmDomNamedNodeMap* (*get_attributes) (LsmDomNode* self);
#endif
diff --git a/src/lsmsvgsvgelement.c b/src/lsmsvgsvgelement.c
index 7c30134..b00ef8e 100644
--- a/src/lsmsvgsvgelement.c
+++ b/src/lsmsvgsvgelement.c
@@ -24,7 +24,7 @@
#include <lsmsvgstyle.h>
#include <lsmsvgview.h>
#include <lsmdebug.h>
-#include <lsmdomdocument.h>
+#include <lsmsvgdocument.h>
#include <math.h>
#include <stdio.h>
@@ -46,6 +46,7 @@ lsm_svg_svg_element_measure (LsmSvgSvgElement *self, double *width, double *heig
LsmDomDocument *document;
LsmSvgViewbox *svg_viewbox;
LsmBox viewport;
+ gboolean is_outermost_svg;
double resolution_ppi;
double svg_x;
double svg_y;
@@ -64,13 +65,15 @@ lsm_svg_svg_element_measure (LsmSvgSvgElement *self, double *width, double *heig
svg_viewbox = lsm_svg_viewbox_new (resolution_ppi, &viewport);
font_size = 10 * resolution_ppi / 72.0;
- if (lsm_attribute_is_defined (&self->x.base))
+ is_outermost_svg = LSM_IS_SVG_DOCUMENT (lsm_dom_node_get_parent_node (LSM_DOM_NODE (self)));
+
+ if (lsm_attribute_is_defined (&self->x.base) && !is_outermost_svg)
svg_x = lsm_svg_length_normalize (&self->x.length, svg_viewbox,
font_size, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
else
svg_x = viewport.x;
- if (lsm_attribute_is_defined (&self->y.base))
+ if (lsm_attribute_is_defined (&self->y.base) && !is_outermost_svg)
svg_y = lsm_svg_length_normalize (&self->y.length, svg_viewbox,
font_size, LSM_SVG_LENGTH_DIRECTION_VERTICAL);
else
@@ -111,10 +114,19 @@ _svg_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgSvgElement *svg = LSM_SVG_SVG_ELEMENT (self);
gboolean is_viewbox_defined;
+ gboolean is_outermost_svg;
LsmBox viewport;
- viewport.x = lsm_svg_view_normalize_length (view, &svg->x.length, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
- viewport.y = lsm_svg_view_normalize_length (view, &svg->y.length, LSM_SVG_LENGTH_DIRECTION_VERTICAL);
+ is_outermost_svg = LSM_IS_SVG_DOCUMENT (lsm_dom_node_get_parent_node (LSM_DOM_NODE (self)));
+
+ if (is_outermost_svg) {
+ /* outermost svg - ignore x and y */
+ viewport.x = 0;
+ viewport.y = 0;
+ } else {
+ viewport.x = lsm_svg_view_normalize_length (view, &svg->x.length, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
+ viewport.y = lsm_svg_view_normalize_length (view, &svg->y.length, LSM_SVG_LENGTH_DIRECTION_VERTICAL);
+ }
viewport.width = lsm_svg_view_normalize_length (view, &svg->width.length, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
viewport.height = lsm_svg_view_normalize_length (view, &svg->height.length, LSM_SVG_LENGTH_DIRECTION_VERTICAL);
diff --git a/test/svg/misc/undo-128-d-sodipodi.svg b/test/svg/misc/undo-128-d-sodipodi.svg
new file mode 100644
index 0000000..74f8644
--- /dev/null
+++ b/test/svg/misc/undo-128-d-sodipodi.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg
+ xml:space="preserve"
+ x="0.133331in"
+ y="-0.504638in"
+ width="1.24063in"
+ height="1.04445in"
+ style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality"
+ viewBox="133 0 1241 1044"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ sodipodi:docname="/mnt/windows/Themes/Icons/undo-128-d-sodipodi.svg"
+ sodipodi:docbase="/mnt/windows/Themes/Icons/"
+ id="svg251"> <sodipodi:namedview
+ id="base">
+ </sodipodi:namedview>
+ <defs
+ id="defs252"> <style
+ type="text/css"
+ id="style253"> <text>
+ .str0 {stroke:#007844;stroke-width:44}
+ .fil0 {fill:url(#id0)}
+ </text>
+
+ </style>
+ <linearGradient
+ id="id0"
+ x1="1593"
+ y1="836"
+ x2="144"
+ y2="-215"> <stop
+ offset="0"
+ style="stop-color:#009240"
+ id="stop255">
+ </stop>
+ <stop
+ offset="0.294118"
+ style="stop-color:#3DB330"
+ id="stop256">
+ </stop>
+ <stop
+ offset="1"
+ style="stop-color:#B9DB7D"
+ id="stop257">
+ </stop>
+
+ </linearGradient>
+
+ </defs>
+ <g
+ id="____ 1"
+ transform="matrix(1 0 0 1 -262.029 -4.90719e-14)"> <path
+ id="40038688"
+ class="fil0 str0"
+ d="M489 533c111,122 200,211 200,211 0,0 0,0 0,0 0,0 -533,0 -533,0 0,0 0,-44 0,-222 0,-178 0,-333 0,-333 0,0 164,173 175,184 11,11 102,-118 147,-162 44,-44 89,-89 133,-111 45,-22 100,-78 245,-78 144,0 186,16 264,49 78,33 111,67 144,111 34,45 47,73 69,140 23,67 23,156 11,245 -11,88 -26,122 -60,188 -33,67 -106,123 -173,167 -67,45 -133,67 -189,78 -55,11 -133,22 -178,22 -44,0 -88,-33 -55,-33 33,0 133,-11 233,-67 100,-55 145,-100 189,-155 45,-56 56,-145 56,-212 0,-66 -14,-151 -58,-195 -44,-44 -87,-82 -209,-82 -122,0 -176,44 -254,100 -77,56 -90,100 -157,155z">
+ </path>
+
+ </g>
+
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]