Commit db1f068d authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

exo: removes unnecessary override of GetExtraHitTestShapeRects

GetExtraHitTestShapeRects() is called solely from
WindowTargeter::EventLocationInsideBounds(). As CustomTargeter completely
overrides EventLocationInsideBounds() there is no need to also override
GetExtraHitTestShapeRects(). This removes the unnecessary override.

I'm also removing the implementation of Surface::GetHitTestShapeRects() to
the test, as that is now the only place that needs to call it.

BUG=878836
TEST=covered by tests

Change-Id: I75569904bdfe5bd4d4384436488e4cc0b224ee3d
Reviewed-on: https://chromium-review.googlesource.com/1196913Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587696}
parent 370c8bc2
......@@ -45,6 +45,7 @@
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tree_host.h"
#include "ui/compositor_extra/shadow.h"
#include "ui/display/display.h"
......
......@@ -177,12 +177,6 @@ class CustomWindowTargeter : public aura::WindowTargeter {
return surface->HitTest(local_point);
}
std::unique_ptr<HitTestRects> GetExtraHitTestShapeRects(
aura::Window* window) const override {
Surface* surface = Surface::AsSurface(window);
return surface ? surface->GetHitTestShapeRects() : nullptr;
}
private:
DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
};
......@@ -664,17 +658,6 @@ void Surface::GetHitTestMask(gfx::Path* mask) const {
hit_test_region_.GetBoundaryPath(mask);
}
std::unique_ptr<aura::WindowTargeter::HitTestRects>
Surface::GetHitTestShapeRects() const {
if (hit_test_region_.IsEmpty())
return nullptr;
auto rects = std::make_unique<aura::WindowTargeter::HitTestRects>();
for (gfx::Rect rect : hit_test_region_)
rects->push_back(rect);
return rects;
}
void Surface::SetSurfaceDelegate(SurfaceDelegate* delegate) {
DCHECK(!delegate_ || !delegate);
delegate_ = delegate;
......
......@@ -21,7 +21,6 @@
#include "components/viz/common/resources/transferable_resource.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "ui/aura/window.h"
#include "ui/aura/window_targeter.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/transform.h"
......@@ -93,6 +92,7 @@ class Surface final : public ui::PropertyHandler {
// This sets the region of the surface that can receive pointer and touch
// events. The region is clipped to the surface bounds.
void SetInputRegion(const cc::Region& region);
const cc::Region& hit_test_region() const { return hit_test_region_; }
// This resets the region of the surface that can receive pointer and touch
// events to be wide-open. This will be clipped to the surface bounds.
......@@ -192,11 +192,6 @@ class Surface final : public ui::PropertyHandler {
// Sets |mask| to the path that delineates the hit test region of the surface.
void GetHitTestMask(gfx::Path* mask) const;
// Returns the current input region of surface in the form of a set of
// hit-test rects.
std::unique_ptr<aura::WindowTargeter::HitTestRects> GetHitTestShapeRects()
const;
// Set the surface delegate.
void SetSurfaceDelegate(SurfaceDelegate* delegate);
......
......@@ -32,6 +32,16 @@
namespace exo {
namespace {
std::unique_ptr<std::vector<gfx::Rect>> GetHitTestShapeRects(Surface* surface) {
if (surface->hit_test_region().IsEmpty())
return nullptr;
auto rects = std::make_unique<std::vector<gfx::Rect>>();
for (gfx::Rect rect : surface->hit_test_region())
rects->push_back(rect);
return rects;
}
class SurfaceTest : public test::ExoTestBase,
public ::testing::WithParamInterface<float> {
public:
......@@ -270,7 +280,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
{
// Default input region should match surface bounds.
auto rects = surface->GetHitTestShapeRects();
auto rects = GetHitTestShapeRects(surface.get());
ASSERT_TRUE(rects);
ASSERT_EQ(1u, rects->size());
ASSERT_EQ(gfx::Rect(512, 512), (*rects)[0]);
......@@ -281,7 +291,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
surface->SetInputRegion(gfx::Rect(256, 256));
surface->Commit();
auto rects = surface->GetHitTestShapeRects();
auto rects = GetHitTestShapeRects(surface.get());
ASSERT_TRUE(rects);
ASSERT_EQ(1u, rects->size());
ASSERT_EQ(gfx::Rect(256, 256), (*rects)[0]);
......@@ -292,7 +302,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
surface->SetInputRegion(gfx::Rect());
surface->Commit();
EXPECT_FALSE(surface->GetHitTestShapeRects());
EXPECT_FALSE(GetHitTestShapeRects(surface.get()));
}
{
......@@ -305,7 +315,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
surface->SetInputRegion(region);
surface->Commit();
auto rects = surface->GetHitTestShapeRects();
auto rects = GetHitTestShapeRects(surface.get());
ASSERT_TRUE(rects);
ASSERT_EQ(10u, rects->size());
cc::Region result;
......@@ -319,7 +329,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
surface->SetInputRegion(gfx::Rect(-50, -50, 1000, 100));
surface->Commit();
auto rects = surface->GetHitTestShapeRects();
auto rects = GetHitTestShapeRects(surface.get());
ASSERT_TRUE(rects);
ASSERT_EQ(1u, rects->size());
ASSERT_EQ(gfx::Rect(512, 50), (*rects)[0]);
......@@ -341,7 +351,7 @@ TEST_P(SurfaceTest, SetInputRegion) {
child_surface->Commit();
surface->Commit();
auto rects = surface->GetHitTestShapeRects();
auto rects = GetHitTestShapeRects(surface.get());
ASSERT_TRUE(rects);
ASSERT_EQ(2u, rects->size());
cc::Region result = cc::UnionRegions((*rects)[0], (*rects)[1]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment