Percent values no longe work on shapes.

Bug #1430873 reported by Tavmjong Bah
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Triaged
High
Tavmjong Bah

Bug Description

In trunk, using % values with shapes no longer works. Example:

<rect x="25%" y="25%" width="50%" height="50%" fill="red"/>

should produce a red rectangle half the height and half the width of the SVG centered in the middle. This works as expected in 0.91.

Test file attached.

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :
Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.91+devel rev >= 13938 on OS X 10.7.5

tags: added: regression units
Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.92
status: New → Confirmed
Revision history for this message
jazzynico (jazzynico) wrote :

Reproduced on Crunchbang Waldorf, Inkscape trunk rev. 13994.
The missing circle and rectangle still exist, but are very small (50% is converted to 0.5 and 25% to 0.25...).

tags: removed: regression
Changed in inkscape:
importance: Medium → Undecided
status: Confirmed → Triaged
importance: Undecided → Medium
tags: added: regression
Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

 OK, this bug reveals all kinds of nastiness.

1. We shouldn't be setting the 'viewBox' if it is not already set. Inkscape normally does not change existing elements unless an element is actually edited inside Inkscape.

2. Setting 'viewBox' triggers an unnecessary rewriting of all the child elements. There is no reason to do this.

3. During rewriting an element with an SVGLength, only the 'computed' value is rewritten (which in the case of percent, is the percent value as the actual "computed" value is determined at rendering time). This leaves the 'unit' and 'value' parts incorrect which causes the "computed" value to be misinterpreted.

4. Changing the code to write out the 'value' and 'unit' in addition to the 'computed' value works for rendering an element but in editing an element (dragging a node), again only the 'computed' value is written leading to incorrect 'unit' and 'value' parts.

su_v (suv-lp)
Changed in inkscape:
importance: Medium → High
Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

Updates 14004 and 14009 fix ellipses and rectangles with % values, respectively.

One more nastiness: Moving one node causes set() to be called for all attributes but update() is not called. This leaves the computed values where the unit is % (or 'em'/'ex') incorrect which means that the nodes corresponding to the attribute values are placed on the screen in the wrong positions. Also, undoing an action does the same thing. I've added 'viewport' to SPItem so that the viewport is cached. This can then be used in set() to calculate the correct computed values. One could image eventually preservering the use of % values as attributes are edited as the 'viewport' information is now available.

Revision history for this message
jazzynico (jazzynico) wrote :

Percentage values confirmed fixed in 0.92, so the bug could be closed Fix released with no milestone.

@Tav, could you please check the other items you reported, and, if there's something to be fixed, rename the report accordingly (or open a new report)?
Thanks!

Changed in inkscape:
assignee: nobody → Tavmjong Bah (tavmjong-free)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.