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

Fix box shadows when inner mask rect has invalid size. #2824

Merged
merged 1 commit into from Jun 18, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -6,7 +6,7 @@ use api::{BorderRadius, ClipMode, LayoutPoint, LayoutPointAu, LayoutRect, Layout
use app_units::Au;
use prim_store::EdgeAaSegmentMask;
use std::{cmp, usize};
use util::extract_inner_rect_safe;
use util::{extract_inner_rect_safe, RectHelpers};

bitflags! {
pub struct ItemFlags: u8 {
@@ -210,63 +210,71 @@ impl SegmentBuilder {
inner_rect: LayoutRect,
inner_clip_mode: Option<ClipMode>,
) {
debug_assert!(outer_rect.contains_rect(&inner_rect));

let p0 = outer_rect.origin;
let p1 = inner_rect.origin;
let p2 = inner_rect.bottom_right();
let p3 = outer_rect.bottom_right();
if inner_rect.is_well_formed_and_nonempty() {
debug_assert!(outer_rect.contains_rect(&inner_rect));

let p0 = outer_rect.origin;
let p1 = inner_rect.origin;
let p2 = inner_rect.bottom_right();
let p3 = outer_rect.bottom_right();

let segments = &[
LayoutRect::new(
LayoutPoint::new(p0.x, p0.y),
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p0.y),
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p2.y),
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p0.x, p2.y),
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p1.x, p0.y),
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p1.y),
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
),
LayoutRect::new(
LayoutPoint::new(p1.x, p2.y),
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p0.x, p1.y),
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
),
];

let segments = &[
LayoutRect::new(
LayoutPoint::new(p0.x, p0.y),
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p0.y),
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p2.y),
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p0.x, p2.y),
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p1.x, p0.y),
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
),
LayoutRect::new(
LayoutPoint::new(p2.x, p1.y),
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
),
LayoutRect::new(
LayoutPoint::new(p1.x, p2.y),
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
),
LayoutRect::new(
LayoutPoint::new(p0.x, p1.y),
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
),
];
for segment in segments {
self.items.push(Item::new(
*segment,
None,
true
));
}

for segment in segments {
if inner_clip_mode.is_some() {
self.items.push(Item::new(
inner_rect,
inner_clip_mode,
false,
));
}
} else {
self.items.push(Item::new(
*segment,
outer_rect,
None,
true
));
}

if inner_clip_mode.is_some() {
self.items.push(Item::new(
inner_rect,
inner_clip_mode,
false,
));
}
}

// Push some kind of clipping region into the segment builder.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
---
root:
items:
- type: stacking-context
items:
- type: box-shadow
bounds: [ 50, 50, 400.1, 400.1 ]
color: red
blur-radius: 10
clip-mode: inset
border-radius: 185
@@ -27,3 +27,5 @@ platform(linux,mac) fuzzy(1,685) == overlap1.yaml overlap1.png
platform(linux,mac) == no-stretch.yaml no-stretch.png
platform(linux,mac) == box-shadow-stretch-mode-x.yaml box-shadow-stretch-mode-x.png
platform(linux,mac) == box-shadow-stretch-mode-y.yaml box-shadow-stretch-mode-y.png
platform(linux,mac) == inset-mask-region.yaml inset-mask-region.png

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