View | Details | Raw Unified | Return to issue 122594
Collapse All | Expand All

(-)svgio/source/svgreader/svgsvgnode.cxx (-2 / +58 lines)
Lines 182-189 Link Here
182
                            // create target range homing x,y, width and height as given
182
                            // create target range homing x,y, width and height as given
183
                            const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0);
183
                            const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0);
184
                            const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0);
184
                            const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0);
185
                            const double fW(getWidth().isSet() ? getWidth().solve(*this, xcoordinate) : getViewBox()->getWidth());
185
                            const bool bWidthIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit());
186
                            const double fH(getHeight().isSet() ? getHeight().solve(*this, ycoordinate) : getViewBox()->getHeight());
186
                            const bool bHeightIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit());
187
                            const SvgSvgNode* pParentSvgSvgNode = 0;
188
                            double fW(0.0);
189
                            double fH(0.0);
190
191
                            // #122594# if width/height is not given, it's 100% (see 5.1.2 The ‘svg’ element in SVG1.1 spec).
192
                            // If it is relative, the question is to what. The previous implementatin assumed relative to the
193
                            // local ViewBox which is implied by (4.2 Basic data types):
194
                            //
195
                            // "Note that the non-property <length> definition also allows a percentage unit identifier. 
196
                            // The meaning of a percentage length value depends on the attribute for which the percentage 
197
                            // length value has been specified. Two common cases are: (a) when a percentage length value 
198
                            // represents a percentage of the viewport width or height (refer to the section that discusses 
199
                            // units in general), and (b) when a percentage length value represents a percentage of the 
200
                            // bounding box width or height on a given object (refer to the section that describes object 
201
                            // bounding box units)."
202
                            //
203
                            // This is not closer specified for the SVG element itself as non-outmost element, but comparisons
204
                            // with common browsers shows that it's mostly interpreted relative to the viewBox of the parent.
205
                            // Adding code to search the parent SVG element and calculating width/height relative to it's
206
                            // viewBox width/height (and no longer to the local viewBox).
207
                            if(bWidthIsRelative || bHeightIsRelative)
208
                            {
209
                                for(const SvgNode* pParent = getParent(); pParent && !pParentSvgSvgNode; pParent = pParent->getParent())
210
                                {
211
                                    pParentSvgSvgNode = dynamic_cast< const SvgSvgNode* >(pParent);
212
                                }
213
                            }
214
215
                            if(bWidthIsRelative)
216
                            {
217
                                fW = getWidth().isSet() ? getWidth().getNumber() * 0.01 : 1.0;
218
219
                                if(pParentSvgSvgNode)
220
                                {
221
                                    fW *= pParentSvgSvgNode->getViewBox()->getWidth();
222
                                }
223
                            }
224
                            else
225
                            {
226
                                fW = getWidth().solve(*this, xcoordinate);
227
                            }
228
229
                            if(bHeightIsRelative)
230
                            {
231
                                fH = getHeight().isSet() ? getHeight().getNumber() * 0.01 : 1.0;
232
233
                                if(pParentSvgSvgNode)
234
                                {
235
                                    fH *= pParentSvgSvgNode->getViewBox()->getHeight();
236
                                }
237
                            }
238
                            else
239
                            {
240
                                fH = getHeight().solve(*this, ycoordinate);
241
                            }
242
187
                            const basegfx::B2DRange aTarget(fX, fY, fX + fW, fY + fH);
243
                            const basegfx::B2DRange aTarget(fX, fY, fX + fW, fY + fH);
188
244
189
                            if(aTarget.equal(*getViewBox()))
245
                            if(aTarget.equal(*getViewBox()))

Return to issue 122594