Use "SemanticsFoo" consistently instead of "SemanticFoo" (#6233)
This change might make our grammar less perfect, but it will increase our sanity.
This commit is contained in:
@@ -204,7 +204,7 @@ BoxConstraints _getAdditionalConstraints(String label) {
|
||||
);
|
||||
}
|
||||
|
||||
class _RenderSlider extends RenderConstrainedBox implements SemanticActionHandler {
|
||||
class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandler {
|
||||
_RenderSlider({
|
||||
double value,
|
||||
int divisions,
|
||||
@@ -445,7 +445,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticActionHandle
|
||||
bool get isSemanticBoundary => isInteractive;
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => _annotate;
|
||||
SemanticsAnnotator get semanticsAnnotator => _annotate;
|
||||
|
||||
void _annotate(SemanticsNode semantics) {
|
||||
if (isInteractive)
|
||||
@@ -453,13 +453,13 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticActionHandle
|
||||
}
|
||||
|
||||
@override
|
||||
void performAction(SemanticAction action) {
|
||||
void performAction(SemanticsAction action) {
|
||||
switch (action) {
|
||||
case SemanticAction.increase:
|
||||
case SemanticsAction.increase:
|
||||
if (isInteractive)
|
||||
onChanged((value + _kAdjustmentUnit).clamp(0.0, 1.0));
|
||||
break;
|
||||
case SemanticAction.decrease:
|
||||
case SemanticsAction.decrease:
|
||||
if (isInteractive)
|
||||
onChanged((value - _kAdjustmentUnit).clamp(0.0, 1.0));
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,7 @@ final Tween<double> _kRadialReactionRadiusTween = new Tween<double>(begin: 0.0,
|
||||
/// This class handles storing the current value, dispatching ValueChanged on a
|
||||
/// tap gesture and driving a changed animation. Subclasses are responsible for
|
||||
/// painting.
|
||||
abstract class RenderToggleable extends RenderConstrainedBox implements SemanticActionHandler {
|
||||
abstract class RenderToggleable extends RenderConstrainedBox implements SemanticsActionHandler {
|
||||
/// Creates a toggleable render object.
|
||||
///
|
||||
/// The [value], [activeColor], and [inactiveColor] arguments must not be
|
||||
@@ -286,19 +286,19 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
|
||||
bool get isSemanticBoundary => isInteractive;
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => _annotate;
|
||||
SemanticsAnnotator get semanticsAnnotator => _annotate;
|
||||
|
||||
void _annotate(SemanticsNode semantics) {
|
||||
semantics
|
||||
..hasCheckedState = true
|
||||
..isChecked = _value;
|
||||
if (isInteractive)
|
||||
semantics.addAction(SemanticAction.tap);
|
||||
semantics.addAction(SemanticsAction.tap);
|
||||
}
|
||||
|
||||
@override
|
||||
void performAction(SemanticAction action) {
|
||||
if (action == SemanticAction.tap)
|
||||
void performAction(SemanticsAction action) {
|
||||
if (action == SemanticsAction.tap)
|
||||
_handleTap();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,11 @@ semantics.
|
||||
|
||||
Semantic annotators are functions that, given a `SemanticsNode`, set
|
||||
some flags or strings on the object. They are obtained from
|
||||
`getSemanticAnnotators()`. For example, here is how `RenderParagraph`
|
||||
`getSemanticsAnnotators()`. For example, here is how `RenderParagraph`
|
||||
annotates the `SemanticsNode` with its text:
|
||||
|
||||
```dart
|
||||
Iterable<SemanticAnnotator> getSemanticAnnotators() sync* {
|
||||
Iterable<SemanticsAnnotator> getSemanticsAnnotators() sync* {
|
||||
yield (SemanticsNode node) {
|
||||
node.label = text.toPlainText();
|
||||
};
|
||||
|
||||
@@ -187,7 +187,7 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
|
||||
/// sent to the GPU.
|
||||
///
|
||||
/// 6. The semantics phase: All the dirty [RenderObject]s in the system have
|
||||
/// their semantics updated (see [RenderObject.semanticAnnotator]). This
|
||||
/// their semantics updated (see [RenderObject.SemanticsAnnotator]). This
|
||||
/// generates the [SemanticsNode] tree. See
|
||||
/// [RenderObject.markNeedsSemanticsUpdate] for further details on marking an
|
||||
/// object dirty for semantics.
|
||||
@@ -295,7 +295,7 @@ class SemanticsServer extends mojom.SemanticsServer {
|
||||
|
||||
@override
|
||||
void performAction(int id, mojom.SemanticAction encodedAction) {
|
||||
_semanticsOwner.performAction(id, SemanticAction.values[encodedAction.mojoEnumValue]);
|
||||
_semanticsOwner.performAction(id, SemanticsAction.values[encodedAction.mojoEnumValue]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ abstract class _SemanticsFragment {
|
||||
_children = children ?? const <_SemanticsFragment>[];
|
||||
}
|
||||
|
||||
final SemanticAnnotator annotator;
|
||||
final SemanticsAnnotator annotator;
|
||||
|
||||
List<RenderObject> _ancestorChain;
|
||||
void addAncestor(RenderObject ancestor) {
|
||||
@@ -574,7 +574,7 @@ class _CleanSemanticsFragment extends _SemanticsFragment {
|
||||
abstract class _InterestingSemanticsFragment extends _SemanticsFragment {
|
||||
_InterestingSemanticsFragment({
|
||||
RenderObject renderObjectOwner,
|
||||
SemanticAnnotator annotator,
|
||||
SemanticsAnnotator annotator,
|
||||
Iterable<_SemanticsFragment> children
|
||||
}) : super(renderObjectOwner: renderObjectOwner, annotator: annotator, children: children);
|
||||
|
||||
@@ -608,7 +608,7 @@ abstract class _InterestingSemanticsFragment extends _SemanticsFragment {
|
||||
class _RootSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
_RootSemanticsFragment({
|
||||
RenderObject renderObjectOwner,
|
||||
SemanticAnnotator annotator,
|
||||
SemanticsAnnotator annotator,
|
||||
Iterable<_SemanticsFragment> children
|
||||
}) : super(renderObjectOwner: renderObjectOwner, annotator: annotator, children: children);
|
||||
|
||||
@@ -619,7 +619,7 @@ class _RootSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
assert(currentSemantics == null);
|
||||
assert(parentSemantics == null);
|
||||
renderObjectOwner._semantics ??= new SemanticsNode.root(
|
||||
handler: renderObjectOwner is SemanticActionHandler ? renderObjectOwner as dynamic : null,
|
||||
handler: renderObjectOwner is SemanticsActionHandler ? renderObjectOwner as dynamic : null,
|
||||
owner: renderObjectOwner.owner.semanticsOwner
|
||||
);
|
||||
SemanticsNode node = renderObjectOwner._semantics;
|
||||
@@ -638,14 +638,14 @@ class _RootSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
class _ConcreteSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
_ConcreteSemanticsFragment({
|
||||
RenderObject renderObjectOwner,
|
||||
SemanticAnnotator annotator,
|
||||
SemanticsAnnotator annotator,
|
||||
Iterable<_SemanticsFragment> children
|
||||
}) : super(renderObjectOwner: renderObjectOwner, annotator: annotator, children: children);
|
||||
|
||||
@override
|
||||
SemanticsNode establishSemanticsNode(_SemanticsGeometry geometry, SemanticsNode currentSemantics, SemanticsNode parentSemantics) {
|
||||
renderObjectOwner._semantics ??= new SemanticsNode(
|
||||
handler: renderObjectOwner is SemanticActionHandler ? renderObjectOwner as dynamic : null
|
||||
handler: renderObjectOwner is SemanticsActionHandler ? renderObjectOwner as dynamic : null
|
||||
);
|
||||
SemanticsNode node = renderObjectOwner._semantics;
|
||||
if (geometry != null) {
|
||||
@@ -666,7 +666,7 @@ class _ConcreteSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
class _ImplicitSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
_ImplicitSemanticsFragment({
|
||||
RenderObject renderObjectOwner,
|
||||
SemanticAnnotator annotator,
|
||||
SemanticsAnnotator annotator,
|
||||
Iterable<_SemanticsFragment> children
|
||||
}) : super(renderObjectOwner: renderObjectOwner, annotator: annotator, children: children);
|
||||
|
||||
@@ -681,7 +681,7 @@ class _ImplicitSemanticsFragment extends _InterestingSemanticsFragment {
|
||||
_haveConcreteNode = currentSemantics == null && annotator != null;
|
||||
if (haveConcreteNode) {
|
||||
renderObjectOwner._semantics ??= new SemanticsNode(
|
||||
handler: renderObjectOwner is SemanticActionHandler ? renderObjectOwner as dynamic : null
|
||||
handler: renderObjectOwner is SemanticsActionHandler ? renderObjectOwner as dynamic : null
|
||||
);
|
||||
node = renderObjectOwner._semantics;
|
||||
} else {
|
||||
@@ -2117,7 +2117,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
||||
});
|
||||
_needsSemanticsUpdate = false;
|
||||
_needsSemanticsGeometryUpdate = false;
|
||||
SemanticAnnotator annotator = semanticAnnotator;
|
||||
SemanticsAnnotator annotator = semanticsAnnotator;
|
||||
if (parent is! RenderObject)
|
||||
return new _RootSemanticsFragment(renderObjectOwner: this, annotator: annotator, children: children);
|
||||
if (isSemanticBoundary)
|
||||
@@ -2167,7 +2167,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
||||
/// [hasSemantics] isn't true, then the associated call to
|
||||
/// [markNeedsSemanticsUpdate] must not have `onlyChanges` set, as it is
|
||||
/// possible that the node should be entirely removed.
|
||||
SemanticAnnotator get semanticAnnotator => null;
|
||||
SemanticsAnnotator get semanticsAnnotator => null;
|
||||
|
||||
|
||||
// EVENTS
|
||||
|
||||
@@ -246,7 +246,7 @@ class RenderParagraph extends RenderBox {
|
||||
}
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => _annotate;
|
||||
SemanticsAnnotator get semanticsAnnotator => _annotate;
|
||||
|
||||
void _annotate(SemanticsNode node) {
|
||||
node.label = text.toPlainText();
|
||||
|
||||
@@ -2321,7 +2321,7 @@ class RenderMetaData extends RenderProxyBoxWithHitTestBehavior {
|
||||
|
||||
/// Listens for the specified gestures from the semantics server (e.g.
|
||||
/// an accessibility tool).
|
||||
class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticActionHandler {
|
||||
class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsActionHandler {
|
||||
/// Creates a render object that listens for specific semantic gestures.
|
||||
///
|
||||
/// The [scrollFactor] argument must not be null.
|
||||
@@ -2406,13 +2406,13 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
}
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => isSemanticBoundary ? _annotate : null;
|
||||
SemanticsAnnotator get semanticsAnnotator => isSemanticBoundary ? _annotate : null;
|
||||
|
||||
void _annotate(SemanticsNode node) {
|
||||
if (onTap != null)
|
||||
node.addAction(SemanticAction.tap);
|
||||
node.addAction(SemanticsAction.tap);
|
||||
if (onLongPress != null)
|
||||
node.addAction(SemanticAction.longPress);
|
||||
node.addAction(SemanticsAction.longPress);
|
||||
if (onHorizontalDragUpdate != null)
|
||||
node.addHorizontalScrollingActions();
|
||||
if (onVerticalDragUpdate != null)
|
||||
@@ -2420,17 +2420,17 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
}
|
||||
|
||||
@override
|
||||
void performAction(SemanticAction action) {
|
||||
void performAction(SemanticsAction action) {
|
||||
switch (action) {
|
||||
case SemanticAction.tap:
|
||||
case SemanticsAction.tap:
|
||||
if (onTap != null)
|
||||
onTap();
|
||||
break;
|
||||
case SemanticAction.longPress:
|
||||
case SemanticsAction.longPress:
|
||||
if (onLongPress != null)
|
||||
onLongPress();
|
||||
break;
|
||||
case SemanticAction.scrollLeft:
|
||||
case SemanticsAction.scrollLeft:
|
||||
if (onHorizontalDragUpdate != null) {
|
||||
final double primaryDelta = size.width * -scrollFactor;
|
||||
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||
@@ -2438,7 +2438,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
));
|
||||
}
|
||||
break;
|
||||
case SemanticAction.scrollRight:
|
||||
case SemanticsAction.scrollRight:
|
||||
if (onHorizontalDragUpdate != null) {
|
||||
final double primaryDelta = size.width * scrollFactor;
|
||||
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||
@@ -2446,7 +2446,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
));
|
||||
}
|
||||
break;
|
||||
case SemanticAction.scrollUp:
|
||||
case SemanticsAction.scrollUp:
|
||||
if (onVerticalDragUpdate != null) {
|
||||
final double primaryDelta = size.height * -scrollFactor;
|
||||
onVerticalDragUpdate(new DragUpdateDetails(
|
||||
@@ -2454,7 +2454,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
));
|
||||
}
|
||||
break;
|
||||
case SemanticAction.scrollDown:
|
||||
case SemanticsAction.scrollDown:
|
||||
if (onVerticalDragUpdate != null) {
|
||||
final double primaryDelta = size.height * scrollFactor;
|
||||
onVerticalDragUpdate(new DragUpdateDetails(
|
||||
@@ -2462,8 +2462,8 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
));
|
||||
}
|
||||
break;
|
||||
case SemanticAction.increase:
|
||||
case SemanticAction.decrease:
|
||||
case SemanticsAction.increase:
|
||||
case SemanticsAction.decrease:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
@@ -2471,11 +2471,11 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
||||
}
|
||||
|
||||
/// Add annotations to the [SemanticsNode] for this subtree.
|
||||
class RenderSemanticAnnotations extends RenderProxyBox {
|
||||
class RenderSemanticsAnnotations extends RenderProxyBox {
|
||||
/// Creates a render object that attaches a semantic annotation.
|
||||
///
|
||||
/// The [container] argument must not be null.
|
||||
RenderSemanticAnnotations({
|
||||
RenderSemanticsAnnotations({
|
||||
RenderBox child,
|
||||
bool container: false,
|
||||
bool checked,
|
||||
@@ -2534,7 +2534,7 @@ class RenderSemanticAnnotations extends RenderProxyBox {
|
||||
bool get isSemanticBoundary => container;
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => checked != null || label != null ? _annotate : null;
|
||||
SemanticsAnnotator get semanticsAnnotator => checked != null || label != null ? _annotate : null;
|
||||
|
||||
void _annotate(SemanticsNode node) {
|
||||
if (checked != null) {
|
||||
@@ -2559,7 +2559,7 @@ class RenderMergeSemantics extends RenderProxyBox {
|
||||
RenderMergeSemantics({ RenderBox child }) : super(child);
|
||||
|
||||
@override
|
||||
SemanticAnnotator get semanticAnnotator => _annotate;
|
||||
SemanticsAnnotator get semanticsAnnotator => _annotate;
|
||||
|
||||
void _annotate(SemanticsNode node) {
|
||||
node.mergeAllDescendantsIntoThisNode = true;
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' show Rect;
|
||||
|
||||
import 'package:flutter_services/semantics.dart' as mojom;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_services/semantics.dart' as mojom;
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'node.dart';
|
||||
|
||||
/// The possible actions that can be conveyed from the operating system
|
||||
/// accessibility APIs to a [SemanticsNode] object.
|
||||
enum SemanticAction {
|
||||
enum SemanticsAction {
|
||||
/// The equivalent of a user briefly tapping the screen with the finger
|
||||
/// without moving it.
|
||||
tap,
|
||||
@@ -70,26 +70,26 @@ enum SemanticAction {
|
||||
/// (e.g. [handleSemanticTap]() will only be called if
|
||||
/// [SemanticsNode.canBeTapped] is true, [handleSemanticScrollDown]() will only
|
||||
/// be called if [SemanticsNode.canBeScrolledVertically] is true, etc).
|
||||
abstract class SemanticActionHandler { // ignore: one_member_abstracts
|
||||
abstract class SemanticsActionHandler { // ignore: one_member_abstracts
|
||||
/// Called when the object implementing this interface receives a
|
||||
/// [SemanticAction]. For example, if the user of an accessibility tool
|
||||
/// [SemanticsAction]. For example, if the user of an accessibility tool
|
||||
/// instructs their device that they wish to tap a button, the [RenderObject]
|
||||
/// behind that button would have its [performAction] method called with the
|
||||
/// [SemanticAction.tap] action.
|
||||
void performAction(SemanticAction action);
|
||||
/// [SemanticsAction.tap] action.
|
||||
void performAction(SemanticsAction action);
|
||||
}
|
||||
|
||||
/// The type of function returned by [RenderObject.getSemanticAnnotators()].
|
||||
/// The type of function returned by [RenderObject.getSemanticsAnnotators()].
|
||||
///
|
||||
/// These callbacks are called with the [SemanticsNode] object that
|
||||
/// corresponds to the [RenderObject]. (One [SemanticsNode] can
|
||||
/// correspond to multiple [RenderObject] objects.)
|
||||
///
|
||||
/// See [RenderObject.getSemanticAnnotators()] for details on the
|
||||
/// See [RenderObject.getSemanticsAnnotators()] for details on the
|
||||
/// contract that semantic annotators must follow.
|
||||
typedef void SemanticAnnotator(SemanticsNode semantics);
|
||||
typedef void SemanticsAnnotator(SemanticsNode semantics);
|
||||
|
||||
enum _SemanticFlags {
|
||||
enum _SemanticsFlags {
|
||||
mergeAllDescendantsIntoThisNode,
|
||||
inheritedMergeAllDescendantsIntoThisNode, // whether an ancestor had mergeAllDescendantsIntoThisNode set
|
||||
hasCheckedState,
|
||||
@@ -113,7 +113,7 @@ class SemanticsNode extends AbstractNode {
|
||||
/// Each semantic node has a unique identifier that is assigned when the node
|
||||
/// is created.
|
||||
SemanticsNode({
|
||||
SemanticActionHandler handler
|
||||
SemanticsActionHandler handler
|
||||
}) : _id = _generateNewId(),
|
||||
_actionHandler = handler;
|
||||
|
||||
@@ -121,7 +121,7 @@ class SemanticsNode extends AbstractNode {
|
||||
///
|
||||
/// The root node is assigned an identifier of zero.
|
||||
SemanticsNode.root({
|
||||
SemanticActionHandler handler,
|
||||
SemanticsActionHandler handler,
|
||||
SemanticsOwner owner
|
||||
}) : _id = 0,
|
||||
_actionHandler = handler {
|
||||
@@ -135,7 +135,7 @@ class SemanticsNode extends AbstractNode {
|
||||
}
|
||||
|
||||
final int _id;
|
||||
final SemanticActionHandler _actionHandler;
|
||||
final SemanticsActionHandler _actionHandler;
|
||||
|
||||
|
||||
// GEOMETRY
|
||||
@@ -171,45 +171,45 @@ class SemanticsNode extends AbstractNode {
|
||||
|
||||
|
||||
// FLAGS AND LABELS
|
||||
// These are supposed to be set by SemanticAnnotator obtained from getSemanticAnnotators
|
||||
// These are supposed to be set by SemanticsAnnotator obtained from getSemanticsAnnotators
|
||||
|
||||
final Set<SemanticAction> _actions = new Set<SemanticAction>();
|
||||
final Set<SemanticsAction> _actions = new Set<SemanticsAction>();
|
||||
|
||||
/// Adds the given action to the set of semantic actions.
|
||||
///
|
||||
/// If the user chooses to perform an action,
|
||||
/// [SemanticActionHandler.performAction] will be called with the chosen
|
||||
/// [SemanticsActionHandler.performAction] will be called with the chosen
|
||||
/// action.
|
||||
void addAction(SemanticAction action) {
|
||||
void addAction(SemanticsAction action) {
|
||||
if (_actions.add(action))
|
||||
_markDirty();
|
||||
}
|
||||
|
||||
/// Adds the [SemanticAction.scrollLeft] and [SemanticAction.scrollRight] actions.
|
||||
/// Adds the [SemanticsAction.scrollLeft] and [SemanticsAction.scrollRight] actions.
|
||||
void addHorizontalScrollingActions() {
|
||||
addAction(SemanticAction.scrollLeft);
|
||||
addAction(SemanticAction.scrollRight);
|
||||
addAction(SemanticsAction.scrollLeft);
|
||||
addAction(SemanticsAction.scrollRight);
|
||||
}
|
||||
|
||||
/// Adds the [SemanticAction.scrollUp] and [SemanticAction.scrollDown] actions.
|
||||
/// Adds the [SemanticsAction.scrollUp] and [SemanticsAction.scrollDown] actions.
|
||||
void addVerticalScrollingActions() {
|
||||
addAction(SemanticAction.scrollUp);
|
||||
addAction(SemanticAction.scrollDown);
|
||||
addAction(SemanticsAction.scrollUp);
|
||||
addAction(SemanticsAction.scrollDown);
|
||||
}
|
||||
|
||||
/// Adds the [SemanticAction.increase] and [SemanticAction.decrease] actions.
|
||||
/// Adds the [SemanticsAction.increase] and [SemanticsAction.decrease] actions.
|
||||
void addAdjustmentActions() {
|
||||
addAction(SemanticAction.increase);
|
||||
addAction(SemanticAction.decrease);
|
||||
addAction(SemanticsAction.increase);
|
||||
addAction(SemanticsAction.decrease);
|
||||
}
|
||||
|
||||
bool _hasAction(SemanticAction action) {
|
||||
bool _hasAction(SemanticsAction action) {
|
||||
return _actionHandler != null && _actions.contains(action);
|
||||
}
|
||||
|
||||
BitField<_SemanticFlags> _flags = new BitField<_SemanticFlags>.filled(_SemanticFlags.values.length, false);
|
||||
BitField<_SemanticsFlags> _flags = new BitField<_SemanticsFlags>.filled(_SemanticsFlags.values.length, false);
|
||||
|
||||
void _setFlag(_SemanticFlags flag, bool value, { bool needsHandler: false }) {
|
||||
void _setFlag(_SemanticsFlags flag, bool value, { bool needsHandler: false }) {
|
||||
assert(value != null);
|
||||
assert((!needsHandler) || (_actionHandler != null) || (value == false));
|
||||
if (_flags[flag] != value) {
|
||||
@@ -219,21 +219,21 @@ class SemanticsNode extends AbstractNode {
|
||||
}
|
||||
|
||||
/// Whether all this node and all of its descendants should be treated as one logical entity.
|
||||
bool get mergeAllDescendantsIntoThisNode => _flags[_SemanticFlags.mergeAllDescendantsIntoThisNode];
|
||||
set mergeAllDescendantsIntoThisNode(bool value) => _setFlag(_SemanticFlags.mergeAllDescendantsIntoThisNode, value);
|
||||
bool get mergeAllDescendantsIntoThisNode => _flags[_SemanticsFlags.mergeAllDescendantsIntoThisNode];
|
||||
set mergeAllDescendantsIntoThisNode(bool value) => _setFlag(_SemanticsFlags.mergeAllDescendantsIntoThisNode, value);
|
||||
|
||||
bool get _inheritedMergeAllDescendantsIntoThisNode => _flags[_SemanticFlags.inheritedMergeAllDescendantsIntoThisNode];
|
||||
set _inheritedMergeAllDescendantsIntoThisNode(bool value) => _setFlag(_SemanticFlags.inheritedMergeAllDescendantsIntoThisNode, value);
|
||||
bool get _inheritedMergeAllDescendantsIntoThisNode => _flags[_SemanticsFlags.inheritedMergeAllDescendantsIntoThisNode];
|
||||
set _inheritedMergeAllDescendantsIntoThisNode(bool value) => _setFlag(_SemanticsFlags.inheritedMergeAllDescendantsIntoThisNode, value);
|
||||
|
||||
bool get _shouldMergeAllDescendantsIntoThisNode => mergeAllDescendantsIntoThisNode || _inheritedMergeAllDescendantsIntoThisNode;
|
||||
|
||||
/// Whether this node has Boolean state that can be controlled by the user.
|
||||
bool get hasCheckedState => _flags[_SemanticFlags.hasCheckedState];
|
||||
set hasCheckedState(bool value) => _setFlag(_SemanticFlags.hasCheckedState, value);
|
||||
bool get hasCheckedState => _flags[_SemanticsFlags.hasCheckedState];
|
||||
set hasCheckedState(bool value) => _setFlag(_SemanticsFlags.hasCheckedState, value);
|
||||
|
||||
/// If this node has Boolean state that can be controlled by the user, whether that state is on or off, cooresponding to `true` and `false`, respectively.
|
||||
bool get isChecked => _flags[_SemanticFlags.isChecked];
|
||||
set isChecked(bool value) => _setFlag(_SemanticFlags.isChecked, value);
|
||||
bool get isChecked => _flags[_SemanticsFlags.isChecked];
|
||||
set isChecked(bool value) => _setFlag(_SemanticsFlags.isChecked, value);
|
||||
|
||||
/// A textual description of this node.
|
||||
String get label => _label;
|
||||
@@ -430,7 +430,7 @@ class SemanticsNode extends AbstractNode {
|
||||
result.strings = new mojom.SemanticStrings();
|
||||
result.strings.label = label;
|
||||
List<mojom.SemanticsNode> children = <mojom.SemanticsNode>[];
|
||||
Set<SemanticAction> mergedActions = new Set<SemanticAction>();
|
||||
Set<SemanticsAction> mergedActions = new Set<SemanticsAction>();
|
||||
mergedActions.addAll(_actions);
|
||||
if (_shouldMergeAllDescendantsIntoThisNode) {
|
||||
_visitDescendants((SemanticsNode node) {
|
||||
@@ -451,7 +451,7 @@ class SemanticsNode extends AbstractNode {
|
||||
}
|
||||
result.children = children;
|
||||
result.actions = <int>[];
|
||||
for (SemanticAction action in mergedActions)
|
||||
for (SemanticsAction action in mergedActions)
|
||||
result.actions.add(action.index);
|
||||
_dirty = false;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ class SemanticsNode extends AbstractNode {
|
||||
buffer.write('; $rect');
|
||||
if (wasAffectedByClip)
|
||||
buffer.write(' (clipped)');
|
||||
for (SemanticAction action in _actions) {
|
||||
for (SemanticsAction action in _actions) {
|
||||
buffer.write('; $action');
|
||||
}
|
||||
if (hasCheckedState) {
|
||||
@@ -627,7 +627,7 @@ class SemanticsOwner {
|
||||
_dirtyNodes.clear();
|
||||
}
|
||||
|
||||
SemanticActionHandler _getSemanticActionHandlerForId(int id, { @required SemanticAction action }) {
|
||||
SemanticsActionHandler _getSemanticsActionHandlerForId(int id, { @required SemanticsAction action }) {
|
||||
assert(action != null);
|
||||
SemanticsNode result = _nodes[id];
|
||||
if (result != null && result._shouldMergeAllDescendantsIntoThisNode && !result._hasAction(action)) {
|
||||
@@ -648,8 +648,8 @@ class SemanticsOwner {
|
||||
///
|
||||
/// If the [SemanticsNode] has not indicated that it can perform the action,
|
||||
/// this function does nothing.
|
||||
void performAction(int id, SemanticAction action) {
|
||||
SemanticActionHandler handler = _getSemanticActionHandlerForId(id, action: action);
|
||||
void performAction(int id, SemanticsAction action) {
|
||||
SemanticsActionHandler handler = _getSemanticsActionHandlerForId(id, action: action);
|
||||
handler?.performAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2719,14 +2719,14 @@ class Semantics extends SingleChildRenderObjectWidget {
|
||||
final String label;
|
||||
|
||||
@override
|
||||
RenderSemanticAnnotations createRenderObject(BuildContext context) => new RenderSemanticAnnotations(
|
||||
RenderSemanticsAnnotations createRenderObject(BuildContext context) => new RenderSemanticsAnnotations(
|
||||
container: container,
|
||||
checked: checked,
|
||||
label: label
|
||||
);
|
||||
|
||||
@override
|
||||
void updateRenderObject(BuildContext context, RenderSemanticAnnotations renderObject) {
|
||||
void updateRenderObject(BuildContext context, RenderSemanticsAnnotations renderObject) {
|
||||
renderObject
|
||||
..container = container
|
||||
..checked = checked
|
||||
|
||||
@@ -268,7 +268,7 @@ abstract class WidgetsBinding extends BindingBase implements GestureBinding, Ren
|
||||
/// sent to the GPU.
|
||||
///
|
||||
/// 7. The semantics phase: All the dirty [RenderObject]s in the system have
|
||||
/// their semantics updated (see [RenderObject.semanticAnnotator]). This
|
||||
/// their semantics updated (see [RenderObject.SemanticsAnnotator]). This
|
||||
/// generates the [SemanticsNode] tree. See
|
||||
/// [RenderObject.markNeedsSemanticsUpdate] for further details on marking an
|
||||
/// object dirty for semantics.
|
||||
|
||||
@@ -78,14 +78,14 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
|
||||
|
||||
void _handleTap() {
|
||||
assert(_lastPointerDownLocation != null);
|
||||
_client._performAction(_lastPointerDownLocation, SemanticAction.tap);
|
||||
_client._performAction(_lastPointerDownLocation, SemanticsAction.tap);
|
||||
setState(() {
|
||||
_lastPointerDownLocation = null;
|
||||
});
|
||||
}
|
||||
void _handleLongPress() {
|
||||
assert(_lastPointerDownLocation != null);
|
||||
_client._performAction(_lastPointerDownLocation, SemanticAction.longPress);
|
||||
_client._performAction(_lastPointerDownLocation, SemanticsAction.longPress);
|
||||
setState(() {
|
||||
_lastPointerDownLocation = null;
|
||||
});
|
||||
@@ -127,7 +127,7 @@ class _SemanticsDebuggerEntry {
|
||||
_SemanticsDebuggerEntry(this.id);
|
||||
|
||||
final int id;
|
||||
final Set<SemanticAction> actions = new Set<SemanticAction>();
|
||||
final Set<SemanticsAction> actions = new Set<SemanticsAction>();
|
||||
bool hasCheckedState = false;
|
||||
bool isChecked = false;
|
||||
String label;
|
||||
@@ -139,7 +139,7 @@ class _SemanticsDebuggerEntry {
|
||||
String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.write('_SemanticsDebuggerEntry($id; $rect; "$label"');
|
||||
for (SemanticAction action in actions)
|
||||
for (SemanticsAction action in actions)
|
||||
buffer.write('; $action');
|
||||
buffer
|
||||
..write('${hasCheckedState ? isChecked ? "; checked" : "; unchecked" : ""}')
|
||||
@@ -166,7 +166,7 @@ class _SemanticsDebuggerEntry {
|
||||
if (node.actions != null) {
|
||||
actions.clear();
|
||||
for (int encodedAction in node.actions)
|
||||
actions.add(SemanticAction.values[encodedAction]);
|
||||
actions.add(SemanticsAction.values[encodedAction]);
|
||||
}
|
||||
if (node.strings != null) {
|
||||
assert(node.strings.label != null);
|
||||
@@ -210,15 +210,15 @@ class _SemanticsDebuggerEntry {
|
||||
);
|
||||
|
||||
bool get _isScrollable {
|
||||
return actions.contains(SemanticAction.scrollLeft)
|
||||
|| actions.contains(SemanticAction.scrollRight)
|
||||
|| actions.contains(SemanticAction.scrollUp)
|
||||
|| actions.contains(SemanticAction.scrollDown);
|
||||
return actions.contains(SemanticsAction.scrollLeft)
|
||||
|| actions.contains(SemanticsAction.scrollRight)
|
||||
|| actions.contains(SemanticsAction.scrollUp)
|
||||
|| actions.contains(SemanticsAction.scrollDown);
|
||||
}
|
||||
|
||||
bool get _isAdjustable {
|
||||
return actions.contains(SemanticAction.increase)
|
||||
|| actions.contains(SemanticAction.decrease);
|
||||
return actions.contains(SemanticsAction.increase)
|
||||
|| actions.contains(SemanticsAction.decrease);
|
||||
}
|
||||
|
||||
TextPainter textPainter;
|
||||
@@ -229,14 +229,14 @@ class _SemanticsDebuggerEntry {
|
||||
annotations.add(isChecked ? 'checked' : 'unchecked');
|
||||
wantsTap = true;
|
||||
}
|
||||
if (actions.contains(SemanticAction.tap)) {
|
||||
if (actions.contains(SemanticsAction.tap)) {
|
||||
if (!wantsTap)
|
||||
annotations.add('button');
|
||||
} else {
|
||||
if (wantsTap)
|
||||
annotations.add('disabled');
|
||||
}
|
||||
if (actions.contains(SemanticAction.longPress))
|
||||
if (actions.contains(SemanticsAction.longPress))
|
||||
annotations.add('long-pressable');
|
||||
if (_isScrollable)
|
||||
annotations.add('scrollable');
|
||||
@@ -384,7 +384,7 @@ class _SemanticsClient extends ChangeNotifier {
|
||||
return rootNode?.hitTest(position, filter);
|
||||
}
|
||||
|
||||
void _performAction(Point position, SemanticAction action) {
|
||||
void _performAction(Point position, SemanticsAction action) {
|
||||
_SemanticsDebuggerEntry entry = _hitTest(position, (_SemanticsDebuggerEntry entry) => entry.actions.contains(action));
|
||||
_semanticsOwner.performAction(entry?.id ?? 0, action);
|
||||
}
|
||||
@@ -396,17 +396,17 @@ class _SemanticsClient extends ChangeNotifier {
|
||||
return;
|
||||
if (vx.abs() > vy.abs()) {
|
||||
if (vx.sign < 0) {
|
||||
_performAction(position, SemanticAction.decrease);
|
||||
_performAction(position, SemanticAction.scrollLeft);
|
||||
_performAction(position, SemanticsAction.decrease);
|
||||
_performAction(position, SemanticsAction.scrollLeft);
|
||||
} else {
|
||||
_performAction(position, SemanticAction.increase);
|
||||
_performAction(position, SemanticAction.scrollRight);
|
||||
_performAction(position, SemanticsAction.increase);
|
||||
_performAction(position, SemanticsAction.scrollRight);
|
||||
}
|
||||
} else {
|
||||
if (vy.sign < 0)
|
||||
_performAction(position, SemanticAction.scrollUp);
|
||||
_performAction(position, SemanticsAction.scrollUp);
|
||||
else
|
||||
_performAction(position, SemanticAction.scrollDown);
|
||||
_performAction(position, SemanticsAction.scrollDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user