Skip to content

Commit d9dfd1b

Browse files
authored
[engine] Sync Flutter 3.22.0 source code (#67)
1 parent 39f7d91 commit d9dfd1b

File tree

14 files changed

+167
-54
lines changed

14 files changed

+167
-54
lines changed

flutter/shell/platform/common/accessibility_bridge.cc

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void AccessibilityBridge::CommitUpdates() {
9191
}
9292

9393
for (size_t i = results.size(); i > 0; i--) {
94-
for (SemanticsNode node : results[i - 1]) {
94+
for (const SemanticsNode& node : results[i - 1]) {
9595
ConvertFlutterUpdate(node, update);
9696
}
9797
}
@@ -149,18 +149,6 @@ AccessibilityBridge::GetPendingEvents() const {
149149
return result;
150150
}
151151

152-
void AccessibilityBridge::RecreateNodeDelegates() {
153-
for (const auto& [node_id, old_platform_node_delegate] : id_wrapper_map_) {
154-
std::shared_ptr<FlutterPlatformNodeDelegate> platform_node_delegate =
155-
CreateFlutterPlatformNodeDelegate();
156-
platform_node_delegate->Init(
157-
std::static_pointer_cast<FlutterPlatformNodeDelegate::OwnerBridge>(
158-
shared_from_this()),
159-
old_platform_node_delegate->GetAXNode());
160-
id_wrapper_map_[node_id] = platform_node_delegate;
161-
}
162-
}
163-
164152
void AccessibilityBridge::OnNodeWillBeDeleted(ui::AXTree* tree,
165153
ui::AXNode* node) {}
166154

@@ -215,7 +203,7 @@ std::optional<ui::AXTreeUpdate>
215203
AccessibilityBridge::CreateRemoveReparentedNodesUpdate() {
216204
std::unordered_map<int32_t, ui::AXNodeData> updates;
217205

218-
for (auto node_update : pending_semantics_node_updates_) {
206+
for (const auto& node_update : pending_semantics_node_updates_) {
219207
for (int32_t child_id : node_update.second.children_in_traversal_order) {
220208
// Skip nodes that don't exist or have a parent in the current tree.
221209
ui::AXNode* child = tree_->GetFromId(child_id);
@@ -345,7 +333,7 @@ void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
345333
return;
346334
}
347335
if (flags & kFlutterSemanticsFlagHasToggledState) {
348-
node_data.role = ax::mojom::Role::kToggleButton;
336+
node_data.role = ax::mojom::Role::kSwitch;
349337
return;
350338
}
351339
if (flags & kFlutterSemanticsFlagIsSlider) {
@@ -365,6 +353,13 @@ void AccessibilityBridge::SetStateFromFlutterUpdate(ui::AXNodeData& node_data,
365353
const SemanticsNode& node) {
366354
FlutterSemanticsFlag flags = node.flags;
367355
FlutterSemanticsAction actions = node.actions;
356+
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState &&
357+
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsExpanded) {
358+
node_data.AddState(ax::mojom::State::kExpanded);
359+
} else if (flags &
360+
FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState) {
361+
node_data.AddState(ax::mojom::State::kCollapsed);
362+
}
368363
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
369364
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0) {
370365
node_data.AddState(ax::mojom::State::kEditable);
@@ -482,7 +477,7 @@ void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
482477
: flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked
483478
? ax::mojom::CheckedState::kTrue
484479
: ax::mojom::CheckedState::kFalse));
485-
} else if (node_data.role == ax::mojom::Role::kToggleButton) {
480+
} else if (node_data.role == ax::mojom::Role::kSwitch) {
486481
node_data.AddIntAttribute(
487482
ax::mojom::IntAttribute::kCheckedState,
488483
static_cast<int32_t>(

flutter/shell/platform/common/accessibility_bridge.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,6 @@ class AccessibilityBridge
157157
virtual std::shared_ptr<FlutterPlatformNodeDelegate>
158158
CreateFlutterPlatformNodeDelegate() = 0;
159159

160-
//------------------------------------------------------------------------------
161-
/// @brief Recreate all FlutterPlatformNodeDelegates.
162-
///
163-
/// This can be useful for subclasses when updating some
164-
/// properties that are used by node delegates, such as views.
165-
/// Each node is recreated using
166-
/// CreateFlutterPlatformNodeDelegate, then initialized using
167-
/// AXNodes from their corresponding old one.
168-
void RecreateNodeDelegates();
169-
170160
private:
171161
// See FlutterSemanticsNode in embedder.h
172162
typedef struct {

flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <iostream>
99
#include <string>
10+
#include <utility>
1011

1112
#include "binary_messenger.h"
1213
#include "message_codec.h"
@@ -78,7 +79,8 @@ class BasicMessageChannel {
7879
void Send(const T& message, BinaryReply reply) {
7980
std::unique_ptr<std::vector<uint8_t>> raw_message =
8081
codec_->EncodeMessage(message);
81-
messenger_->Send(name_, raw_message->data(), raw_message->size(), reply);
82+
messenger_->Send(name_, raw_message->data(), raw_message->size(),
83+
std::move(reply));
8284
}
8385

8486
// Registers a handler that should be called any time a message is
@@ -97,7 +99,7 @@ class BasicMessageChannel {
9799
BinaryMessageHandler binary_handler = [handler, codec, channel_name](
98100
const uint8_t* binary_message,
99101
const size_t binary_message_size,
100-
BinaryReply binary_reply) {
102+
const BinaryReply& binary_reply) {
101103
// Use this channel's codec to decode the message and build a reply
102104
// handler.
103105
std::unique_ptr<T> message =

flutter/shell/platform/common/client_wrapper/include/flutter/event_channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class EventChannel {
6969
// Mutable state to track the handler's listening status.
7070
is_listening = bool(false)](const uint8_t* message,
7171
const size_t message_size,
72-
BinaryReply reply) mutable {
72+
const BinaryReply& reply) mutable {
7373
constexpr char kOnListenMethod[] = "listen";
7474
constexpr char kOnCancelMethod[] = "cancel";
7575

flutter/shell/platform/common/client_wrapper/include/flutter/method_result_functions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <functional>
99
#include <string>
10+
#include <utility>
1011

1112
#include "method_result.h"
1213

@@ -36,7 +37,7 @@ class MethodResultFunctions : public MethodResult<T> {
3637
ResultHandlerNotImplemented<T> on_not_implemented)
3738
: on_success_(on_success),
3839
on_error_(on_error),
39-
on_not_implemented_(on_not_implemented) {}
40+
on_not_implemented_(std::move(on_not_implemented)) {}
4041

4142
virtual ~MethodResultFunctions() = default;
4243

flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PluginRegistrar {
5454
void AddPlugin(std::unique_ptr<Plugin> plugin);
5555

5656
protected:
57-
FlutterDesktopPluginRegistrarRef registrar() { return registrar_; }
57+
FlutterDesktopPluginRegistrarRef registrar() const { return registrar_; }
5858

5959
// Destroys all owned plugins. Subclasses should call this at the beginning of
6060
// their destructors to prevent the possibility of an owned plugin trying to

flutter/shell/platform/common/client_wrapper/include/flutter/texture_registrar.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstdint>
1111
#include <functional>
1212
#include <memory>
13+
#include <utility>
1314
#include <variant>
1415

1516
namespace flutter {
@@ -28,7 +29,7 @@ class PixelBufferTexture {
2829
// take care of proper synchronization. It also needs to be ensured that the
2930
// returned buffer isn't released prior to unregistering this texture.
3031
explicit PixelBufferTexture(CopyBufferCallback copy_buffer_callback)
31-
: copy_buffer_callback_(copy_buffer_callback) {}
32+
: copy_buffer_callback_(std::move(copy_buffer_callback)) {}
3233

3334
// Returns the callback-provided FlutterDesktopPixelBuffer that contains the
3435
// actual pixel data. The intended surface size is specified by |width| and
@@ -53,7 +54,7 @@ class GpuSurfaceTexture {
5354
GpuSurfaceTexture(FlutterDesktopGpuSurfaceType surface_type,
5455
ObtainDescriptorCallback obtain_descriptor_callback)
5556
: surface_type_(surface_type),
56-
obtain_descriptor_callback_(obtain_descriptor_callback) {}
57+
obtain_descriptor_callback_(std::move(obtain_descriptor_callback)) {}
5758

5859
// Returns the callback-provided FlutterDesktopGpuSurfaceDescriptor that
5960
// contains the surface handle. The intended surface size is specified by

flutter/shell/platform/common/incoming_message_dispatcher.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_PLATFORM_CPP_INCOMING_MESSAGE_DISPATCHER_H_
6-
#define FLUTTER_SHELL_PLATFORM_CPP_INCOMING_MESSAGE_DISPATCHER_H_
5+
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_INCOMING_MESSAGE_DISPATCHER_H_
6+
#define FLUTTER_SHELL_PLATFORM_COMMON_INCOMING_MESSAGE_DISPATCHER_H_
77

88
#include <functional>
99
#include <map>
@@ -75,4 +75,4 @@ class IncomingMessageDispatcher {
7575

7676
} // namespace flutter
7777

78-
#endif // FLUTTER_SHELL_PLATFORM_CPP_INCOMING_MESSAGE_DISPATCHER_H_
78+
#endif // FLUTTER_SHELL_PLATFORM_COMMON_INCOMING_MESSAGE_DISPATCHER_H_

flutter/shell/platform/common/path_utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_PLATFORM_GLFW_PATH_UTILS_H_
6-
#define FLUTTER_SHELL_PLATFORM_GLFW_PATH_UTILS_H_
5+
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_PATH_UTILS_H_
6+
#define FLUTTER_SHELL_PLATFORM_COMMON_PATH_UTILS_H_
77

88
#include <filesystem>
99

@@ -15,4 +15,4 @@ std::filesystem::path GetExecutableDirectory();
1515

1616
} // namespace flutter
1717

18-
#endif // FLUTTER_SHELL_PLATFORM_GLFW_PATH_UTILS_H_
18+
#endif // FLUTTER_SHELL_PLATFORM_COMMON_PATH_UTILS_H_

flutter/shell/platform/common/platform_provided_menu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef PLATFORM_COMMON_PLATFORM_PROVIDED_MENU_H_
6-
#define PLATFORM_COMMON_PLATFORM_PROVIDED_MENU_H_
5+
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_PLATFORM_PROVIDED_MENU_H_
6+
#define FLUTTER_SHELL_PLATFORM_COMMON_PLATFORM_PROVIDED_MENU_H_
77

88
namespace flutter {
99

@@ -49,4 +49,4 @@ enum class PlatformProvidedMenu {
4949

5050
} // namespace flutter
5151

52-
#endif // PLATFORM_COMMON_PLATFORM_provided_MENU_H_
52+
#endif // FLUTTER_SHELL_PLATFORM_COMMON_PLATFORM_PROVIDED_MENU_H_

0 commit comments

Comments
 (0)