-
Notifications
You must be signed in to change notification settings - Fork 6k
Rewire ios accessibility bridge receive semantics enabled signal #56691
Changes from all commits
4519ab4
1421b58
eca9985
836dbe3
d59971c
8b68a16
ff43b6c
e868fd9
7eab3c6
ab3fa7a
0057b80
a5a3f44
b438911
c67e23d
14fd4ed
f05255f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -382,9 +382,8 @@ class FlutterView { | |
|
|
||
| /// Change the retained semantics data about this [FlutterView]. | ||
| /// | ||
| /// If [PlatformDispatcher.semanticsEnabled] is true, the user has requested that this function | ||
| /// be called whenever the semantic content of this [FlutterView] | ||
| /// changes. | ||
| /// Th [setSemanticsTreeEnabled] must be called with true before sending | ||
| /// update through this method. | ||
| /// | ||
| /// This function disposes the given update, which means the semantics update | ||
| /// cannot be used further. | ||
|
|
@@ -393,6 +392,26 @@ class FlutterView { | |
| @Native<Void Function(Pointer<Void>)>(symbol: 'PlatformConfigurationNativeApi::UpdateSemantics') | ||
| external static void _updateSemantics(_NativeSemanticsUpdate update); | ||
|
|
||
| /// Informs the engine whether the framework is generating a semantics tree. | ||
| /// | ||
| /// Only framework knows when semantics tree should be generated. It uses this | ||
| /// method to notify the engine such event. | ||
| /// | ||
| /// In the case where platforms want to enable semantics, e.g. when detected running | ||
| /// assitive technologies, it notifies framework through the | ||
| /// [PlatformDispatcher.onSemanticsEnabledChanged]. | ||
| /// | ||
| /// After this has been set to true, platforms are expected to prepare for accepting | ||
| /// semantics update sent via [updateSemantics]. When this is set to false, platforms | ||
| /// may dispose any resources associated with processing semantics as no further | ||
| /// semantics updates will be sent via [updateSemantics]. | ||
| /// | ||
| /// One must call this method with true before sending update through [updateSemantics]. | ||
| void setSemanticsTreeEnabled(bool enabled) => _setSemanticsTreeEnabled(enabled); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the framework only allowed to call updateSemantics after setting this to true? We should document that here and on updateSemantics.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Should we just call this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setSemanticsEnabled is used exclusively by platform to let framework know it "wants" semantics to turn on. SetSemanticsTreeEnabled is framework signal to tell platform that "yes i will start compiling semantics"
Do you have other name suggestion? how about setSemanticsCompilingEnabled ? |
||
|
|
||
| @Native<Void Function(Bool)>(symbol: 'PlatformConfigurationNativeApi::SetSemanticsTreeEnabled') | ||
| external static void _setSemanticsTreeEnabled(bool update); | ||
|
|
||
| @override | ||
| String toString() => 'FlutterView(id: $viewId)'; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it is possible that either the platform OR the framework turns on semantics. Who is in charge of keeping track of this? If the platform turned on semantics and then the framework turns off semantics by calling this method - do we just leave the platform hanging and not provide it with a semantics tree anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
framework is keep track of this since it is the one who knows how many semantics handles are generated.
platform can send signal through SetSemanticsEnabled to framework, but it shouldnt initialize resource for accessibility until framework sends setSemanticsTreeEnabled back.
when framework turn off semantics(can happen when last handle is disposed), it will send setSemanticsTreeEnabled(false), platform will then know it can dispose its accessibility resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document that contract here? And on where the signal from the platform is send to the framework?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it tricky to write document in this class, this api is facing framework so i find it weird to document framework behavior in this doc, so I mainly document what this function does and when the consume should call this function. let me try to see what I can come up with