Skip to content

Unify background placement code - #19651

Merged
bors-servo merged 2 commits into
servo:masterfrom
pyfisch:background-placement
Jan 2, 2018
Merged

bors-servo merged 2 commits into
servo:masterfrom
pyfisch:background-placement

Conversation

@pyfisch

@pyfisch pyfisch commented Dec 27, 2017 •

Copy link
Copy Markdown
Contributor

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

It should be noted that backgrounds are not clipped to
rounded border corners.
(This was done before but worked only in simple cases)
See: #19649

This solves the following issues:
closes #19626
closes #16657
closes #19482 (examples from http://lea.verou.me/css3patterns/ are rendered perfectly but the round border is completely ignored now)
closes #19577

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors

I enabled a few tests with the first commit but I have written about a dozen manual tests I will try to turn into ref tests either before or after this patch lands.

@bors-servo try

The relationship between the different inputs is visualized in this flowchart:
flowchart-background


This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @emilio: components/layout/display_list_builder.rs, components/layout/fragment.rs, components/layout/webrender_helpers.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 27, 2017

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a pretty neat cleanup!

Haven't gone through the math yet, but looks nice overall.

// normal but only display a single tile.
if image_size * 2 >= *size {
tile_image(position,
size,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Indentation here is off.

bounds.size.height)
}
fn compute_background_placement(&self,
state: &mut DisplayListBuildState,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe indenting these using block indentation, like:

fn compute_background_placement(
    &self,
    state: &mut ...,
) -> (Rect<Au>, Size2D<Au>, Size2D<Au>, Rect<Au>) {

is nicer. We should reformat this file to that style eventually anyway.

absolute_bounds: Rect<Au>,
intrinsic_size: Option<Size2D<Au>>,
index: usize)
-> (Rect<Au>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe a struct would be nicer instead of a tuple? It's not clear what each field means without looking at the function implementation.

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
@pyfisch
pyfisch force-pushed the background-placement branch from 2888a19 to 3b3d4a9 Compare December 28, 2017 19:14
@pyfisch

pyfisch commented Dec 28, 2017

Copy link
Copy Markdown
Contributor Author

Fixed nits.

@pyfisch

pyfisch commented Dec 28, 2017

Copy link
Copy Markdown
Contributor Author

Another bug is that background-attachment: fixed is scrolled with the window contents while it should stay attached to the viewport. (This was not broken by this PR) See these two tests:

Can you give me an example how to accomplish the fixed positioning? The webrender issue mentions push_clip_and_scroll_info but how exactly is it used here?

@emilio

emilio commented Dec 29, 2017

Copy link
Copy Markdown
Member

Can you give me an example how to accomplish the fixed positioning? The webrender issue mentions push_clip_and_scroll_info but how exactly is it used here?

Probably @glennw or @kvark can :)

@kvark

kvark commented Dec 29, 2017

Copy link
Copy Markdown
Member

Also cc @mrobinson

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. Not sure if you want to wait for the fixed image stuff or land this before, or prefer review from @glennw / @kvark / @mrobinson.

absolute_anchor_origin: Au,
image_size: Au) {
// Avoid division by zero below!
if image_size == Au(0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd make sense to comment why the outparams are sane in this case, or why it doesn't matter..

let own_size = if let Some(size) = intrinsic_size {
size
} else {
return match bg_size {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be cleaner with match intrinsic_size { ..., but no strong preference I guess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if understand this. match bg_size { ... matches on the CSS property background-size. Maybe you meant I should replace own_size with intrinsic_size?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a replacement for if let Some(size) = intrinsic_size on line 1050

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will change it.

&mut tile_spacing.height,
pos_y,
css_clip.origin.y,
css_clip.size.height);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Paren on the next line, here and in the rest of the calls using this format.

css_clip.origin.y,
css_clip.size.height);

return BackgroundPlacement { bounds, tile_size, tile_spacing, css_clip }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: No need for return.

@pyfisch
pyfisch force-pushed the background-placement branch from f074c8d to b97e6a5 Compare January 1, 2018 16:44
@pyfisch

pyfisch commented Jan 1, 2018

Copy link
Copy Markdown
Contributor Author

Force pushed the fixed nits.

@pyfisch

pyfisch commented Jan 1, 2018

Copy link
Copy Markdown
Contributor Author

This looks fine to me. Not sure if you want to wait for the fixed image stuff or land this before, or prefer review from @glennw / @kvark / @mrobinson.

I'd like to land this as is.

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's land it as soon as that nit is addressed :)

-> Size2D<Au> {
match intrinsic_size {
None => {
match bg_size {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I would've keep the early return, just using match, but it's not a big deal, this looks fine too, thanks!

// Images with a zero width or height are not displayed.
// Therefore the positions do not matter and can be left unchanged.
// NOTE: A possible optimization is not to build
// display lists in this case at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/display lists/display items/

@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

Mind filing issues for the remaining bits @pyfisch? Thanks a lot!

@pyfisch
pyfisch force-pushed the background-placement branch from b97e6a5 to 9849295 Compare January 1, 2018 18:32
@pyfisch

pyfisch commented Jan 1, 2018

Copy link
Copy Markdown
Contributor Author

nit: s/display lists/display items/

done.

I've opened #19650, #19669, #19672 for the remaining bits. Anything missing?

@pyfisch

pyfisch commented Jan 1, 2018

Copy link
Copy Markdown
Contributor Author

Travis failure is: oci runtime error: exec failed: container_linux.go:265: starting container process caused "could not create session key: disk quota exceeded"

@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

Yeah, same failure happened over #19668. We don't gate on travis though, so should be gtg, thanks!

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9849295 has been approved by emilio

@highfive highfive assigned emilio and unassigned mbrubeck Jan 1, 2018
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 1, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9849295 with merge f6111c5...

bors-servo pushed a commit that referenced this pull request Jan 1, 2018
Unify background placement code

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value, see #19650)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
(This was done before but worked only in simple cases)
See: #19649

This solves the following issues:
closes #19626
closes #16657
closes #19482 (examples from http://lea.verou.me/css3patterns/ are rendered perfectly but the round border is completely ignored now)
closes #19577

- `./mach build -d` does not report any errors
- `./mach test-tidy` does not report any errors

I enabled a few tests with the first commit but I have written about a dozen manual tests I will try to turn into ref tests either before or after this patch lands.

@bors-servo try

The relationship between the different inputs is visualized in this flowchart:
![flowchart-background](https://user-images.githubusercontent.com/2781017/34394430-5a06c72c-eb59-11e7-9d51-3d23e2215f07.png)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19651)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 1, 2018
Test the interaction between background-repeat: spaced
and CSS borders. Fix tile_image_axis() function.
@pyfisch
pyfisch force-pushed the background-placement branch from 9849295 to cf12e27 Compare January 2, 2018 12:57
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 2, 2018
@pyfisch

pyfisch commented Jan 2, 2018

Copy link
Copy Markdown
Contributor Author

Sorry for the failing tests. My computer is really slow at running them all. Are there options to speed up ./mach test-wpt? I just saw that the builders run test-wpt --release --processes 24 --total-chunks 2 --this-chunk 1 --always-succeed. Are the tests much faster with release builds and what number of processes should be used on a quad-core Laptop? Are the other parameters relevant?

At some point I was allowed to start bors with

@bors-servo try

but this doesn't work anymore. (Or does it?)

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit cf12e27 with merge 62d2179...

bors-servo pushed a commit that referenced this pull request Jan 2, 2018
Unify background placement code

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value, see #19650)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
(This was done before but worked only in simple cases)
See: #19649

This solves the following issues:
closes #19626
closes #16657
closes #19482 (examples from http://lea.verou.me/css3patterns/ are rendered perfectly but the round border is completely ignored now)
closes #19577

- `./mach build -d` does not report any errors
- `./mach test-tidy` does not report any errors

I enabled a few tests with the first commit but I have written about a dozen manual tests I will try to turn into ref tests either before or after this patch lands.

@bors-servo try

The relationship between the different inputs is visualized in this flowchart:
![flowchart-background](https://user-images.githubusercontent.com/2781017/34394430-5a06c72c-eb59-11e7-9d51-3d23e2215f07.png)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19651)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt3

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Jan 2, 2018
@emilio

emilio commented Jan 2, 2018

Copy link
Copy Markdown
Member

It does! And those tests are unexpected passes, so we need to mark them passing, not fixing anything :)

@pyfisch

pyfisch commented Jan 2, 2018 •

Copy link
Copy Markdown
Contributor Author

so we need to mark them passing, not fixing anything :)

Bad word choice on my side. I meant to mark them as passing by deleting the metadata files. The tests should pass now. (Only Mac crashed while building for some reason.)

@pyfisch

pyfisch commented Jan 2, 2018

Copy link
Copy Markdown
Contributor Author

All tests passed. (Except on Mac where some builders failed.)

@emilio Can you please approve?

@emilio

emilio commented Jan 2, 2018

Copy link
Copy Markdown
Member

Sure thing! Thanks a lot @pyfisch!

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit cf12e27 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-tests-failed The changes caused existing tests to fail. labels Jan 2, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit cf12e27 with merge 691bff8...

bors-servo pushed a commit that referenced this pull request Jan 2, 2018
Unify background placement code

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value, see #19650)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
(This was done before but worked only in simple cases)
See: #19649

This solves the following issues:
closes #19626
closes #16657
closes #19482 (examples from http://lea.verou.me/css3patterns/ are rendered perfectly but the round border is completely ignored now)
closes #19577

- `./mach build -d` does not report any errors
- `./mach test-tidy` does not report any errors

I enabled a few tests with the first commit but I have written about a dozen manual tests I will try to turn into ref tests either before or after this patch lands.

@bors-servo try

The relationship between the different inputs is visualized in this flowchart:
![flowchart-background](https://user-images.githubusercontent.com/2781017/34394430-5a06c72c-eb59-11e7-9d51-3d23e2215f07.png)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19651)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: emilio
Pushing 691bff8 to master...

@bors-servo
bors-servo merged commit cf12e27 into servo:master Jan 2, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 2, 2018
@pyfisch
pyfisch deleted the background-placement branch January 2, 2018 16:03
@CYBAI

CYBAI commented Jan 3, 2018

Copy link
Copy Markdown
Member

@pyfisch Congrats!!!!!!

jdm pushed a commit to web-platform-tests/wpt that referenced this pull request Jan 4, 2018
Test the interaction between background-repeat: spaced
and CSS borders. Fix tile_image_axis() function.

Upstreamed from servo/servo#19651 [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants