After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 624375 - background-position doesn't seem to be supported.
background-position doesn't seem to be supported.
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
2.29.x
Other Linux
: Normal normal
: ---
Assigned To: Dan Winship
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2010-07-14 19:37 UTC by Jakub Steiner
Modified: 2010-09-01 16:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
according to the stylesheet, the icon should have been placed on the top left corner. (1.41 KB, image/png)
2010-07-14 19:37 UTC, Jakub Steiner
  Details
[StThemeNode] Add basic background-position support (4.47 KB, patch)
2010-07-18 19:42 UTC, drago01
none Details | Review
[StThemeNode] Add basic background-position support (5.74 KB, patch)
2010-07-18 19:53 UTC, drago01
needs-work Details | Review
[StThemeNode] Add basic background-position support (6.18 KB, patch)
2010-08-28 11:04 UTC, drago01
reviewed Details | Review
[StThemeNode] Add basic background-position support (5.03 KB, patch)
2010-08-31 17:18 UTC, drago01
committed Details | Review

Description Jakub Steiner 2010-07-14 19:37:11 UTC
Created attachment 165907 [details]
according to the stylesheet, the icon should have been placed on the top left corner.

Key property for CSS styling is to be able to position the background image on the block. As the attached screenshot shows, this doesn't seem to be implemented:

#searchEntry {
    padding: 4px;
    border-radius: 4px;
    color: #444;
    border: 1px solid #565656;

    background-gradient-direction: vertical;
    background-gradient-start: #ccc;
    background-gradient-end: #eee;

    background-image: url(search.svg);
    background-repeat: no-repeat;
    background-position: 0 0; /* doesn't seem to be supported */
    caret-color: #fff;
    caret-size: 1px;
    height: 16px;
    padding-left: 20px;
}

See http://www.w3.org/TR/CSS2/colors.html#propdef-background-position
Comment 1 drago01 2010-07-18 19:42:59 UTC
Created attachment 166133 [details] [review]
[StThemeNode] Add basic background-position support

Add basic support for background-position, which only supports absoulte
values.

Also don't require an unit to be specified for 0 (because the unit does not
really matter here 0 is 0 regardless of the unit).
Comment 2 drago01 2010-07-18 19:53:39 UTC
Created attachment 166134 [details] [review]
[StThemeNode] Add basic background-position support

Add basic support for background-position, which only supports absoulte
values.

Also don't require an unit to be specified for 0 (because the unit does not
really matter here 0 is 0 regardless of the unit).
Comment 3 Dan Winship 2010-08-02 17:05:38 UTC
Comment on attachment 166134 [details] [review]
[StThemeNode] Add basic background-position support

>Add basic support for background-position, which only supports absoulte

typo in "absolute"

>       if (new_h > box_h)
>         {
>-          /* center for new width */
>-          offset = ((box_w) - new_w) * 0.5;
>+          /* honor the specified position if any */

I'm not sure how background-image scaling and positioning interact in HTML, but this can't be right (the spec doesn't seem to discuss scaling at all, implying that maybe background-image is never scaled-down in HTML?). In particular, your code ends up using either the specified x position or the specified y position, but not both.

>+          if (self->background_position[0] != -1)

You're allowed to specify negative positions (to offset the image in the opposite direction), so you can't use -1 as a sentinel. So you'll need an explicit "background_position_set" flag or something.

It would also be better to have separate background_position_x and background_position_y fields (like we do with the various height/width properties) rather than using an array (which we generally only do for properties where there's a corresponding enumeration, eg StSide or StCorner).

Also, for all of the other properties, we convert to int when parsing the CSS. I'm not sure background-position needs to be any different.
Comment 4 drago01 2010-08-02 21:19:17 UTC
(In reply to comment #3)
> (From update of attachment 166134 [details] [review])
> >Add basic support for background-position, which only supports absoulte
> 
> typo in "absolute"

... OK

> >       if (new_h > box_h)
> >         {
> >-          /* center for new width */
> >-          offset = ((box_w) - new_w) * 0.5;
> >+          /* honor the specified position if any */
> 
> I'm not sure how background-image scaling and positioning interact in HTML, but
> this can't be right (the spec doesn't seem to discuss scaling at all, implying
> that maybe background-image is never scaled-down in HTML?).

It isn't ... its will just get "cut off" if it doesn't fit (at least pretty much any browser I know of does it this way; not sure which spec specifies that if any)

> In particular, your
> code ends up using either the specified x position or the specified y position,
> but not both.

That wasn't intentional, that's a stupid bug ...

> >+          if (self->background_position[0] != -1)
> 
> You're allowed to specify negative positions (to offset the image in the
> opposite direction), so you can't use -1 as a sentinel. So you'll need an
> explicit "background_position_set" flag or something.

Indeed, good point.

> It would also be better to have separate background_position_x and
> background_position_y fields (like we do with the various height/width
> properties) rather than using an array (which we generally only do for
> properties where there's a corresponding enumeration, eg StSide or StCorner).

OK

> Also, for all of the other properties, we convert to int when parsing the CSS.
> I'm not sure background-position needs to be any different.

OK, wasn't aware of that, but yeah we should be consistent here.
Comment 5 drago01 2010-08-28 11:04:08 UTC
Created attachment 168940 [details] [review]
[StThemeNode] Add basic background-position support

Add basic support for background-position, which only supports absolute
values.

Also don't require an unit to be specified for 0 (because the unit does not
really matter here 0 is 0 regardless of the unit).
Comment 6 Dan Winship 2010-08-31 17:04:27 UTC
Comment on attachment 168940 [details] [review]
[StThemeNode] Add basic background-position support

>+              result->x1 = self->background_position_x;
>+              result->x2 = self->background_position_x + new_w;
>+              result->y1 = self->background_position_y;
>+              result->y2 = box_h;

This still seems strange... we scale the image, but not the offset.

I think "if (self->background_position_set)" should be outside the check-if-it-needs-to-be-scaled, and we should just not do scaling if the image is absolutely positioned.

(We may actually want to revisit the idea of scaling even in the non-positioned case...)

>+      /* honor the specified position if any */
>+      if (self->background_position_set)
>+        {
>+          result->x1 = allocation->x1 + self->background_position_x;
>+          result->y1 = allocation->y1 + self->background_position_y;

Remove "allocation->x1 + " and "allocation->y1 + ". "result" is a box inside "allocation", not inside allocation's parent.


the rest looks good
Comment 7 drago01 2010-08-31 17:18:17 UTC
Created attachment 169178 [details] [review]
[StThemeNode] Add basic background-position support

Add basic support for background-position, which only supports absolute
values.

Also don't require an unit to be specified for 0 (because the unit does not
really matter here 0 is 0 regardless of the unit).
Comment 8 Dan Winship 2010-09-01 15:54:34 UTC
Comment on attachment 169178 [details] [review]
[StThemeNode] Add basic background-position support

good, except

>+  /* scale the background into the allocated bounds, when not being absolutly positioned */

typo. "absolutely"
Comment 9 drago01 2010-09-01 16:14:22 UTC
Attachment 169178 [details] pushed as 9f9067e - [StThemeNode] Add basic background-position support