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

Apply border-radius to img, canvas, iframe #17589

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

adjust clipping region of img, canvas and iframe for border radius

  • Loading branch information
streichgeorg committed Jun 29, 2017
commit 7f1896138b5eacfc976eb0613c97705ef3eee520
@@ -830,18 +830,25 @@ fn convert_ellipse_size_keyword(keyword: ShapeExtent,
}
}

fn clip_for_border_radius(style: &ServoComputedValues,
clip: &Rect<Au>) -> ClippingRegion {
let border_radii = build_border_radius(clip, style.get_border());
let mut adjusted_clip = ClippingRegion::max();
if !border_radii.is_square() {
adjusted_clip.intersect_with_rounded_rect(clip, &border_radii);
};

This comment has been minimized.

@emilio

emilio Jul 2, 2017

Member

nit: This semicolon is not needed, please remove it.


adjusted_clip
}

impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_background_if_applicable(&self,
state: &mut DisplayListBuildState,
style: &ServoComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>) {
// Adjust the clipping region as necessary to account for `border-radius`.
let border_radii = build_border_radius(absolute_bounds, style.get_border());
let mut clip = ClippingRegion::max();
if !border_radii.is_square() {
clip.intersect_with_rounded_rect(absolute_bounds, &border_radii);
};
let clip = clip_for_border_radius(style, absolute_bounds);

let background = style.get_background();

// FIXME: This causes a lot of background colors to be displayed when they are clearly not
@@ -1834,6 +1841,8 @@ impl FragmentDisplayListBuilding for Fragment {
let stacking_relative_content_box =
self.stacking_relative_content_box(stacking_relative_border_box);

let clipping_region = clip_for_border_radius(&self.style, &stacking_relative_content_box);

This comment has been minimized.

@emilio

emilio Jul 2, 2017

Member

Why stacking_relative_border_box? I'd have expected this to use clip.

Also, what about the other uses for the clip rect? Should they account for border-radius too?

This comment has been minimized.

@streichgeorg

streichgeorg Jul 2, 2017

Author Contributor

I tried clip and it doesn't work, but it works with stacking_relative_content_box so I just used that. I don't really have any oversight over this code so I don't know why that is.


match self.specific {
SpecificFragmentInfo::TruncatedFragment(box TruncatedFragmentInfo {
text_info: Some(ref text_fragment),
@@ -1892,7 +1901,7 @@ impl FragmentDisplayListBuilding for Fragment {
if !stacking_relative_content_box.is_empty() {
let base = state.create_base_display_item(
&stacking_relative_content_box,
&ClippingRegion::from_rect(clip),
&clipping_region,
self.node,
self.style.get_cursor(Cursor::Default),
DisplayListSection::Content);
@@ -1913,7 +1922,7 @@ impl FragmentDisplayListBuilding for Fragment {
if let Some(ref image) = image_fragment.image {
let base = state.create_base_display_item(
&stacking_relative_content_box,
&ClippingRegion::from_rect(clip),
&clipping_region,
self.node,
self.style.get_cursor(Cursor::Default),
DisplayListSection::Content);
@@ -1944,7 +1953,7 @@ impl FragmentDisplayListBuilding for Fragment {

let base = state.create_base_display_item(
&stacking_relative_content_box,
&ClippingRegion::from_rect(clip),
&clipping_region,
self.node,
self.style.get_cursor(Cursor::Default),
DisplayListSection::Content);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.