Skip to content

gfx: Fix bug with 1px width borders disappearing - #7577

Merged
bors-servo merged 2 commits into
servo:masterfrom
bjwbell:borders_pixel_rounding_bug
Sep 9, 2015
Merged

bors-servo merged 2 commits into
servo:masterfrom
bjwbell:borders_pixel_rounding_bug

Conversation

@bjwbell

@bjwbell bjwbell commented Sep 9, 2015

Copy link
Copy Markdown
Contributor

In to_nearest_azure_rect when rounding to pixel coordinates, maintain
the invariant of rect non-overlap (if before rounding two rects don't overlap).

The previous code rounded the rect top left corner to the nearest pixel with
the size rounded to the nearest pixel multiple which can violate the
non-overlap condition, e.g.
10px×9.60px at (0px,6.6px) & 10px×9.60px at (0px,16.2px)
would round to
10px×10.0px at (0px,7.0px) & 10px×10.0px at (0px,16.0px), which overlap.

Instead round each corner to the nearest pixel.

For rects that dont need to satify the non-overlap condition and with
width or height between 0.5px and 1px, rounding each rect corner to the
nearest pixel can yield an empty rect e.g.
10px×0.6px at 0px,28.56px -> 10px×0px at 0px,29px.

For this scenario a new function to_nearest_non_empty_azure_rect
rounds the rect top left corner to the nearest pixel and the rect size
to the nearest pixel multiple. It's possible for non-overlapping rects
after this rounding to overlap.

This should fix #7184 "rounding ...borders not to be visible", without breaking #7152 "Underlines less than 1px high sometimes invisible".

r? @mbrubeck

Review on Reviewable

In to_nearest_azure_rect when rounding to pixel coordinates, maintain
the invariant of rect non-overlap (if before rounding two rects don't overlap).

The previous code rounded the rect top left corner to the nearest pixel with
the size rounded to the nearest pixel multiple which can violate the
non-overlap condition, e.g.
10px×9.60px at (0px,6.6px) & 10px×9.60px at (0px,16.2px)
would round to
10px×10.0px at (0px,7.0px) & 10px×10.0px at (0px,16.0px), which overlap.

Instead round each corner to the nearest pixel.

For rects that dont need to satify the non-overlap condition and with
width or height between 0.5px and 1px, rounding each rect corner to the
nearest pixel can yield an empty rect e.g.
10px×0.6px at 0px,28.56px -> 10px×0px at 0px,29px.

For this scenario a new function to_nearest_non_empty_azure_rect
rounds the rect top left corner to the nearest pixel and the rect size
to the nearest pixel multiple. It's possible for non-overlapping rects
after this rounding to overlap.
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 9, 2015
@mbrubeck

mbrubeck commented Sep 9, 2015

Copy link
Copy Markdown
Contributor

Looks good! I appreciate the detailed comments, too.


Reviewed 6 of 6 files at r1.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from the review on Reviewable.io

@mbrubeck

mbrubeck commented Sep 9, 2015

Copy link
Copy Markdown
Contributor

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 642b348 has been approved by mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 642b348 with merge 585e104...

@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 Sep 9, 2015
bors-servo pushed a commit that referenced this pull request Sep 9, 2015
gfx: Fix bug with 1px width borders disappearing

In to_nearest_azure_rect when rounding to pixel coordinates, maintain
the invariant of rect non-overlap (if before rounding two rects don't overlap).

The previous code rounded the rect top left corner to the nearest pixel with
the size rounded to the nearest pixel multiple which can violate the
non-overlap condition, e.g.
10px×9.60px at (0px,6.6px) & 10px×9.60px at (0px,16.2px)
would round to
10px×10.0px at (0px,7.0px) & 10px×10.0px at (0px,16.0px), which overlap.

Instead round each corner to the nearest pixel.

For rects that dont need to satify the non-overlap condition and with
width or height between 0.5px and 1px, rounding each rect corner to the
nearest pixel can yield an empty rect e.g.
10px×0.6px at 0px,28.56px -> 10px×0px at 0px,29px.

For this scenario a new function to_nearest_non_empty_azure_rect
rounds the rect top left corner to the nearest pixel and the rect size
to the nearest pixel multiple. It's possible for non-overlapping rects
after this rounding to overlap.

This should fix #7184 "rounding ...borders not to be visible", without breaking #7152 "Underlines less than 1px high sometimes invisible".

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7577)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@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 Sep 9, 2015
@jdm

jdm commented Sep 9, 2015

Copy link
Copy Markdown
Member

The reftest analyzer shows this test is missing a pixel line of orange at the bottom of the rendered test.

@jdm

jdm commented Sep 9, 2015

Copy link
Copy Markdown
Member
/css21_dev/html4/position-relative-035.htm
------------------------------------------
FAIL [Parent]

@mbrubeck

mbrubeck commented Sep 9, 2015

Copy link
Copy Markdown
Contributor

/css21_dev/html4/position-relative-035.htm

Note: #7152 changed this test from failing on both our test platforms to failing on Mac only. The Mac failure seems to be different (the line of text is missing completely).

@bjwbell

bjwbell commented Sep 9, 2015

Copy link
Copy Markdown
Contributor Author

Interesting, I actually hadn't run test-css locally. I'll take a look at it.

There is no easy way to pass position-relative-035 & also
pass both tests/ref/border_rounding_1px_invisible_issue_7184 and
tests/ref/text_decoration_underline_subpx.

servo#7161, "Snap rectangles to nearest
pixels...", did fix position-relative-035 (except
for OS X) but broke 1px borders.
@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 Sep 9, 2015
@bjwbell

bjwbell commented Sep 9, 2015

Copy link
Copy Markdown
Contributor Author

@mbrubeck rerun bors?

@mbrubeck

mbrubeck commented Sep 9, 2015

Copy link
Copy Markdown
Contributor

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 1f44686 has been approved by mbrubeck

@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 Sep 9, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 1f44686 with merge f29ddb4...

bors-servo pushed a commit that referenced this pull request Sep 9, 2015
gfx: Fix bug with 1px width borders disappearing

In to_nearest_azure_rect when rounding to pixel coordinates, maintain
the invariant of rect non-overlap (if before rounding two rects don't overlap).

The previous code rounded the rect top left corner to the nearest pixel with
the size rounded to the nearest pixel multiple which can violate the
non-overlap condition, e.g.
10px×9.60px at (0px,6.6px) & 10px×9.60px at (0px,16.2px)
would round to
10px×10.0px at (0px,7.0px) & 10px×10.0px at (0px,16.0px), which overlap.

Instead round each corner to the nearest pixel.

For rects that dont need to satify the non-overlap condition and with
width or height between 0.5px and 1px, rounding each rect corner to the
nearest pixel can yield an empty rect e.g.
10px×0.6px at 0px,28.56px -> 10px×0px at 0px,29px.

For this scenario a new function to_nearest_non_empty_azure_rect
rounds the rect top left corner to the nearest pixel and the rect size
to the nearest pixel multiple. It's possible for non-overlapping rects
after this rounding to overlap.

This should fix #7184 "rounding ...borders not to be visible", without breaking #7152 "Underlines less than 1px high sometimes invisible".

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7577)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 1f44686 into servo:master Sep 9, 2015
@bjwbell
bjwbell deleted the borders_pixel_rounding_bug branch September 9, 2015 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rounding issue causing some borders not to be visible.

5 participants