Bug 1447131 - Handle backface-visibility:hidden in WebRender hit testing. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Mon, 26 Mar 2018 19:17:58 -0400
changeset 772798 a6ff0fc6c5fa77d0e76ce74e755c689da25a36a0
parent 772797 a07799862c24e38b13b286a9def06828f4c5b258
child 772799 3748e68eaaf274dccda1a14a9275da46605ad79c
push id104049
push userbballo@mozilla.com
push dateMon, 26 Mar 2018 23:21:29 +0000
reviewerskats
bugs1447131
milestone61.0a1
Bug 1447131 - Handle backface-visibility:hidden in WebRender hit testing. r=kats MozReview-Commit-ID: 4keSrs1aGpS
gfx/webrender/src/hit_test.rs
--- a/gfx/webrender/src/hit_test.rs
+++ b/gfx/webrender/src/hit_test.rs
@@ -52,24 +52,26 @@ impl HitTestClipChainDescriptor {
     }
 }
 
 #[derive(Clone)]
 pub struct HitTestingItem {
     rect: LayerRect,
     clip_rect: LayerRect,
     tag: ItemTag,
+    is_backface_visible: bool,
 }
 
 impl HitTestingItem {
     pub fn new(tag: ItemTag, info: &LayerPrimitiveInfo) -> HitTestingItem {
         HitTestingItem {
             rect: info.rect,
             clip_rect: info.clip_rect,
             tag: tag,
+            is_backface_visible: info.is_backface_visible,
         }
     }
 }
 
 #[derive(Clone)]
 pub struct HitTestingRun(pub Vec<HitTestingItem>, pub ScrollNodeAndClipChain);
 
 enum HitTestRegion {
@@ -260,16 +262,21 @@ impl HitTester {
                 if !self.is_point_clipped_in_for_node(point, root_node_index, &mut test) {
                     continue;
                 }
                 let point_in_viewport = match test.node_cache[&root_node_index] {
                     Some(point) => point,
                     None => continue,
                 };
 
+                // Don't hit items with backface-visibility:hidden if they are facing the back.
+                if !item.is_backface_visible && transform.is_backface_visible() {
+                    continue;
+                }
+
                 result.items.push(HitTestItem {
                     pipeline: pipeline_id,
                     tag: item.tag,
                     point_in_viewport,
                     point_relative_to_item: point_in_layer - item.rect.origin.to_vector(),
                 });
                 if !test.flags.contains(HitTestFlags::FIND_ALL) {
                     return result;