Unverified Commit f1a8eed0 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Revert "Clean up matters related to "offstageness". (#27425)" (#27915)

This reverts commit 1d93e924.
parent 2cbd050f
......@@ -2465,11 +2465,8 @@ class _OffstageElement extends SingleChildRenderObjectElement {
@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
assert(() {
if (!widget.offstage)
super.debugVisitOnstageChildren(visitor);
return true;
}());
if (!widget.offstage)
super.debugVisitOnstageChildren(visitor);
}
}
......
......@@ -2666,11 +2666,6 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
/// The default implementation defers to [visitChildren] and therefore treats
/// the element as onstage.
///
/// This method should only be used in tests and debug code. In production,
/// the vague concept of "onstage" vs "offstage" is meaningless and should not
/// be used to affect widget behavior; this method does nothing in release
/// builds.
///
/// See also:
///
/// * [Offstage] widget that hides its children.
......@@ -2678,9 +2673,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
/// * [RenderObject.visitChildrenForSemantics], in contrast to this method,
/// designed specifically for excluding parts of the UI from the semantics
/// tree.
void debugVisitOnstageChildren(ElementVisitor visitor) {
assert(() { visitChildren(visitor); return true; }());
}
void debugVisitOnstageChildren(ElementVisitor visitor) => visitChildren(visitor);
/// Wrapper around [visitChildren] for [BuildContext].
@override
......
......@@ -472,11 +472,8 @@ class _TheatreElement extends RenderObjectElement {
@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
assert(() {
if (_onstage != null)
visitor(_onstage);
return true;
}());
if (_onstage != null)
visitor(_onstage);
}
@override
......
......@@ -1179,24 +1179,21 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
assert(() {
_childElements.values.where((Element child) {
final SliverMultiBoxAdaptorParentData parentData = child.renderObject.parentData;
double itemExtent;
switch (renderObject.constraints.axis) {
case Axis.horizontal:
itemExtent = child.renderObject.paintBounds.width;
break;
case Axis.vertical:
itemExtent = child.renderObject.paintBounds.height;
break;
}
final SliverConstraints constraints = renderObject.constraints;
return parentData.layoutOffset < constraints.scrollOffset + constraints.remainingPaintExtent
&& parentData.layoutOffset + itemExtent > constraints.scrollOffset;
}).forEach(visitor);
return true;
}());
_childElements.values.where((Element child) {
final SliverMultiBoxAdaptorParentData parentData = child.renderObject.parentData;
double itemExtent;
switch (renderObject.constraints.axis) {
case Axis.horizontal:
itemExtent = child.renderObject.paintBounds.width;
break;
case Axis.vertical:
itemExtent = child.renderObject.paintBounds.height;
break;
}
return parentData.layoutOffset < renderObject.constraints.scrollOffset + renderObject.constraints.remainingPaintExtent &&
parentData.layoutOffset + itemExtent > renderObject.constraints.scrollOffset;
}).forEach(visitor);
}
}
......
......@@ -208,13 +208,10 @@ class _ViewportElement extends MultiChildRenderObjectElement {
@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
assert(() {
children.where((Element e) {
final RenderSliver renderSliver = e.renderObject;
return renderSliver.geometry.visible;
}).forEach(visitor);
return true;
}());
children.where((Element e) {
final RenderSliver renderSliver = e.renderObject;
return renderSliver.geometry.visible;
}).forEach(visitor);
}
}
......
......@@ -32,7 +32,8 @@ class CommonFinders {
/// expect(find.text('Back'), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder text(String text, { bool skipOffstage = true }) => _TextFinder(text, skipOffstage: skipOffstage);
/// Looks for widgets that contain a [Text] descendant with `text`
......@@ -50,7 +51,8 @@ class CommonFinders {
/// tester.tap(find.widgetWithText(Button, 'Update'));
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder widgetWithText(Type widgetType, String text, { bool skipOffstage = true }) {
return find.ancestor(
of: find.text(text, skipOffstage: skipOffstage),
......@@ -66,7 +68,8 @@ class CommonFinders {
/// expect(find.byKey(backKey), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byKey(Key key, { bool skipOffstage = true }) => _KeyFinder(key, skipOffstage: skipOffstage);
/// Finds widgets by searching for widgets with a particular type.
......@@ -83,7 +86,8 @@ class CommonFinders {
/// expect(find.byType(IconButton), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byType(Type type, { bool skipOffstage = true }) => _WidgetTypeFinder(type, skipOffstage: skipOffstage);
/// Finds [Icon] widgets containing icon data equal to the `icon`
......@@ -95,7 +99,8 @@ class CommonFinders {
/// expect(find.byIcon(Icons.inbox), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byIcon(IconData icon, { bool skipOffstage = true }) => _WidgetIconFinder(icon, skipOffstage: skipOffstage);
/// Looks for widgets that contain an [Icon] descendant displaying [IconData]
......@@ -113,7 +118,8 @@ class CommonFinders {
/// tester.tap(find.widgetWithIcon(Button, Icons.arrow_forward));
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder widgetWithIcon(Type widgetType, IconData icon, { bool skipOffstage = true }) {
return find.ancestor(
of: find.byIcon(icon),
......@@ -135,7 +141,8 @@ class CommonFinders {
/// expect(find.byElementType(SingleChildRenderObjectElement), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byElementType(Type type, { bool skipOffstage = true }) => _ElementTypeFinder(type, skipOffstage: skipOffstage);
/// Finds widgets whose current widget is the instance given by the
......@@ -153,7 +160,8 @@ class CommonFinders {
/// tester.tap(find.byWidget(myButton));
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byWidget(Widget widget, { bool skipOffstage = true }) => _WidgetFinder(widget, skipOffstage: skipOffstage);
/// Finds widgets using a widget [predicate].
......@@ -172,7 +180,8 @@ class CommonFinders {
/// fails to locate the desired widget. Otherwise, the description prints the
/// signature of the predicate function.
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byWidgetPredicate(WidgetPredicate predicate, { String description, bool skipOffstage = true }) {
return _WidgetPredicateFinder(predicate, description: description, skipOffstage: skipOffstage);
}
......@@ -185,7 +194,8 @@ class CommonFinders {
/// expect(find.byTooltip('Back'), findsOneWidget);
/// ```
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byTooltip(String message, { bool skipOffstage = true }) {
return byWidgetPredicate(
(Widget widget) => widget is Tooltip && widget.message == message,
......@@ -212,7 +222,8 @@ class CommonFinders {
/// fails to locate the desired widget. Otherwise, the description prints the
/// signature of the predicate function.
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
/// If the `skipOffstage` argument is true (the default), then this skips
/// nodes that are [Offstage] or that are from inactive [Route]s.
Finder byElementPredicate(ElementPredicate predicate, { String description, bool skipOffstage = true }) {
return _ElementPredicateFinder(predicate, description: description, skipOffstage: skipOffstage);
}
......@@ -231,13 +242,9 @@ class CommonFinders {
/// If the [matchRoot] argument is true then the widget(s) specified by [of]
/// will be matched along with the descendants.
///
/// The `skipOffstage` argument maps to [Finder.skipOffstage] (q.v.).
Finder descendant({
@required Finder of,
@required Finder matching,
bool matchRoot = false,
bool skipOffstage = true,
}) {
/// If the [skipOffstage] argument is true (the default), then nodes that are
/// [Offstage] or that are from inactive [Route]s are skipped.
Finder descendant({ Finder of, Finder matching, bool matchRoot = false, bool skipOffstage = true }) {
return _DescendantFinder(of, matching, matchRoot: matchRoot, skipOffstage: skipOffstage);
}
......@@ -289,25 +296,9 @@ abstract class Finder {
/// Whether this finder skips nodes that are offstage.
///
/// By default, finders skip nodes that are considered "offstage". The term is
/// very loosely defined and is only meaningful in a debug environment; it is
/// not a term that applies in production. A widget is considered "offstage"
/// if it is "not really visible".
///
/// If [skipOffstage] is true, then the elements are walked using
/// [Element.debugVisitOnstageChildren]. This skips hidden children of
/// [Offstage] widgets, children of inactive [Route]s, some non-visible
/// children in viewports, and other nodes that are generally considered to be
/// "not there" when considering what the user can see.
///
/// The [skipOffstage] argument can be set to `false` to match _all_ nodes
/// regardless of this status. This is useful to test for the presence of
/// widgets being kept alive using [KeepAlive], for instance.
///
/// See also:
///
/// * [Element.debugVisitOnstageChildren], which can be overriden to
/// decide whether a child is onstage or offstage.
/// If this is true, then the elements are walked using
/// [Element.debugVisitOnstageChildren]. This skips offstage children of
/// [Offstage] widgets, as well as children of inactive [Route]s.
final bool skipOffstage;
/// Returns all the [Element]s that will be considered by this finder.
......
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