0
Files
src/ash/pointer_watcher_adapter.h
Trent Apted a250ec3ab9 Introduce an ObserverList<T>::Unchecked type alias.
This is a precursor to https://crrev.com/c/1053338 which introduces
base::CheckedObserver. Existing observers will be unchecked (as they
are already). There is no behavior change with this CL.

The CL is mechanical. The bulk was done with variations on a sed script:

git grep -l ' base::ObserverList<.*> .*;' -- '*.cc' '*.h' '*.mm' | \
  xargs -IX sed -i -r 's/(^[ ]*)base::ObserverList<([^>]*)> (.*);/'\
    '\1base::ObserverList<\2>::Unchecked \3;/' X

With some manual follow-ups to get special cases.

TBR=gab@chromium.org

Bug: 842987
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:ios-simulator-full-configs;luci.chromium.try:linux_layout_tests_slimming_paint_v2;luci.chromium.try:linux_mojo;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Idffe88e2b52f67f9226eb7b6d922070349dacc22
Reviewed-on: https://chromium-review.googlesource.com/1175511
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584330}
2018-08-19 08:52:19 +00:00

71 lines
2.3 KiB
C++

// Copyright 2016 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 ASH_POINTER_WATCHER_ADAPTER_H_
#define ASH_POINTER_WATCHER_ADAPTER_H_
#include "ash/ash_export.h"
#include "base/macros.h"
#include "base/observer_list.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Point;
}
namespace ui {
class LocatedEvent;
class PointerEvent;
} // namespace ui
namespace views {
class PointerWatcher;
enum class PointerWatcherEventTypes;
} // namespace views
namespace ash {
// Support for PointerWatchers in ash, implemented with a pre-target
// EventHandler on the Shell.
class ASH_EXPORT PointerWatcherAdapter : public ui::EventHandler {
public:
PointerWatcherAdapter();
~PointerWatcherAdapter() override;
// See Shell::AddPointerWatcher() for details.
void AddPointerWatcher(views::PointerWatcher* watcher,
views::PointerWatcherEventTypes events);
void RemovePointerWatcher(views::PointerWatcher* watcher);
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnTouchEvent(ui::TouchEvent* event) override;
private:
gfx::Point GetLocationInScreen(const ui::LocatedEvent& event) const;
gfx::NativeView GetTargetWindow(const ui::LocatedEvent& event) const;
// Calls OnPointerEventObserved() on the appropriate set of watchers as
// determined by the type of event. |original_event| is the original
// event supplied to OnMouseEvent()/OnTouchEvent(), |pointer_event| is
// |original_event| converted to a PointerEvent.
void NotifyWatchers(const ui::PointerEvent& pointer_event,
const ui::LocatedEvent& original_event);
// The true parameter to ObserverList indicates the list must be empty on
// destruction. Two sets of observers are maintained, one for observers not
// needing moves |non_move_watchers_| and |move_watchers_| for those
// observers wanting moves too.
base::ObserverList<views::PointerWatcher, true>::Unchecked non_move_watchers_;
base::ObserverList<views::PointerWatcher, true>::Unchecked move_watchers_;
base::ObserverList<views::PointerWatcher, true>::Unchecked drag_watchers_;
DISALLOW_COPY_AND_ASSIGN(PointerWatcherAdapter);
};
} // namespace ash
#endif // ASH_POINTER_WATCHER_ADAPTER_H_