From f59e95ee3df314fe82de12c9f76ad484cd5d69f7 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 6 Feb 2019 15:17:29 -0500 Subject: [PATCH] Ensure transparent hit test region is sized and positioned correctly. --- components/layout/display_list/builder.rs | 25 ++++++++++++-- tests/wpt/mozilla/meta/MANIFEST.json | 10 ++++++ .../tests/mozilla/hit-test-background.html | 33 +++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/hit-test-background.html diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 17cdd5cdc1a..2a107ed0c88 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -390,7 +390,25 @@ impl<'a> DisplayListBuildState<'a> { } else { self.current_clipping_and_scrolling }; + self.create_base_display_item_with_clipping_and_scrolling( + bounds, + clip_rect, + node, + cursor, + section, + clipping_and_scrolling, + ) + } + fn create_base_display_item_with_clipping_and_scrolling( + &self, + bounds: Rect, + clip_rect: Rect, + node: OpaqueNode, + cursor: Option, + section: DisplayListSection, + clipping_and_scrolling: ClippingAndScrolling, + ) -> BaseDisplayItem { BaseDisplayItem::new( bounds.to_layout(), DisplayItemMetadata { @@ -1640,14 +1658,15 @@ impl Fragment { // of this fragment's background but behind its content. This ensures that any // hit tests inside the content box but not on actual content target the current // scrollable ancestor. - let content_size = TypedRect::from_size(content_size); - let base = state.create_base_display_item( + let content_size = TypedRect::new(stacking_relative_border_box.origin, content_size); + let base = state.create_base_display_item_with_clipping_and_scrolling( content_size, content_size, self.node, // FIXME(emilio): Why does this ignore pointer-events? get_cursor(&self.style, Cursor::Default).or(Some(Cursor::Default)), - DisplayListSection::Content, + display_list_section, + state.current_clipping_and_scrolling, ); state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( base, diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 7e946f61fb6..1ba99731942 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -12659,6 +12659,12 @@ {} ] ], + "mozilla/hit-test-background.html": [ + [ + "/_mozilla/mozilla/hit-test-background.html", + {} + ] + ], "mozilla/hit_test_multiple_sc.html": [ [ "/_mozilla/mozilla/hit_test_multiple_sc.html", @@ -19418,6 +19424,10 @@ "9baa0cdcd5abad00b321e8b9351a1bc162783ed5", "support" ], + "mozilla/hit-test-background.html": [ + "5212954e4ee6ecb684212e7373e24a2268434b1c", + "testharness" + ], "mozilla/hit_test_multiple_sc.html": [ "1c79d25ea06f80eb515282fb0a53a34f92a25698", "testharness" diff --git a/tests/wpt/mozilla/tests/mozilla/hit-test-background.html b/tests/wpt/mozilla/tests/mozilla/hit-test-background.html new file mode 100644 index 00000000000..5212954e4ee --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/hit-test-background.html @@ -0,0 +1,33 @@ +Hit testing backgrounds of content should report the same element as the content + + + + +