diff options
author | lfg <lfg@chromium.org> | 2016-02-09 12:11:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-09 20:12:36 +0000 |
commit | 9a24ca73f36d6b45f7743328e36f6382fd5cee4d (patch) | |
tree | 983b55c453d9411e2f17019171f29a47c52d02bf /cc/test | |
parent | 02b81ba466ca5698cdd8bcee2ae2aa4401589b7d (diff) | |
download | chromium_src-9a24ca73f36d6b45f7743328e36f6382fd5cee4d.zip chromium_src-9a24ca73f36d6b45f7743328e36f6382fd5cee4d.tar.gz chromium_src-9a24ca73f36d6b45f7743328e36f6382fd5cee4d.tar.bz2 |
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}
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/surface_hittest_test_helpers.cc | 33 | ||||
-rw-r--r-- | cc/test/surface_hittest_test_helpers.h | 17 |
2 files changed, 39 insertions, 11 deletions
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<CompositorFrame> 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<SurfaceId, gfx::Insets> insets_for_surface_; + int reject_target_overrides_; + int accept_target_overrides_; + std::map<SurfaceId, gfx::Insets> insets_for_reject_; + std::map<SurfaceId, gfx::Insets> insets_for_accept_; DISALLOW_COPY_AND_ASSIGN(TestSurfaceHittestDelegate); }; |