Unverified Commit b8d5d9c4 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Revert "Remove single-view assumption from widgets library (#117480)" (#117545)

This reverts commit b8b35671.
parent 95ff8397
...@@ -43,7 +43,6 @@ import 'text_editing_intents.dart'; ...@@ -43,7 +43,6 @@ import 'text_editing_intents.dart';
import 'text_selection.dart'; import 'text_selection.dart';
import 'text_selection_toolbar_anchors.dart'; import 'text_selection_toolbar_anchors.dart';
import 'ticker_provider.dart'; import 'ticker_provider.dart';
import 'view.dart';
import 'widget_span.dart'; import 'widget_span.dart';
export 'package:flutter/services.dart' show SelectionChangedCause, SmartDashesType, SmartQuotesType, TextEditingValue, TextInputType, TextSelection; export 'package:flutter/services.dart' show SelectionChangedCause, SmartDashesType, SmartQuotesType, TextEditingValue, TextInputType, TextSelection;
...@@ -3304,18 +3303,17 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -3304,18 +3303,17 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
@override @override
void didChangeMetrics() { void didChangeMetrics() {
final ui.FlutterView view = View.of(context); if (_lastBottomViewInset != WidgetsBinding.instance.window.viewInsets.bottom) {
if (_lastBottomViewInset != view.viewInsets.bottom) {
SchedulerBinding.instance.addPostFrameCallback((Duration _) { SchedulerBinding.instance.addPostFrameCallback((Duration _) {
_selectionOverlay?.updateForScroll(); _selectionOverlay?.updateForScroll();
}); });
if (_lastBottomViewInset < view.viewInsets.bottom) { if (_lastBottomViewInset < WidgetsBinding.instance.window.viewInsets.bottom) {
// Because the metrics change signal from engine will come here every frame // Because the metrics change signal from engine will come here every frame
// (on both iOS and Android). So we don't need to show caret with animation. // (on both iOS and Android). So we don't need to show caret with animation.
_scheduleShowCaretOnScreen(withAnimation: false); _scheduleShowCaretOnScreen(withAnimation: false);
} }
} }
_lastBottomViewInset = view.viewInsets.bottom; _lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
} }
Future<void> _performSpellCheck(final String text) async { Future<void> _performSpellCheck(final String text) async {
...@@ -3518,7 +3516,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -3518,7 +3516,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if (_hasFocus) { if (_hasFocus) {
// Listen for changing viewInsets, which indicates keyboard showing up. // Listen for changing viewInsets, which indicates keyboard showing up.
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
_lastBottomViewInset = View.of(context).viewInsets.bottom; _lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
if (!widget.readOnly) { if (!widget.readOnly) {
_scheduleShowCaretOnScreen(withAnimation: true); _scheduleShowCaretOnScreen(withAnimation: true);
} }
......
...@@ -13,7 +13,6 @@ import 'framework.dart'; ...@@ -13,7 +13,6 @@ import 'framework.dart';
import 'overscroll_indicator.dart'; import 'overscroll_indicator.dart';
import 'scroll_metrics.dart'; import 'scroll_metrics.dart';
import 'scroll_simulation.dart'; import 'scroll_simulation.dart';
import 'view.dart';
export 'package:flutter/physics.dart' show ScrollSpringSimulation, Simulation, Tolerance; export 'package:flutter/physics.dart' show ScrollSpringSimulation, Simulation, Tolerance;
...@@ -252,7 +251,7 @@ class ScrollPhysics { ...@@ -252,7 +251,7 @@ class ScrollPhysics {
assert(metrics != null); assert(metrics != null);
assert(context != null); assert(context != null);
if (parent == null) { if (parent == null) {
final double maxPhysicalPixels = View.of(context).physicalSize.longestSide; final double maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide;
return velocity.abs() > maxPhysicalPixels; return velocity.abs() > maxPhysicalPixels;
} }
return parent!.recommendDeferredLoading(velocity, metrics, context); return parent!.recommendDeferredLoading(velocity, metrics, context);
......
...@@ -12,7 +12,6 @@ import 'basic.dart'; ...@@ -12,7 +12,6 @@ import 'basic.dart';
import 'binding.dart'; import 'binding.dart';
import 'framework.dart'; import 'framework.dart';
import 'gesture_detector.dart'; import 'gesture_detector.dart';
import 'view.dart';
/// A widget that visualizes the semantics for the child. /// A widget that visualizes the semantics for the child.
/// ///
...@@ -97,7 +96,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi ...@@ -97,7 +96,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
Offset? _lastPointerDownLocation; Offset? _lastPointerDownLocation;
void _handlePointerDown(PointerDownEvent event) { void _handlePointerDown(PointerDownEvent event) {
setState(() { setState(() {
_lastPointerDownLocation = event.position * View.of(context).devicePixelRatio; _lastPointerDownLocation = event.position * WidgetsBinding.instance.window.devicePixelRatio;
}); });
// TODO(ianh): Use a gesture recognizer so that we can reset the // TODO(ianh): Use a gesture recognizer so that we can reset the
// _lastPointerDownLocation when none of the other gesture recognizers win. // _lastPointerDownLocation when none of the other gesture recognizers win.
...@@ -160,7 +159,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi ...@@ -160,7 +159,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
_pipelineOwner, _pipelineOwner,
_client.generation, _client.generation,
_lastPointerDownLocation, // in physical pixels _lastPointerDownLocation, // in physical pixels
View.of(context).devicePixelRatio, WidgetsBinding.instance.window.devicePixelRatio,
widget.labelStyle, widget.labelStyle,
), ),
child: GestureDetector( child: GestureDetector(
......
...@@ -10,7 +10,6 @@ import 'dart:math' as math; ...@@ -10,7 +10,6 @@ import 'dart:math' as math;
import 'dart:ui' as ui import 'dart:ui' as ui
show show
ClipOp, ClipOp,
FlutterView,
Image, Image,
ImageByteFormat, ImageByteFormat,
Paragraph, Paragraph,
...@@ -31,7 +30,6 @@ import 'debug.dart'; ...@@ -31,7 +30,6 @@ import 'debug.dart';
import 'framework.dart'; import 'framework.dart';
import 'gesture_detector.dart'; import 'gesture_detector.dart';
import 'service_extensions.dart'; import 'service_extensions.dart';
import 'view.dart';
/// Signature for the builder callback used by /// Signature for the builder callback used by
/// [WidgetInspector.selectButtonBuilder]. /// [WidgetInspector.selectButtonBuilder].
...@@ -2728,8 +2726,7 @@ class _WidgetInspectorState extends State<WidgetInspector> ...@@ -2728,8 +2726,7 @@ class _WidgetInspectorState extends State<WidgetInspector>
// on the edge of the display. If the pointer is being dragged off the edge // on the edge of the display. If the pointer is being dragged off the edge
// of the display we do not want to select anything. A user can still select // of the display we do not want to select anything. A user can still select
// a widget that is only at the exact screen margin by tapping. // a widget that is only at the exact screen margin by tapping.
final ui.FlutterView view = View.of(context); final Rect bounds = (Offset.zero & (WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio)).deflate(_kOffScreenMargin);
final Rect bounds = (Offset.zero & (view.physicalSize / view.devicePixelRatio)).deflate(_kOffScreenMargin);
if (!bounds.contains(_lastPointerLocation!)) { if (!bounds.contains(_lastPointerLocation!)) {
setState(() { setState(() {
selection.clear(); selection.clear();
......
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