Skip to content

Commit 1cef157

Browse files
authored
[engine] Sync Flutter 3.35.3 source code (#117)
1 parent 62085b9 commit 1cef157

File tree

11 files changed

+327
-52
lines changed

11 files changed

+327
-52
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ deps = {
77
'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@bd557f6f764d1e40b62528a13b124ce740624f8f',
88
'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@a4dda1589d37a7e4b4f7a81ebad01b1083f2e726',
99
'src/third_party/googletest': 'https://github.com/google/googletest@7f036c5563af7d0329f20e8bb42effb04629f0c0',
10-
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@b04011c77cd93e6ab9144af37976733b558d716c',
10+
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@a29e08c72e2ce21813c1edf50cbcdfcac7a7acdd',
1111
'src/third_party/clang': {
1212
'packages': [
1313
{

flutter/shell/platform/common/BUILD.gn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ source_set("common_cpp_library_headers") {
3232

3333
copy("publish_headers") {
3434
sources = _public_headers
35-
outputs = [ "$root_out_dir/public/{{source_file_part}}" ]
35+
outputs = [ "$root_out_dir/{{source_file_part}}" ]
3636
}
3737

3838
source_set("common_cpp_input") {
@@ -54,6 +54,13 @@ source_set("common_cpp_input") {
5454
deps = [ "//flutter/fml:fml" ]
5555
}
5656

57+
source_set("common_cpp_isolate_scope") {
58+
public = [ "isolate_scope.h" ]
59+
sources = [ "isolate_scope.cc" ]
60+
61+
deps = [ "//flutter/fml:fml" ]
62+
}
63+
5764
source_set("common_cpp_enums") {
5865
public = [
5966
"app_lifecycle_state.h",
@@ -116,6 +123,7 @@ source_set("common_cpp") {
116123
deps = [
117124
":common_cpp_library_headers",
118125
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
126+
"//flutter/shell/platform/embedder:embedder_headers",
119127
]
120128

121129
public_deps = [
@@ -132,6 +140,7 @@ source_set("common_cpp_core") {
132140
public = [
133141
"geometry.h",
134142
"path_utils.h",
143+
"windowing.h",
135144
]
136145

137146
sources = [ "path_utils.cc" ]

flutter/shell/platform/common/accessibility_bridge.cc

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -311,43 +311,43 @@ void AccessibilityBridge::ConvertFlutterUpdate(const SemanticsNode& node,
311311

312312
void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
313313
const SemanticsNode& node) {
314-
FlutterSemanticsFlag flags = node.flags;
315-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsButton) {
314+
const FlutterSemanticsFlags* flags = node.flags;
315+
FML_DCHECK(flags) << "SemanticsNode::flags must not be null";
316+
if (flags->is_button) {
316317
node_data.role = ax::mojom::Role::kButton;
317318
return;
318319
}
319-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
320-
!(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly)) {
320+
if (flags->is_text_field && !flags->is_read_only) {
321321
node_data.role = ax::mojom::Role::kTextField;
322322
return;
323323
}
324-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsHeader) {
324+
if (flags->is_header) {
325325
node_data.role = ax::mojom::Role::kHeader;
326326
return;
327327
}
328-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsImage) {
328+
if (flags->is_image) {
329329
node_data.role = ax::mojom::Role::kImage;
330330
return;
331331
}
332-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsLink) {
332+
if (flags->is_link) {
333333
node_data.role = ax::mojom::Role::kLink;
334334
return;
335335
}
336336

337-
if (flags & kFlutterSemanticsFlagIsInMutuallyExclusiveGroup &&
338-
flags & kFlutterSemanticsFlagHasCheckedState) {
337+
if (flags->is_in_mutually_exclusive_group &&
338+
flags->is_checked != FlutterCheckState::kFlutterCheckStateNone) {
339339
node_data.role = ax::mojom::Role::kRadioButton;
340340
return;
341341
}
342-
if (flags & kFlutterSemanticsFlagHasCheckedState) {
342+
if (flags->is_checked != FlutterCheckState::kFlutterCheckStateNone) {
343343
node_data.role = ax::mojom::Role::kCheckBox;
344344
return;
345345
}
346-
if (flags & kFlutterSemanticsFlagHasToggledState) {
346+
if (flags->is_toggled != FlutterTristate::kFlutterTristateNone) {
347347
node_data.role = ax::mojom::Role::kSwitch;
348348
return;
349349
}
350-
if (flags & kFlutterSemanticsFlagIsSlider) {
350+
if (flags->is_slider) {
351351
node_data.role = ax::mojom::Role::kSlider;
352352
return;
353353
}
@@ -362,17 +362,14 @@ void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
362362

363363
void AccessibilityBridge::SetStateFromFlutterUpdate(ui::AXNodeData& node_data,
364364
const SemanticsNode& node) {
365-
FlutterSemanticsFlag flags = node.flags;
365+
const FlutterSemanticsFlags* flags = node.flags;
366366
FlutterSemanticsAction actions = node.actions;
367-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState &&
368-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsExpanded) {
367+
if (flags->is_expanded == FlutterTristate::kFlutterTristateTrue) {
369368
node_data.AddState(ax::mojom::State::kExpanded);
370-
} else if (flags &
371-
FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState) {
369+
} else if (flags->is_expanded == FlutterTristate::kFlutterTristateFalse) {
372370
node_data.AddState(ax::mojom::State::kCollapsed);
373371
}
374-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
375-
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0) {
372+
if (flags->is_text_field && !flags->is_read_only) {
376373
node_data.AddState(ax::mojom::State::kEditable);
377374
}
378375
if (node_data.role == ax::mojom::Role::kStaticText &&
@@ -435,7 +432,7 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
435432
ui::AXNodeData& node_data,
436433
const SemanticsNode& node) {
437434
FlutterSemanticsAction actions = node.actions;
438-
FlutterSemanticsFlag flags = node.flags;
435+
const FlutterSemanticsFlags* flags = node.flags;
439436
node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kScrollable,
440437
actions & kHasScrollingAction);
441438
node_data.AddBoolAttribute(
@@ -444,13 +441,10 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
444441
// TODO(chunhtai): figure out if there is a node that does not clip overflow.
445442
node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren,
446443
!node.children_in_traversal_order.empty());
447-
node_data.AddBoolAttribute(
448-
ax::mojom::BoolAttribute::kSelected,
449-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsSelected);
450-
node_data.AddBoolAttribute(
451-
ax::mojom::BoolAttribute::kEditableRoot,
452-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
453-
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0);
444+
node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected,
445+
flags->is_selected);
446+
node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot,
447+
flags->is_text_field && !flags->is_read_only);
454448
// Mark nodes as line breaking so that screen readers don't
455449
// merge all consecutive objects into one.
456450
// TODO(schectman): When should a node have this attribute set?
@@ -462,15 +456,13 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
462456
void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
463457
ui::AXNodeData& node_data,
464458
const SemanticsNode& node) {
465-
FlutterSemanticsFlag flags = node.flags;
459+
const FlutterSemanticsFlags* flags = node.flags;
466460
node_data.AddIntAttribute(ax::mojom::IntAttribute::kTextDirection,
467461
node.text_direction);
468462

469463
int sel_start = node.text_selection_base;
470464
int sel_end = node.text_selection_extent;
471-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
472-
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0 &&
473-
!node.value.empty()) {
465+
if (flags->is_text_field && !flags->is_read_only && !node.value.empty()) {
474466
// By default the text field selection should be at the end.
475467
sel_start = sel_start == -1 ? node.value.length() : sel_start;
476468
sel_end = sel_end == -1 ? node.value.length() : sel_end;
@@ -483,16 +475,16 @@ void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
483475
node_data.AddIntAttribute(
484476
ax::mojom::IntAttribute::kCheckedState,
485477
static_cast<int32_t>(
486-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsCheckStateMixed
478+
(flags->is_checked == FlutterCheckState::kFlutterCheckStateMixed)
487479
? ax::mojom::CheckedState::kMixed
488-
: flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked
480+
: (flags->is_checked == FlutterCheckState::kFlutterCheckStateTrue)
489481
? ax::mojom::CheckedState::kTrue
490482
: ax::mojom::CheckedState::kFalse));
491483
} else if (node_data.role == ax::mojom::Role::kSwitch) {
492484
node_data.AddIntAttribute(
493485
ax::mojom::IntAttribute::kCheckedState,
494486
static_cast<int32_t>(
495-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsToggled
487+
(flags->is_toggled == FlutterTristate::kFlutterTristateTrue)
496488
? ax::mojom::CheckedState::kTrue
497489
: ax::mojom::CheckedState::kFalse));
498490
}
@@ -548,13 +540,13 @@ void AccessibilityBridge::SetTooltipFromFlutterUpdate(
548540

549541
void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
550542
ui::AXTreeUpdate& tree_update) {
551-
FlutterSemanticsFlag flags = node.flags;
543+
const FlutterSemanticsFlags* flags = node.flags;
552544
// Set selection of the focused node if:
553545
// 1. this text field has a valid selection
554546
// 2. this text field doesn't have a valid selection but had selection stored
555547
// in the tree.
556-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
557-
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused) {
548+
if (flags->is_text_field &&
549+
flags->is_focused == FlutterTristate::kFlutterTristateTrue) {
558550
if (node.text_selection_base != -1) {
559551
tree_update.tree_data.sel_anchor_object_id = node.id;
560552
tree_update.tree_data.sel_anchor_offset = node.text_selection_base;
@@ -570,12 +562,11 @@ void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
570562
}
571563
}
572564

573-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused &&
565+
if (flags->is_focused == FlutterTristate::kFlutterTristateTrue &&
574566
tree_update.tree_data.focus_id != node.id) {
575567
tree_update.tree_data.focus_id = node.id;
576568
tree_update.has_tree_data = true;
577-
} else if ((flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused) ==
578-
0 &&
569+
} else if (flags->is_focused != FlutterTristate::kFlutterTristateTrue &&
579570
tree_update.tree_data.focus_id == node.id) {
580571
tree_update.tree_data.focus_id = ui::AXNode::kInvalidAXID;
581572
tree_update.has_tree_data = true;
@@ -587,7 +578,10 @@ AccessibilityBridge::FromFlutterSemanticsNode(
587578
const FlutterSemanticsNode2& flutter_node) {
588579
SemanticsNode result;
589580
result.id = flutter_node.id;
590-
result.flags = flutter_node.flags;
581+
FML_DCHECK(flutter_node.flags2)
582+
<< "FlutterSemanticsNode2::flags2 must not be null";
583+
584+
result.flags = flutter_node.flags2;
591585
result.actions = flutter_node.actions;
592586
result.text_selection_base = flutter_node.text_selection_base;
593587
result.text_selection_extent = flutter_node.text_selection_extent;
@@ -596,8 +590,6 @@ AccessibilityBridge::FromFlutterSemanticsNode(
596590
result.scroll_position = flutter_node.scroll_position;
597591
result.scroll_extent_max = flutter_node.scroll_extent_max;
598592
result.scroll_extent_min = flutter_node.scroll_extent_min;
599-
result.elevation = flutter_node.elevation;
600-
result.thickness = flutter_node.thickness;
601593
if (flutter_node.label) {
602594
result.label = std::string(flutter_node.label);
603595
}

flutter/shell/platform/common/accessibility_bridge.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class AccessibilityBridge
161161
// See FlutterSemanticsNode in embedder.h
162162
typedef struct {
163163
int32_t id;
164-
FlutterSemanticsFlag flags;
164+
FlutterSemanticsFlags* flags;
165165
FlutterSemanticsAction actions;
166166
int32_t text_selection_base;
167167
int32_t text_selection_extent;
@@ -170,8 +170,6 @@ class AccessibilityBridge
170170
double scroll_position;
171171
double scroll_extent_max;
172172
double scroll_extent_min;
173-
double elevation;
174-
double thickness;
175173
std::string label;
176174
std::string hint;
177175
std::string value;

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

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,57 @@ class EncodableValue : public internal::EncodableValueVariant {
216216
return std::get<int64_t>(*this);
217217
}
218218

219-
// Explicitly provide operator<, delegating to std::variant's operator<.
220-
// There are issues with with the way the standard library-provided
221-
// < and <=> comparisons interact with classes derived from variant.
219+
// The C++ Standard Library implementations can get into issues with recursive
220+
// constraint satisfaction when (among other things) objects of this type (which
221+
// is an `std::variant` subclass) are put into containers like `std::vector`.
222+
//
223+
// A definition of `operator<` is provided to break that recursion. However, in
224+
// C++20 with the latest compilers (Clang compilers newer than 20 and the latest
225+
// GCC variants, see https://gcc.godbolt.org/z/KM6n6qane) requiring that that
226+
// the `std::three_way_comparable` constraint be satisfied requires the
227+
// provision of `operator<=>` to do the same thing.
228+
//
229+
// The code below makes this translation unit be safe to include from both C++17
230+
// and C++20 translation units while also using the newest compilers.
231+
//
232+
// The correctness of the compiler's gripes with this code and the subsequent
233+
// need for these workarounds is not fully understood or explored. If you run
234+
// into issues with this code again, the following breadcrumbs may prove
235+
// useful. If you cannot access some or all of these links, the compiler
236+
// explorer link above should serve a reduced test case to base an investigation
237+
// off of.
238+
//
239+
// * b/423885648#comment8
240+
// * b/423885648#comment19
241+
// * cl/542631351
242+
// * cl/542541552
243+
// * https://github.com/flutter/engine/pull/43091
244+
//
245+
#if __cplusplus >= 202002L
246+
friend std::partial_ordering operator<=>(const EncodableValue& lhs,
247+
const EncodableValue& rhs) {
248+
auto& lv = static_cast<const super&>(lhs);
249+
auto& rv = static_cast<const super&>(rhs);
250+
251+
if (lv < rv) {
252+
return std::partial_ordering::less;
253+
}
254+
255+
if (rv < lv) {
256+
return std::partial_ordering::greater;
257+
}
258+
259+
if (lv == rv) {
260+
return std::partial_ordering::equivalent;
261+
}
262+
263+
return std::partial_ordering::unordered;
264+
}
265+
#else // __cplusplus >= 202002L
222266
friend bool operator<(const EncodableValue& lhs, const EncodableValue& rhs) {
223267
return static_cast<const super&>(lhs) < static_cast<const super&>(rhs);
224268
}
269+
#endif // __cplusplus >= 202002L
225270
};
226271

227272
} // namespace flutter

flutter/shell/platform/common/geometry.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#define FLUTTER_SHELL_PLATFORM_COMMON_GEOMETRY_H_
77

88
#include <cmath>
9+
#include <limits>
10+
#include <optional>
911

1012
namespace flutter {
1113

@@ -45,6 +47,7 @@ class Size {
4547
bool operator==(const Size& other) const {
4648
return width_ == other.width_ && height_ == other.height_;
4749
}
50+
bool operator!=(const Size& other) const { return !(*this == other); }
4851

4952
private:
5053
double width_ = 0.0;
@@ -78,6 +81,27 @@ class Rect {
7881
Size size_;
7982
};
8083

84+
// Encapsulates a min and max size that represents the constraints that some
85+
// arbitrary box is able to take up.
86+
class BoxConstraints {
87+
public:
88+
BoxConstraints() = default;
89+
BoxConstraints(const std::optional<Size>& smallest,
90+
const std::optional<Size>& biggest)
91+
: smallest_(smallest.value_or(Size(0, 0))),
92+
biggest_(
93+
biggest.value_or(Size(std::numeric_limits<double>::infinity(),
94+
std::numeric_limits<double>::infinity()))) {}
95+
BoxConstraints(const BoxConstraints& other) = default;
96+
Size biggest() const { return biggest_; }
97+
Size smallest() const { return smallest_; }
98+
99+
private:
100+
Size smallest_ = Size(0, 0);
101+
Size biggest_ = Size(std::numeric_limits<double>::infinity(),
102+
std::numeric_limits<double>::infinity());
103+
};
104+
81105
} // namespace flutter
82106

83107
#endif // FLUTTER_SHELL_PLATFORM_COMMON_GEOMETRY_H_

0 commit comments

Comments
 (0)