From 4cc04bfe16f1f083a68a815d96cb663de0b0ac7b Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 12 Dec 2017 10:53:15 -0800 Subject: [PATCH] Revert " Add parameters to SemanticActions; implement extend selection for a11y (#4444)" (flutter/engine#4448) This reverts commit 4fc00d4735d43ef0ab9504111541928a3c2167ea. --- engine/src/flutter/lib/ui/hooks.dart | 5 ++--- engine/src/flutter/lib/ui/window.dart | 4 ++-- engine/src/flutter/lib/ui/window/window.cc | 14 +++----------- engine/src/flutter/lib/ui/window/window.h | 4 +--- .../src/flutter/runtime/runtime_controller.cc | 5 ++--- .../src/flutter/runtime/runtime_controller.h | 4 +--- engine/src/flutter/shell/common/engine.cc | 6 ++---- engine/src/flutter/shell/common/engine.h | 4 +--- .../src/flutter/shell/common/platform_view.cc | 7 +++---- .../src/flutter/shell/common/platform_view.h | 4 +--- .../io/flutter/view/AccessibilityBridge.java | 9 +++++---- .../android/io/flutter/view/FlutterView.java | 14 ++------------ .../platform/android/platform_view_android.cc | 19 ++----------------- .../platform/android/platform_view_android.h | 6 +----- .../android/platform_view_android_jni.cc | 9 +++------ 15 files changed, 31 insertions(+), 83 deletions(-) diff --git a/engine/src/flutter/lib/ui/hooks.dart b/engine/src/flutter/lib/ui/hooks.dart index ed201c8c50..8f0f6ae9c4 100644 --- a/engine/src/flutter/lib/ui/hooks.dart +++ b/engine/src/flutter/lib/ui/hooks.dart @@ -85,13 +85,12 @@ void _dispatchPointerDataPacket(ByteData packet) { _invoke1(window.onPointerDataPacket, window._onPointerDataPacketZone, _unpackPointerDataPacket(packet)); } -void _dispatchSemanticsAction(int id, int action, ByteData args) { - _invoke3( +void _dispatchSemanticsAction(int id, int action) { + _invoke2( window.onSemanticsAction, window._onSemanticsActionZone, id, SemanticsAction.values[action], - args, ); } diff --git a/engine/src/flutter/lib/ui/window.dart b/engine/src/flutter/lib/ui/window.dart index 2e8ea7a1b4..f6a9d6e01d 100644 --- a/engine/src/flutter/lib/ui/window.dart +++ b/engine/src/flutter/lib/ui/window.dart @@ -14,7 +14,7 @@ typedef void FrameCallback(Duration duration); typedef void PointerDataPacketCallback(PointerDataPacket packet); /// Signature for [Window.onSemanticsAction]. -typedef void SemanticsActionCallback(int id, SemanticsAction action, ByteData args); +typedef void SemanticsActionCallback(int id, SemanticsAction action); /// Signature for responses to platform messages. /// @@ -439,7 +439,7 @@ class Window { /// The setting indicating whether time should always be shown in the 24-hour /// format. - /// + /// /// This option is used by [showTimePicker]. bool get alwaysUse24HourFormat => _alwaysUse24HourFormat; bool _alwaysUse24HourFormat = false; diff --git a/engine/src/flutter/lib/ui/window/window.cc b/engine/src/flutter/lib/ui/window/window.cc index 7b4cf2cde1..beb655df77 100644 --- a/engine/src/flutter/lib/ui/window/window.cc +++ b/engine/src/flutter/lib/ui/window/window.cc @@ -223,22 +223,14 @@ void Window::DispatchPointerDataPacket(const PointerDataPacket& packet) { {data_handle}); } -void Window::DispatchSemanticsAction(int32_t id, - SemanticsAction action, - std::vector args) { +void Window::DispatchSemanticsAction(int32_t id, SemanticsAction action) { tonic::DartState* dart_state = library_.dart_state().get(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); - Dart_Handle args_handle = (args.empty()) ? Dart_Null() : ToByteData(args); - - if (Dart_IsError(args_handle)) - return; - - DartInvokeField( - library_.value(), "_dispatchSemanticsAction", - {ToDart(id), ToDart(static_cast(action)), args_handle}); + DartInvokeField(library_.value(), "_dispatchSemanticsAction", + {ToDart(id), ToDart(static_cast(action))}); } void Window::BeginFrame(fxl::TimePoint frameTime) { diff --git a/engine/src/flutter/lib/ui/window/window.h b/engine/src/flutter/lib/ui/window/window.h index fa8ce41835..ac65feaf26 100644 --- a/engine/src/flutter/lib/ui/window/window.h +++ b/engine/src/flutter/lib/ui/window/window.h @@ -49,9 +49,7 @@ class Window { void UpdateSemanticsEnabled(bool enabled); void DispatchPlatformMessage(fxl::RefPtr message); void DispatchPointerDataPacket(const PointerDataPacket& packet); - void DispatchSemanticsAction(int32_t id, - SemanticsAction action, - std::vector args); + void DispatchSemanticsAction(int32_t id, SemanticsAction action); void BeginFrame(fxl::TimePoint frameTime); void CompletePlatformMessageResponse(int response_id, diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index 025e4917ac..d3348ad7c5 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -106,11 +106,10 @@ void RuntimeController::DispatchPointerDataPacket( } void RuntimeController::DispatchSemanticsAction(int32_t id, - SemanticsAction action, - std::vector args) { + SemanticsAction action) { TRACE_EVENT1("flutter", "RuntimeController::DispatchSemanticsAction", "mode", "basic"); - GetWindow()->DispatchSemanticsAction(id, action, std::move(args)); + GetWindow()->DispatchSemanticsAction(id, action); } Window* RuntimeController::GetWindow() { diff --git a/engine/src/flutter/runtime/runtime_controller.h b/engine/src/flutter/runtime/runtime_controller.h index d70bb177c8..d774c5de87 100644 --- a/engine/src/flutter/runtime/runtime_controller.h +++ b/engine/src/flutter/runtime/runtime_controller.h @@ -42,9 +42,7 @@ class RuntimeController : public WindowClient, public IsolateClient { void DispatchPlatformMessage(fxl::RefPtr message); void DispatchPointerDataPacket(const PointerDataPacket& packet); - void DispatchSemanticsAction(int32_t id, - SemanticsAction action, - std::vector args); + void DispatchSemanticsAction(int32_t id, SemanticsAction action); Dart_Port GetMainPort(); std::string GetIsolateName(); diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index 04de8a2b41..e550e0a393 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -554,11 +554,9 @@ void Engine::DispatchPointerDataPacket(const PointerDataPacket& packet) { runtime_->DispatchPointerDataPacket(packet); } -void Engine::DispatchSemanticsAction(int id, - blink::SemanticsAction action, - std::vector args) { +void Engine::DispatchSemanticsAction(int id, blink::SemanticsAction action) { if (runtime_) - runtime_->DispatchSemanticsAction(id, action, std::move(args)); + runtime_->DispatchSemanticsAction(id, action); } void Engine::SetSemanticsEnabled(bool enabled) { diff --git a/engine/src/flutter/shell/common/engine.h b/engine/src/flutter/shell/common/engine.h index 7706b6da50..6f7eb7c087 100644 --- a/engine/src/flutter/shell/common/engine.h +++ b/engine/src/flutter/shell/common/engine.h @@ -72,9 +72,7 @@ class Engine : public blink::RuntimeDelegate { void SetViewportMetrics(const blink::ViewportMetrics& metrics); void DispatchPlatformMessage(fxl::RefPtr message); void DispatchPointerDataPacket(const PointerDataPacket& packet); - void DispatchSemanticsAction(int id, - blink::SemanticsAction action, - std::vector args); + void DispatchSemanticsAction(int id, blink::SemanticsAction action); void SetSemanticsEnabled(bool enabled); void ScheduleFrame(bool regenerate_layer_tree = true) override; diff --git a/engine/src/flutter/shell/common/platform_view.cc b/engine/src/flutter/shell/common/platform_view.cc index fc331c962e..eccd26916d 100644 --- a/engine/src/flutter/shell/common/platform_view.cc +++ b/engine/src/flutter/shell/common/platform_view.cc @@ -55,13 +55,12 @@ void PlatformView::DispatchPlatformMessage( } void PlatformView::DispatchSemanticsAction(int32_t id, - blink::SemanticsAction action, - std::vector args) { + blink::SemanticsAction action) { blink::Threads::UI()->PostTask( - [ engine = engine_->GetWeakPtr(), id, action, args = std::move(args) ] { + [ engine = engine_->GetWeakPtr(), id, action ] { if (engine) { engine->DispatchSemanticsAction( - id, static_cast(action), std::move(args)); + id, static_cast(action)); } }); } diff --git a/engine/src/flutter/shell/common/platform_view.h b/engine/src/flutter/shell/common/platform_view.h index f572cb2bdf..a377f721ef 100644 --- a/engine/src/flutter/shell/common/platform_view.h +++ b/engine/src/flutter/shell/common/platform_view.h @@ -41,9 +41,7 @@ class PlatformView : public std::enable_shared_from_this { virtual void Attach() = 0; void DispatchPlatformMessage(fxl::RefPtr message); - void DispatchSemanticsAction(int32_t id, - blink::SemanticsAction action, - std::vector args); + void DispatchSemanticsAction(int32_t id, blink::SemanticsAction action); void SetSemanticsEnabled(bool enabled); void NotifyCreated(std::unique_ptr surface); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java index e0bbec66b0..81b6e99e02 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -312,16 +312,17 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess boolean performCursorMoveAction(SemanticsObject object, int virtualViewId, Bundle arguments, boolean forward) { final int granularity = arguments.getInt( AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT); - final boolean extendSelection = arguments.getBoolean( - AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); + // TODO(goderbauer): support extending selections. + // final boolean extendSelection = arguments.getBoolean( + // AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); switch (granularity) { case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER: { if (forward && object.hasAction(Action.MOVE_CURSOR_FORWARD_BY_CHARACTER)) { - mOwner.dispatchSemanticsAction(virtualViewId, Action.MOVE_CURSOR_FORWARD_BY_CHARACTER, extendSelection); + mOwner.dispatchSemanticsAction(virtualViewId, Action.MOVE_CURSOR_FORWARD_BY_CHARACTER); return true; } if (!forward && object.hasAction(Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER)) { - mOwner.dispatchSemanticsAction(virtualViewId, Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER, extendSelection); + mOwner.dispatchSemanticsAction(virtualViewId, Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER); return true; } } diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java index 4d29787d5a..3c287ce84e 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java @@ -682,7 +682,7 @@ public class FlutterView extends SurfaceView ByteBuffer buffer, int position); private static native void nativeDispatchSemanticsAction(long nativePlatformViewAndroid, int id, - int action, ByteBuffer args, int argsPosition); + int action); private static native void nativeSetSemanticsEnabled(long nativePlatformViewAndroid, boolean enabled); @@ -743,19 +743,9 @@ public class FlutterView extends SurfaceView private TouchExplorationListener mTouchExplorationListener; protected void dispatchSemanticsAction(int id, AccessibilityBridge.Action action) { - dispatchSemanticsAction(id, action, null); - } - - protected void dispatchSemanticsAction(int id, AccessibilityBridge.Action action, Object args) { if (!isAttached()) return; - ByteBuffer encodedArgs = null; - int position = 0; - if (args != null) { - encodedArgs = StandardMessageCodec.INSTANCE.encodeMessage(args); - position = encodedArgs.position(); - } - nativeDispatchSemanticsAction(mNativeView.get(), id, action.value, encodedArgs, position); + nativeDispatchSemanticsAction(mNativeView.get(), id, action.value); } @Override diff --git a/engine/src/flutter/shell/platform/android/platform_view_android.cc b/engine/src/flutter/shell/platform/android/platform_view_android.cc index 8e628c7397..61893a58f1 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android.cc @@ -410,24 +410,9 @@ void PlatformViewAndroid::HandlePlatformMessageEmptyResponse(int response_id) { nullptr); } -void PlatformViewAndroid::DispatchSemanticsAction(JNIEnv* env, - jint id, - jint action, - jobject args, - jint args_position) { - if (env->IsSameObject(args, NULL)) { - std::vector args_vector; - PlatformView::DispatchSemanticsAction( - id, static_cast(action), args_vector); - return; - } - - uint8_t* args_data = static_cast(env->GetDirectBufferAddress(args)); - std::vector args_vector = - std::vector(args_data, args_data + args_position); - +void PlatformViewAndroid::DispatchSemanticsAction(jint id, jint action) { PlatformView::DispatchSemanticsAction( - id, static_cast(action), std::move(args_vector)); + id, static_cast(action)); } void PlatformViewAndroid::SetSemanticsEnabled(jboolean enabled) { diff --git a/engine/src/flutter/shell/platform/android/platform_view_android.h b/engine/src/flutter/shell/platform/android/platform_view_android.h index 48b2604001..6308d4c744 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android.h +++ b/engine/src/flutter/shell/platform/android/platform_view_android.h @@ -79,11 +79,7 @@ class PlatformViewAndroid : public PlatformView { void InvokePlatformMessageEmptyResponseCallback(JNIEnv* env, jint response_id); - void DispatchSemanticsAction(JNIEnv* env, - jint id, - jint action, - jobject args, - jint args_position); + void DispatchSemanticsAction(jint id, jint action); void SetSemanticsEnabled(jboolean enabled); diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc b/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc index 448e809f6c..42673a32b3 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc @@ -236,11 +236,8 @@ static void DispatchSemanticsAction(JNIEnv* env, jobject jcaller, jlong platform_view, jint id, - jint action, - jobject args, - jint args_position) { - return PLATFORM_VIEW->DispatchSemanticsAction(env, id, action, args, - args_position); + jint action) { + return PLATFORM_VIEW->DispatchSemanticsAction(id, action); } static void SetSemanticsEnabled(JNIEnv* env, @@ -416,7 +413,7 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { }, { .name = "nativeDispatchSemanticsAction", - .signature = "(JIILjava/nio/ByteBuffer;I)V", + .signature = "(JII)V", .fnPtr = reinterpret_cast(&shell::DispatchSemanticsAction), }, {