Bug 91572 - css background-position value text and length/percentage
Summary: css background-position value text and length/percentage
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml renderer (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-18 07:24 UTC by Yan Morin
Modified: 2004-10-22 21:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yan Morin 2004-10-18 07:24:36 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

KHTML/CSS doesn't handle case when there is a keyword (left, center, right)  with a percentage or length in second or the opposite a percentage or length with a keyword (top, center, bottom).

Exemple: 
background-position: left 10px;
background-position: center 2em;
background-position: right 80%;
and
background-position: 10px top;
background-position: 2em center;
background-position: 80% bottom;

@see khtml/css/parser.php:585

Simple test case with background-position: center 10px:
http://yansanmo.no-ip.org:8080/test/css/backgroundImage.htm
Comment 1 Stephan Kulow 2004-10-18 09:18:11 UTC
From http://www.w3.org/TR/REC-CSS2/colors.html#background-properties:
"Keywords cannot be combined with percentage values or length values"

So it should ignore the background-position tag and render as if you didn't
specify it at all. Problem is: no browser does. 

Mozilla and IE agree on ignoring the statement in the the spec and konqueror ignores the 10px. 
Comment 2 Stephan Kulow 2004-10-18 09:26:48 UTC
I'm really undecided how to fix your bug report. I guess I would fix the strictness part, but if you found this problem on a web site we should rather
add a "IE compliance" check.
Comment 3 Stephan Kulow 2004-10-18 09:37:39 UTC
https://bugzilla.mozilla.org/show_bug.cgi?id=237065 - that's interesting. They closed a very similiar bug report as INVALID. Still the supplied test case works in my firefox :)
Comment 4 Yan Morin 2004-10-18 13:40:50 UTC
http://www.w3.org/TR/CSS21/colors.html#background-properties
Combinations of keyword, length and percentage values are allowed, (e.g., '50% 2cm' or 'center 2cm' or 'center 10%').
Value:  
[ [ <percentage> | <length> | left | center | right ] [ <percentage> | <length> | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit 

And with MSIE:
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/backgroundposition.asp
Comment 5 bert 2004-10-18 14:32:44 UTC
Stephan Kulow writes:
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
>         
> http://bugs.kde.org/show_bug.cgi?id=91572        
> 
> 
> 
> 
> ------- Additional Comments From coolo kde org  2004-10-18 09:37 -------
> https://bugzilla.mozilla.org/show_bug.cgi?id=237065 - that's interesting. They closed a very similiar bug report as INVALID. Still the supplied test case works in my firefox :)

It's a change between CSS2 and CSS 2.1. Several implementers reported
that it was as easy to support it as to reject it (and in fact most
browsers supported it) and so there was no good reason to forbid
'center 10px' anymore. Thus the CSS working group relaxed the syntax
in the revised edition of CSS2.

'10px 50%'   --> allowed (10 px from the left, 50% from the top)
'left 10%'   --> allowed (0% from the left, 10% from the top)
'center 5%'  --> allowed (50% from the left, 5% from the top)
'5% center'  --> allowed (5% from the left, 50% from the top)
'2px bottom' --> allowed (2px from the left, 100% from the top)
'center top' --> allowed (50% from the left, 0% from the top)
'top center' --> allowed! (in this case vertical comes before horizontal)
'right top'  --> allowd (100% from the left, 0% from the top)
'top right'  --> allowed! (in this case vertical comes before horizontal)
'10px left'  --> NOT allowed (10px from the left and 50% from the left?)
'top 20%'    --> NOT allowed (0% from the top and 20% from the top?)



Bert
Comment 6 Yan Morin 2004-10-18 19:29:02 UTC
Some tests cases (with the Bert's test cases).
http://yansanmo.no-ip.org:8080/test/css/backgroundPosition.php

With a 800x600 screen, the green square should be over the background 
or as the text says.
Comment 7 Stephan Kulow 2004-10-22 21:30:55 UTC
CVS commit by coolo: 

implementing CSS 2.1 compliant parsing of background-position. There are several
cases to catch, which makes the code a bit longer than the usual property.
BUG: 91572


  M +5 -0      ChangeLog   1.308
  M +196 -80   css/cssparser.cpp   1.296
  M +6 -1      css/cssparser.h   1.77