Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify background placement code #19651

Merged
merged 2 commits into from Jan 2, 2018
Merged

Conversation

@pyfisch
Copy link
Contributor

pyfisch commented Dec 27, 2017

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


This change is Reviewable

@highfive
Copy link

highfive commented Dec 27, 2017

Heads up! This PR modifies the following files:

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

emilio left a comment

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,

This comment has been minimized.

Copy link
@emilio

emilio Dec 28, 2017

Member

nit: Indentation here is off.

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

This comment has been minimized.

Copy link
@emilio

emilio Dec 28, 2017

Member

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>,

This comment has been minimized.

Copy link
@emilio

emilio Dec 28, 2017

Member

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 pyfisch:background-placement branch from 2888a19 to 3b3d4a9 Dec 28, 2017
@pyfisch
Copy link
Contributor Author

pyfisch commented Dec 28, 2017

Fixed nits.

@pyfisch
Copy link
Contributor Author

pyfisch commented Dec 28, 2017

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
Copy link
Member

emilio commented Dec 29, 2017

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
Copy link
Member

kvark commented Dec 29, 2017

Also cc @mrobinson

Copy link
Member

emilio left a comment

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) {

This comment has been minimized.

Copy link
@emilio

emilio Dec 31, 2017

Member

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 {

This comment has been minimized.

Copy link
@emilio

emilio Dec 31, 2017

Member

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

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jan 1, 2018

Author Contributor

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?

This comment has been minimized.

Copy link
@mbrubeck

mbrubeck Jan 1, 2018

Contributor

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

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jan 1, 2018

Author Contributor

Thanks. Will change it.

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

This comment has been minimized.

Copy link
@emilio

emilio Dec 31, 2017

Member

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 }

This comment has been minimized.

Copy link
@emilio

emilio Dec 31, 2017

Member

nit: No need for return.

@pyfisch pyfisch force-pushed the pyfisch:background-placement branch from f074c8d to b97e6a5 Jan 1, 2018
@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 1, 2018

Force pushed the fixed nits.

@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 1, 2018

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 approved these changes Jan 1, 2018
Copy link
Member

emilio left a comment

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

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

This comment has been minimized.

Copy link
@emilio

emilio Jan 1, 2018

Member

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.

This comment has been minimized.

Copy link
@emilio

emilio Jan 1, 2018

Member

nit: s/display lists/display items/

@emilio
Copy link
Member

emilio commented Jan 1, 2018

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

@pyfisch pyfisch force-pushed the pyfisch:background-placement branch from b97e6a5 to 9849295 Jan 1, 2018
@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 1, 2018

nit: s/display lists/display items/

done.

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

@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 1, 2018

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
Copy link
Member

emilio commented Jan 1, 2018

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
Contributor

bors-servo commented Jan 1, 2018

📌 Commit 9849295 has been approved by emilio

@highfive highfive assigned emilio and unassigned mbrubeck Jan 1, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Jan 1, 2018

Testing commit 9849295 with merge f6111c5...

bors-servo added 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
Contributor

bors-servo commented Jan 1, 2018

💔 Test failed - linux-rel-wpt

Test the interaction between background-repeat: spaced
and CSS borders. Fix tile_image_axis() function.
@pyfisch pyfisch force-pushed the pyfisch:background-placement branch from 9849295 to cf12e27 Jan 2, 2018
@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 2, 2018

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
Contributor

bors-servo commented Jan 2, 2018

Trying commit cf12e27 with merge 62d2179...

bors-servo added 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
Contributor

bors-servo commented Jan 2, 2018

💔 Test failed - mac-rel-wpt3

@emilio
Copy link
Member

emilio commented Jan 2, 2018

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

@pyfisch
Copy link
Contributor Author

pyfisch commented Jan 2, 2018

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
Copy link
Contributor Author

pyfisch commented Jan 2, 2018

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

@emilio Can you please approve?

@emilio
Copy link
Member

emilio commented Jan 2, 2018

Sure thing! Thanks a lot @pyfisch!

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Jan 2, 2018

📌 Commit cf12e27 has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Jan 2, 2018

Testing commit cf12e27 with merge 691bff8...

bors-servo added 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
Contributor

bors-servo commented Jan 2, 2018

@bors-servo bors-servo merged commit cf12e27 into servo:master Jan 2, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Jan 2, 2018
3 of 3 tasks complete
@pyfisch pyfisch deleted the pyfisch:background-placement branch Jan 2, 2018
@CYBAI
Copy link
Collaborator

CYBAI commented Jan 3, 2018

@pyfisch Congrats!!!!!!

jdm added 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
Projects
None yet
7 participants
You can’t perform that action at this time.