From 9a24ca73f36d6b45f7743328e36f6382fd5cee4d Mon Sep 17 00:00:00 2001 From: lfg Date: Tue, 9 Feb 2016 12:11:09 -0800 Subject: Adds an interface to SurfaceHittestDelegate in order to override the hittesting decision to accept a surface. This will be used to override hittesting on transparent backgrounds. BUG=491334 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1663433002 Cr-Commit-Position: refs/heads/master@{#374433} --- cc/test/surface_hittest_test_helpers.cc | 33 +++++++++++++++++++++++++++------ cc/test/surface_hittest_test_helpers.h | 17 ++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) (limited to 'cc/test') diff --git a/cc/test/surface_hittest_test_helpers.cc b/cc/test/surface_hittest_test_helpers.cc index b83d6d4..5766273 100644 --- a/cc/test/surface_hittest_test_helpers.cc +++ b/cc/test/surface_hittest_test_helpers.cc @@ -93,27 +93,48 @@ scoped_ptr CreateCompositorFrame(const gfx::Rect& root_rect, } TestSurfaceHittestDelegate::TestSurfaceHittestDelegate() - : target_overrides_(0) {} + : reject_target_overrides_(0), accept_target_overrides_(0) {} TestSurfaceHittestDelegate::~TestSurfaceHittestDelegate() {} -void TestSurfaceHittestDelegate::AddInsetsForSurface( +void TestSurfaceHittestDelegate::AddInsetsForRejectSurface( const SurfaceId& surface_id, const gfx::Insets& inset) { - insets_for_surface_.insert(std::make_pair(surface_id, inset)); + insets_for_reject_.insert(std::make_pair(surface_id, inset)); +} + +void TestSurfaceHittestDelegate::AddInsetsForAcceptSurface( + const SurfaceId& surface_id, + const gfx::Insets& inset) { + insets_for_accept_.insert(std::make_pair(surface_id, inset)); } bool TestSurfaceHittestDelegate::RejectHitTarget( const SurfaceDrawQuad* surface_quad, const gfx::Point& point_in_quad_space) { - if (!insets_for_surface_.count(surface_quad->surface_id)) + if (!insets_for_reject_.count(surface_quad->surface_id)) return false; gfx::Rect bounds(surface_quad->rect); - bounds.Inset(insets_for_surface_[surface_quad->surface_id]); + bounds.Inset(insets_for_reject_[surface_quad->surface_id]); // If the point provided falls outside the inset, then we skip this surface. if (!bounds.Contains(point_in_quad_space)) { if (surface_quad->rect.Contains(point_in_quad_space)) - ++target_overrides_; + ++reject_target_overrides_; + return true; + } + return false; +} + +bool TestSurfaceHittestDelegate::AcceptHitTarget( + const SurfaceDrawQuad* surface_quad, + const gfx::Point& point_in_quad_space) { + if (!insets_for_accept_.count(surface_quad->surface_id)) + return false; + gfx::Rect bounds(surface_quad->rect); + bounds.Inset(insets_for_accept_[surface_quad->surface_id]); + // If the point provided falls outside the inset, then we accept this surface. + if (!bounds.Contains(point_in_quad_space)) { + ++accept_target_overrides_; return true; } return false; diff --git a/cc/test/surface_hittest_test_helpers.h b/cc/test/surface_hittest_test_helpers.h index 4a27659..e3f8ff9 100644 --- a/cc/test/surface_hittest_test_helpers.h +++ b/cc/test/surface_hittest_test_helpers.h @@ -70,18 +70,25 @@ class TestSurfaceHittestDelegate : public SurfaceHittestDelegate { TestSurfaceHittestDelegate(); ~TestSurfaceHittestDelegate(); - int target_overrides() const { return target_overrides_; } + int reject_target_overrides() const { return reject_target_overrides_; } + int accept_target_overrides() const { return accept_target_overrides_; } - void AddInsetsForSurface(const SurfaceId& surface_id, - const gfx::Insets& inset); + void AddInsetsForRejectSurface(const SurfaceId& surface_id, + const gfx::Insets& inset); + void AddInsetsForAcceptSurface(const SurfaceId& surface_id, + const gfx::Insets& inset); // SurfaceHittestDelegate implementation. bool RejectHitTarget(const SurfaceDrawQuad* surface_quad, const gfx::Point& point_in_quad_space) override; + bool AcceptHitTarget(const SurfaceDrawQuad* surface_quad, + const gfx::Point& point_in_quad_space) override; private: - int target_overrides_; - std::map insets_for_surface_; + int reject_target_overrides_; + int accept_target_overrides_; + std::map insets_for_reject_; + std::map insets_for_accept_; DISALLOW_COPY_AND_ASSIGN(TestSurfaceHittestDelegate); }; -- cgit v1.1