Skip to content

Commit 635d144

Browse files
committed
Fix border corners with zero widths being drawn.
Fixes #1897.
1 parent 917e4f9 commit 635d144

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

webrender/src/border.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use util::{lerp, pack_as_float};
1515
#[repr(u8)]
1616
#[derive(Debug, Copy, Clone, PartialEq)]
1717
pub enum BorderCornerInstance {
18+
None,
1819
Single, // Single instance needed - corner styles are same or similar.
1920
Double, // Different corner styles. Draw two instances, one per style.
2021
}
@@ -128,8 +129,8 @@ impl NormalBorderHelpers for NormalBorder {
128129
corner: BorderCorner,
129130
border_rect: &LayerRect,
130131
) -> BorderCornerKind {
131-
// If either width is zero, a corner isn't formed.
132-
if width0 == 0.0 || width1 == 0.0 {
132+
// If both widths are zero, a corner isn't formed.
133+
if width0 == 0.0 && width1 == 0.0 {
133134
return BorderCornerKind::None;
134135
}
135136

@@ -139,9 +140,13 @@ impl NormalBorderHelpers for NormalBorder {
139140
}
140141

141142
match (edge0.style, edge1.style) {
142-
// If either edge is none or hidden, no corner is needed.
143-
(BorderStyle::None, _) | (_, BorderStyle::None) => BorderCornerKind::None,
144-
(BorderStyle::Hidden, _) | (_, BorderStyle::Hidden) => BorderCornerKind::None,
143+
// If both edges are none or hidden, no corner is needed.
144+
(BorderStyle::None, BorderStyle::None) |
145+
(BorderStyle::None, BorderStyle::Hidden) |
146+
(BorderStyle::Hidden, BorderStyle::None) |
147+
(BorderStyle::Hidden, BorderStyle::Hidden) => {
148+
BorderCornerKind::None
149+
}
145150

146151
// If both borders are solid, we can draw them with a simple rectangle if
147152
// both the colors match and there is no radius.
@@ -429,16 +434,19 @@ impl FrameBuilder {
429434
let mut corner_instances = [BorderCornerInstance::Single; 4];
430435

431436
for (i, corner) in corners.iter().enumerate() {
432-
match corner {
433-
&BorderCornerKind::Mask(corner_data, corner_radius, widths, kind) => {
437+
match *corner {
438+
BorderCornerKind::Mask(corner_data, corner_radius, widths, kind) => {
434439
let clip_source =
435440
BorderCornerClipSource::new(corner_data, corner_radius, widths, kind);
436441
extra_clips.push(ClipSource::BorderCorner(clip_source));
437442
}
438-
&BorderCornerKind::Clip(instance_kind) => {
443+
BorderCornerKind::Clip(instance_kind) => {
439444
corner_instances[i] = instance_kind;
440445
}
441-
_ => {}
446+
BorderCornerKind::Solid => {}
447+
BorderCornerKind::None => {
448+
corner_instances[i] = BorderCornerInstance::None;
449+
}
442450
}
443451
}
444452

webrender/src/tiling.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ impl AlphaRenderItem {
427427
{
428428
let sub_index = i as i32;
429429
match *instance_kind {
430+
BorderCornerInstance::None => {}
430431
BorderCornerInstance::Single => {
431432
batch.push(base_instance.build(
432433
sub_index,

0 commit comments

Comments
 (0)