Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
.onyx { | ||
color: white; | ||
} | ||
.item { | ||
background-color: #333; | ||
border-bottom: 1px solid white; | ||
} | ||
.top { | ||
margin: 0px; | ||
border: 0px; | ||
height: 1px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="onyx"> | ||
<div class="top"></div> | ||
<div class="item">1</div> | ||
<div class="item">2</div> | ||
<div class="item">3</div> | ||
<div class="item">4</div> | ||
</div> | ||
</body> | ||
</html> |
22 changes: 22 additions & 0 deletions
22
tests/ref/border_rounding_1px_invisible_issue_7184_ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
.onyx { | ||
color: white; | ||
} | ||
.item { | ||
background-color: #333; | ||
border-top: 1px solid white; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="onyx"> | ||
<div class="item">1</div> | ||
<div class="item">2</div> | ||
<div class="item">3</div> | ||
<div class="item">4</div> | ||
</div> | ||
</body> | ||
</html> |