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

Add support for border-radius #25423

Merged
merged 3 commits into from Jan 6, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Clip background-color to border-radius

  • Loading branch information
SimonSapin committed Jan 3, 2020
commit 347d5825d1a784b3ed39849c4e9d544489ca78d8
@@ -47,6 +47,13 @@ impl DisplayListBuilder {
flags: wr::PrimitiveFlags::default(),
}
}

fn clipping_and_scrolling_scope<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> R {
let previous = self.current_space_and_clip;
let result = f(self);
self.current_space_and_clip = previous;
result
}
}

/// Contentful paint, for the purpose of
@@ -133,7 +140,7 @@ impl BoxFragment {
let hit_info = hit_info(&self.style, self.tag, Cursor::Default);
let border_radius = self.border_radius(&border_rect);

self.background_display_items(builder, hit_info, border_rect);
self.background_display_items(builder, hit_info, border_rect, &border_radius);
self.border_display_items(builder, hit_info, border_rect, border_radius);
let content_rect = self
.content_rect
@@ -168,13 +175,28 @@ impl BoxFragment {
builder: &mut DisplayListBuilder,
hit_info: HitInfo,
border_rect: units::LayoutRect,
border_radius: &wr::BorderRadius,
) {
let background_color = self
.style
.resolve_color(self.style.clone_background_color());
if background_color.alpha > 0 || hit_info.is_some() {
let common = builder.common_properties(border_rect, hit_info);
builder.wr.push_rect(&common, rgba(background_color))
builder.clipping_and_scrolling_scope(|builder| {
if !border_radius.is_zero() {
builder.current_space_and_clip.clip_id = builder.wr.define_clip(
&builder.current_space_and_clip,
border_rect,
Some(wr::ComplexClipRegion {
rect: border_rect,
radii: *border_radius,
mode: wr::ClipMode::Clip,
}),
None,
);
}
let common = builder.common_properties(border_rect, hit_info);
builder.wr.push_rect(&common, rgba(background_color))
});
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.