Visitar URL original
Revert "Reverts "Reapply "Add set semantics enabled API and wire iOS … · chunhtai/flutter@8bf3682 · GitHub
Skip to content

Commit 8bf3682

Browse files
committed
Revert "Reverts "Reapply "Add set semantics enabled API and wire iOS a11y bridge (#161… (flutter#171198)" (flutter#174153)"
This reverts commit 960d107.
1 parent 111f5a4 commit 8bf3682

35 files changed

Lines changed: 558 additions & 72 deletions

‎dev/integration_tests/ios_host_app/flutterapp/lib/main‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const BasicMessageChannel<String> _kReloadChannel =
3232
void main() {
3333
// Ensures bindings are initialized before doing anything.
3434
WidgetsFlutterBinding.ensureInitialized();
35+
ui.PlatformDispatcher.instance.setSemanticsTreeEnabled(true);
3536
// Start listening immediately for messages from the iOS side. ObjC calls
3637
// will be made to let us know when we should be changing the app state.
3738
_kReloadChannel.setMessageHandler(run);

‎engine/src/flutter/ci/licenses_golden/excluded_files‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@
287287
../../../flutter/runtime/fixtures
288288
../../../flutter/runtime/no_dart_plugin_registrant_unittests.cc
289289
../../../flutter/runtime/platform_isolate_manager_unittests.cc
290+
../../../flutter/runtime/runtime_controller_unittests.cc
290291
../../../flutter/runtime/type_conversions_unittests.cc
291292
../../../flutter/shell/common/animator_unittests.cc
292293
../../../flutter/shell/common/base64_unittests.cc

‎engine/src/flutter/ci/licenses_golden/licenses_flutter‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53508,6 +53508,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.
5350853508
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm + ../../../flutter/LICENSE
5350953509
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h + ../../../flutter/LICENSE
5351053510
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm + ../../../flutter/LICENSE
53511+
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_view_ios_test.mm + ../../../flutter/LICENSE
5351153512
ORIGIN: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.h + ../../../flutter/LICENSE
5351253513
ORIGIN: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.mm + ../../../flutter/LICENSE
5351353514
ORIGIN: ../../../flutter/shell/platform/darwin/macos/InternalFlutterSwift-Bridging-Header.h + ../../../flutter/LICENSE
@@ -56592,6 +56593,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.mm
5659256593
FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm
5659356594
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h
5659456595
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm
56596+
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios_test.mm
5659556597
FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.h
5659656598
FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.mm
5659756599
FILE: ../../../flutter/shell/platform/darwin/macos/InternalFlutterSwift-Bridging-Header.h

‎engine/src/flutter/lib/ui/dart_ui.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ typedef CanvasPath Path;
103103
V(PlatformConfigurationNativeApi::UpdateSemantics) \
104104
V(PlatformConfigurationNativeApi::SetNeedsReportTimings) \
105105
V(PlatformConfigurationNativeApi::SetIsolateDebugName) \
106+
V(PlatformConfigurationNativeApi::SetSemanticsTreeEnabled) \
106107
V(PlatformConfigurationNativeApi::RequestDartPerformanceMode) \
107108
V(PlatformConfigurationNativeApi::GetPersistentIsolateData) \
108109
V(PlatformConfigurationNativeApi::ComputePlatformResolvedLocale) \

‎engine/src/flutter/lib/ui/platform_dispatcher.dart‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,26 @@ class PlatformDispatcher {
716716
@Native<Void Function(Int64)>(symbol: 'PlatformConfigurationNativeApi::RegisterBackgroundIsolate')
717717
external static void __registerBackgroundIsolate(int rootIsolateId);
718718

719+
/// Informs the engine whether the framework is generating a semantics tree.
720+
///
721+
/// Only framework knows when semantics tree should be generated. It uses this
722+
/// method to notify the engine whether the framework will generate a semantics tree.
723+
///
724+
/// In the case where platforms want to enable semantics, e.g. when
725+
/// assistive technologies are enabled, it notifies framework through
726+
/// [onSemanticsEnabledChanged].
727+
///
728+
/// After this has been set to true, platforms are expected to prepare for accepting
729+
/// semantics update sent via [FlutterView.updateSemantics]. When this is set to false, platforms
730+
/// may dispose any resources associated with processing semantics as no further
731+
/// semantics updates will be sent via [FlutterView.updateSemantics].
732+
///
733+
/// One must call this method with true before sending update through [updateSemantics].
734+
void setSemanticsTreeEnabled(bool enabled) => _setSemanticsTreeEnabled(enabled);
735+
736+
@Native<Void Function(Bool)>(symbol: 'PlatformConfigurationNativeApi::SetSemanticsTreeEnabled')
737+
external static void _setSemanticsTreeEnabled(bool update);
738+
719739
/// Deprecated. Migrate to [ChannelBuffers.setListener] instead.
720740
///
721741
/// Called whenever this platform dispatcher receives a message from a

‎engine/src/flutter/lib/ui/window.dart‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,8 @@ class FlutterView {
390390

391391
/// Change the retained semantics data about this [FlutterView].
392392
///
393-
/// If [PlatformDispatcher.semanticsEnabled] is true, the user has requested that this function
394-
/// be called whenever the semantic content of this [FlutterView]
395-
/// changes.
393+
/// [PlatformDispatcher.setSemanticsTreeEnabled] must be called with true
394+
/// before sending update through this method.
396395
///
397396
/// This function disposes the given update, which means the semantics update
398397
/// cannot be used further.

‎engine/src/flutter/lib/ui/window/platform_configuration.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,14 @@ void PlatformConfigurationNativeApi::UpdateSemantics(int64_t view_id,
669669
view_id, update);
670670
}
671671

672+
void PlatformConfigurationNativeApi::SetSemanticsTreeEnabled(bool enabled) {
673+
UIDartState::ThrowIfUIOperationsProhibited();
674+
UIDartState::Current()
675+
->platform_configuration()
676+
->client()
677+
->SetSemanticsTreeEnabled(enabled);
678+
}
679+
672680
Dart_Handle PlatformConfigurationNativeApi::ComputePlatformResolvedLocale(
673681
Dart_Handle supportedLocalesHandle) {
674682
UIDartState::ThrowIfUIOperationsProhibited();

‎engine/src/flutter/lib/ui/window/platform_configuration.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ class PlatformConfigurationClient {
9898
///
9999
virtual void UpdateSemantics(int64_t viewId, SemanticsUpdate* update) = 0;
100100

101+
//--------------------------------------------------------------------------
102+
/// @brief Notifies whether Framework starts generating semantics tree.
103+
///
104+
/// @param[in] enabled True if Framework starts generating semantics tree.
105+
///
106+
virtual void SetSemanticsTreeEnabled(bool enabled) = 0;
107+
101108
//--------------------------------------------------------------------------
102109
/// @brief When the Flutter application has a message to send to the
103110
/// underlying platform, the message needs to be forwarded to
@@ -626,6 +633,8 @@ class PlatformConfigurationNativeApi {
626633

627634
static void UpdateSemantics(int64_t viewId, SemanticsUpdate* update);
628635

636+
static void SetSemanticsTreeEnabled(bool enabled);
637+
629638
static void SetNeedsReportTimings(bool value);
630639

631640
static Dart_Handle GetPersistentIsolateData();

‎engine/src/flutter/lib/web_ui/lib/platform_dispatcher.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ abstract class PlatformDispatcher {
8585

8686
void scheduleWarmUpFrame({required VoidCallback beginFrame, required VoidCallback drawFrame});
8787

88+
void setSemanticsTreeEnabled(bool enabled) {}
89+
8890
AccessibilityFeatures get accessibilityFeatures;
8991

9092
VoidCallback? get onAccessibilityFeaturesChanged;

‎engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,15 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
709709
FrameService.instance.scheduleWarmUpFrame(beginFrame: beginFrame, drawFrame: drawFrame);
710710
}
711711

712+
@override
713+
void setSemanticsTreeEnabled(bool enabled) {
714+
if (!enabled) {
715+
for (final EngineFlutterView view in views) {
716+
view.semantics.reset();
717+
}
718+
}
719+
}
720+
712721
/// Updates the application's rendering on the GPU with the newly provided
713722
/// [Scene]. This function must be called within the scope of the
714723
/// [onBeginFrame] or [onDrawFrame] callbacks being invoked. If this function

0 commit comments

Comments
 (0)