You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Andreas Delmelle <an...@telenet.be> on 2008/02/08 18:32:07 UTC

Q: Interpretation of decimal values in background-position-*

Hi all

Last night I committed a tweak to resolve percentages for line-height  
early, when parsed. This became possible after a previous change in  
which I made sure that percentages for font-size are also resolved  
early.

The benefit, as mentioned in the commit message: a reduction of the  
amount of non-cacheable PercentLength instances, replaced by cached  
FixedLengths. A small tweak, since I don't think it saves all that  
much. Then again, every little bit helps...

Now while going over it again, and trying to do the same for  
background-position, I noticed that there is currently a testcase -- 
IIRC, one I added myself when implementing the background-position  
shorthand-- where a specified value of "0.5" is expected to yield a  
percentage... After my changes, it yields an absolute value of 500mpt.
So I re-read the Rec on this one, and it seems the first  
interpretation is wrong. If I take the spec literally, then a value  
of "0.5" would actually be a length (and thus equal to "0.5px"), so  
the 500mpt is correct (when using the default source resolution of  
72dpi).

Before I commit, I thought I'd check to see if anyone disagrees with  
the above behavior.



Cheers

Andreas

Re: Q: Interpretation of decimal values in background-position-*

Posted by Andreas Delmelle <an...@telenet.be>.
On Feb 11, 2008, at 11:44, Vincent Hennebert wrote:

> Andreas Delmelle wrote:
> <snip/>
>> Now while going over it again, and trying to do the same for
>> background-position, I noticed that there is currently a testcase
>> --IIRC, one I added myself when implementing the background-position
>> shorthand-- where a specified value of "0.5" is expected to yield a
>> percentage... After my changes, it yields an absolute value of  
>> 500mpt.
>> So I re-read the Rec on this one, and it seems the first  
>> interpretation
>> is wrong. If I take the spec literally, then a value of "0.5" would
>> actually be a length (and thus equal to "0.5px"), so the 500mpt is
>> correct (when using the default source resolution of 72dpi).
>>
>> Before I commit, I thought I'd check to see if anyone disagrees  
>> with the
>> above behavior.
>
> In my opinion specifying "0.5" is simply wrong. The property expects,
> among others, a <percentage> or a <length>. So one should specify  
> either
> "50%" or "0.5px", but not a number alone since it becomes  
> impossible to
> determine if it’s a percentage or a length. An error should  
> probably be
> thrown in this case.

OK, currently FOP's behavior is to assume pixels as units for  
unqualified lengths (like many HTML browsers).
As I recall, this was once requested by a fop-user. Originally, we  
did throw an error for this, but apparently, for some this was too  
strict an interpretation.

Just checking to see if no one depended on the interpretation  
0.5=50%, but I think I'll leave the pixel-fallback in place FTM...


Cheers

Andreas

Re: Q: Interpretation of decimal values in background-position-*

Posted by Vincent Hennebert <vi...@anyware-tech.com>.
Hi Andreas,

Andreas Delmelle wrote:
<snip/>
> Now while going over it again, and trying to do the same for
> background-position, I noticed that there is currently a testcase
> --IIRC, one I added myself when implementing the background-position
> shorthand-- where a specified value of "0.5" is expected to yield a
> percentage... After my changes, it yields an absolute value of 500mpt.
> So I re-read the Rec on this one, and it seems the first interpretation
> is wrong. If I take the spec literally, then a value of "0.5" would
> actually be a length (and thus equal to "0.5px"), so the 500mpt is
> correct (when using the default source resolution of 72dpi).
> 
> Before I commit, I thought I'd check to see if anyone disagrees with the
> above behavior.

In my opinion specifying "0.5" is simply wrong. The property expects, 
among others, a <percentage> or a <length>. So one should specify either 
"50%" or "0.5px", but not a number alone since it becomes impossible to 
determine if it’s a percentage or a length. An error should probably be 
thrown in this case.

Vincent


-- 
Vincent Hennebert                            Anyware Technologies
http://people.apache.org/~vhennebert         http://www.anyware-tech.com
Apache FOP Committer                         FOP Development/Consulting

Re: Q: Interpretation of decimal values in background-position-*

Posted by Andreas Delmelle <an...@telenet.be>.
On Feb 8, 2008, at 18:32, Andreas Delmelle wrote:

> Now while going over it again, and trying to do the same for  
> background-position, I noticed that there is currently a testcase -- 
> IIRC, one I added myself when implementing the background-position  
> shorthand-- where a specified value of "0.5" is expected to yield a  
> percentage...

Correction: "... expected to yield a NumberProperty with Double  
corresponding to the value 0.5"