Commit 41a91a7a authored by Adam Barth's avatar Adam Barth Committed by GitHub

Use "SemanticsFoo" consistently instead of "SemanticFoo" (#6233)

This change might make our grammar less perfect, but it will increase our
sanity.
parent 60814764
......@@ -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;
......
......@@ -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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment