Bug 120623 - [CSS Background] Position property should be ignored when using repeat: space
Summary: [CSS Background] Position property should be ignored when using repeat: space
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-03 02:07 PDT by Andrei Parvu
Modified: 2013-09-19 07:40 PDT (History)
7 users (show)

See Also:


Attachments
Patch (7.53 KB, patch)
2013-09-03 02:19 PDT, Andrei Parvu
no flags Details | Formatted Diff | Diff
Patch (7.63 KB, patch)
2013-09-03 07:04 PDT, Andrei Parvu
no flags Details | Formatted Diff | Diff
Patch (8.01 KB, patch)
2013-09-03 23:31 PDT, Andrei Parvu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Parvu 2013-09-03 02:07:26 PDT
As the spec [1] says, background/mask-position property should be ignored when using repeat: space, if there are at least two copies of the image on a direction. If there is not enough space for two copies, only one should be drawn, and background/mask-position should determine its position.

[1] - http://www.w3.org/TR/css3-background/#the-background-repeat
Comment 1 Andrei Parvu 2013-09-03 02:19:52 PDT
Created attachment 210338 [details]
Patch
Comment 2 Dirk Schulze 2013-09-03 05:26:39 PDT
Comment on attachment 210338 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=210338&action=review

> Source/WebCore/ChangeLog:7
> +        The background/mask-position should be ignored when using repeat: space, if there are
> +        at least two copies of the image in one direction.

The last part of the sentence is confusing. I needed to read the spec again to understand what you mean. Maybe just quite the spec :)

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1358
> +            backgroundRepeatX = NoRepeatFill;

Doesn't that affect computed style? The spec is just speaking about visual differences.
Comment 3 Andrei Parvu 2013-09-03 06:52:30 PDT
> 
> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1358
> > +            backgroundRepeatX = NoRepeatFill;
> 
> Doesn't that affect computed style? The spec is just speaking about visual differences.

backgroundRepeatX is a local variable, it doesn't affect he computed style.
Comment 4 Andrei Parvu 2013-09-03 07:04:41 PDT
Created attachment 210370 [details]
Patch
Comment 5 Andrei Parvu 2013-09-03 07:05:18 PDT
(In reply to comment #4)
> Created an attachment (id=210370) [details]
> Patch

Modified the description in the change log.
Comment 6 Dirk Schulze 2013-09-03 08:27:38 PDT
Comment on attachment 210370 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=210370&action=review

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1353
> +        if (space) {

You are not checking for positive as suggested in the ChangeLog, but for zero. Negtative values would still enter the code path.

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1358
> +            geometry.setSpaceSize(FloatSize(space, 0));
> +            geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0);
> +        } else
> +            backgroundRepeatX = NoRepeatFill;

To be honest, I do not understand the code path good enough. I would have assumed that you check how many tiles fit into the paint area. If it is less than two... disable spacing and use background-position instead. Maybe the code path does it, but I don't see it. Can you elaborate more please?
Comment 7 Andrei Parvu 2013-09-03 23:31:14 PDT
Created attachment 210432 [details]
Patch
Comment 8 Andrei Parvu 2013-09-03 23:36:40 PDT
(In reply to comment #6)
> (From update of attachment 210370 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=210370&action=review
> 
> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1353
> > +        if (space) {
> 
> You are not checking for positive as suggested in the ChangeLog, but for zero. Negtative values would still enter the code path.
> 
> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1358
> > +            geometry.setSpaceSize(FloatSize(space, 0));
> > +            geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0);
> > +        } else
> > +            backgroundRepeatX = NoRepeatFill;
> 
> To be honest, I do not understand the code path good enough. I would have assumed that you check how many tiles fit into the paint area. If it is less than two... disable spacing and use background-position instead. Maybe the code path does it, but I don't see it. Can you elaborate more please?

getSpace() now returns -1 if the number of tiles is less than two; in this case the repeat of the image is set as NoRepeatFill. If space is greater or equal to zero, then the value of background/mask-position is ignored when computing 'computedX/YPosition'.
Comment 9 Dirk Schulze 2013-09-17 14:39:29 PDT
Comment on attachment 210432 [details]
Patch

r=me
Comment 10 Andrei Parvu 2013-09-17 23:54:47 PDT
(In reply to comment #9)
> (From update of attachment 210432 [details])
> r=me

Thanks for the review. Could you also commit the patch?
Comment 11 WebKit Commit Bot 2013-09-19 07:40:32 PDT
Comment on attachment 210432 [details]
Patch

Clearing flags on attachment: 210432

Committed r156097: <http://trac.webkit.org/changeset/156097>
Comment 12 WebKit Commit Bot 2013-09-19 07:40:35 PDT
All reviewed patches have been landed.  Closing bug.