@@ -95,6 +95,9 @@ class SemanticsData extends Diagnosticable {
95
95
@required this .nextNodeId,
96
96
@required this .rect,
97
97
@required this .textSelection,
98
+ @required this .scrollPosition,
99
+ @required this .scrollExtentMax,
100
+ @required this .scrollExtentMin,
98
101
this .tags,
99
102
this .transform,
100
103
}) : assert (flags != null ),
@@ -156,6 +159,38 @@ class SemanticsData extends Diagnosticable {
156
159
/// if this node represents a text field.
157
160
final TextSelection textSelection;
158
161
162
+ /// Indicates the current scrolling position in logical pixels if the node is
163
+ /// scrollable.
164
+ ///
165
+ /// The properties [scrollExtentMin] and [scrollExtentMax] indicate the valid
166
+ /// in-range values for this property. The value for [scrollPosition] may
167
+ /// (temporarily) be outside that range, e.g. during an overscroll.
168
+ ///
169
+ /// See also:
170
+ ///
171
+ /// * [ScrollPosition.pixels] , from where this value is usually taken.
172
+ final double scrollPosition;
173
+
174
+ /// Indicates the maximum in-range value for [scrollPosition] if the node is
175
+ /// scrollable.
176
+ ///
177
+ /// This value may be infinity if the scroll is unbound.
178
+ ///
179
+ /// See also:
180
+ ///
181
+ /// * [ScrollPosition.maxScrollExtent] , from where this value is usually taken.
182
+ final double scrollExtentMax;
183
+
184
+ /// Indicates the mimimum in-range value for [scrollPosition] if the node is
185
+ /// scrollable.
186
+ ///
187
+ /// This value may be infinity if the scroll is unbound.
188
+ ///
189
+ /// See also:
190
+ ///
191
+ /// * [ScrollPosition.minScrollExtent] , from where this value is usually taken.
192
+ final double scrollExtentMin;
193
+
159
194
/// The bounding box for this node in its coordinate system.
160
195
final Rect rect;
161
196
@@ -204,7 +239,10 @@ class SemanticsData extends Diagnosticable {
204
239
properties.add (new EnumProperty <TextDirection >('textDirection' , textDirection, defaultValue: null ));
205
240
properties.add (new IntProperty ('nextNodeId' , nextNodeId, defaultValue: null ));
206
241
if (textSelection? .isValid == true )
207
- properties.add (new MessageProperty ('text selection' , '[${textSelection .start }, ${textSelection .end }]' ));
242
+ properties.add (new MessageProperty ('textSelection' , '[${textSelection .start }, ${textSelection .end }]' ));
243
+ properties.add (new DoubleProperty ('scrollExtentMin' , scrollExtentMin, defaultValue: null ));
244
+ properties.add (new DoubleProperty ('scrollPosition' , scrollPosition, defaultValue: null ));
245
+ properties.add (new DoubleProperty ('scrollExtentMax' , scrollExtentMax, defaultValue: null ));
208
246
}
209
247
210
248
@override
@@ -224,11 +262,14 @@ class SemanticsData extends Diagnosticable {
224
262
&& typedOther.rect == rect
225
263
&& setEquals (typedOther.tags, tags)
226
264
&& typedOther.textSelection == textSelection
265
+ && typedOther.scrollPosition == scrollPosition
266
+ && typedOther.scrollExtentMax == scrollExtentMax
267
+ && typedOther.scrollExtentMin == scrollExtentMin
227
268
&& typedOther.transform == transform;
228
269
}
229
270
230
271
@override
231
- int get hashCode => ui.hashValues (flags, actions, label, value, increasedValue, decreasedValue, hint, textDirection, nextNodeId, rect, tags, textSelection, transform);
272
+ int get hashCode => ui.hashValues (flags, actions, label, value, increasedValue, decreasedValue, hint, textDirection, nextNodeId, rect, tags, textSelection, scrollPosition, scrollExtentMax, scrollExtentMin, transform);
232
273
}
233
274
234
275
class _SemanticsDiagnosticableNode extends DiagnosticableNode <SemanticsNode > {
@@ -915,6 +956,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
915
956
_textDirection != config.textDirection ||
916
957
_sortOrder != config._sortOrder ||
917
958
_textSelection != config._textSelection ||
959
+ _scrollPosition != config._scrollPosition ||
960
+ _scrollExtentMax != config._scrollExtentMax ||
961
+ _scrollExtentMin != config._scrollExtentMin ||
918
962
_actionsAsBits != config._actionsAsBits ||
919
963
_mergeAllDescendantsIntoThisNode != config.isMergingSemanticsOfDescendants;
920
964
}
@@ -1011,6 +1055,42 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1011
1055
TextSelection get textSelection => _textSelection;
1012
1056
TextSelection _textSelection;
1013
1057
1058
+ /// Indicates the current scrolling position in logical pixels if the node is
1059
+ /// scrollable.
1060
+ ///
1061
+ /// The properties [scrollExtentMin] and [scrollExtentMax] indicate the valid
1062
+ /// in-range values for this property. The value for [scrollPosition] may
1063
+ /// (temporarily) be outside that range, e.g. during an overscroll.
1064
+ ///
1065
+ /// See also:
1066
+ ///
1067
+ /// * [ScrollPosition.pixels] , from where this value is usually taken.
1068
+ double get scrollPosition => _scrollPosition;
1069
+ double _scrollPosition;
1070
+
1071
+
1072
+ /// Indicates the maximum in-range value for [scrollPosition] if the node is
1073
+ /// scrollable.
1074
+ ///
1075
+ /// This value may be infinity if the scroll is unbound.
1076
+ ///
1077
+ /// See also:
1078
+ ///
1079
+ /// * [ScrollPosition.maxScrollExtent] , from where this value is usually taken.
1080
+ double get scrollExtentMax => _scrollExtentMax;
1081
+ double _scrollExtentMax;
1082
+
1083
+ /// Indicates the mimimum in-range value for [scrollPosition] if the node is
1084
+ /// scrollable.
1085
+ ///
1086
+ /// This value may be infinity if the scroll is unbound.
1087
+ ///
1088
+ /// See also:
1089
+ ///
1090
+ /// * [ScrollPosition.minScrollExtent] from where this value is usually taken.
1091
+ double get scrollExtentMin => _scrollExtentMin;
1092
+ double _scrollExtentMin;
1093
+
1014
1094
bool _canPerformAction (SemanticsAction action) => _actions.containsKey (action);
1015
1095
1016
1096
static final SemanticsConfiguration _kEmptyConfig = new SemanticsConfiguration ();
@@ -1043,6 +1123,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1043
1123
_actions = new Map <SemanticsAction , _SemanticsActionHandler >.from (config._actions);
1044
1124
_actionsAsBits = config._actionsAsBits;
1045
1125
_textSelection = config._textSelection;
1126
+ _scrollPosition = config._scrollPosition;
1127
+ _scrollExtentMax = config._scrollExtentMax;
1128
+ _scrollExtentMin = config._scrollExtentMin;
1046
1129
_mergeAllDescendantsIntoThisNode = config.isMergingSemanticsOfDescendants;
1047
1130
_replaceChildren (childrenInInversePaintOrder ?? const < SemanticsNode > []);
1048
1131
@@ -1074,6 +1157,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1074
1157
int nextNodeId = _nextNodeId;
1075
1158
Set <SemanticsTag > mergedTags = tags == null ? null : new Set <SemanticsTag >.from (tags);
1076
1159
TextSelection textSelection = _textSelection;
1160
+ double scrollPosition = _scrollPosition;
1161
+ double scrollExtentMax = _scrollExtentMax;
1162
+ double scrollExtentMin = _scrollExtentMin;
1077
1163
1078
1164
if (mergeAllDescendantsIntoThisNode) {
1079
1165
_visitDescendants ((SemanticsNode node) {
@@ -1083,6 +1169,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1083
1169
textDirection ?? = node._textDirection;
1084
1170
nextNodeId ?? = node._nextNodeId;
1085
1171
textSelection ?? = node._textSelection;
1172
+ scrollPosition ?? = node._scrollPosition;
1173
+ scrollExtentMax ?? = node._scrollExtentMax;
1174
+ scrollExtentMin ?? = node._scrollExtentMin;
1086
1175
if (value == '' || value == null )
1087
1176
value = node._value;
1088
1177
if (increasedValue == '' || increasedValue == null )
@@ -1123,6 +1212,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1123
1212
transform: transform,
1124
1213
tags: mergedTags,
1125
1214
textSelection: textSelection,
1215
+ scrollPosition: scrollPosition,
1216
+ scrollExtentMax: scrollExtentMax,
1217
+ scrollExtentMin: scrollExtentMin,
1126
1218
);
1127
1219
}
1128
1220
@@ -1160,6 +1252,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1160
1252
nextNodeId: data.nextNodeId,
1161
1253
textSelectionBase: data.textSelection != null ? data.textSelection.baseOffset : - 1 ,
1162
1254
textSelectionExtent: data.textSelection != null ? data.textSelection.extentOffset : - 1 ,
1255
+ scrollPosition: data.scrollPosition != null ? data.scrollPosition : double .nan,
1256
+ scrollExtentMax: data.scrollExtentMax != null ? data.scrollExtentMax : double .nan,
1257
+ scrollExtentMin: data.scrollExtentMin != null ? data.scrollExtentMin : double .nan,
1163
1258
transform: data.transform? .storage ?? _kIdentityTransform,
1164
1259
children: children,
1165
1260
);
@@ -1232,6 +1327,9 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1232
1327
properties.add (new DiagnosticsProperty <SemanticsSortOrder >('sortOrder' , sortOrder, defaultValue: null ));
1233
1328
if (_textSelection? .isValid == true )
1234
1329
properties.add (new MessageProperty ('text selection' , '[${_textSelection .start }, ${_textSelection .end }]' ));
1330
+ properties.add (new DoubleProperty ('scrollExtentMin' , scrollExtentMin, defaultValue: null ));
1331
+ properties.add (new DoubleProperty ('scrollPosition' , scrollPosition, defaultValue: null ));
1332
+ properties.add (new DoubleProperty ('scrollExtentMax' , scrollExtentMax, defaultValue: null ));
1235
1333
}
1236
1334
1237
1335
/// Returns a string representation of this node and its descendants.
@@ -2088,6 +2186,56 @@ class SemanticsConfiguration {
2088
2186
_hasBeenAnnotated = true ;
2089
2187
}
2090
2188
2189
+ /// Indicates the current scrolling position in logical pixels if the node is
2190
+ /// scrollable.
2191
+ ///
2192
+ /// The properties [scrollExtentMin] and [scrollExtentMax] indicate the valid
2193
+ /// in-range values for this property. The value for [scrollPosition] may
2194
+ /// (temporarily) be outside that range, e.g. during an overscroll.
2195
+ ///
2196
+ /// See also:
2197
+ ///
2198
+ /// * [ScrollPosition.pixels] , from where this value is usually taken.
2199
+ double get scrollPosition => _scrollPosition;
2200
+ double _scrollPosition;
2201
+ set scrollPosition (double value) {
2202
+ assert (value != null );
2203
+ _scrollPosition = value;
2204
+ _hasBeenAnnotated = true ;
2205
+ }
2206
+
2207
+ /// Indicates the maximum in-range value for [scrollPosition] if the node is
2208
+ /// scrollable.
2209
+ ///
2210
+ /// This value may be infinity if the scroll is unbound.
2211
+ ///
2212
+ /// See also:
2213
+ ///
2214
+ /// * [ScrollPosition.maxScrollExtent] , from where this value is usually taken.
2215
+ double get scrollExtentMax => _scrollExtentMax;
2216
+ double _scrollExtentMax;
2217
+ set scrollExtentMax (double value) {
2218
+ assert (value != null );
2219
+ _scrollExtentMax = value;
2220
+ _hasBeenAnnotated = true ;
2221
+ }
2222
+
2223
+ /// Indicates the minimum in-range value for [scrollPosition] if the node is
2224
+ /// scrollable.
2225
+ ///
2226
+ /// This value may be infinity if the scroll is unbound.
2227
+ ///
2228
+ /// See also:
2229
+ ///
2230
+ /// * [ScrollPosition.minScrollExtent] , from where this value is usually taken.
2231
+ double get scrollExtentMin => _scrollExtentMin;
2232
+ double _scrollExtentMin;
2233
+ set scrollExtentMin (double value) {
2234
+ assert (value != null );
2235
+ _scrollExtentMin = value;
2236
+ _hasBeenAnnotated = true ;
2237
+ }
2238
+
2091
2239
// TAGS
2092
2240
2093
2241
/// The set of tags that this configuration wants to add to all child
@@ -2171,6 +2319,9 @@ class SemanticsConfiguration {
2171
2319
_actionsAsBits | = other._actionsAsBits;
2172
2320
_flags | = other._flags;
2173
2321
_textSelection ?? = other._textSelection;
2322
+ _scrollPosition ?? = other._scrollPosition;
2323
+ _scrollExtentMax ?? = other._scrollExtentMax;
2324
+ _scrollExtentMin ?? = other._scrollExtentMin;
2174
2325
2175
2326
textDirection ?? = other.textDirection;
2176
2327
_sortOrder = _sortOrder? .merge (other._sortOrder);
@@ -2214,6 +2365,9 @@ class SemanticsConfiguration {
2214
2365
.._flags = _flags
2215
2366
.._tagsForChildren = _tagsForChildren
2216
2367
.._textSelection = _textSelection
2368
+ .._scrollPosition = _scrollPosition
2369
+ .._scrollExtentMax = _scrollExtentMax
2370
+ .._scrollExtentMin = _scrollExtentMin
2217
2371
.._actionsAsBits = _actionsAsBits
2218
2372
.._actions.addAll (_actions);
2219
2373
}
0 commit comments