diff --git a/DEPS b/DEPS index 5846b3d8..3fa3f375 100644 --- a/DEPS +++ b/DEPS @@ -4,10 +4,10 @@ deps = { 'src/third_party/rapidjson': 'https://fuchsia.googlesource.com/third_party/rapidjson@ef3564c5c8824989393b87df25355baf35ff544b', - 'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0', - 'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@2ce528fb5e0f92e57c97ec3ff53b75359d33af12', + 'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@bd557f6f764d1e40b62528a13b124ce740624f8f', + 'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@a4dda1589d37a7e4b4f7a81ebad01b1083f2e726', 'src/third_party/googletest': 'https://github.com/google/googletest@7f036c5563af7d0329f20e8bb42effb04629f0c0', - 'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@f6ed8d7df6bfdf6fb08b38dd93c2ee1eba476b5a', + 'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@b04011c77cd93e6ab9144af37976733b558d716c', 'src/third_party/clang': { 'packages': [ { @@ -21,7 +21,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/${{platform}}', - 'version': 'git_revision:b79031308cc878488202beb99883ec1f2efd9a6d', + 'version': 'git_revision:7a8aa3a08a13521336853a28c46537ec04338a2d', }, ], 'dep_type': 'cipd', diff --git a/flutter/shell/platform/common/BUILD.gn b/flutter/shell/platform/common/BUILD.gn index 1e9dd194..64bf2b04 100644 --- a/flutter/shell/platform/common/BUILD.gn +++ b/flutter/shell/platform/common/BUILD.gn @@ -54,6 +54,23 @@ source_set("common_cpp_input") { deps = [ "//flutter/fml:fml" ] } +source_set("common_cpp_enums") { + public = [ + "app_lifecycle_state.h", + "platform_provided_menu.h", + ] + + public_configs = [ "//flutter:config" ] +} + +source_set("common_cpp_switches") { + public = [ "engine_switches.h" ] + + sources = [ "engine_switches.cc" ] + + public_configs = [ "//flutter:config" ] +} + source_set("common_cpp_accessibility") { public = [ "accessibility_bridge.h", diff --git a/flutter/shell/platform/common/app_lifecycle_state.h b/flutter/shell/platform/common/app_lifecycle_state.h new file mode 100644 index 00000000..fdce098b --- /dev/null +++ b/flutter/shell/platform/common/app_lifecycle_state.h @@ -0,0 +1,89 @@ +// Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_COMMON_APP_LIFECYCLE_STATE_H_ +#define FLUTTER_SHELL_PLATFORM_COMMON_APP_LIFECYCLE_STATE_H_ + +namespace flutter { + +/** + * These constants describe the possible lifecycle states of the application. + * They must be kept up to date with changes in the framework's + * AppLifecycleState enum. They are passed to the embedder's |SetLifecycleState| + * function. + * + * States not supported on a platform will be synthesized by the framework when + * transitioning between states which are supported, so that all implementations + * share the same state machine. + * + * Here is the state machine: + * + * +-----------+ +-----------+ + * | detached |------------------------------>| resumed | + * +-----------+ +-----------+ + * ^ ^ + * | | + * | v + * +-----------+ +--------------+ +-----------+ + * | paused |<------>| hidden |<----->| inactive | + * +-----------+ +--------------+ +-----------+ + */ +enum class AppLifecycleState { + /** + * Corresponds to the Framework's AppLifecycleState.detached: The initial + * state of the state machine. On Android, iOS, and web, also the final state + * of the state machine when all views are detached. Other platforms do not + * re-enter this state after initially leaving it. + */ + kDetached, + + /** + * Corresponds to the Framework's AppLifecycleState.resumed: The nominal + * "running" state of the application. The application is visible, has input + * focus, and is running. + */ + kResumed, + + /** + * Corresponds to the Framework's AppLifecycleState.inactive: At least one + * view of the application is visible, but none have input focus. The + * application is otherwise running normally. + */ + kInactive, + + /** + * Corresponds to the Framework's AppLifecycleState.hidden: All views of an + * application are hidden, either because the application is being stopped (on + * iOS and Android), or because it is being minimized or on a desktop that is + * no longer visible (on desktop), or on a tab that is no longer visible (on + * web). + */ + kHidden, + + /** + * Corresponds to the Framework's AppLifecycleState.paused: The application is + * not running, and can be detached or started again at any time. This state + * is typically only entered into on iOS and Android. + */ + kPaused, +}; + +constexpr const char* AppLifecycleStateToString(AppLifecycleState state) { + switch (state) { + case AppLifecycleState::kDetached: + return "AppLifecycleState.detached"; + case AppLifecycleState::kResumed: + return "AppLifecycleState.resumed"; + case AppLifecycleState::kInactive: + return "AppLifecycleState.inactive"; + case AppLifecycleState::kHidden: + return "AppLifecycleState.hidden"; + case AppLifecycleState::kPaused: + return "AppLifecycleState.paused"; + } +} + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_COMMON_APP_LIFECYCLE_STATE_H_ diff --git a/flutter/shell/platform/common/client_wrapper/standard_codec.cc b/flutter/shell/platform/common/client_wrapper/standard_codec.cc index 5e93d407..d5f4b2fd 100644 --- a/flutter/shell/platform/common/client_wrapper/standard_codec.cc +++ b/flutter/shell/platform/common/client_wrapper/standard_codec.cc @@ -301,6 +301,7 @@ const StandardMessageCodec& StandardMessageCodec::GetInstance( if (it == sInstances->end()) { // Uses new due to private constructor (to prevent API clients from // accidentally passing temporary codec instances to channels). + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto emplace_result = sInstances->emplace( serializer, std::unique_ptr( new StandardMessageCodec(serializer))); @@ -348,6 +349,7 @@ const StandardMethodCodec& StandardMethodCodec::GetInstance( if (it == sInstances->end()) { // Uses new due to private constructor (to prevent API clients from // accidentally passing temporary codec instances to channels). + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto emplace_result = sInstances->emplace( serializer, std::unique_ptr( new StandardMethodCodec(serializer))); diff --git a/flutter/shell/platform/embedder/embedder.h b/flutter/shell/platform/embedder/embedder.h index 80b43e11..26d7d2b7 100644 --- a/flutter/shell/platform/embedder/embedder.h +++ b/flutter/shell/platform/embedder/embedder.h @@ -249,6 +249,13 @@ typedef enum { /// The semantics node has the quality of either being "selected" or /// "not selected". kFlutterSemanticsFlagHasSelectedState = 1 << 28, + /// Whether a semantics node has the quality of being required. + kFlutterSemanticsFlagHasRequiredState = 1 << 29, + /// Whether user input is required on the semantics node before a form can be + /// submitted. + /// + /// Only applicable when kFlutterSemanticsFlagHasRequiredState flag is on. + kFlutterSemanticsFlagIsRequired = 1 << 30, } FlutterSemanticsFlag; typedef enum { @@ -1067,6 +1074,74 @@ typedef struct { FlutterRemoveViewCallback remove_view_callback; } FlutterRemoveViewInfo; +/// Represents the direction in which the focus transitioned across +/// [FlutterView]s. +typedef enum { + /// Indicates the focus transition did not have a direction. + /// + /// This is typically associated with focus being programmatically requested + /// or when focus is lost. + kUndefined, + + /// Indicates the focus transition was performed in a forward direction. + /// + /// This is typically result of the user pressing tab. + kForward, + + /// Indicates the focus transition was performed in a backward direction. + /// + /// This is typically result of the user pressing shift + tab. + kBackward, +} FlutterViewFocusDirection; + +/// Represents the focus state of a given [FlutterView]. +typedef enum { + /// Specifies that a view does not have platform focus. + kUnfocused, + + /// Specifies that a view has platform focus. + kFocused, +} FlutterViewFocusState; + +/// A view focus event is sent to the engine by the embedder when a native view +/// focus state has changed. +/// +/// Passed through FlutterEngineSendViewFocusEvent. +typedef struct { + /// The size of this struct. + /// Must be sizeof(FlutterViewFocusEvent). + size_t struct_size; + + /// The identifier of the view that received the focus event. + FlutterViewId view_id; + + /// The focus state of the view. + FlutterViewFocusState state; + + /// The direction in which the focus transitioned across [FlutterView]s. + FlutterViewFocusDirection direction; +} FlutterViewFocusEvent; + +/// A FlutterViewFocusChangeRequest is sent by the engine to the embedder when +/// when a FlutterView focus state has changed and native view focus +/// needs to be updated. +/// +/// Received in FlutterProjectArgs.view_focus_change_request_callback. +typedef struct { + /// The size of this struct. + /// Must be sizeof(FlutterViewFocusChangeRequest). + size_t struct_size; + + /// The identifier of the view that received the focus event. + FlutterViewId view_id; + + /// The focus state of the view. + FlutterViewFocusState state; + + /// The direction in which the focus transitioned across [FlutterView]s. + FlutterViewFocusDirection direction; +} FlutterViewFocusChangeRequest; + /// The phase of the pointer event. typedef enum { kCancel, @@ -1619,6 +1694,8 @@ typedef struct { /// Array of semantics custom action pointers. Has length /// `custom_action_count`. FlutterSemanticsCustomAction2** custom_actions; + // The ID of the view that this update is associated with. + FlutterViewId view_id; } FlutterSemanticsUpdate2; typedef void (*FlutterUpdateSemanticsNodeCallback)( @@ -1651,6 +1728,10 @@ typedef void (*FlutterChannelUpdateCallback)( const FlutterChannelUpdate* /* channel update */, void* /* user data */); +typedef void (*FlutterViewFocusChangeRequestCallback)( + const FlutterViewFocusChangeRequest* /* request */, + void* /* user data */); + typedef struct _FlutterTaskRunner* FlutterTaskRunner; typedef struct { @@ -1710,6 +1791,10 @@ typedef struct { /// Specify a callback that is used to set the thread priority for embedder /// task runners. void (*thread_priority_setter)(FlutterThreadPriority); + /// Specify the task runner for the thread on which the UI tasks will be run. + /// This may be same as platform_task_runner, in which case the Flutter engine + /// will run the UI isolate on platform thread. + const FlutterTaskRunnerDescription* ui_task_runner; } FlutterCustomTaskRunners; typedef struct { @@ -2556,8 +2641,40 @@ typedef struct { /// being registered on the framework side. The callback is invoked from /// a task posted to the platform thread. FlutterChannelUpdateCallback channel_update_callback; + + /// The callback invoked by the engine when FlutterView focus state has + /// changed. The embedder can use this callback to request focus change for + /// the native view. The callback is invoked from a task posted to the + /// platform thread. + FlutterViewFocusChangeRequestCallback view_focus_change_request_callback; + + /// Opaque identifier provided by the engine. Accessible in Dart code through + /// `PlatformDispatcher.instance.engineId`. Can be used in native code to + /// retrieve the engine instance that is running the Dart code. + int64_t engine_id; } FlutterProjectArgs; +typedef struct { + /// The size of this struct. Must be + /// sizeof(FlutterSendSemanticsActionInfo). + size_t struct_size; + + /// The ID of the view that includes the node. + FlutterViewId view_id; + + /// The semantics node identifier. + uint64_t node_id; + + /// The semantics action. + FlutterSemanticsAction action; + + /// Data associated with the action. + const uint8_t* data; + + /// The data length. + size_t data_length; +} FlutterSendSemanticsActionInfo; + #ifndef FLUTTER_ENGINE_NO_PROTOTYPES // NOLINTBEGIN(google-objc-function-naming) @@ -2605,8 +2722,8 @@ FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data); /// engine may need the embedder to post tasks back to it before /// `FlutterEngineRun` has returned. Embedders can only post tasks /// to the engine if they have a handle to the engine. In such -/// cases, embedders are advised to get the engine handle via the -/// `FlutterInitializeCall`. Then they can call +/// cases, embedders are advised to get the engine handle by calling +/// `FlutterEngineInitialize`. Then they can call /// `FlutterEngineRunInitialized` knowing that they will be able to /// service custom tasks on other threads with the engine handle. /// @@ -2760,6 +2877,16 @@ FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo* info); +//------------------------------------------------------------------------------ +/// @brief Notifies the engine that platform view focus state has changed. +/// +/// @param[in] engine A running engine instance +/// @param[in] event The focus event data describing the change. +FLUTTER_EXPORT +FlutterEngineResult FlutterEngineSendViewFocusEvent( + FLUTTER_API_SYMBOL(FlutterEngine) engine, + const FlutterViewFocusEvent* event); + FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendWindowMetricsEvent( FLUTTER_API_SYMBOL(FlutterEngine) engine, @@ -2981,7 +3108,10 @@ FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures( FlutterAccessibilityFeature features); //------------------------------------------------------------------------------ -/// @brief Dispatch a semantics action to the specified semantics node. +/// @brief Dispatch a semantics action to the specified semantics node +/// in the implicit view. +/// +/// @deprecated Use `FlutterEngineSendSemanticsAction` instead. /// /// @param[in] engine A running engine instance. /// @param[in] node_id The semantics node identifier. @@ -2999,6 +3129,22 @@ FlutterEngineResult FlutterEngineDispatchSemanticsAction( const uint8_t* data, size_t data_length); +//------------------------------------------------------------------------------ +/// @brief Dispatch a semantics action to the specified semantics node +/// within a specific view. +/// +/// @param[in] engine A running engine instance. +/// @param[in] info The dispatch semantics on view arguments. +/// This can be deallocated once +/// |FlutterEngineSendSemanticsAction| returns. +/// +/// @return The result of the call. +/// +FLUTTER_EXPORT +FlutterEngineResult FlutterEngineSendSemanticsAction( + FLUTTER_API_SYMBOL(FlutterEngine) engine, + const FlutterSendSemanticsActionInfo* info); + //------------------------------------------------------------------------------ /// @brief Notify the engine that a vsync event occurred. A baton passed to /// the platform via the vsync callback must be returned. This call @@ -3386,6 +3532,9 @@ typedef FlutterEngineResult (*FlutterEngineDispatchSemanticsActionFnPtr)( FlutterSemanticsAction action, const uint8_t* data, size_t data_length); +typedef FlutterEngineResult (*FlutterEngineSendSemanticsActionFnPtr)( + FLUTTER_API_SYMBOL(FlutterEngine) engine, + const FlutterSendSemanticsActionInfo* info); typedef FlutterEngineResult (*FlutterEngineOnVsyncFnPtr)( FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, @@ -3436,6 +3585,9 @@ typedef FlutterEngineResult (*FlutterEngineAddViewFnPtr)( typedef FlutterEngineResult (*FlutterEngineRemoveViewFnPtr)( FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo* info); +typedef FlutterEngineResult (*FlutterEngineSendViewFocusEventFnPtr)( + FLUTTER_API_SYMBOL(FlutterEngine) engine, + const FlutterViewFocusEvent* event); /// Function-pointer-based versions of the APIs above. typedef struct { @@ -3484,6 +3636,8 @@ typedef struct { FlutterEngineSetNextFrameCallbackFnPtr SetNextFrameCallback; FlutterEngineAddViewFnPtr AddView; FlutterEngineRemoveViewFnPtr RemoveView; + FlutterEngineSendViewFocusEventFnPtr SendViewFocusEvent; + FlutterEngineSendSemanticsActionFnPtr SendSemanticsAction; } FlutterEngineProcTable; //------------------------------------------------------------------------------