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

Make hit tests against box shadows always fail. #9428

Merged
merged 1 commit into from Jan 26, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Make hit tests against box shadows always fail.

Closes #9268.
  • Loading branch information
pcwalton committed Jan 26, 2016
commit 32a68a43ec52f248e955948210f6dfba9b34b0bf
@@ -390,23 +390,30 @@ impl DisplayList {
return;
}

if let DisplayItem::BorderClass(ref border) = *item {
// If the point is inside the border, it didn't hit the border!
let interior_rect =
Rect::new(
Point2D::new(border.base.bounds.origin.x +
border.border_widths.left,
border.base.bounds.origin.y +
border.border_widths.top),
Size2D::new(border.base.bounds.size.width -
(border.border_widths.left +
border.border_widths.right),
border.base.bounds.size.height -
(border.border_widths.top +
border.border_widths.bottom)));
if interior_rect.contains(&point) {
return;
match *item {
DisplayItem::BorderClass(ref border) => {
// If the point is inside the border, it didn't hit the border!
let interior_rect =
Rect::new(
Point2D::new(border.base.bounds.origin.x +
border.border_widths.left,
border.base.bounds.origin.y +
border.border_widths.top),
Size2D::new(border.base.bounds.size.width -
(border.border_widths.left +
border.border_widths.right),
border.base.bounds.size.height -
(border.border_widths.top +
border.border_widths.bottom)));
if interior_rect.contains(&point) {
return;
}
}
DisplayItem::BoxShadowClass(_) => {
// Box shadows can never be hit.
return
}
_ => {}
}

// We found a hit!
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<!-- Clicking under the shadow should still activate the green div. -->
<style>
.green {
background: green;
position: absolute;
top: 45px;
left: 170px;
width: 100px;
height: 50px;
}
.red {
background: red;
position: absolute;
top: 20px;
left: 20px;
width: 100px;
height: 100px;
box-shadow: 100px 0 0 rgba(0,0,0,0.1);
transform: translateX(1px);
}
</style>
<div class="green" onclick="console.log('You clicked me!')"></div>
<div class="red"></div>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.