Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUnify background placement code #19651
Conversation
highfive
commented
Dec 27, 2017
|
Heads up! This PR modifies the following files:
|
|
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.
This comment has been minimized.
| bounds.size.height) | ||
| } | ||
| fn compute_background_placement(&self, | ||
| state: &mut DisplayListBuildState, |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
|
Fixed nits. |
|
Another bug is that
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? |
|
Also cc @mrobinson |
|
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.
This comment has been minimized.
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.
This comment has been minimized.
emilio
Dec 31, 2017
Member
This may be cleaner with match intrinsic_size { ..., but no strong preference I guess
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
mbrubeck
Jan 1, 2018
Contributor
As a replacement for if let Some(size) = intrinsic_size on line 1050
This comment has been minimized.
This comment has been minimized.
| &mut tile_spacing.height, | ||
| pos_y, | ||
| css_clip.origin.y, | ||
| css_clip.size.height); |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
|
Force pushed the fixed nits. |
I'd like to land this as is. |
|
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.
This comment has been minimized.
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.
This comment has been minimized.
|
Mind filing issues for the remaining bits @pyfisch? Thanks a lot! |
|
Travis failure is: |
|
Yeah, same failure happened over #19668. We don't gate on travis though, so should be gtg, thanks! @bors-servo r+ |
|
|
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:  <!-- 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 -->
|
|
Test the interaction between background-repeat: spaced and CSS borders. Fix tile_image_axis() function.
|
Sorry for the failing tests. My computer is really slow at running them all. Are there options to speed up At some point I was allowed to start bors with @bors-servo try but this doesn't work anymore. (Or does it?) |
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:  <!-- 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 -->
|
|
|
It does! And those tests are unexpected passes, 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.) |
|
All tests passed. (Except on Mac where some builders failed.) @emilio Can you please approve? |
|
Sure thing! Thanks a lot @pyfisch! @bors-servo r+ |
|
|
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:  <!-- 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 -->
|
|
|
@pyfisch Congrats!!!!!! |
Test the interaction between background-repeat: spaced and CSS borders. Fix tile_image_axis() function. Upstreamed from servo/servo#19651 [ci skip]
pyfisch commentedDec 27, 2017
•
edited
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 -ddoes not report any errors./mach test-tidydoes not report any errorsI 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:

This change is