Commit d7d9e582 authored by Ria Jiang's avatar Ria Jiang Committed by Commit Bot

Delete HitTestDataProviderAura.

HitTestDataProviderAura is no longer in use; all previous use cases
were updated to use HitTestDataProviderDrawQuad. Clean up
HitTestDataProviderAura related code.

Bug: none
Change-Id: I2e67411c1c145cf5e5fe527c79ec2bfbd00c6570
Reviewed-on: https://chromium-review.googlesource.com/c/1338327Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Ria Jiang <riajiang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608636}
parent 786b4918
...@@ -32,7 +32,6 @@ jumbo_component("aura") { ...@@ -32,7 +32,6 @@ jumbo_component("aura") {
"env_input_state_controller.h", "env_input_state_controller.h",
"env_observer.h", "env_observer.h",
"event_injector.h", "event_injector.h",
"hit_test_data_provider_aura.h",
"input_state_lookup.h", "input_state_lookup.h",
"input_state_lookup_win.h", "input_state_lookup_win.h",
"layout_manager.h", "layout_manager.h",
...@@ -108,7 +107,6 @@ jumbo_component("aura") { ...@@ -108,7 +107,6 @@ jumbo_component("aura") {
"env.cc", "env.cc",
"env_input_state_controller.cc", "env_input_state_controller.cc",
"event_injector.cc", "event_injector.cc",
"hit_test_data_provider_aura.cc",
"input_state_lookup.cc", "input_state_lookup.cc",
"input_state_lookup_win.cc", "input_state_lookup_win.cc",
"layout_manager.cc", "layout_manager.cc",
...@@ -381,7 +379,6 @@ test("aura_unittests") { ...@@ -381,7 +379,6 @@ test("aura_unittests") {
"../compositor_extra/shadow_unittest.cc", "../compositor_extra/shadow_unittest.cc",
"//ui/aura_extra/window_occlusion_impl_unittest_win.cc", "//ui/aura_extra/window_occlusion_impl_unittest_win.cc",
"gestures/gesture_recognizer_unittest.cc", "gestures/gesture_recognizer_unittest.cc",
"hit_test_data_provider_aura_unittest.cc",
"mouse_location_manager_unittest.cc", "mouse_location_manager_unittest.cc",
"mus/drag_drop_controller_mus_unittest.cc", "mus/drag_drop_controller_mus_unittest.cc",
"mus/focus_synchronizer_unittest.cc", "mus/focus_synchronizer_unittest.cc",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/aura/hit_test_data_provider_aura.h"
#include "base/containers/adapters.h"
#include "components/viz/common/hit_test/hit_test_region_list.h"
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/window.h"
#include "ui/aura/window_targeter.h"
namespace {
void PopulateHitTestRegion(viz::HitTestRegion* hit_test_region,
const aura::Window* window,
uint32_t flags,
const gfx::Rect& rect) {
const ui::Layer* layer = window->layer();
DCHECK(layer);
DCHECK(window->GetFrameSinkId().is_valid());
hit_test_region->frame_sink_id = window->GetFrameSinkId();
// Checking |layer| may not be correct, since the actual layer that embeds
// the surface may be a descendent of |layer|, instead of |layer| itself.
if (window->IsEmbeddingClient())
hit_test_region->flags =
flags | viz::HitTestRegionFlags::kHitTestChildSurface;
else
hit_test_region->flags = flags | viz::HitTestRegionFlags::kHitTestMine;
hit_test_region->rect = rect;
hit_test_region->transform = layer->transform();
}
} // namespace
namespace aura {
HitTestDataProviderAura::HitTestDataProviderAura(aura::Window* window)
: window_(window) {}
HitTestDataProviderAura::~HitTestDataProviderAura() {}
base::Optional<viz::HitTestRegionList> HitTestDataProviderAura::GetHitTestData(
const viz::CompositorFrame& compositor_frame) const {
const ws::mojom::EventTargetingPolicy event_targeting_policy =
window_->event_targeting_policy();
if (!window_->IsVisible() ||
event_targeting_policy == ws::mojom::EventTargetingPolicy::NONE)
return base::nullopt;
base::Optional<viz::HitTestRegionList> hit_test_region_list(base::in_place);
hit_test_region_list->flags =
event_targeting_policy ==
ws::mojom::EventTargetingPolicy::DESCENDANTS_ONLY
? viz::HitTestRegionFlags::kHitTestIgnore
: viz::HitTestRegionFlags::kHitTestMine;
// TODO(crbug.com/805416): Use pixels instead of DIP units for bounds.
hit_test_region_list->bounds = window_->bounds();
GetHitTestDataRecursively(window_, &*hit_test_region_list);
return hit_test_region_list;
}
void HitTestDataProviderAura::GetHitTestDataRecursively(
aura::Window* window,
viz::HitTestRegionList* hit_test_region_list) const {
if (window->IsEmbeddingClient())
return;
WindowTargeter* parent_targeter = window->targeter();
// TODO(varkha): Figure out if we need to add hit-test regions for |window|.
// Walk the children in Z-order (reversed order of children()) to produce
// the hit-test data. Each child's hit test data is added before the hit-test
// data from the child's descendants because the child could clip its
// descendants for the purpose of event handling.
for (aura::Window* child : base::Reversed(window->children())) {
const ws::mojom::EventTargetingPolicy event_targeting_policy =
child->event_targeting_policy();
if (!child->IsVisible() ||
event_targeting_policy == ws::mojom::EventTargetingPolicy::NONE)
continue;
if (event_targeting_policy !=
ws::mojom::EventTargetingPolicy::DESCENDANTS_ONLY) {
gfx::Rect rect_mouse(child->bounds());
gfx::Rect rect_touch;
bool touch_and_mouse_are_same = true;
WindowTargeter* targeter = child->targeter();
if (!targeter)
targeter = parent_targeter;
// Use the |child|'s (when set) or the |window|'s |targeter| to query for
// possibly expanded hit-test area. Use the |child| bounds with mouse and
// touch flags when there is no |targeter|.
if (targeter &&
targeter->GetHitTestRects(child, &rect_mouse, &rect_touch)) {
touch_and_mouse_are_same = rect_mouse == rect_touch;
}
auto shape_rects =
targeter ? targeter->GetExtraHitTestShapeRects(child) : nullptr;
if (shape_rects) {
// The |child| has a complex shape. Clip it to |rect_mouse|.
const gfx::Vector2d offset = child->bounds().OffsetFromOrigin();
for (const gfx::Rect& shape_rect : *shape_rects) {
gfx::Rect rect = shape_rect;
rect.Offset(offset);
rect.Intersect(rect_mouse);
if (rect.IsEmpty())
continue;
hit_test_region_list->regions.emplace_back();
PopulateHitTestRegion(&hit_test_region_list->regions.back(), child,
viz::HitTestRegionFlags::kHitTestMouse |
viz::HitTestRegionFlags::kHitTestTouch,
rect);
}
} else {
// The |child| has possibly same mouse and touch hit-test areas.
if (!rect_mouse.IsEmpty()) {
hit_test_region_list->regions.emplace_back();
PopulateHitTestRegion(&hit_test_region_list->regions.back(), child,
touch_and_mouse_are_same
? (viz::HitTestRegionFlags::kHitTestMouse |
viz::HitTestRegionFlags::kHitTestTouch)
: viz::HitTestRegionFlags::kHitTestMouse,
rect_mouse);
}
if (!touch_and_mouse_are_same && !rect_touch.IsEmpty()) {
hit_test_region_list->regions.emplace_back();
PopulateHitTestRegion(&hit_test_region_list->regions.back(), child,
viz::HitTestRegionFlags::kHitTestTouch,
rect_touch);
}
}
}
if (event_targeting_policy != ws::mojom::EventTargetingPolicy::TARGET_ONLY)
GetHitTestDataRecursively(child, hit_test_region_list);
}
}
} // namespace aura
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_HIT_TEST_DATA_PROVIDER_AURA_H_
#define UI_AURA_HIT_TEST_DATA_PROVIDER_AURA_H_
#include "base/macros.h"
#include "components/viz/client/hit_test_data_provider.h"
#include "ui/aura/aura_export.h"
namespace aura {
class Window;
// A HitTestDataProvider that captures hit-test areas from a aura::Window tree
// and packages it to be submitted to compositor frame sink. The |window| used
// when creating the HitTestDataProviderAura should outlive the data provider.
class AURA_EXPORT HitTestDataProviderAura : public viz::HitTestDataProvider {
public:
explicit HitTestDataProviderAura(Window* window);
~HitTestDataProviderAura() override;
// HitTestDataProvider:
base::Optional<viz::HitTestRegionList> GetHitTestData(
const viz::CompositorFrame& compositor_frame) const override;
private:
// Recursively walks the children of |window| and uses |window|'s
// EventTargeter to generate hit-test data for the |window|'s descendants.
// Populates |hit_test_region_list|.
void GetHitTestDataRecursively(
aura::Window* window,
viz::HitTestRegionList* hit_test_region_list) const;
aura::Window* const window_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(HitTestDataProviderAura);
};
} // namespace aura
#endif // UI_AURA_HIT_TEST_DATA_PROVIDER_AURA_H_
This diff is collapsed.
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "services/ws/public/mojom/window_tree_constants.mojom.h" #include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/hit_test_data_provider_aura.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
#include "ui/aura/window_occlusion_tracker.h" #include "ui/aura/window_occlusion_tracker.h"
...@@ -169,19 +168,14 @@ WindowPortLocal::CreateLayerTreeFrameSink() { ...@@ -169,19 +168,14 @@ WindowPortLocal::CreateLayerTreeFrameSink() {
params.pipes.client_request = std::move(client_request); params.pipes.client_request = std::move(client_request);
params.enable_surface_synchronization = true; params.enable_surface_synchronization = true;
params.client_name = kExo; params.client_name = kExo;
if (features::IsVizHitTestingDrawQuadEnabled()) { bool root_accepts_events =
bool root_accepts_events = (window_->event_targeting_policy() ==
(window_->event_targeting_policy() == ws::mojom::EventTargetingPolicy::TARGET_ONLY) ||
ws::mojom::EventTargetingPolicy::TARGET_ONLY) || (window_->event_targeting_policy() ==
(window_->event_targeting_policy() == ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS); params.hit_test_data_provider =
params.hit_test_data_provider = std::make_unique<viz::HitTestDataProviderDrawQuad>(
std::make_unique<viz::HitTestDataProviderDrawQuad>( true /* should_ask_for_child_region */, root_accepts_events);
true /* should_ask_for_child_region */, root_accepts_events);
} else {
params.hit_test_data_provider =
std::make_unique<HitTestDataProviderAura>(window_);
}
auto frame_sink = auto frame_sink =
std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>( std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>(
nullptr /* context_provider */, nullptr /* worker_context_provider */, nullptr /* context_provider */, nullptr /* worker_context_provider */,
......
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