Commit 3142aba4 authored by Ian Hickson's avatar Ian Hickson

Refactor the Gesturer's interfaces (#3459)

* Refactor the Gesturer's interfaces

This makes them more coherent.

It also makes it easier for the tests to override each specific part of
hit-testing, should that be necessary.

* Update binding.dart
parent 22e8d85d
......@@ -17,7 +17,7 @@ import 'hit_test.dart';
import 'pointer_router.dart';
/// A binding for the gesture subsystem.
abstract class Gesturer extends BindingBase implements HitTestTarget, HitTestable {
abstract class Gesturer extends BindingBase implements HitTestable, HitTestDispatcher, HitTestTarget {
@override
void initInstances() {
......@@ -75,12 +75,17 @@ abstract class Gesturer extends BindingBase implements HitTestTarget, HitTestabl
}
/// Determine which [HitTestTarget] objects are located at a given position.
@override
@override // from HitTestable
void hitTest(HitTestResult result, Point position) {
result.add(new HitTestEntry(this));
}
/// Dispatch the given event to the path of the given hit test result
/// Dispatch an event to a hit test result's path.
///
/// This sends the given event to every [HitTestTarget] in the entries
/// of the given [HitTestResult], and catches exceptions that any of
/// the handlers might throw. The `result` argument must not be null.
@override // from HitTestDispatcher
void dispatchEvent(PointerEvent event, HitTestResult result) {
assert(result != null);
for (HitTestEntry entry in result.path) {
......@@ -105,7 +110,7 @@ abstract class Gesturer extends BindingBase implements HitTestTarget, HitTestabl
}
}
@override
@override // from HitTestTarget
void handleEvent(PointerEvent event, HitTestEntry entry) {
pointerRouter.route(event);
if (event is PointerDownEvent) {
......
......@@ -9,6 +9,12 @@ abstract class HitTestable { // ignore: one_member_abstracts
void hitTest(HitTestResult result, Point position);
}
/// An object that can dispatch events.
abstract class HitTestDispatcher { // ignore: one_member_abstracts
/// Override this function to dispatch events.
void dispatchEvent(PointerEvent event, HitTestResult result);
}
/// An object that can handle events.
abstract class HitTestTarget { // ignore: one_member_abstracts
/// Override this function to receive events.
......
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