@@ -221,16 +221,39 @@ - (id)accessibilityContainer {
221221
222222// private methods
223223
224+ - (float )scrollExtentMax {
225+ if (![_semanticsObject isAccessibilityBridgeAlive ]) {
226+ return 0.0 ;
227+ }
228+ float scrollExtentMax = _semanticsObject.node .scrollExtentMax ;
229+ if (isnan (scrollExtentMax)) {
230+ scrollExtentMax = 0.0 ;
231+ } else if (!isfinite (scrollExtentMax)) {
232+ scrollExtentMax = kScrollExtentMaxForInf + [self scrollPosition ];
233+ }
234+ return scrollExtentMax;
235+ }
236+
237+ - (float )scrollPosition {
238+ if (![_semanticsObject isAccessibilityBridgeAlive ]) {
239+ return 0.0 ;
240+ }
241+ float scrollPosition = _semanticsObject.node .scrollPosition ;
242+ if (isnan (scrollPosition)) {
243+ scrollPosition = 0.0 ;
244+ }
245+ NSCAssert (isfinite(scrollPosition), @"The scrollPosition must not be infinity");
246+ return scrollPosition;
247+ }
248+
224249- (CGSize)contentSizeInternal {
225250 CGRect result;
226251 const SkRect& rect = _semanticsObject.node .rect ;
227- float scrollExtentMax = isfinite (_semanticsObject.node .scrollExtentMax )
228- ? _semanticsObject.node .scrollExtentMax
229- : kScrollExtentMaxForInf + _semanticsObject.node .scrollPosition ;
252+
230253 if (_semanticsObject.node .actions & flutter::kVerticalScrollSemanticsActions ) {
231- result = CGRectMake (rect.x (), rect.y (), rect.width (), rect.height () + scrollExtentMax);
254+ result = CGRectMake (rect.x (), rect.y (), rect.width (), rect.height () + [ self scrollExtentMax ] );
232255 } else if (_semanticsObject.node .actions & flutter::kHorizontalScrollSemanticsActions ) {
233- result = CGRectMake (rect.x (), rect.y (), rect.width () + scrollExtentMax, rect.height ());
256+ result = CGRectMake (rect.x (), rect.y (), rect.width () + [ self scrollExtentMax ] , rect.height ());
234257 } else {
235258 result = CGRectMake (rect.x (), rect.y (), rect.width (), rect.height ());
236259 }
@@ -242,11 +265,11 @@ - (CGPoint)contentOffsetInternal {
242265 CGPoint origin = self.frame .origin ;
243266 const SkRect& rect = _semanticsObject.node .rect ;
244267 if (_semanticsObject.node .actions & flutter::kVerticalScrollSemanticsActions ) {
245- result = ConvertPointToGlobal (
246- _semanticsObject, CGPointMake (rect.x (), rect.y () + _semanticsObject. node . scrollPosition ));
268+ result = ConvertPointToGlobal (_semanticsObject,
269+ CGPointMake (rect.x (), rect.y () + [ self scrollPosition ] ));
247270 } else if (_semanticsObject.node .actions & flutter::kHorizontalScrollSemanticsActions ) {
248- result = ConvertPointToGlobal (
249- _semanticsObject, CGPointMake (rect.x () + _semanticsObject. node . scrollPosition , rect.y ()));
271+ result = ConvertPointToGlobal (_semanticsObject,
272+ CGPointMake (rect.x () + [ self scrollPosition ] , rect.y ()));
250273 } else {
251274 result = origin;
252275 }
0 commit comments